[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] wooh-kiki-woohwooh - Sequencing from text, using BufRd and Phasor



You can also use a /b_query message. It responds with an Array of info about the buffer, the last item of which is the sample rate.

The implemented .query method for the Buffer class just posts this info, but if you take a look at it, it should let you know how to go about this:

query {
'/b_info',{ arg a,b,c;
var bb,bufnum,numFrames,numChannels,sr;
# bb, bufnum,numFrames,numChannels,sr = c;
Post << "bufnum :" << bufnum << Char.nl
<< "numFrames : " << numFrames << Char.nl
<< "numChannels : " << numChannels << Char.nl
<< "sampleRate :" << sr << Char.nl << Char.nl;
}).add.removeWhenDone;
server.sendMsg("/b_query",bufnum)
}

S.


On Friday, January 2, 2004, at 08:28 AM, Julian Rohrhuber wrote:

Any idea how I can get a one off, non-ugen value for The SampleRate?
I need this for the time.wait in my loop.

if you want to have the files's sample rate on the client side, you can

1) either read the sound file header:

(

z = SoundFile.new;

z.openRead("sounds/a11wlk01.wav");

z.inspect;

z.close;


)

z.sampleRate returns the sample rate for you.


2)
the other way (less intuitive):
you can use a SendTrig to send any value over from the server to the client:

SendTrig.kr(Impulse.kr(0), 0, BufSampleRate.ir(bufnum));

the first way seems the better solution.



/you wrote: *******
I can't see that the Sample Rate would not be a constant thing for a particular buffer.


something like

time = dict[word.asSymbol].at(7)/BufSampleRate.kr(bufid).AsFloat;

would be nice instead of my hardcoded

time = dict[word.asSymbol].at(7)/11250;

Do BufRateScale and BufSampleRate do roughly the same thing?




.Andrew



SynthDef("playbuf-segment", {arg out= 0, bufnum= 0, offset= 0.0, length= 0.5, rate= 1.0;
Out.ar(out,
EnvGen.kr(Env.linen(0.005, length, 0.01), doneAction: 2)
*
PlayBuf.ar(1, bufnum, BufRateScale.ir(bufnum)*rate, 1, BufFrames.ir(bufnum)*offset);
)
}).load(s);


SynthDef("playWord", { arg buf, start, end, dur;
var retval;
retval = BufRd.ar(1,buf, Line.ar( start, end, dur/BufSampleRate.kr(buf), doneAction: 2 ));
Out.ar(0, retval); // send output to audio bus zero.
}).load(s);



On Tuesday, December 30, 2003, at 02:41 pm, Fredrik Olofsson wrote:

hi andrew,

The problem with the code below is that the elements (beep, columbia, this) are looping:

here's how i did a similar thing using playbuf cut off by an envelope. stripped down code from the drummachine posted here 21 dec.
(
s= Server.local;
s.boot.waitForBoot({
SynthDef("playbuf-segment", {arg out= 0, bufnum= 0, offset= 0.0, length= 0.5, rate= 1.0;
Out.ar(out,
EnvGen.kr(Env.linen(0.005, length, 0.01), doneAction: 2)
*
PlayBuf.ar(1, bufnum, BufRateScale.ir(bufnum)*rate, 1, BufFrames.ir(bufnum)*offset);
)
}).load(s);
})
)

b= Buffer.read(s, "sounds/a11wlk01.wav");

//\length in seconds and \offset in percent but that should be easy to change
Synth.grain("playbuf-segment", [\bufnum, b.bufnum, \offset, 0.46, \length, 0.85, \rate, 0.8]) //"houston over"

7f0


#|
fredrikolofsson.com klippav.org
|#

_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users



_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users

--








.
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users