made quality-settings (internal processing samplerate, interpolation and so on) independent of audio-devices (final output) and added new qualitySettings-structure to mixer - might be still buggy and HQ-mode is currently not working, this is going to be fixed tomorrow, anyways important preparation for new project-export-dialog

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@957 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-05-05 23:14:48 +00:00
parent 2b7b813f2f
commit 5cfb1b2f96
57 changed files with 441 additions and 325 deletions

View File

@@ -206,7 +206,8 @@ QString audioFileProcessor::nodeName( void ) const
Uint32 audioFileProcessor::getBeatLen( notePlayHandle * _n ) const
{
const float freq_factor = BaseFreq / _n->frequency() *
engine::getMixer()->sampleRate() / DEFAULT_SAMPLE_RATE;
engine::getMixer()->processingSampleRate() /
engine::getMixer()->baseSampleRate();
return( static_cast<Uint32>( floorf( ( m_sampleBuffer.endFrame() -
m_sampleBuffer.startFrame() ) *

View File

@@ -246,7 +246,7 @@ void bitInvader::normalize( void )
// analyze
float max = 0;
const float* samples = m_graph.samples();
for (int i=0; i < m_graph.length(); i++)
for (unsigned int i=0; i < m_graph.length(); i++)
{
if (fabsf(samples[i]) > max) { max = fabs(samples[i]); }
}
@@ -277,10 +277,12 @@ void bitInvader::playNote( notePlayHandle * _n, bool,
factor = normalizeFactor;
}
_n->m_pluginData = new bSynth( const_cast<float*>( m_graph.samples() ),
_n->m_pluginData = new bSynth(
const_cast<float*>( m_graph.samples() ),
m_graph.length(),
_n->frequency(), m_interpolation.value(), factor,
engine::getMixer()->sampleRate() );
_n->frequency(),
m_interpolation.value(), factor,
engine::getMixer()->processingSampleRate() );
}
const fpp_t frames = _n->framesLeftForCurrentPeriod();

View File

@@ -123,7 +123,7 @@ void kickerInstrument::playNote( notePlayHandle * _n, bool,
sampleFrame * _working_buffer )
{
const float decfr = m_decayModel.value() *
engine::getMixer()->sampleRate() / 1000.0f;
engine::getMixer()->processingSampleRate() / 1000.0f;
const f_cnt_t tfp = _n->totalFramesPlayed();
if ( tfp == 0 )
@@ -152,7 +152,7 @@ void kickerInstrument::playNote( notePlayHandle * _n, bool,
sweepOsc * so = static_cast<sweepOsc *>( _n->m_pluginData );
so->update( _working_buffer, frames, f1, f2,
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
if( _n->released() )
{

View File

@@ -1,7 +1,7 @@
/*
* ladspa_port_dialog.cpp - dialog to test a LADSPA plugin
*
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -95,11 +95,11 @@ ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key )
{
if( min != NOHINT )
{
min *= engine::getMixer()->sampleRate();
min *= engine::getMixer()->processingSampleRate();
}
if( max != NOHINT )
{
max *= engine::getMixer()->sampleRate();
max *= engine::getMixer()->processingSampleRate();
}
}

View File

@@ -227,7 +227,7 @@ void ladspaEffect::pluginInstantiation( void )
if( manager->areHintsSampleRateDependent(
m_key, port ) )
{
p->max *= engine::getMixer()->sampleRate();
p->max *= engine::getMixer()->processingSampleRate();
}
p->min = manager->getLowerBound( m_key, port );
@@ -239,7 +239,7 @@ void ladspaEffect::pluginInstantiation( void )
if( manager->areHintsSampleRateDependent(
m_key, port ) )
{
p->min *= engine::getMixer()->sampleRate();
p->min *= engine::getMixer()->processingSampleRate();
}
p->def = manager->getDefaultSetting( m_key, port );
@@ -296,7 +296,7 @@ void ladspaEffect::pluginInstantiation( void )
for( ch_cnt_t proc = 0; proc < getProcessorCount(); proc++ )
{
LADSPA_Handle effect = manager->instantiate( m_key,
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
if( effect == NULL )
{
QMessageBox::warning( 0, "Effect",

View File

@@ -72,7 +72,7 @@
//
//#define engine::getMixer()->sampleRate() 44100.0f
//#define engine::getMixer()->processingSampleRate() 44100.0f
extern "C"
@@ -110,8 +110,8 @@ void lb302Filter::recalc()
{
vcf_e1 = exp(6.109 + 1.5876*(fs->envmod) + 2.1553*(fs->cutoff) - 1.2*(1.0-(fs->reso)));
vcf_e0 = exp(5.613 - 0.8*(fs->envmod) + 2.1553*(fs->cutoff) - 0.7696*(1.0-(fs->reso)));
vcf_e0*=M_PI/engine::getMixer()->sampleRate();
vcf_e1*=M_PI/engine::getMixer()->sampleRate();
vcf_e0*=M_PI/engine::getMixer()->processingSampleRate();
vcf_e1*=M_PI/engine::getMixer()->processingSampleRate();
vcf_e1 -= vcf_e0;
vcf_rescoeff = exp(-1.20 + 3.455*(fs->reso));
@@ -249,14 +249,14 @@ void lb302Filter3Pole::envRecalc()
w = vcf_e0 + vcf_c0;
k = (fs->cutoff > 0.975)?0.975:fs->cutoff;
kfco = 50.f + (k)*((2300.f-1600.f*(fs->envmod))+(w) *
(700.f+1500.f*(k)+(1500.f+(k)*(engine::getMixer()->sampleRate()/2.f-6000.f)) *
(700.f+1500.f*(k)+(1500.f+(k)*(engine::getMixer()->processingSampleRate()/2.f-6000.f)) *
(fs->envmod)) );
//+iacc*(.3+.7*kfco*kenvmod)*kaccent*kaccurve*2000
#ifdef LB_24_IGNORE_ENVELOPE
// kfcn = fs->cutoff;
kfcn = 2.0 * kfco / engine::getMixer()->sampleRate();
kfcn = 2.0 * kfco / engine::getMixer()->processingSampleRate();
#else
kfcn = w;
#endif
@@ -490,7 +490,7 @@ void lb302Synth::filterChanged( void )
float d = 0.2 + (2.3*vcf_dec_knob.value());
d *= engine::getMixer()->sampleRate(); // d *= smpl rate
d *= engine::getMixer()->processingSampleRate(); // d *= smpl rate
fs.envdecay = pow(0.1, 1.0/d * ENVINC); // decay is 0.1 to the 1/d * ENVINC
// vcf_envdecay is now adjusted for both
// sampling rate and ENVINC
@@ -513,15 +513,15 @@ void lb302Synth::db24Toggled( void )
void lb302Synth::detuneChanged( void )
{
float freq = vco_inc*engine::getMixer()->sampleRate()/vco_detune;
float freq = vco_inc*engine::getMixer()->processingSampleRate()/vco_detune;
float slidebase_freq=0;
if(vco_slide) {
slidebase_freq = vco_slidebase*engine::getMixer()->sampleRate()/vco_detune;
slidebase_freq = vco_slidebase*engine::getMixer()->processingSampleRate()/vco_detune;
}
vco_detune = powf(2.0f, (float)vco_fine_detune_knob.value()/1200.0f);
vco_inc = freq*vco_detune/engine::getMixer()->sampleRate();
vco_inc = freq*vco_detune/engine::getMixer()->processingSampleRate();
// If a slide note is pending,
if(vco_slideinc)
@@ -530,7 +530,7 @@ void lb302Synth::detuneChanged( void )
// If currently sliding,
// May need to rescale vco_slide as well
if(vco_slide)
vco_slidebase = slidebase_freq*vco_detune/engine::getMixer()->sampleRate();
vco_slidebase = slidebase_freq*vco_detune/engine::getMixer()->processingSampleRate();
}
@@ -565,7 +565,7 @@ void lb302Synth::recalcFilter()
// THIS IS OLD 3pole/24dB code, I may reintegrate it. Don't need it
// right now. Should be toggled by LB_24_RES_TRICK at the moment.
/*kfcn = 2.0 * (((vcf_cutoff*3000))) / engine::getMixer()->sampleRate();
/*kfcn = 2.0 * (((vcf_cutoff*3000))) / engine::getMixer()->processingSampleRate();
kp = ((-2.7528*kfcn + 3.0429)*kfcn + 1.718)*kfcn - 0.9984;
kp1 = kp+1.0;
kp1h = 0.5*kp1;
@@ -708,7 +708,7 @@ int lb302Synth::process(sampleFrame *outbuf, const Uint32 size)
// Handle Envelope
if(vca_mode==0) {
vca_a+=(vca_a0-vca_a)*vca_attack;
if(sample_cnt>=0.5*engine::getMixer()->sampleRate())
if(sample_cnt>=0.5*engine::getMixer()->processingSampleRate())
vca_mode = 2;
}
else if(vca_mode == 1) {
@@ -925,14 +925,14 @@ void lb302Synth::playNote( notePlayHandle * _n, bool,
// END NOT SURE OF
// Reserve this note for retrigger in process()
hold_note.vco_inc = _n->frequency()*vco_detune/engine::getMixer()->sampleRate(); // TODO: Use actual sampling rate.
hold_note.vco_inc = _n->frequency()*vco_detune/engine::getMixer()->processingSampleRate(); // TODO: Use actual sampling rate.
hold_note.dead = deadToggle->value();
use_hold_note = true;
catch_decay = 1;
}
#else
lb302Note note;
note.vco_inc = _n->frequency()*vco_detune/engine::getMixer()->sampleRate(); // TODO: Use actual sampling rate.
note.vco_inc = _n->frequency()*vco_detune/engine::getMixer()->processingSampleRate(); // TODO: Use actual sampling rate.
note.dead = deadToggle.value();
initNote(&note);
vca_mode=0;
@@ -943,7 +943,7 @@ void lb302Synth::playNote( notePlayHandle * _n, bool,
/// Start a new note.
else {
lb302Note note;
note.vco_inc = _n->frequency()*vco_detune/engine::getMixer()->sampleRate(); // TODO: Use actual sampling rate.
note.vco_inc = _n->frequency()*vco_detune/engine::getMixer()->processingSampleRate(); // TODO: Use actual sampling rate.
note.dead = deadToggle.value();
initNote(&note);
use_hold_note = false;

View File

@@ -140,11 +140,11 @@ void liveToolView::keyPressEvent( QKeyEvent * _ke )
switch( _ke->key() )
{
case Qt::Key_Space:
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
engine::getSong()->pause();
}
else if( engine::getSong()->paused() &&
else if( engine::getSong()->isPaused() &&
engine::getSong()->playMode() ==
song::Mode_PlaySong )
{

View File

@@ -572,11 +572,11 @@ void oscillatorObject::updateVolume( void )
void oscillatorObject::updateDetuning( void )
{
m_detuningLeft = powf( 2.0f, m_harmonic
+ (float)m_detuneModel.value() / 100.0f )
/ engine::getMixer()->sampleRate();
+ (float)m_detuneModel.value() / 100.0f ) /
engine::getMixer()->processingSampleRate();
m_detuningRight = powf( 2.0f, m_harmonic
- (float)m_detuneModel.value() / 100.0f )
/ engine::getMixer()->sampleRate();
- (float)m_detuneModel.value() / 100.0f ) /
engine::getMixer()->processingSampleRate();
}

View File

@@ -386,7 +386,8 @@ void sf2Instrument::updateSampleRate( void )
double tempRate;
// Set & get, returns the true sample rate
fluid_settings_setnum( m_settings, "synth.sample-rate", engine::getMixer()->sampleRate() );
fluid_settings_setnum( m_settings, "synth.sample-rate",
engine::getMixer()->processingSampleRate() );
fluid_settings_getnum( m_settings, "synth.sample-rate", &tempRate );
m_internalSampleRate = static_cast<int>( tempRate );
@@ -414,7 +415,7 @@ void sf2Instrument::updateSampleRate( void )
m_synthMutex.unlock();
}
if( m_internalSampleRate < engine::getMixer()->sampleRate() )
if( m_internalSampleRate < engine::getMixer()->processingSampleRate() )
{
m_synthMutex.lock();
if( m_srcState != NULL )
@@ -480,11 +481,11 @@ void sf2Instrument::play( bool _try_parallelizing,
m_synthMutex.lock();
if( m_internalSampleRate < engine::getMixer()->sampleRate() &&
if( m_internalSampleRate < engine::getMixer()->processingSampleRate() &&
m_srcState != NULL )
{
const fpp_t f = frames * m_internalSampleRate /
engine::getMixer()->sampleRate();
engine::getMixer()->processingSampleRate();
sampleFrame * tmp = new sampleFrame[f];
fluid_synth_write_float( m_synth, f, tmp, 0, 2, tmp, 1, 2 );

View File

@@ -232,7 +232,7 @@ void malletsInstrument::playNote( notePlayHandle * _n, bool,
m_vibratoFreqModel.value(),
p,
(Uint8) m_spreadModel.value(),
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
}
else if( p == 9 )
{
@@ -245,7 +245,7 @@ void malletsInstrument::playNote( notePlayHandle * _n, bool,
m_lfoSpeedModel.value(),
m_adsrModel.value(),
(Uint8) m_spreadModel.value(),
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
}
else
{
@@ -258,7 +258,7 @@ void malletsInstrument::playNote( notePlayHandle * _n, bool,
m_strikeModel.value() * 128.0,
m_velocityModel.value(),
(Uint8) m_spreadModel.value(),
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
}
}

View File

@@ -181,7 +181,7 @@ void oscillatorObject::updateDetuningLeft( void )
{
m_detuningLeft = powf( 2.0f, ( (float)m_coarseModel.value() * 100.0f
+ (float)m_fineLeftModel.value() ) / 1200.0f )
/ engine::getMixer()->sampleRate();
/ engine::getMixer()->processingSampleRate();
}
@@ -191,7 +191,7 @@ void oscillatorObject::updateDetuningRight( void )
{
m_detuningRight = powf( 2.0f, ( (float)m_coarseModel.value() * 100.0f
+ (float)m_fineRightModel.value() ) / 1200.0f )
/ engine::getMixer()->sampleRate();
/ engine::getMixer()->processingSampleRate();
}

View File

@@ -276,7 +276,7 @@ void vibed::playNote( notePlayHandle * _n, bool, sampleFrame * _working_buffer )
if ( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL )
{
_n->m_pluginData = new stringContainer( _n->frequency(),
engine::getMixer()->sampleRate(),
engine::getMixer()->processingSampleRate(),
m_sampleLength );
for( Uint8 i = 0; i < 9; ++i )

View File

@@ -1,7 +1,7 @@
/*
* vibrating_sring.h - model of a vibrating string lifted from pluckedSynth
*
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/yahoo/com>
* Copyright (c) 2006-2008 Danny McRae <khjklujn/at/yahoo/com>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -27,6 +27,8 @@
#include "templates.h"
#include "interpolation.h"
#include "mixer.h"
#include "engine.h"
vibratingString::vibratingString( float _pitch,
float _pick,
@@ -39,7 +41,8 @@ vibratingString::vibratingString( float _pitch,
float _string_loss,
float _detune,
bool _state ) :
m_oversample( 2 * _oversample / (int)( _sample_rate / SAMPLE_RATES[0] ) ),
m_oversample( 2 * _oversample / (int)( _sample_rate /
engine::getMixer()->baseSampleRate() ) ),
m_randomize( _randomize ),
m_stringLoss( 1.0f - _string_loss ),
m_state( 0.1f )

View File

@@ -422,7 +422,8 @@ void remoteVSTPlugin::updateSampleRate( void )
{
lock();
writeValueS<Sint16>( VST_SAMPLE_RATE );
writeValueS<sample_rate_t>( engine::getMixer()->sampleRate() );
writeValueS<sample_rate_t>(
engine::getMixer()->processingSampleRate() );
unlock();
}
@@ -530,7 +531,7 @@ Sint16 remoteVSTPlugin::processNextMessage( void )
writeValueS<Sint16>( VST_SAMPLE_RATE );
// handle is the same
writeValueS<sample_rate_t>(
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
break;
case VST_GET_BUFFER_SIZE: