From 753e6b4c8c764c11055af51774356f0bbf6e5682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Przemys=C5=82aw=20Pluta?= Date: Thu, 26 Mar 2020 20:12:50 +0100 Subject: [PATCH] Updated smnp.music (markdown) --- smnp.music.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/smnp.music.md b/smnp.music.md index 23754d6..3189c81 100644 --- a/smnp.music.md +++ b/smnp.music.md @@ -1,8 +1,55 @@ # Functions -## `noteFromInt(intPitch: int, numerator: int, denominator: int)` ## `noteFromInt(intPitch: int, duration: int, dot: bool)` +Creates a note with given duration (including or not the dot) basing on passed `intRepr` value. The `intRepr` is a number representation of note's octave and pitch. It is computed using following algorithm: +1. map available pitches to `integer`: + C ⇒ 0 + C# ⇒ 1 + D ⇒ 2 + D# ⇒ 3 + E ⇒ 4 + F ⇒ 5 + F# ⇒ 6 + G ⇒ 7 + G# ⇒ 8 + A ⇒ 9 + A# ⇒ 10 + H ⇒ 11 +2. convert a note's pitch value using mappings above +3. multiple note's octave by 12 and add it to the result of the second point + +For example: +``` +# For @f#5 note: +# 1. f# => 6 +# 2. 5th octave => 5 * 12 = 60 +# 3. 60 + 6 = 66 +# 66 is the intRepr of @f#5 note +``` + +Note, that the `intRepr` depends only on pitch and octave. Note duration doesn't have any effect on the `intRepr` value. That's why the function accepts also duration-related arguments. + +## `noteFromInt(intPitch: int, numerator: int, denominator: int)` +Works similarly to `noteFromInt(intPitch: int, duration: int, dot: bool)`, however instead of determining note duration on `duration` and `dot` values, it enables you to provide a fully qualified duration as a fraction. + +Find out more about it at the description of [smnp.lang::Note](https://github.com/bartlomiej-pluta/smnp/wiki/smnp.lang#notepitch-string-octave-int-durationnumerator-int-durationdenominator-int) constructor. + ## `range(begin: note, end: note, filter: string = "all", duration: int = 4, dot: bool = false)` +Returns a list contained of notes from begin (inclusive) to end (exclusive) with given duration (and optional dot). + +This function also allows you to filter output notes using one of following values as a `filter` argument: +* `diatonic` - returns only diatonic notes (C, D, E, ...) +* `chromatic` - returns only chromatic notes (C#, D#, F#, ...) +* `all` - returns all notes (C, C#, D, D#, ...) + +### Example +``` +println(range(@g3, @g) == [@g3, @g#3, @a3, @b3, @h3, @c, @c#, @d, @d#, @e, @f, @f#, @g]); # true +println(range(@c, @c5, "diatonic") == [@c, @d, @e, @f, @g, @a, @h, @c5]); # true +println(range(@d5, @a5, "chromatic") == [@d#5, @f#5, @g#5]); # true +``` + ## `transpose(value: int, ...notes: )` + ## `transpose(value: int, notes: list)` ## `triplet(a: note, b: note, c: note)` ## `quintuplet(a: note, b: note, c: note, d: note, e: note)`