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) ...@@ -259,10 +259,12 @@ void Plugin::run(uint32_t sampleCount)
// loop over active samples // loop over active samples
for(uint16_t counter = 0; counter < maxActive; counter++) { for(uint16_t counter = 0; counter < maxActive; counter++) {
SamplePlay &play = active[counter]; SamplePlay &play = active[counter];
uint16_t channel = play.channel(); if(play.active()) {
uint32_t i = 0; uint16_t channel = play.channel();
while(play.active() && i < sampleCount) { uint32_t i = play.start();
outputPort[channel][i++] += play.next(i); while(play.hasNext() && i < sampleCount) {
outputPort[channel][i++] += play.next();
}
} }
} }
......
...@@ -52,13 +52,18 @@ public: ...@@ -52,13 +52,18 @@ public:
void activate(SampleFileBuffer *s, uint32_t off) { void activate(SampleFileBuffer *s, uint32_t off) {
mSample = s, offset = off, index = 0; mSample = s, offset = off, index = 0;
} }
float next(uint32_t i) { uint32_t start() {
if(i < offset) { return 0; } uint32_t ret = offset;
float &ret = mSample->data()[index++];
if(index == mSample->size()) { index = -1; }
offset = 0; offset = 0;
return ret; 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(); } uint16_t channel() { return mSample->channel(); }
void cancel() { index = -1; } 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