Mercurial > hg > beaglert
diff core/Scope.cpp @ 485:506a319c08cf prerelease
Scope can now take a float* to an array instead of individual variables
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Tue, 21 Jun 2016 15:17:38 +0100 |
parents | efc9a9f8e63d |
children |
line wrap: on
line diff
--- a/core/Scope.cpp Tue Jun 21 15:16:55 2016 +0100 +++ b/core/Scope.cpp Tue Jun 21 15:17:38 2016 +0100 @@ -80,6 +80,47 @@ started = false; } +void Scope::log(float* values){ + //TODO: contains lots of duplicated code from log(float,...). + //TODO: needs refactoring + // check for any received OSC messages + while (oscServer.messageWaiting()){ + parseMessage(oscServer.popMessage()); + } + + if (!started) return; + + if (downSampling > 1){ + if (downSampleCount < downSampling){ + downSampleCount++; + return; + } + downSampleCount = 1; + } + + int startingWritePointer = writePointer; + + // save the logged samples into the buffer + for (int i=0; i<numChannels; i++) { + buffer[i*channelWidth + writePointer] = values[i]; + } + + writePointer = (writePointer+1)%channelWidth; + + // if upSampling > 1, save repeated samples into the buffer + for (int j=1; j<upSampling; j++){ + + buffer[writePointer] = buffer[startingWritePointer]; + + for (int i=1; i<numChannels; i++) { + buffer[i*channelWidth + writePointer] = buffer[i*channelWidth + startingWritePointer]; + } + + writePointer = (writePointer+1)%channelWidth; + + } + +} void Scope::log(float chn1, ...){ // check for any received OSC messages