Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions outputQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ Generator::addWave(unsigned char note, unsigned char vel) {
wav.state_age = 0;
wav.age = 0;
wav.env = defaultEnv;

mutex.lock();
waveList.push_back(wav);
mutex.unlock();
}

qint64
Expand Down Expand Up @@ -228,6 +229,7 @@ Generator::generateData(qint64 len) {
filteredData = QVector<qreal>(numSamples, 0);

// All samples for each active note in waveList are synthesized separately.
mutex.lock();
QMutableListIterator<Wave> i(waveList);

while (i.hasNext()) {
Expand Down Expand Up @@ -305,7 +307,8 @@ Generator::generateData(qint64 len) {
i.setValue(wav);
}
}

mutex.unlock();

for (unsigned int sample = 0; sample < numSamples; sample++) {
convBuffer[convBuffer_ind] = synthData[sample];
filteredData[sample] = 0;
Expand All @@ -323,7 +326,7 @@ Generator::generateData(qint64 len) {
delayBuffer[delayBuffer_ind] = filteredData[sample];
delayBuffer_ind = (delayBuffer_ind + 1) % delayBuffer_size;

// Primitive Reverb algorith.
// Primitive Reverb algorithm.
if (rev.active) {
qreal reverb = 0;
unsigned int ind;
Expand Down
2 changes: 2 additions & 0 deletions outputQt.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <QList>
#include <QMutableListIterator>
#include <QMutex>

#include "linearSynthesis.h"
#include "ADSRenvelope.h"
Expand Down Expand Up @@ -124,6 +125,7 @@ public slots:

qreal fftTimer;

QMutex mutex;
#ifdef USE_FFTW
fftw_complex *fftwIn, *fftwOut;
fftw_plan fftwPlan;
Expand Down