Is it possible in e.g. BufRd + Phasor or related combinations, to link the read position in an audio Buffer directly to a e.g. fader via MIDI or OSC and to get the playback speed from the fader movement speed and direction?
thanks for any suggestions!
Rainer
Is it possible in e.g. BufRd + Phasor or related combinations, to link the read position in an audio Buffer directly to a e.g. fader via MIDI or OSC and to get the playback speed from the fader movement speed and direction?
You could do the first derivative (Ableitung) of the fader values in a
MIDIFunc.cc function subtracting the current fader value from the previous fader
value, dividing it by the time elapsed. This would give you the speed
of the fader movement, and its sign (plus or minus) would give the
movement direction.
Example:
Move Fader from 100 to 101 in one second:
(101-100)/1 = speed 1
Move Fader from 100 to 102 in one second:
(102-100)/1 = speed 2
Move fader from 100 to 102 in two seconds:
(102-100)/2 = speed 1
Move fader from 100 to 102 in two seconds:
(100-102)/4 = speed -0.5
I hope there are more and better ideas out there.
best, Peter
hello Peter!
sorry for my late reply!
thank you for your suggestion. the thing I am not able to figure out is, how „the Buffer reports“ the position of the playhead across time and non linear movement of the play position caused by the manual movement of the fader.
best
Rainer
Here’s an example using a gui slider to play a soundfile:
(
// read a whole sound into memory
s = Server.local;
b = Buffer.read(s, ExampleFiles.child);
)
(
// make gui
w = Window("<<< Move slider to hear a sound >>>").front;
c = SoundFileView(w, 800 @ 200).load(ExampleFiles.child);
d = Slider(w).minSize_(Size(800, 40))
.thumbSize_(10)
.orientation_(\horizontal)
.action_({
arg view;
x.set(\phase, view.value);
});
w.layout = VLayout(c, d);
)
(
// make synth
x = {arg phase = 0, vol = 0.2; // input phase and volume
var sig, phs;
phs = K2A.ar(phase); // phase needs to be audio rate
phs = phs.lag(0.5); // sounds better with smoothing - try other values
sig = BufRd.ar(1, b, phs * BufFrames.ir(b));
sig = LeakDC.ar(sig); // best to remove any DC offset
sig = vol * sig;
sig = sig ! 2; // stereo
}.play;
)
// clean up
(
x.free;
b.free;
)