[sc-users] RecordBuf bug?? SampleRate and buffer .write question
Dan Stowell
danstowell at gmail.com
Sat Feb 2 06:12:38 PST 2008
2008/2/2, marinos <marinos at agxivatein.com>:
>
> This works fine for mono Buffers
>
> SynthDef(\recbuf, {arg out=0,bufnum=0, in=1, reclevel=1;
> var audioin;
> audioin=AudioIn.ar(in);
> RecordBuf.ar(audioin,bufnum,0,reclevel);}).send(s);
>
> Synth(\recbuf,[\in, 1]) or \in, 2 etc..
>
> but this
>
> Synth(\recbuf,[\in, [1,2]])
>
> doesn't
>
> And what I can't conceive is why this works...
>
> SynthDef(\recbuf, {arg out=0,bufnum=0, , reclevel=1;
> var audioin;
> audioin=AudioIn.ar([1,2]);
> RecordBuf.ar(audioin,bufnum,0,reclevel);}).send(s);
>
> ???
> Is sth I do wrong??
Your problem is like what was discussed before: the world inside the
synthdef is *different* from the world outside the synthdef. Inside
the synthdef, "AudioIn.ar([1,2])" creates a two-channel unit, FIXED at
two channels. Inside the other synthdef, "AudioIn.ar(in)" creates a
one-channel unit, FIXED at one channel. Trying to change the value of
"in" from a single value to an array *cannot* change the number of
connections inside the synthdef. Imagine the synthdef as a series of
pipes connecting things together - once you've created the synthdef,
you've specified the arrangement of pipes, and you can't suddenly
decide "ooh, actually I wanted two pipes there, not one".
Why is it like this? Yes, it's a little inconvenient that you can't
flip between mono and stereo at will. But it's a lot more efficient
this way. And it's not really very difficult to create one mono
synthdef, and one stereo one.
> And sth else.
> If a have a z sec buffer and I rec inside that x secs of audio where
> x<z, is there a way to write on a file only these x secs of audio,?? or
> is there a way to get the number of frames recorded in a file, meaning
> that if I write only x secs in a z sec buffer how can Iget ther numver
> of frames of only those x secs??
Hmm, not sure of the best way to do this. At one point I used a sort
of "trimming" where I grabbed the buffer as an array, then deleted all
the zeroes from the end until I hit a non-zero value. There may be
neater ways.
> And finally I seem not to be able to understand how SampleRate works. I
> just need to pass the server SampleRate to various ugens. I used
> SampleRate(s) to allocate buffers and everything worked fine, but when I
> used it inside a SynthDef it didn't worked, furthermore why these
> doesn't return a number??
>
> SampleRate(s).value;
> {sampleRate(s)+1}.value;
>
> How can I obtain the samplerate from the server as a number to perform
> mathematicals with?
"SampleRate" is a UGen. This means it can only be used inside a
synthdef, to define some sort of signal flow.
In the language more generally you can find the sample rate like this:
s.sampleRate
HTH
Dan
--
http://www.mcld.co.uk
More information about the sc-users
mailing list