jevstrudel.git / website / src / pages / learn / tonal.mdx
tonal.mdx72 lines · 1.7 KB · raw
1---
2title: Tonal Functions
3layout: ../../layouts/MainLayout.astro
4---
5
6import { MiniRepl } from '../../docs/MiniRepl';
7import { JsDoc } from '../../docs/JsDoc';
8
9# Tonal Functions
10
11These functions use [tonaljs](https://github.com/tonaljs/tonal) to provide helpers for musical operations.
12
13### voicing()
14
15<JsDoc client:idle name="voicing" h={0} />
16
17Here's an example of how you can play chords and a bassline:
18
19<MiniRepl
20  client:idle
21  tune={`chord("<C^7 A7b13 Dm7 G7>*2")
22  .dict('ireal').layer(
23  x=>x.struct("[~ x]*2").voicing()
24  ,
25  x=>n("0*4").set(x).mode("root:g2").voicing()
26  .s('sawtooth').cutoff("800:4:2")
27)`}
28/>
29
30### scale(name)
31
32<JsDoc client:idle name="scale" h={0} />
33
34### transpose(semitones)
35
36Transposes all notes to the given number of semitones:
37
38<MiniRepl client:only="react" tune={`"[c2 c3]*4".transpose("<0 -2 5 3>").note()`} />
39
40This method gets really exciting when we use it with a pattern as above.
41
42Instead of numbers, scientific interval notation can be used as well:
43
44<MiniRepl client:only="react" tune={`"[c2 c3]*4".transpose("<1P -2M 4P 3m>").note()`} />
45
46### scaleTranspose(steps)
47
48Transposes notes inside the scale by the number of steps:
49
50<MiniRepl
51  client:idle
52  tune={`"[-8 [2,4,6]]*2"
53.scale('C4 bebop major')
54.scaleTranspose("<0 -1 -2 -3 -4 -5 -6 -4>*2")
55.note()`}
56/>
57
58### rootNotes(octave = 2)
59
60Turns chord symbols into root notes of chords in given octave.
61
62<MiniRepl client:only="react" tune={`"<C^7 A7b13 Dm7 G7>*2".rootNotes(3).note()`} />
63
64Together with layer, struct and voicings, this can be used to create a basic backing track:
65
66<MiniRepl
67  client:idle
68  tune={`"<C^7 A7b13 Dm7 G7>*2".layer(
69  x => x.voicings('lefthand').struct("[~ x]*2").note(),
70  x => x.rootNotes(2).note().s('sawtooth').cutoff(800)
71)`}
72/>