From 2dc02001b76e127654660d4a2b2432b7e298d658 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Wed, 22 Jan 2014 21:55:33 +0100 Subject: [PATCH] Instrument: also render sound for MIDI-based instruments when muted In order to provide smooth muting functionality (i.e. immediate proper sound when unmuting) always render audio buffers for MIDI-based instruments. This is more important than potentially reduced CPU usage while muted. Closes #69. --- include/Instrument.h | 4 +--- include/InstrumentPlayHandle.h | 7 ++----- plugins/opl2/opl2instrument.cpp | 2 +- plugins/vestige/vestige.cpp | 12 +++++------- plugins/zynaddsubfx/ZynAddSubFx.cpp | 9 ++------- src/core/Instrument.cpp | 8 -------- 6 files changed, 11 insertions(+), 31 deletions(-) diff --git a/include/Instrument.h b/include/Instrument.h index 6e0e69012..7cec41019 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -2,7 +2,7 @@ * Instrument.h - declaration of class Instrument, which provides a * standard interface for all instrument plugins * - * Copyright (c) 2005-2009 Tobias Doerffel + * Copyright (c) 2005-2014 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -117,8 +117,6 @@ public: virtual bool isFromTrack( const track * _track ) const; - bool isMuted() const; - protected: inline InstrumentTrack * instrumentTrack() const diff --git a/include/InstrumentPlayHandle.h b/include/InstrumentPlayHandle.h index ccb3e6f18..b34675e4a 100644 --- a/include/InstrumentPlayHandle.h +++ b/include/InstrumentPlayHandle.h @@ -1,7 +1,7 @@ /* * InstrumentPlayHandle.h - play-handle for driving an instrument * - * Copyright (c) 2005-2009 Tobias Doerffel + * Copyright (c) 2005-2014 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -45,10 +45,7 @@ public: virtual void play( sampleFrame * _working_buffer ) { - if( !m_instrument->isMuted() ) - { - m_instrument->play( _working_buffer ); - } + m_instrument->play( _working_buffer ); } virtual bool done() const diff --git a/plugins/opl2/opl2instrument.cpp b/plugins/opl2/opl2instrument.cpp index 0117d1650..38e141211 100644 --- a/plugins/opl2/opl2instrument.cpp +++ b/plugins/opl2/opl2instrument.cpp @@ -238,7 +238,7 @@ bool opl2instrument::handleMidiEvent( const midiEvent & _me, // int key; static int lastvoice=0; - if( _me.m_type == MidiNoteOn && !isMuted() ) { + if( _me.m_type == MidiNoteOn ) { // to get us in line with MIDI key = _me.key() +12; for(int i=lastvoice+1; i!=lastvoice; ++i,i%=9) { diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 0cee1a4aa..6dfea9f69 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -313,15 +313,13 @@ void vestigeInstrument::play( sampleFrame * _buf ) bool vestigeInstrument::handleMidiEvent( const midiEvent & _me, const midiTime & _time ) { - if( !isMuted() ) + m_pluginMutex.lock(); + if( m_plugin != NULL ) { - m_pluginMutex.lock(); - if( m_plugin != NULL ) - { - m_plugin->processMidiEvent( _me, _time ); - } - m_pluginMutex.unlock(); + m_plugin->processMidiEvent( _me, _time ); } + m_pluginMutex.unlock(); + return true; } diff --git a/plugins/zynaddsubfx/ZynAddSubFx.cpp b/plugins/zynaddsubfx/ZynAddSubFx.cpp index 18775b5dd..ad2dde50a 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -1,7 +1,7 @@ /* * ZynAddSubFx.cpp - ZynAddSubxFX-embedding plugin * - * Copyright (c) 2008-2013 Tobias Doerffel + * Copyright (c) 2008-2014 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -343,14 +343,9 @@ void ZynAddSubFxInstrument::play( sampleFrame * _buf ) bool ZynAddSubFxInstrument::handleMidiEvent( const midiEvent & _me, const midiTime & _time ) { - // do not send NoteOn events if muted - if( _me.type() == MidiNoteOn && isMuted() ) - { - return true; - } // do not forward external MIDI Control Change events if the according // LED is not checked - else if( _me.type() == MidiControlChange && + if( _me.type() == MidiControlChange && _me.sourcePort() != this && m_forwardMidiCcModel.value() == false ) { diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index ad45bb846..339043ef9 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -96,14 +96,6 @@ bool Instrument::isFromTrack( const track * _track ) const -bool Instrument::isMuted() const -{ - return m_instrumentTrack->isMuted(); -} - - - - void Instrument::applyRelease( sampleFrame * buf, const notePlayHandle * _n ) { const fpp_t frames = _n->framesLeftForCurrentPeriod();