sampleframes and samplerate outside of perform64() and dsp64()
Hi, I want to access the sampleframes variable outside of the perform64 function and I want to access the samplerate variable outside of the dsp64 function.
Right now, I’m assigning x->sampleframes = sampleframes inside of perform64(), and x->samplerate inside dsp64(). Access to these assignments is only possible after audio is enabled, which isn’t ideal for my object.
thanks in advance,
you are only gonna get reliable samplerate and sampleframes (or block size) information after the audio has been enabled, since different objects in different sub-patchers might operate at different rates (i.e. poly~). However if you want to access those fields before turning audio on and still get values that make somewhat sense here is the way to do it:
in your new method add the following:
x->samplerate = sys_getsr();
x->sampleframes = sys_getblksize();
Both functions are defined in z_dsp.h that will need to be included of course.
Hope this is what you were after…
z_dsp.h has lots of methods!
One more related question:
My understanding of the perform64 function is that it loops at a rate of samplerate/sampleframes.
What if I want to generate audio output for every sample, and not every frame of samples?
I can’t imagine all of the msp~ objects being calculated at 1/64th the samplerate, so I must have a misunderstanding.
Mostly, I’m looking for reasons why the oscillator I built is noisy.
thanks in advance,
I believe your understanding is correct, but let me rephrase it:
the perform64 method gets called at a rate of samplerate/sampleframes.
Inside the perform64 method you loop through each sample for that frame.
Audio output is generated for every sample and it could not be otherwise.
However, for efficiency reasons the audio system works with buffers of a certain (power of 2) length (64,128,256,512,etc…). So what the perform64 method hands to you are groups of samples.
You could tell MSP to work with buffers of 1 sample, but – as you’ll notice – it will be very inefficient.
Hope this helps clarifying things a bit.
Oh yeah, I update the variables inside the while(n–) loop and yes! 44,100 sounds way better than ~686 sample rate. now it makes sense.
thanks for your help!
Forums > Dev