Commit b7298a82 authored by jhammen's avatar jhammen
Browse files

process thread simplify inner loop

parent 1b961acf
......@@ -259,10 +259,12 @@ void Plugin::run(uint32_t sampleCount)
// loop over active samples
for(uint16_t counter = 0; counter < maxActive; counter++) {
SamplePlay &play = active[counter];
uint16_t channel = play.channel();
uint32_t i = 0;
while(play.active() && i < sampleCount) {
outputPort[channel][i++] += play.next(i);
if(play.active()) {
uint16_t channel = play.channel();
uint32_t i = play.start();
while(play.hasNext() && i < sampleCount) {
outputPort[channel][i++] += play.next();
}
}
}
......
......@@ -52,13 +52,18 @@ public:
void activate(SampleFileBuffer *s, uint32_t off) {
mSample = s, offset = off, index = 0;
}
float next(uint32_t i) {
if(i < offset) { return 0; }
float &ret = mSample->data()[index++];
if(index == mSample->size()) { index = -1; }
uint32_t start() {
uint32_t ret = offset;
offset = 0;
return ret;
}
bool hasNext() {
if(index == mSample->size()) { index = -1; }
return index >= 0;
}
float next() {
return mSample->data()[index++];
}
uint16_t channel() { return mSample->channel(); }
void cancel() { index = -1; }
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment