made rendering happen with one global working-buffer per thread - hopefully improves L1/L2-cache-efficiency

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@890 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-04-05 19:06:32 +00:00
parent 7f72593f06
commit c8c5382b35
38 changed files with 286 additions and 218 deletions

View File

@@ -1,5 +1,45 @@
2008-04-05 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/patman/patman.cpp:
* plugins/patman/patman.h:
* plugins/lb302/lb302.cpp:
* plugins/lb302/lb302.h:
* plugins/organic/organic.cpp:
* plugins/organic/organic.h:
* plugins/bit_invader/bit_invader.cpp:
* plugins/bit_invader/bit_invader.h:
* plugins/vibed/vibed.h:
* plugins/vibed/vibed.cpp:
* plugins/triple_oscillator/triple_oscillator.h:
* plugins/triple_oscillator/triple_oscillator.cpp:
* plugins/audio_file_processor/audio_file_processor.cpp:
* plugins/audio_file_processor/audio_file_processor.h:
* plugins/stk/mallets/mallets.cpp:
* plugins/stk/mallets/mallets.h:
* plugins/sf2_player/sf2_player.cpp:
* plugins/sf2_player/sf2_player.h:
* plugins/vestige/vestige.cpp:
* plugins/vestige/vestige.h:
* plugins/kicker/kicker.cpp:
* plugins/kicker/kicker.h:
* include/instrument_play_handle.h:
* include/mixer.h:
* include/instrument_track.h:
* include/instrument.h:
* include/note_play_handle.h:
* include/sample_play_handle.h:
* include/dummy_instrument.h:
* include/preset_preview_play_handle.h:
* include/play_handle.h:
* src/tracks/instrument_track.cpp:
* src/core/preset_preview_play_handle.cpp:
* src/core/note_play_handle.cpp:
* src/core/sample_play_handle.cpp:
* src/core/mixer.cpp:
* src/core/instrument.cpp:
made rendering happen with one global working-buffer per thread -
hopefully improves L1/L2-cache-efficiency
* include/file_browser.h:
* src/gui/file_browser.cpp:
do not examine directories for being empty when adding them - speeds

View File

@@ -43,6 +43,9 @@ public:
{
}
virtual void playNote( notePlayHandle *, bool, sampleFrame * )
{
}
virtual void saveSettings( QDomDocument &, QDomElement & )
{

View File

@@ -54,25 +54,26 @@ public:
// --------------------------------------------------------------------
// if the plugin doesn't play each note, it can create an instrument-
// play-handle and re-implement this method, so that it mixes it's
// play-handle and re-implement this method, so that it mixes its
// output buffer only once per mixer-period
virtual void play( bool _try_parallelizing = FALSE );
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer );
// to be overloaded by actual plugin
virtual void FASTCALL playNote( notePlayHandle * note_to_play,
bool _try_parallelizing );
// to be implemented by actual plugin
virtual void playNote( notePlayHandle * _note_to_play,
bool _try_parallelizing,
sampleFrame * _working_buf ) = 0;
// needed for deleting plugin-specific-data of a note - plugin has to
// cast void-ptr so that the plugin-data is deleted properly
// (call of dtor if it's a class etc.)
virtual void FASTCALL deleteNotePluginData( notePlayHandle *
_note_to_play );
virtual void deleteNotePluginData( notePlayHandle * _note_to_play );
// Get number of sample-frames that should be used when playing beat
// (note with unspecified length)
// Per default this function returns 0. In this case, channel is using
// the length of the longest envelope (if one active).
virtual f_cnt_t FASTCALL beatLen( notePlayHandle * _n ) const;
virtual f_cnt_t beatLen( notePlayHandle * _n ) const;
// some instruments need a certain number of release-frames even
@@ -91,6 +92,7 @@ public:
return( FALSE );
}
// instrument-play-handle-based instruments should return FALSE
inline virtual bool notePlayHandleBased( void ) const
{
return( TRUE );
@@ -111,7 +113,7 @@ public:
// instantiate instrument-plugin with given name or return NULL
// on failure
static instrument * FASTCALL instantiate( const QString & _plugin_name,
static instrument * instantiate( const QString & _plugin_name,
instrumentTrack * _instrument_track );
virtual bool isFromTrack( const track * _track ) const;

View File

@@ -44,9 +44,10 @@ public:
}
inline virtual void play( bool _try_parallelizing )
inline virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer )
{
m_instrument->play( _try_parallelizing );
m_instrument->play( _try_parallelizing, _working_buffer );
}
inline virtual bool done( void ) const

View File

@@ -85,7 +85,8 @@ public:
// for capturing note-play-events -> need that for arpeggio,
// filter and so on
void playNote( notePlayHandle * _n, bool _try_parallelizing );
void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
QString instrumentName( void ) const;
inline const instrument * getInstrument( void ) const

View File

@@ -38,7 +38,6 @@
#include "types.h"
#include "note.h"
#include "play_handle.h"
#include "fifo_buffer.h"
@@ -87,6 +86,9 @@ const Keys BaseKey = Key_A;
const Octaves BaseOctave = DefaultOctave;
#include "play_handle.h"
class mixerWorkerThread;
@@ -342,6 +344,8 @@ private:
fpp_t m_framesPerPeriod;
sampleFrame * m_workingBuf;
surroundSampleFrame * m_readBuf;
surroundSampleFrame * m_writeBuf;

View File

@@ -2,7 +2,7 @@
* note_play_handle.h - declaration of class notePlayHandle which is needed
* by LMMS-Play-Engine
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -27,7 +27,7 @@
#ifndef _NOTE_PLAY_HANDLE_H
#define _NOTE_PLAY_HANDLE_H
#include "play_handle.h"
#include "mixer.h"
#include "basic_filters.h"
#include "bb_track.h"
#include "note.h"
@@ -63,7 +63,8 @@ public:
void updateFrequency( void );
virtual void play( bool _try_parallelizing );
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual inline bool done( void ) const
{

View File

@@ -2,7 +2,7 @@
* play_handle.h - base-class playHandle which is needed by
* LMMS-Player-Engine
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -60,7 +60,8 @@ public:
return( m_type );
}
virtual void play( bool _try_parallelizing = FALSE ) = 0;
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer ) = 0;
virtual bool done( void ) const = 0;
// returns how many frames this play-handle is aligned ahead, i.e.

View File

@@ -2,7 +2,7 @@
* preset_preview_play_handle.h - play-handle for playing a short preview-sound
* of a preset
*
* Copyright (c) 2005-2007 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
*
@@ -40,7 +40,8 @@ public:
presetPreviewPlayHandle( const QString & _preset_file );
virtual ~presetPreviewPlayHandle();
virtual void play( bool _try_parallelizing );
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual bool done( void ) const;
virtual bool isFromTrack( const track * _track ) const;

View File

@@ -1,7 +1,7 @@
/*
* sample_play_handle.h - play-handle for playing a sample
*
* Copyright (c) 2005-2007 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
*
@@ -28,7 +28,7 @@
#include <qobject.h>
#include "play_handle.h"
#include "mixer.h"
#include "sample_buffer.h"
#include "automatable_model.h"
@@ -48,7 +48,8 @@ public:
samplePlayHandle( pattern * _pattern );
virtual ~samplePlayHandle();
virtual void play( bool _try_parallelizing );
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual bool done( void ) const;
virtual bool isFromTrack( const track * _track ) const;

View File

@@ -1,7 +1,7 @@
/*
* audio_file_processor.cpp - instrument for using audio-files
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -105,24 +105,24 @@ audioFileProcessor::~audioFileProcessor()
void audioFileProcessor::playNote( notePlayHandle * _n, bool )
void audioFileProcessor::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
const fpp_t frames = _n->framesLeftForCurrentPeriod();
sampleFrame * buf = new sampleFrame[frames];
if( !_n->m_pluginData )
{
_n->m_pluginData = new handleState( _n->hasDetuningInfo() );
}
if( m_sampleBuffer.play( buf, (handleState *)_n->m_pluginData,
if( m_sampleBuffer.play( _working_buffer,
(handleState *)_n->m_pluginData,
frames, _n->frequency(),
m_loopModel.value() ) == TRUE )
{
applyRelease( buf, _n );
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
applyRelease( _working_buffer, _n );
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
}
delete[] buf;
}

View File

@@ -2,7 +2,7 @@
* audio_file_processor.h - declaration of class audioFileProcessor
* (instrument-plugin for using audio-files)
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -54,20 +54,20 @@ public:
audioFileProcessor( instrumentTrack * _instrument_track );
virtual ~audioFileProcessor();
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
virtual void saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void loadSettings( const QDomElement & _this );
virtual void FASTCALL setParameter( const QString & _param,
virtual void setParameter( const QString & _param,
const QString & _value );
virtual QString nodeName( void ) const;
virtual Uint32 FASTCALL getBeatLen( notePlayHandle * _n ) const;
virtual Uint32 getBeatLen( notePlayHandle * _n ) const;
virtual f_cnt_t desiredReleaseFrames( void ) const
{

View File

@@ -1,7 +1,7 @@
/*
* bit_invader.cpp - instrument which uses a usereditable wavetable
*
* Copyright (c) 2006-2007 Andreas Brandmaier <andy/at/brandmaier/dot/de>
* Copyright (c) 2006-2008 Andreas Brandmaier <andy/at/brandmaier/dot/de>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -261,7 +261,8 @@ QString bitInvader::nodeName( void ) const
}
void bitInvader::playNote( notePlayHandle * _n, bool )
void bitInvader::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
if ( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL )
{
@@ -283,7 +284,6 @@ void bitInvader::playNote( notePlayHandle * _n, bool )
}
const fpp_t frames = _n->framesLeftForCurrentPeriod();
sampleFrame * buf = new sampleFrame[frames];
bSynth * ps = static_cast<bSynth *>( _n->m_pluginData );
for( fpp_t frame = 0; frame < frames; ++frame )
@@ -291,15 +291,13 @@ void bitInvader::playNote( notePlayHandle * _n, bool )
const sample_t cur = ps->nextStringSample();
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl )
{
buf[frame][chnl] = cur;
_working_buffer[frame][chnl] = cur;
}
}
applyRelease( buf, _n );
applyRelease( _working_buffer, _n );
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
delete[] buf;
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
}

View File

@@ -2,7 +2,7 @@
* bit_invader.h - declaration of class bitInvader and bSynth which
* are a wavetable synthesizer
*
* Copyright (c) 2006-2007 Andreas Brandmaier <andy/at/brandmaier/dot/de>
* Copyright (c) 2006-2008 Andreas Brandmaier <andy/at/brandmaier/dot/de>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -67,14 +67,14 @@ public:
bitInvader(instrumentTrack * _channel_track );
virtual ~bitInvader();
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
virtual void saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;

View File

@@ -119,7 +119,8 @@ typedef effectLib::distortion<> distFX;
typedef sweepOscillator<effectLib::monoToStereoAdaptor<distFX> > sweepOsc;
void kickerInstrument::playNote( notePlayHandle * _n, bool )
void kickerInstrument::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
const float decfr = m_decayModel.value() *
engine::getMixer()->sampleRate() / 1000.0f;
@@ -148,11 +149,10 @@ void kickerInstrument::playNote( notePlayHandle * _n, bool )
const float f1 = m_startFreqModel.value() + tfp * fdiff / decfr;
const float f2 = m_startFreqModel.value() + (frames+tfp-1)*fdiff/decfr;
sampleFrame * buf = new sampleFrame[frames];
sweepOsc * so = static_cast<sweepOsc *>( _n->m_pluginData );
so->update( buf, frames, f1, f2, engine::getMixer()->sampleRate() );
so->update( _working_buffer, frames, f1, f2,
engine::getMixer()->sampleRate() );
if( _n->released() )
{
@@ -163,18 +163,17 @@ void kickerInstrument::playNote( notePlayHandle * _n, bool )
desiredReleaseFrames();
for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch )
{
buf[f][ch] *= fac;
_working_buffer[f][ch] *= fac;
}
}
}
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
delete[] buf;
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
}
void kickerInstrument::deleteNotePluginData( notePlayHandle * _n )
{
delete static_cast<sweepOsc *>( _n->m_pluginData );
@@ -191,6 +190,8 @@ pluginView * kickerInstrument::instantiateView( QWidget * _parent )
kickerInstrumentView::kickerInstrumentView( instrument * _instrument,
QWidget * _parent ) :
instrumentView( _instrument, _parent )

View File

@@ -41,14 +41,13 @@ public:
kickerInstrument( instrumentTrack * _instrument_track );
virtual ~kickerInstrument();
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;

View File

@@ -2,7 +2,7 @@
* lb302.cpp - implementation of class lb302 which is a bass synth attempting
* to emulate the Roland TB303 bass synth
*
* Copyright (c) 2006-2007 Paul Giblock <pgib/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Paul Giblock <pgib/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -785,7 +785,8 @@ void lb302Synth::initNote( lb302Note *n)
}
void lb302Synth::playNote( notePlayHandle * _n, bool )
void lb302Synth::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
fpp_t framesPerPeriod = engine::getMixer()->framesPerPeriod();
@@ -947,12 +948,8 @@ void lb302Synth::playNote( notePlayHandle * _n, bool )
}
sampleFrame *buf = new sampleFrame[frames];
process(buf, frames);
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
delete[] buf;
process( _working_buffer, frames);
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
lastFramesPlayed = frames; //_n->framesLeftForCurrentPeriod(); //_n->totalFramesPlayed();
}

View File

@@ -2,7 +2,7 @@
* lb302.h - declaration of class lb302 which is a bass synth attempting to
* emulate the Roland TB303 bass synth
*
* Copyright (c) 2006-2007 Paul Giblock <pgib/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Paul Giblock <pgib/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -191,14 +191,13 @@ public:
lb302Synth( instrumentTrack * _channel_track );
virtual ~lb302Synth();
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;

View File

@@ -1,7 +1,7 @@
/*
* organic.cpp - additive synthesizer for organ-like sounds
*
* Copyright (c) 2006-2007 Andreas Brandmaier <andy/at/brandmaier/dot/de>
* Copyright (c) 2006-2008 Andreas Brandmaier <andy/at/brandmaier/dot/de>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -182,7 +182,8 @@ QString organicInstrument::nodeName( void ) const
void organicInstrument::playNote( notePlayHandle * _n, bool )
void organicInstrument::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
if( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL )
{
@@ -256,10 +257,9 @@ void organicInstrument::playNote( notePlayHandle * _n, bool )
)->oscRight;
const fpp_t frames = _n->framesLeftForCurrentPeriod();
sampleFrame * buf = new sampleFrame[frames];
osc_l->update( buf, frames, 0 );
osc_r->update( buf, frames, 1 );
osc_l->update( _working_buffer, frames, 0 );
osc_r->update( _working_buffer, frames, 1 );
// -- fx section --
@@ -269,17 +269,15 @@ void organicInstrument::playNote( notePlayHandle * _n, bool )
for (int i=0 ; i < frames ; i++)
{
buf[i][0] = waveshape( buf[i][0], t ) * m_volModel.value()
/ 100.0f;
buf[i][1] = waveshape( buf[i][1], t ) * m_volModel.value()
/ 100.0f;
_working_buffer[i][0] = waveshape( _working_buffer[i][0], t ) *
m_volModel.value() / 100.0f;
_working_buffer[i][1] = waveshape( _working_buffer[i][1], t ) *
m_volModel.value() / 100.0f;
}
// -- --
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
delete[] buf;
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
}

View File

@@ -1,7 +1,7 @@
/*
* organic.h - additive synthesizer for organ-like sounds
*
* Copyright (c) 2006-2007 Andreas Brandmaier <andy/at/brandmaier/dot/de>
* Copyright (c) 2006-2008 Andreas Brandmaier <andy/at/brandmaier/dot/de>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -83,14 +83,13 @@ public:
organicInstrument( instrumentTrack * _channel_track );
virtual ~organicInstrument();
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;

View File

@@ -132,7 +132,8 @@ QString patmanInstrument::nodeName( void ) const
void patmanInstrument::playNote( notePlayHandle * _n, bool )
void patmanInstrument::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
if( m_patchFile == "" )
{
@@ -140,7 +141,6 @@ void patmanInstrument::playNote( notePlayHandle * _n, bool )
}
const fpp_t frames = _n->framesLeftForCurrentPeriod();
sampleFrame * buf = new sampleFrame[frames];
if( !_n->m_pluginData )
{
@@ -151,12 +151,12 @@ void patmanInstrument::playNote( notePlayHandle * _n, bool )
float play_freq = hdata->tuned ? _n->frequency() :
hdata->sample->frequency();
if( hdata->sample->play( buf, hdata->state, frames, play_freq,
m_loopedModel.value() ) )
if( hdata->sample->play( _working_buffer, hdata->state, frames,
play_freq, m_loopedModel.value() ) )
{
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
getInstrumentTrack()->processAudioBuffer( _working_buffer,
frames, _n );
}
delete[] buf;
}

View File

@@ -68,13 +68,12 @@ public:
patmanInstrument( instrumentTrack * _track );
virtual ~patmanInstrument();
virtual void playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual void setParameter( const QString & _param,

View File

@@ -210,7 +210,7 @@ void sf2Instrument::updatePatch( void )
void sf2Instrument::playNote( notePlayHandle * _n, bool )
void sf2Instrument::playNote( notePlayHandle * _n, bool, sampleFrame * )
{
const float LOG440 = 2.64345267649f;
@@ -245,19 +245,18 @@ void sf2Instrument::playNote( notePlayHandle * _n, bool )
void sf2Instrument::play( bool _try_parallelizing )
void sf2Instrument::play( bool _try_parallelizing,
sampleFrame * _working_buffer )
{
const fpp_t frames = engine::getMixer()->framesPerPeriod();
sampleFrame * buf = new sampleFrame[frames];
m_synthMutex.lock();
fluid_synth_write_float( m_synth, frames, buf, 0, 2, buf, 1, 2 );
fluid_synth_write_float( m_synth, frames, _working_buffer, 0, 2,
_working_buffer, 1, 2 );
m_synthMutex.unlock();
getInstrumentTrack()->processAudioBuffer( buf, frames, NULL );
delete[] buf;
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames,
NULL );
}

View File

@@ -49,16 +49,16 @@ public:
sf2Instrument( instrumentTrack * _instrument_track );
virtual ~sf2Instrument();
virtual void play( bool _try_parallelizing );
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;

View File

@@ -126,8 +126,6 @@ malletsInstrument::malletsInstrument( instrumentTrack * _instrument_track ):
m_scalers.append( 16.0 );
m_presetsModel.addItem( tr( "Tibetan Bowl" ) );
m_scalers.append( 7.0 );
m_buffer = new sampleFrame[engine::getMixer()->framesPerPeriod()];
}
@@ -135,7 +133,6 @@ malletsInstrument::malletsInstrument( instrumentTrack * _instrument_track ):
malletsInstrument::~malletsInstrument()
{
delete[] m_buffer;
}
@@ -209,7 +206,8 @@ QString malletsInstrument::nodeName( void ) const
void malletsInstrument::playNote( notePlayHandle * _n, bool )
void malletsInstrument::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
if( m_filesMissing )
{
@@ -274,18 +272,13 @@ void malletsInstrument::playNote( notePlayHandle * _n, bool )
}
for( fpp_t frame = 0; frame < frames; ++frame )
{
const sample_t left = ps->nextSampleLeft() *
( m_scalers[m_presetsModel.value()] + add_scale );
const sample_t right = ps->nextSampleRight() *
( m_scalers[m_presetsModel.value()] + add_scale );
for( Uint8 chnl = 0; chnl < DEFAULT_CHANNELS / 2; ++chnl )
{
m_buffer[frame][chnl * DEFAULT_CHANNELS / 2] = left;
m_buffer[frame][( chnl + 1 ) * DEFAULT_CHANNELS / 2] = right;
}
_working_buffer[frame][0] = ps->nextSampleLeft() *
( m_scalers[m_presetsModel.value()] + add_scale );
_working_buffer[frame][1] = ps->nextSampleRight() *
( m_scalers[m_presetsModel.value()] + add_scale );
}
getInstrumentTrack()->processAudioBuffer( m_buffer, frames, _n );
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
}

View File

@@ -123,19 +123,19 @@ public:
malletsInstrument( instrumentTrack * _channel_track );
virtual ~malletsInstrument( void );
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;
virtual pluginView * instantiateView( QWidget * _parent );
private:
knobModel m_hardnessModel;
knobModel m_positionModel;
@@ -160,7 +160,6 @@ private:
knobModel m_spreadModel;
QVector<sample_t> m_scalers;
sampleFrame * m_buffer;
bool m_filesMissing;

View File

@@ -319,7 +319,8 @@ QString tripleOscillator::nodeName( void ) const
void tripleOscillator::playNote( notePlayHandle * _n, bool )
void tripleOscillator::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
if( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL )
{
@@ -383,16 +384,13 @@ void tripleOscillator::playNote( notePlayHandle * _n, bool )
)->oscRight;
const fpp_t frames = _n->framesLeftForCurrentPeriod();
sampleFrame * buf = new sampleFrame[frames];
osc_l->update( buf, frames, 0 );
osc_r->update( buf, frames, 1 );
osc_l->update( _working_buffer, frames, 0 );
osc_r->update( _working_buffer, frames, 1 );
applyRelease( buf, _n );
applyRelease( _working_buffer, _n );
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
delete[] buf;
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
}

View File

@@ -98,16 +98,15 @@ public:
tripleOscillator( instrumentTrack * _track );
virtual ~tripleOscillator();
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual void FASTCALL setParameter( const QString & _param,
virtual void setParameter( const QString & _param,
const QString & _value );
virtual QString nodeName( void ) const;

View File

@@ -231,7 +231,7 @@ void vestigeInstrument::waitForWorkerThread( void )
void vestigeInstrument::play( bool _try_parallelizing )
void vestigeInstrument::play( bool _try_parallelizing, sampleFrame * )
{
m_pluginMutex.lock();
if( m_plugin == NULL )
@@ -254,7 +254,7 @@ void vestigeInstrument::play( bool _try_parallelizing )
void vestigeInstrument::playNote( notePlayHandle * _n, bool )
void vestigeInstrument::playNote( notePlayHandle * _n, bool, sampleFrame * )
{
m_pluginMutex.lock();
if( _n->totalFramesPlayed() == 0 && m_plugin != NULL )

View File

@@ -50,20 +50,20 @@ public:
vestigeInstrument( instrumentTrack * _channel_track );
virtual ~vestigeInstrument();
virtual void play( bool _try_parallelizing );
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;
virtual void FASTCALL setParameter( const QString & _param,
virtual void setParameter( const QString & _param,
const QString & _value );
virtual bool supportsParallelizing( void ) const

View File

@@ -271,7 +271,7 @@ QString vibed::nodeName( void ) const
void vibed::playNote( notePlayHandle * _n, bool )
void vibed::playNote( notePlayHandle * _n, bool, sampleFrame * _working_buffer )
{
if ( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL )
{
@@ -304,12 +304,10 @@ void vibed::playNote( notePlayHandle * _n, bool )
stringContainer * ps = static_cast<stringContainer *>(
_n->m_pluginData );
sampleFrame * buf = new sampleFrame[frames];
for( fpp_t i = 0; i < frames; ++i )
{
buf[i][0] = 0.0f;
buf[i][1] = 0.0f;
_working_buffer[i][0] = 0.0f;
_working_buffer[i][1] = 0.0f;
Uint8 s = 0;
for( Uint8 string = 0; string < 9; ++string )
{
@@ -319,19 +317,17 @@ void vibed::playNote( notePlayHandle * _n, bool )
const float pan = (
m_panKnobs[string]->value() + 1 ) /
2.0f;
const sample_t sample = ps->getStringSample(
s ) *
const sample_t sample =
ps->getStringSample( s ) *
m_volumeKnobs[string]->value() / 100.0f;
buf[i][0] += ( 1.0f - pan ) * sample;
buf[i][1] += pan * sample;
_working_buffer[i][0] += ( 1.0f - pan ) * sample;
_working_buffer[i][1] += pan * sample;
s++;
}
}
}
getInstrumentTrack()->processAudioBuffer( buf, frames, _n );
delete[] buf;
getInstrumentTrack()->processAudioBuffer( _working_buffer, frames, _n );
}

View File

@@ -45,14 +45,13 @@ public:
vibed( instrumentTrack * _channel_track );
virtual ~vibed();
virtual void FASTCALL playNote( notePlayHandle * _n,
bool _try_parallelizing );
virtual void FASTCALL deleteNotePluginData( notePlayHandle * _n );
virtual void playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual void deleteNotePluginData( notePlayHandle * _n );
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName( void ) const;

View File

@@ -49,14 +49,7 @@ instrument::~instrument()
void instrument::play( bool )
{
}
void instrument::playNote( notePlayHandle *, bool )
void instrument::play( bool, sampleFrame * )
{
}

View File

@@ -68,6 +68,39 @@
sample_rate_t SAMPLE_RATES[QUALITY_LEVELS] = { 44100, 88200 } ;
#define ALIGN_SIZE 64
void aligned_free( void * _buf )
{
if( _buf != NULL )
{
int *ptr2=(int *)_buf - 1;
_buf = (char *)_buf- *ptr2;
free(_buf);
}
}
void * aligned_malloc( int _bytes )
{
char *ptr,*ptr2,*aligned_ptr;
int align_mask = ALIGN_SIZE- 1;
ptr=(char *)malloc(_bytes +ALIGN_SIZE+ sizeof(int));
if(ptr==NULL) return(NULL);
ptr2 = ptr + sizeof(int);
aligned_ptr = ptr2 + (ALIGN_SIZE- ((size_t)ptr2 & align_mask));
ptr2 = aligned_ptr - sizeof(int);
*((int *)ptr2)=(int)(aligned_ptr - ptr);
return(aligned_ptr);
}
class mixerWorkerThread : public QThread
{
public:
@@ -146,6 +179,9 @@ public:
private:
virtual void run( void )
{
sampleFrame * working_buf = (sampleFrame *) aligned_malloc(
m_mixer->framesPerPeriod() *
sizeof( sampleFrame ) );
m_jobWait.acquire();
m_jobAccepted.acquire();
m_idle = TRUE;
@@ -167,7 +203,7 @@ private:
switch( it->type )
{
case PlayHandle:
it->playHandleJob->play();
it->playHandleJob->play( FALSE, working_buf );
break;
case AudioPortEffects:
{
@@ -196,6 +232,7 @@ private:
m_idle = TRUE;
m_sem->release();
}
aligned_free( working_buf );
}
mixer * m_mixer;
@@ -211,6 +248,7 @@ private:
mixer::mixer( void ) :
m_framesPerPeriod( DEFAULT_BUFFER_SIZE ),
m_workingBuf( NULL ),
m_readBuf( NULL ),
m_writeBuf( NULL ),
m_cpuLoad( 0 ),
@@ -249,10 +287,14 @@ mixer::mixer( void ) :
m_fifo = new fifo( 1 );
}
m_workingBuf = (sampleFrame*) aligned_malloc( m_framesPerPeriod *
sizeof( sampleFrame ) );
for( Uint8 i = 0; i < 3; i++ )
{
m_readBuf = new surroundSampleFrame[m_framesPerPeriod];
m_readBuf = (surroundSampleFrame*)
aligned_malloc( m_framesPerPeriod *
sizeof( surroundSampleFrame ) );
clearAudioBuffer( m_readBuf, m_framesPerPeriod );
m_bufferPool.push_back( m_readBuf );
}
@@ -287,8 +329,10 @@ mixer::~mixer()
for( Uint8 i = 0; i < 3; i++ )
{
delete[] m_bufferPool[i];
aligned_free( m_bufferPool[i] );
}
aligned_free( m_workingBuf );
}
@@ -435,7 +479,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
playHandle * n = m_playHandles[idx];
if( !n->done() && n->supportsParallelizing() )
{
n->play( TRUE );
n->play( TRUE, m_workingBuf );
par_hndls.push_back( n );
}
++idx;
@@ -489,7 +533,7 @@ if( COND_NPH )
if( !( *it )->done() )
{
( *it )->play();
( *it )->play( FALSE, m_workingBuf );
}
}
}

View File

@@ -157,7 +157,8 @@ notePlayHandle::~notePlayHandle()
void notePlayHandle::play( bool _try_parallelizing )
void notePlayHandle::play( bool _try_parallelizing,
sampleFrame * _working_buffer )
{
if( m_muted == TRUE )
{
@@ -177,7 +178,8 @@ void notePlayHandle::play( bool _try_parallelizing )
if( framesLeft() > 0 )
{
// play note!
m_instrumentTrack->playNote( this, _try_parallelizing );
m_instrumentTrack->playNote( this, _try_parallelizing,
_working_buffer );
}
if( m_released == TRUE )
@@ -238,7 +240,7 @@ void notePlayHandle::play( bool _try_parallelizing )
for( notePlayHandleVector::iterator it = m_subNotes.begin();
it != m_subNotes.end(); )
{
( *it )->play( _try_parallelizing );
( *it )->play( _try_parallelizing, _working_buffer );
if( ( *it )->done() )
{
delete *it;

View File

@@ -161,9 +161,10 @@ presetPreviewPlayHandle::~presetPreviewPlayHandle()
void presetPreviewPlayHandle::play( bool _try_parallelizing )
void presetPreviewPlayHandle::play( bool _try_parallelizing,
sampleFrame * _working_buffer )
{
m_previewNote->play( _try_parallelizing );
m_previewNote->play( _try_parallelizing, _working_buffer );
}

View File

@@ -116,7 +116,8 @@ samplePlayHandle::~samplePlayHandle()
void samplePlayHandle::play( bool /* _try_parallelizing */ )
void samplePlayHandle::play( bool /* _try_parallelizing */,
sampleFrame * _working_buffer )
{
//play( 0, _try_parallelizing );
if( framesDone() >= totalFrames() )
@@ -128,14 +129,11 @@ void samplePlayHandle::play( bool /* _try_parallelizing */ )
if( !( m_track && m_track->muted() )
&& !( m_bbTrack && m_bbTrack->muted() ) )
{
sampleFrame * buf = new sampleFrame[frames];
stereoVolumeVector v = { { m_volumeModel->value(),
m_volumeModel->value() } };
m_sampleBuffer->play( buf, &m_state, frames );
engine::getMixer()->bufferToPort( buf, frames, offset(), v,
m_audioPort );
delete[] buf;
m_sampleBuffer->play( _working_buffer, &m_state, frames );
engine::getMixer()->bufferToPort( _working_buffer, frames,
offset(), v, m_audioPort );
}
m_frame += frames;

View File

@@ -338,7 +338,8 @@ void instrumentTrack::processOutEvent( const midiEvent & _me,
void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing )
void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing,
sampleFrame * _working_buffer )
{
// arpeggio- and chord-widget has to do its work -> adding sub-notes
// for chords/arpeggios
@@ -400,7 +401,8 @@ void instrumentTrack::playNote( notePlayHandle * _n, bool _try_parallelizing )
}
}
// all is done, so now lets play the note!
m_instrument->playNote( _n, _try_parallelizing );
m_instrument->playNote( _n, _try_parallelizing,
_working_buffer );
}
}