diff --git a/include/MidiPort.h b/include/MidiPort.h index c8a3c6e44..07c61d788 100644 --- a/include/MidiPort.h +++ b/include/MidiPort.h @@ -124,6 +124,8 @@ public: return m_writablePorts; } + void invalidateCilent(); + MidiPortMenu* m_readablePortsMenu; MidiPortMenu* m_writablePortsMenu; diff --git a/include/MixerWorkerThread.h b/include/MixerWorkerThread.h index 9bf2be077..7c3792392 100644 --- a/include/MixerWorkerThread.h +++ b/include/MixerWorkerThread.h @@ -47,10 +47,10 @@ public: Dynamic // jobs can be added while processing queue } ; -#define JOB_QUEUE_SIZE 1024 +#define JOB_QUEUE_SIZE 8192 JobQueue() : m_items(), - m_queueSize( 0 ), + m_writeIndex( 0 ), m_itemsDone( 0 ), m_opMode( Static ) { @@ -66,7 +66,7 @@ public: private: std::atomic m_items[JOB_QUEUE_SIZE]; - std::atomic_int m_queueSize; + std::atomic_int m_writeIndex; std::atomic_int m_itemsDone; OperationMode m_opMode; diff --git a/plugins/Flanger/FlangerControls.cpp b/plugins/Flanger/FlangerControls.cpp index 4ba91dba3..fa3640db4 100644 --- a/plugins/Flanger/FlangerControls.cpp +++ b/plugins/Flanger/FlangerControls.cpp @@ -43,6 +43,7 @@ FlangerControls::FlangerControls( FlangerEffect *effect ) : { connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changedSampleRate() ) ); + connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( changedPlaybackState() ) ); } @@ -81,3 +82,9 @@ void FlangerControls::changedSampleRate() } + + +void FlangerControls::changedPlaybackState() +{ + m_effect->restartLFO(); +} diff --git a/plugins/Flanger/FlangerControls.h b/plugins/Flanger/FlangerControls.h index bbd8444fa..d51141ed0 100644 --- a/plugins/Flanger/FlangerControls.h +++ b/plugins/Flanger/FlangerControls.h @@ -57,6 +57,7 @@ public: private slots: void changedSampleRate(); + void changedPlaybackState(); private: FlangerEffect* m_effect; diff --git a/plugins/Flanger/FlangerEffect.cpp b/plugins/Flanger/FlangerEffect.cpp index 2f5d96ef5..1404c06b0 100644 --- a/plugins/Flanger/FlangerEffect.cpp +++ b/plugins/Flanger/FlangerEffect.cpp @@ -68,7 +68,7 @@ FlangerEffect::~FlangerEffect() { delete m_rDelay; } - if(m_lfo ) + if( m_lfo ) { delete m_lfo; } @@ -139,6 +139,15 @@ void FlangerEffect::changeSampleRate() + +void FlangerEffect::restartLFO() +{ + m_lfo->restart(); +} + + + + extern "C" { diff --git a/plugins/Flanger/FlangerEffect.h b/plugins/Flanger/FlangerEffect.h index ad1052b5a..a70e87827 100644 --- a/plugins/Flanger/FlangerEffect.h +++ b/plugins/Flanger/FlangerEffect.h @@ -44,6 +44,7 @@ public: return &m_flangerControls; } void changeSampleRate(); + void restartLFO(); private: FlangerControls m_flangerControls; diff --git a/plugins/Flanger/QuadratureLfo.h b/plugins/Flanger/QuadratureLfo.h index 90f7f77dc..e7e27d14a 100644 --- a/plugins/Flanger/QuadratureLfo.h +++ b/plugins/Flanger/QuadratureLfo.h @@ -53,6 +53,14 @@ public: + inline void restart() + { + m_phase = 0; + } + + + + inline void setSampleRate ( int samplerate ) { m_samplerate = samplerate; diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 177a90437..f52e10ac7 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -292,9 +292,7 @@ void ConfigManager::setDefaultSoundfont( const QString & _sf ) void ConfigManager::setBackgroundArtwork( const QString & _ba ) { -#ifdef LMMS_HAVE_FLUIDSYNTH m_backgroundArtwork = _ba; -#endif } void ConfigManager::setGIGDir(const QString &gd) diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index 5a87b54dd..a2aecb9c9 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -344,7 +344,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) if( _n->origin() == NotePlayHandle::OriginArpeggio || _n->origin() == NotePlayHandle::OriginNoteStacking || !m_arpEnabledModel.value() || - ( _n->isReleased() && _n->releaseFramesDone() >= _n->actualReleaseFramesToDo() ) ) + _n->isReleased() ) { return; } @@ -412,7 +412,6 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) // Skip notes randomly if( m_arpSkipModel.value() ) { - if( 100 * ( (float) rand() / (float)( RAND_MAX + 1.0f ) ) < m_arpSkipModel.value() ) { // Set master note to prevent the note to extend over skipped notes @@ -501,12 +500,6 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) continue; } - float vol_level = 1.0f; - if( _n->isReleased() ) - { - vol_level = _n->volumeLevel( cur_frame + gated_frames ); - } - // create new arp-note // create sub-note-play-handle, only ptr to note is different @@ -515,7 +508,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) NotePlayHandleManager::acquire( _n->instrumentTrack(), frames_processed, gated_frames, - Note( MidiTime( 0 ), MidiTime( 0 ), sub_note_key, (volume_t) qRound( _n->getVolume() * vol_level ), + Note( MidiTime( 0 ), MidiTime( 0 ), sub_note_key, _n->getVolume(), _n->getPanning(), _n->detuning() ), _n, -1, NotePlayHandle::OriginArpeggio ) ); diff --git a/src/core/MixerWorkerThread.cpp b/src/core/MixerWorkerThread.cpp index d7e252528..9632d22c7 100644 --- a/src/core/MixerWorkerThread.cpp +++ b/src/core/MixerWorkerThread.cpp @@ -25,6 +25,7 @@ #include "MixerWorkerThread.h" #include +#include #include #include @@ -39,7 +40,7 @@ QList MixerWorkerThread::workerThreads; // implementation of internal JobQueue void MixerWorkerThread::JobQueue::reset( OperationMode _opMode ) { - m_queueSize = 0; + m_writeIndex = 0; m_itemsDone = 0; m_opMode = _opMode; } @@ -54,7 +55,13 @@ void MixerWorkerThread::JobQueue::addJob( ThreadableJob * _job ) // update job state _job->queue(); // actually queue the job via atomic operations - m_items[m_queueSize++] = _job; + auto index = m_writeIndex++; + if (index < JOB_QUEUE_SIZE) { + m_items[index] = _job; + } else { + qWarning() << "Job queue is full!"; + ++m_itemsDone; + } } } @@ -63,10 +70,10 @@ void MixerWorkerThread::JobQueue::addJob( ThreadableJob * _job ) void MixerWorkerThread::JobQueue::run() { bool processedJob = true; - while (processedJob && m_itemsDone < m_queueSize) + while (processedJob && m_itemsDone < m_writeIndex) { processedJob = false; - for( int i = 0; i < m_queueSize; ++i ) + for( int i = 0; i < m_writeIndex && i < JOB_QUEUE_SIZE; ++i ) { ThreadableJob * job = m_items[i].exchange(nullptr); if( job ) @@ -86,7 +93,7 @@ void MixerWorkerThread::JobQueue::run() void MixerWorkerThread::JobQueue::wait() { - while (m_itemsDone < m_queueSize) + while (m_itemsDone < m_writeIndex) { #if defined(LMMS_HOST_X86) || defined(LMMS_HOST_X86_64) _mm_pause(); diff --git a/src/core/Track.cpp b/src/core/Track.cpp index c8f68d459..15de5a983 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -143,7 +143,9 @@ void TrackContentObject::movePosition( const MidiTime & pos ) { if( m_startPosition != pos ) { + Engine::mixer()->requestChangeInModel(); m_startPosition = pos; + Engine::mixer()->doneChangeInModel(); Engine::getSong()->updateLength(); emit positionChanged(); } diff --git a/src/core/midi/MidiClient.cpp b/src/core/midi/MidiClient.cpp index 8ba70bcb7..b88c64db1 100644 --- a/src/core/midi/MidiClient.cpp +++ b/src/core/midi/MidiClient.cpp @@ -38,6 +38,10 @@ MidiClient::MidiClient() MidiClient::~MidiClient() { //TODO: noteOffAll(); / clear all ports + for (MidiPort* port : m_midiPorts) + { + port->invalidateCilent(); + } } diff --git a/src/core/midi/MidiPort.cpp b/src/core/midi/MidiPort.cpp index 43019876e..9e3cdb13d 100644 --- a/src/core/midi/MidiPort.cpp +++ b/src/core/midi/MidiPort.cpp @@ -27,9 +27,12 @@ #include "MidiPort.h" #include "MidiClient.h" +#include "MidiDummy.h" #include "Note.h" #include "Song.h" +static MidiDummy s_dummyClient; + MidiPort::MidiPort( const QString& name, @@ -410,4 +413,7 @@ void MidiPort::updateOutputProgram() - +void MidiPort::invalidateCilent() +{ + m_midiClient = &s_dummyClient; +} diff --git a/src/gui/Forms/EffectSelectDialog.ui b/src/gui/Forms/EffectSelectDialog.ui index a9c6de019..f8e773486 100644 --- a/src/gui/Forms/EffectSelectDialog.ui +++ b/src/gui/Forms/EffectSelectDialog.ui @@ -102,6 +102,7 @@ RowTableView + QTableView
RowTableView.h
diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index f88e1dcf6..5063761e2 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -1525,9 +1525,7 @@ void SetupDialog::setDefaultSoundfont( const QString & _sf ) void SetupDialog::setBackgroundArtwork( const QString & _ba ) { -#ifdef LMMS_HAVE_FLUIDSYNTH m_backgroundArtwork = _ba; -#endif }