Updated smnp.music (markdown)
@@ -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: <note, int, string>)`
|
||||
|
||||
## `transpose(value: int, notes: list<note, int, string>)`
|
||||
## `triplet(a: note, b: note, c: note)`
|
||||
## `quintuplet(a: note, b: note, c: note, d: note, e: note)`
|
||||
|
||||
Reference in New Issue
Block a user