I'm trying to learn how to use event patterns. I typed out the following, expecting a sequence which 'jumps down' an octave each time:
p = Pbind(*[
instrument: \mySynth,
midinote: Pseq([108, 96, 84, 72, 60, 48, 36, 24, 12], inf),
dur: 0.2
]);
SynthDef(
"mySynth",
{
|midinote, gate = 1|
var stereofreq = [midinote, midinote];
var audio = Pulse.ar(stereofreq, 0.5, mul: 0.8);
var env = Linen.kr(gate, 0.01, 1, 0.1, doneAction: 2);
OffsetOut.ar(0, audio * env);
}
).add;
p.play;
I certainly get a descending sequence, but the interval is not an octave. Am I missing some detail of the midinote
key?
Yes you are missing something: the data in the midinote
key is magically transformed into Hertz values in the freq
key when the pattern is played. So when you write your synthdef, you shouldn't use midinote
, instead use freq
.
It might seem like suspicious magic, but think about it this way: you can write a SynthDef once, using freq
, and thereafter you are free to use midinote
or freq
or degree
in your patterns, and they'll all be converted, without you having to rewrite your SynthDef to use the different-named control.
To understand more about what is going on, this page is very helpful: Pattern Guide 07: Value Conversions