I have a question without any code to show, since I don’t even know where to start! So any tips and helps are very appreciated. What I want to do is to have a buffer of longer audio file being played, and at certain point I want to apply some programmed effects to only those moments in the playback. For instance imagine I have a synth which would apply a reverb. Then I let the buffer be played, and each time I make an instance of that synth, the effect (here reverb) is applied to where ever the buffer playback is right now, so the reverber takes (so to speak) a short snapshot of the moment it was created from the buffer, and applied it’s effect to that snapshot.
Can any one help?
Hi,
is this the kind of thing you are describing?
~buf = Buffer.read(s, "/path/to/sound.wav");
~verbBus = Bus.audio(s, 2);
(
// play the buffer in full
~playback = {
var sig = PlayBuf.ar(2, ~buf, BufRateScale.kr(~buf), doneAction: 2);
Out.ar(~verbBus, sig);
Out.ar(0, sig);
}.play;
)
(
// apply reverb to just the next 5 seconds of buffer playback
{
var in = In.ar(~verbBus, 2) * Env([0, 1, 1, 0], [0.1, 4.8, 0.1]).kr;
var sig = FreeVerb2.ar(in[0], in[1], 1);
DetectSilence.ar(sig, doneAction: 2);
Out.ar(0, sig);
}.play(addAction: \addToTail);
)
Or, do you actually need to know what the current play position is into the buffer for some effect? This is a bit difficult with longer sound files but I have a plugin that can help with that.
Best
E
This technique is actually pretty good, I have to experiment a bit with it! For now many thanks!
The thing which is missing for me is: I want the part of the playback I hear when I run it through the effect bus, is only the output of the effect bus, i.e. only for the time of the effect (in your code 5 seconds) the playback should come out of the effect bus, and as soos as the 5 secs are over, the playback goes back to the main output.
In other words the effect bus(ses) should temporarily shut down the Out.ar(0, ...
.
How could I make this?
Much better to make an effect synth that always exists. Then have two Out.ar
s, one that sends to the main out, and one to the effect synth. Then it’s just a matter of changing the gain for each. If you need to change the effect, you can also alter the \effectBus.kr
, rerouting it.
Another way is to use XOut with a fade envelope.
If XOut’s fade input is 0, then you’ll get the dry signal; if it’s 1, then the wet signal only passes through (the dry signal is totally suppressed).
ReplaceOut also suppresses the dry signal, but it does so instantaneously, so you’re likely to hear clicks at the start and end. Using the XOut fade input with a short Env.asr would smooth the transition.
hjh
This is a version using Jordan’s suggestion of a constant effect synth. (I think you could add more effects easily…)
~buf = Buffer.read(s, "/path/to/audio.wav");
~verbBus = Bus.audio(s, 2);
(
~playback = {
var verbAmt = \verbAmt.kr(0, 0.1); // 0-1 dry/wet
var sig = PlayBuf.ar(2, ~buf, BufRateScale.kr(~buf), doneAction: 2);
Out.ar(~verbBus, sig * verbAmt);
Out.ar(0, sig * (1 - verbAmt));
}.play.onFree({ ~reverb.free; });
~reverb = {
var in = In.ar(~verbBus, 2);
var sig = FreeVerb2.ar(in[0], in[1], 1);
Out.ar(0, sig);
}.play(addAction: \addToTail);
)
(
// 5 seconds of reverb
fork {
~playback.set(\verbAmt, 1);
5.wait;
~playback.set(\verbAmt, 0);
}
)
~playback.free;
hope it’s helpful