Hello all,
I am using RecordBuf to record audio input to buffers and then play them inside a Pdef in realtime. I would like to be able to record audio into 8 different buffers. Right now I have it working for 1 buffer, however I am running into a few issues. Below is an overview.
I created this GUI component with a ‘Resample’ button that uses .mouseDownAction to start recording when the button is pressed down:
Here is the code for this button. I am using sig = SoundIn.ar(0) and RecordBuf for this.
~resamplerButton = Button(w, Rect(10, 100, 80, 26))
.states_([["Record", Color.black, Color.white]])
.mouseDownAction_({
a = {
var sig;
'Recording...'.postln;
sig = SoundIn.ar(0);
RecordBuf.ar(sig, ~bufbank[80], 0, \reclevel.kr(0.1), \prelevel.kr(0), 1, 1);
}.play;
})
.action_({ arg butt, mod;
'Finished recording'.postln;
a.release(0.1);
});
The audio is recording and being saved to ~bufbank[80], however the audio is very quiet. Also, when I press this button, I am getting overlap of the music playing + the sound that is being recorded and it becomes quite distorted. Is it possible to silently record this audio?
Secondly, I am routing all of my audio to this Master output channel:
~master1 = (
SynthDef(\mastermix, {
arg moogcut = 29000, gain = 0, highcut = 22, masterfader = 1, mix = 0.33, room = 0.5, damp = 0.5, delaytime = 0, pitchRatio = 1, pitchDispersion = 0, fader = 1;
var sig;
sig = In.ar(~patch4, 2);
sig = FreeVerb.ar(sig, mix, room, damp);
sig = Compander.ar(sig);
sig = Limiter.ar(sig);
sig = Out.ar(0, sig * masterfader);
}).play(~master1);
);
Instead of recording ‘SoundIn’, is it possible to Record the sound directly from ~master1? Would that make any difference?
And my last question- Right now I am defining the length of the buffer inside of Buffer.alloc. It is my understanding that the s.sampleRate
represents the sample rate of the server, and multiplying it by 4 gives me the total number of samples for a 4-second buffer:
8.do({ arg i;
~bufbank.add(Buffer.alloc(s, s.sampleRate * 4, 1));
});
Is it possible to have the buffer be exactly equal to how long as the recording is?
Thank you all for your help.