Mercurial > hg > beaglert
comparison 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 |
comparison
equal
deleted
inserted
replaced
484:afbc8f973bb3 | 485:506a319c08cf |
---|---|
78 | 78 |
79 void Scope::stop(){ | 79 void Scope::stop(){ |
80 started = false; | 80 started = false; |
81 } | 81 } |
82 | 82 |
83 void Scope::log(float* values){ | |
84 //TODO: contains lots of duplicated code from log(float,...). | |
85 //TODO: needs refactoring | |
86 // check for any received OSC messages | |
87 while (oscServer.messageWaiting()){ | |
88 parseMessage(oscServer.popMessage()); | |
89 } | |
90 | |
91 if (!started) return; | |
92 | |
93 if (downSampling > 1){ | |
94 if (downSampleCount < downSampling){ | |
95 downSampleCount++; | |
96 return; | |
97 } | |
98 downSampleCount = 1; | |
99 } | |
100 | |
101 int startingWritePointer = writePointer; | |
102 | |
103 // save the logged samples into the buffer | |
104 for (int i=0; i<numChannels; i++) { | |
105 buffer[i*channelWidth + writePointer] = values[i]; | |
106 } | |
107 | |
108 writePointer = (writePointer+1)%channelWidth; | |
109 | |
110 // if upSampling > 1, save repeated samples into the buffer | |
111 for (int j=1; j<upSampling; j++){ | |
112 | |
113 buffer[writePointer] = buffer[startingWritePointer]; | |
114 | |
115 for (int i=1; i<numChannels; i++) { | |
116 buffer[i*channelWidth + writePointer] = buffer[i*channelWidth + startingWritePointer]; | |
117 } | |
118 | |
119 writePointer = (writePointer+1)%channelWidth; | |
120 | |
121 } | |
122 | |
123 } | |
83 void Scope::log(float chn1, ...){ | 124 void Scope::log(float chn1, ...){ |
84 | 125 |
85 // check for any received OSC messages | 126 // check for any received OSC messages |
86 while (oscServer.messageWaiting()){ | 127 while (oscServer.messageWaiting()){ |
87 parseMessage(oscServer.popMessage()); | 128 parseMessage(oscServer.popMessage()); |