Forums > MaxMSP

csound~ and sample rate

Dec 11 2009 | 9:59 pm

Hi there,

I’m playing around with some csound code using the csound~ external in Max for Live. It works great, but I have one question. I run Ableton at different sample rates depending on different projects and I wonder is there a way to pass sample rate information in a variable to my csound orchestra from max, or is this (up/downsampling) handled automatically?

E.g. Ableton is running at 48KHz, How do I make sure my "csound~" "max4Live audio effects" plugins run at the same sample rate?

For the time being I have my csound code all using 96Khz as the SR. Am I worrying about nothing?? I cant seem to figure this out,

Thanks in advance,


Dec 12 2009 | 11:03 pm

AFAIK, there’s no way to dynamically set the sample rate. [csound~] does not automatically upsample/downsample when MSP sr and Csound sr don’t match. Upsampling/downsampling is possible inside Csound using User Defined Opcodes (UDO), but the global Csound sr is always set in the header of the orchestra.

You could just use one [csound~] instance, but change out the orchestra based on the current sr.

Or you could create multiple instances of [csound~] running different orchestras. Then bypass those that don’t match the current sr (use the message "bypass 1" to save cpu cycles).

I’ve been thinking about using Erik de Castro Lopo’s Secret Rabbit Code to do automatic sample rate conversion, but I haven’t gotten around to it. Maybe next year.


Dec 13 2009 | 7:21 pm

Thanks Davis,

A friend of mine came back to me from the csound list with a possible solution. Haven’t got it going yet but will report back if/when I do:

Basically it involves using a dspstate~ object to get the current max sample rate, then sending that to the csound command line message box for csound~:

csound test.csd –sample-rate=$1

Seemingly the above command line flag will override the SR in the test.csd

It may be a solution, but like I said; haven’t got round to testing it yet.

Dec 14 2009 | 12:11 am

Wow, I need to re-read the manual. I’ve never heard of that flag before.

Anyways, I just tried it out and it looks like you have to supply the control rate and sample rate:

csound -r 88200 -k 11025 test.csd

The implied ksmps is 8 = 88200/11025

Thanks for the info, and good luck.


Dec 14 2009 | 2:35 pm

Cool, that should do the trick, thanks for your help,


Viewing 5 posts - 1 through 5 (of 5 total)

Forums > MaxMSP