How do you get the sample rate in SNEX?
-
How do you get hold of sample rate inside of a SNEX node?
I need to use sample rate in some of my snex calculations.
(eg. Filtering)Is there a way to get hold of the sample rate being used in the rest of HISE? and if so, how do I get that value? Or is there a way to get the sample rate of the user's daw project.
I want to be able to pass it into code like so.
It's quite important for my calculations.
Thanks. -
-
@griffinboy the prepare callback has an argument that will provide you with the processing specs.
ps.sampleRate ps.numChannels ps.blockSize
If you're using oversampling, it will also be factored in already, so just take whatever value is being passed there.
-
@Christoph-Hart
Thank you!You'll have to forgive me for not knowing how to pass it in, I am not very familiar with C++ yet
ps. <- does not seem to appear in the HISE documentation. I assume this is prepare specs
-
@griffinboy check this example, it saves the sample rate to be used to calculate the pitch factor of the sample playback:
https://docs.hise.audio/tutorials/scriptnode/index.html#snex-oneshot-player
-
@Christoph-Hart Perfect thanks for your time
-
The working answer:
// Get sampleRate inside a snex node double sr = 0.0; void prepare(PrepareSpecs ps) { sr = ps.sampleRate; }
-