View Full Version : Counting Samples
RRokkenAudio
01-31-2010, 12:09 AM
If I wanted to count and flip a "switch" at every 4000 samples. Where would I put this code? Thinking it wouldn't go in the Process loop(double replacing)...
~Rob.
It would go in the Process function. You'd have to have a count of samples that persists between calls to Process to cope with the (most common) case where you get given less than 4000 samples each time.
And you'd have to write it so that it could handle the case where the switch flips part way through the process replacing. So, you'd process the first part of the block of samples with the switch off, then you'd flip the switch and process the remaining samples with the switch on.
RRokkenAudio
01-31-2010, 03:35 AM
For some reason i was under the impression that anything in the process loop would be a max of ur sample rate and then reset to zero, there's where i was thinking I couldn't do a full count. BTW: I'm trying to drop audio every minute.
Sample/Block confusion.
~Rob.
Xenakios
01-31-2010, 06:06 AM
For some reason i was under the impression that anything in the process loop would be a max of ur sample rate and then reset to zero, there's where i was thinking I couldn't do a full count. BTW: I'm trying to drop audio every minute.
Sample/Block confusion.
~Rob.
VST doesn't really have anything to use for "at sample". If you need something to happen at sample accuracy, you have to implement it yourself in the audio processing function, using counters and so on. The process block can be asked to process any number of samples at any call, so don't rely on that number of samples being some particular value. That is, in :
void PlugExample::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
nFrames isn't a number you can trust to be the same at each call, or a number that is a power-of-2 (64,128,256,512,1024,2048 etc). I just thought to mention this that you don't make your plugins buggy because of such assumptions. (There are unfortunately plugins around that do expect nFrames to be the same and/or a power-of-2 number...)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.