Tutorial
How to write different notes different ways
Revisiting our synth from last time we have this pretty straight forward pattern:
fn synth(freq, partials=2, fundVol=1, cutoff=80) {
let sig = for i in 1..=partials { saw(freq * i) * fundVol/i } *
env(0.01, 0.1, 0.8, 0.1, dur*0.8)
sig >> lowpass(cutoff, 0.5)
}
play([80, 80, 80, 80], synth)
We are free to keep writing frequencies if we choose. Let’s make it more musical
play([73.42, 87.31, 82.41, 58.27], synth)
You can write out the hertz for d2, f2 and e2 and b flat 1. Signal generators take hertz as an input parameter by default.
Or you can use midi values. For those we need to add a conversion in our synth
fn synth(n, partials=2, fundVol=1, cutoff=80) {
let sig = for i in 1..=partials { saw(n.m2h * i) * fundVol/i } *
env(0.01, 0.1, 0.8, 0.1, dur*0.8)
sig >> lowpass(cutoff, 0.5)
}
play([38, 41, 40, 34], synth)
For convention and clarity’s sake I change freq to n for note.
And since we are passing a midi value in we use n.m2h.
This function converts the midi value to hertz.
Once we have that conversion in our synth, we don’t need to use numbers any more, we can write:
play([d2, f2, e2, bf1], synth)
Note that f stands for flat and s stands for sharp.
I don’t even need to repeat the octave numbers until I need to change octaves.
play([d2, f, e2, bf1], synth)
E is a special case, becuase of rhythm. You can use octave numbers from 0 to 9 representing all of the standard midi pitches except for the bottom -1 octave. Check out this reference
Ok, so we have a little pattern, but we want more than just a stead 4 quarters.
If you are familiar with somthing like strudel you will be probably be comfortable with proportional rhythm in patterns.
The unit of measure is a cycle which is equivalent to a bar. This can be changed via tempo and meter in the transport toolbar.
Each slot in a pattern is equivalent to 1 unit by default. so:
play([d2, f, e2, bf1], synth)
is 4 quarters.