Hi everyone,
n00bish question. Some background:
I am working on a piece that plays back shuffled pentatonic scales and transposes them around. I have the pattern stuff all worked out, but I’d love to take it to the next level and hook up an instrument: specifically, play my saxophone, read the pitch from that, and use it as a root note of a scale, updated as I play new notes.
Pitch.kr is simple enough; I can write a SynthDef that spits out the nearest midinote to what I’m playing into the microphone, but I don’t know how to get that number into my pattern in real time, or with a short delay.
This Synth shows a constant flow of the current midi note in the post window:
(
SynthDef(\pitchFollow, { |out|
var in, amp, freq, midinote, hasFreq;
in = Mix.new(SoundIn.ar([0, 1]));
amp = Amplitude.kr(in, 0.05, 0.05);
# freq, hasFreq = Pitch.kr(in, ampThreshold: 0.1);
midinote = freq.cpsmidi.round(1);
midinote.poll;
};
).play;
)
Can I get the output of that Synth to control a version of the following pattern, replacing ~root? (with a PatternProxy or something like that…?):
~root = 60;
(
Pdef(\test,
Pbind(
\midinote, ~root + Prand([0, 2, 4, 7, 9], inf),
\dur, 0.5,
)
).quant=1;
)
I know I can’t use a UGen inside a pattern. Can I turn the output of the Synth into some kind of stream? Can I control how often the Synth or the Pattern checks the current note? i.e. every 0.1 seconds, check the midinote from the mic, then feed that into the pattern (using Pbind so as not to interrupt rhythms).
Pfunc? Pfuncn? Prout?
I’m sure this is a piece of cake for all the wizards out there - thanks in advance.