InstrumentPlayHandle: do not process if InstrumentTrack is muted

While regular instruments were excluded from processing when muted
this did not happen for InstrumentPlayHandle-based instruments. Muting
for exampling tracks with VSTi's inside did not decrease CPU usage.
Checking whether related InstrumentTrack is muted before calling
Instrument::play() fixes this issue.

Closes #2857426.
This commit is contained in:
Tobias Doerffel
2009-09-15 10:10:02 +02:00
parent bb4c93ce37
commit 6940d19969
8 changed files with 41 additions and 22 deletions

View File

@@ -117,6 +117,8 @@ public:
virtual bool isFromTrack( const track * _track ) const;
bool isMuted() const;
protected:
inline InstrumentTrack * instrumentTrack() const

View File

@@ -1,8 +1,8 @@
/*
* instrument_play_handle.h - play-handle for playing an instrument
* InstrumentPlayHandle.h - play-handle for driving an instrument
*
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
@@ -22,7 +22,6 @@
*
*/
#ifndef _INSTRUMENT_PLAY_HANDLE_H
#define _INSTRUMENT_PLAY_HANDLE_H
@@ -46,7 +45,10 @@ public:
virtual void play( sampleFrame * _working_buffer )
{
m_instrument->play( _working_buffer );
if( !m_instrument->isMuted() )
{
m_instrument->play( _working_buffer );
}
}
virtual bool done() const

View File

@@ -31,7 +31,7 @@
#include "lb302.h"
#include "automatable_button.h"
#include "engine.h"
#include "instrument_play_handle.h"
#include "InstrumentPlayHandle.h"
#include "InstrumentTrack.h"
#include "knob.h"
#include "note_play_handle.h"

View File

@@ -33,7 +33,7 @@
#include "lb303.h"
#include "engine.h"
#include "instrument_play_handle.h"
#include "InstrumentPlayHandle.h"
#include "InstrumentTrack.h"
#include "knob.h"
#include "note_play_handle.h"

View File

@@ -34,7 +34,7 @@
#include "sf2_player.h"
#include "engine.h"
#include "InstrumentTrack.h"
#include "instrument_play_handle.h"
#include "InstrumentPlayHandle.h"
#include "note_play_handle.h"
#include "knob.h"
#include "song.h"

View File

@@ -34,7 +34,7 @@
#include "ResourceFileMapper.h"
#include "engine.h"
#include "gui_templates.h"
#include "instrument_play_handle.h"
#include "InstrumentPlayHandle.h"
#include "InstrumentTrack.h"
#include "VstPlugin.h"
#include "pixmap_button.h"
@@ -162,12 +162,15 @@ void vestigeInstrument::play( sampleFrame * _buf )
bool vestigeInstrument::handleMidiEvent( const midiEvent & _me,
const midiTime & _time )
{
m_pluginMutex.lock();
if( m_plugin != NULL )
if( !isMuted() )
{
m_plugin->processMidiEvent( _me, _time );
m_pluginMutex.lock();
if( m_plugin != NULL )
{
m_plugin->processMidiEvent( _me, _time );
}
m_pluginMutex.unlock();
}
m_pluginMutex.unlock();
return true;
}

View File

@@ -34,7 +34,7 @@
#include "ZynAddSubFx.h"
#include "engine.h"
#include "mmp.h"
#include "instrument_play_handle.h"
#include "InstrumentPlayHandle.h"
#include "InstrumentTrack.h"
#include "gui_templates.h"
#include "string_pair_drag.h"
@@ -239,16 +239,19 @@ void ZynAddSubFxInstrument::play( sampleFrame * _buf )
bool ZynAddSubFxInstrument::handleMidiEvent( const midiEvent & _me,
const midiTime & _time )
{
m_pluginMutex.lock();
if( m_remotePlugin )
if( !isMuted() )
{
m_remotePlugin->processMidiEvent( _me, 0 );
m_pluginMutex.lock();
if( m_remotePlugin )
{
m_remotePlugin->processMidiEvent( _me, 0 );
}
else
{
m_plugin->processMidiEvent( _me );
}
m_pluginMutex.unlock();
}
else
{
m_plugin->processMidiEvent( _me );
}
m_pluginMutex.unlock();
return true;
}

View File

@@ -95,6 +95,15 @@ 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();