Mixer: rewrote processing chain of rendered audio buffers

Until now, Mixer not only was responsible for rendering audio buffers
but also managed writing them to audio backend (through a FIFO) and
handled various quality related parameters.

All this functionality has been moved into the new AudioOutputContext
class. It glues together AudioBackend (formerly called AudioDevice),
global quality settings and the Mixer.

The AudioOutputContext class creates a FifoWriter which calls
Mixer::renderNextBuffer() and writes the output into the BufferFifo of
the AudioOutputContext it belongs to. The BufferFifo is read by the
according AudioBackend which belongs to the AudioOutputContext as well.

The AudioOutputContext also handles resampling in case the AudioBackend
wants the buffers in a different samplerate.

During this rewrite the Mixer class and the according source files have
been renamed from "mixer" to "Mixer". This results in small changes
all over LMMS' code base.
This commit is contained in:
Tobias Doerffel
2009-11-29 01:33:25 +01:00
parent 63cb220090
commit 20589f19e4
85 changed files with 1379 additions and 1151 deletions

View File

@@ -2,6 +2,7 @@
* ladspa_description.cpp - LADSPA plugin description
*
* Copyright (c) 2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -30,10 +31,11 @@
#include <QtGui/QScrollArea>
#include <QtGui/QVBoxLayout>
#include "AudioDevice.h"
#include "AudioBackend.h"
#include "AudioOutputContext.h"
#include "engine.h"
#include "ladspa_2_lmms.h"
#include "mixer.h"
#include "Mixer.h"
@@ -73,8 +75,8 @@ ladspaDescription::ladspaDescription( QWidget * _parent,
it != plugins.end(); it++ )
{
if( _type != VALID ||
manager->getDescription( ( *it ).second )->inputChannels
<= engine::getMixer()->audioDev()->channels() )
manager->getDescription( ( *it ).second )->inputChannels <=
engine::mixer()->audioOutputContext()->audioBackend()->channels() )
{
pluginNames.push_back( ( *it ).first );
m_pluginKeys.push_back( ( *it ).second );

View File

@@ -2,7 +2,8 @@
* ladspa_port_dialog.cpp - dialog to test a LADSPA plugin
*
* Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
*
* Copyright (c) 2009 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 +23,6 @@
*
*/
#include "ladspa_port_dialog.h"
#include <QtGui/QLayout>
@@ -31,7 +31,7 @@
#include "embed.h"
#include "engine.h"
#include "ladspa_2_lmms.h"
#include "mixer.h"
#include "Mixer.h"
ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key )
@@ -95,11 +95,11 @@ ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key )
{
if( min != NOHINT )
{
min *= engine::getMixer()->processingSampleRate();
min *= engine::mixer()->processingSampleRate();
}
if( max != NOHINT )
{
max *= engine::getMixer()->processingSampleRate();
max *= engine::mixer()->processingSampleRate();
}
}

View File

@@ -25,14 +25,15 @@
#include <QtGui/QMessageBox>
#include "AudioBackend.h"
#include "AudioOutputContext.h"
#include "LadspaEffect.h"
#include "mmp.h"
#include "AudioDevice.h"
#include "config_mgr.h"
#include "ladspa_2_lmms.h"
#include "LadspaControl.h"
#include "LadspaSubPluginFeatures.h"
#include "mixer.h"
#include "Mixer.h"
#include "EffectChain.h"
#include "Cpu.h"
#include "automation_pattern.h"
@@ -87,7 +88,7 @@ LadspaEffect::LadspaEffect( Model * _parent,
pluginInstantiation();
connect( engine::getMixer(), SIGNAL( sampleRateChanged() ),
connect( engine::mixer(), SIGNAL( sampleRateChanged() ),
this, SLOT( changeSampleRate() ) );
}
@@ -144,13 +145,13 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf,
int frames = _frames;
sampleFrame * o_buf = NULL;
if( m_maxSampleRate < engine::getMixer()->processingSampleRate() )
if( m_maxSampleRate < engine::mixer()->processingSampleRate() )
{
o_buf = _buf;
_buf = CPU::allocFrames( _frames );
sampleDown( o_buf, _buf, m_maxSampleRate );
frames = _frames * m_maxSampleRate /
engine::getMixer()->processingSampleRate();
engine::mixer()->processingSampleRate();
}
// Copy the LMMS audio buffer to the LADSPA input buffer and initialize
@@ -298,7 +299,8 @@ void LadspaEffect::pluginInstantiation()
ladspa2LMMS * manager = engine::getLADSPAManager();
// Calculate how many processing units are needed.
const ch_cnt_t lmms_chnls = engine::getMixer()->audioDev()->channels();
const ch_cnt_t lmms_chnls = engine::mixer()->audioOutputContext()->
audioBackend()->channels();
int effect_channels = manager->getDescription( m_key )->inputChannels;
setProcessorCount( lmms_chnls / effect_channels );
@@ -325,7 +327,7 @@ void LadspaEffect::pluginInstantiation()
// during cleanup. It was easier to troubleshoot with the
// memory management all taking place in one file.
p->buffer =
new LADSPA_Data[engine::getMixer()->framesPerPeriod()];
new LADSPA_Data[engine::mixer()->framesPerPeriod()];
if( p->name.toUpper().contains( "IN" ) &&
manager->isPortInput( m_key, port ) )
@@ -566,7 +568,7 @@ sample_rate_t LadspaEffect::maxSamplerate( const QString & _name )
{
return __buggy_plugins[_name];
}
return engine::getMixer()->processingSampleRate();
return engine::mixer()->processingSampleRate();
}

View File

@@ -28,12 +28,13 @@
#include <QtGui/QHBoxLayout>
#include <QtGui/QLabel>
#include "AudioOutputContext.h"
#include "AudioBackend.h"
#include "LadspaSubPluginFeatures.h"
#include "AudioDevice.h"
#include "engine.h"
#include "ladspa_2_lmms.h"
#include "LadspaBase.h"
#include "mixer.h"
#include "Mixer.h"
LadspaSubPluginFeatures::LadspaSubPluginFeatures( Plugin::PluginTypes _type ) :
@@ -142,7 +143,7 @@ void LadspaSubPluginFeatures::listSubPluginKeys(
it != plugins.end(); ++it )
{
if( lm->getDescription( ( *it ).second )->inputChannels <=
engine::getMixer()->audioDev()->channels() )
engine::mixer()->audioOutputContext()->audioBackend()->channels() )
{
_kl.push_back( ladspaKeyToSubPluginKey( _desc, ( *it ).first, ( *it ).second ) );
}

View File

@@ -37,7 +37,6 @@
#include "InstrumentView.h"
#include "led_checkbox.h"
#include "knob.h"
#include "mixer.h"
class lb302SynthView;
class notePlayHandle;

View File

@@ -30,6 +30,8 @@
#include <QtGui/QFileDialog>
#include <QtXml/QDomDocument>
#include "AudioBackend.h"
#include "AudioOutputContext.h"
#include "ResourceFileMapper.h"
#include "sf2_player.h"
#include "engine.h"
@@ -122,14 +124,14 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) :
m_settings = new_fluid_settings();
fluid_settings_setint( m_settings, (char *) "audio.period-size",
engine::getMixer()->framesPerPeriod() );
engine::mixer()->framesPerPeriod() );
// This is just our starting instance of synth. It is recreated
// everytime we load a new soundfont.
m_synth = new_fluid_synth( m_settings );
InstrumentPlayHandle * iph = new InstrumentPlayHandle( this );
engine::getMixer()->addPlayHandle( iph );
engine::mixer()->addPlayHandle( iph );
//loadFile( configManager::inst()->defaultSoundfont() );
@@ -147,7 +149,7 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) :
connect( &m_patchNum, SIGNAL( dataChanged() ),
this, SLOT( updatePatch() ) );
connect( engine::getMixer(), SIGNAL( sampleRateChanged() ),
connect( engine::mixer(), SIGNAL( sampleRateChanged() ),
this, SLOT( updateSampleRate() ) );
// Gain
@@ -192,7 +194,7 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) :
sf2Instrument::~sf2Instrument()
{
engine::getMixer()->removePlayHandles( instrumentTrack() );
engine::mixer()->removePlayHandles( instrumentTrack() );
freeFont();
delete_fluid_synth( m_synth );
delete_fluid_settings( m_settings );
@@ -498,7 +500,7 @@ void sf2Instrument::updateSampleRate()
// Set & get, returns the true sample rate
fluid_settings_setnum( m_settings, (char *) "synth.sample-rate",
engine::getMixer()->processingSampleRate() );
engine::mixer()->processingSampleRate() );
fluid_settings_getnum( m_settings, (char *) "synth.sample-rate",
&tempRate );
m_internalSampleRate = static_cast<int>( tempRate );
@@ -529,8 +531,9 @@ void sf2Instrument::updateSampleRate()
}
m_synthMutex.lock();
if( engine::getMixer()->currentQualitySettings().interpolation >=
mixer::qualitySettings::Interpolation_SincFastest )
if( engine::mixer()->audioOutputContext()->qualitySettings().
interpolation() >=
AudioOutputContext::QualitySettings::Interpolation_SincFastest )
{
fluid_synth_set_interp_method( m_synth, -1,
FLUID_INTERP_7THORDER );
@@ -541,7 +544,7 @@ void sf2Instrument::updateSampleRate()
FLUID_INTERP_DEFAULT );
}
m_synthMutex.unlock();
if( m_internalSampleRate < engine::getMixer()->processingSampleRate() )
if( m_internalSampleRate < engine::mixer()->processingSampleRate() )
{
m_synthMutex.lock();
if( m_srcState != NULL )
@@ -549,9 +552,9 @@ void sf2Instrument::updateSampleRate()
src_delete( m_srcState );
}
int error;
m_srcState = src_new( engine::getMixer()->
currentQualitySettings().libsrcInterpolation(),
DEFAULT_CHANNELS, &error );
m_srcState = src_new( engine::mixer()->audioOutputContext()->
qualitySettings().libsrcInterpolation(),
DEFAULT_CHANNELS, &error );
if( m_srcState == NULL || error )
{
printf( "error while creating SRC-data-"

View File

@@ -26,7 +26,7 @@
#include "vibrating_string.h"
#include "templates.h"
#include "interpolation.h"
#include "mixer.h"
#include "Mixer.h"
#include "engine.h"
@@ -42,7 +42,7 @@ vibratingString::vibratingString( float _pitch,
float _detune,
bool _state ) :
m_oversample( 2 * _oversample / (int)( _sample_rate /
engine::getMixer()->baseSampleRate() ) ),
engine::mixer()->baseSampleRate() ) ),
m_randomize( _randomize ),
m_stringLoss( 1.0f - _string_loss ),
m_state( 0.1f )

View File

@@ -29,7 +29,6 @@
#include <QtCore/QMutex>
#include <QtGui/QWidget>
#include "mixer.h"
#include "JournallingObject.h"
#include "communication.h"