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

@@ -43,9 +43,8 @@
audioALSA::audioALSA( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, tLimit<ch_cnt_t>(
audioALSA::audioALSA( bool & _success_ful, mixer * _mixer ) :
audioDevice( tLimit<ch_cnt_t>(
configManager::inst()->value( "audioalsa", "channels" ).toInt(),
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
_mixer ),
@@ -70,7 +69,7 @@ audioALSA::audioALSA( const sample_rate_t _sample_rate, bool & _success_ful,
snd_pcm_hw_params_malloc( &m_hwParams );
snd_pcm_sw_params_malloc( &m_swParams );
if( ( err = setHWParams( _sample_rate, channels(),
if( ( err = setHWParams( channels(),
SND_PCM_ACCESS_RW_INTERLEAVED ) ) < 0 )
{
printf( "Setting of hwparams failed: %s\n",
@@ -267,9 +266,7 @@ void audioALSA::run( void )
int audioALSA::setHWParams( const sample_rate_t _sample_rate,
const ch_cnt_t _channels,
snd_pcm_access_t _access )
int audioALSA::setHWParams( const ch_cnt_t _channels, snd_pcm_access_t _access )
{
int err, dir;
@@ -320,32 +317,20 @@ int audioALSA::setHWParams( const sample_rate_t _sample_rate,
// set the sample rate
if( ( err = snd_pcm_hw_params_set_rate( m_handle, m_hwParams,
_sample_rate, 0 ) ) < 0 )
sampleRate(), 0 ) ) < 0 )
{
int q = 0;
if( sampleRate() == SAMPLE_RATES[1] )
{
q = 1;
}
if( sampleRate() == 44100 || sampleRate() == 88200 )
{
SAMPLE_RATES[0] = 48000;
SAMPLE_RATES[1] = 96000;
}
else
{
SAMPLE_RATES[0] = 44100;
SAMPLE_RATES[1] = 88200;
}
setSampleRate( SAMPLE_RATES[q] );
if( ( err = snd_pcm_hw_params_set_rate( m_handle, m_hwParams,
SAMPLE_RATES[q], 0 ) ) < 0 )
getMixer()->baseSampleRate(), 0 ) ) < 0 )
{
printf( "Could not set sample rate: %s\n",
snd_strerror( err ) );
return( err );
}
}
else
{
setSampleRate( getMixer()->processingSampleRate() );
}
m_periodSize = getMixer()->framesPerPeriod();
m_bufferSize = m_periodSize * 8;

View File

@@ -3,7 +3,7 @@
/*
* audio_device.cpp - base-class for audio-devices used by LMMS-mixer
*
* 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
*
@@ -37,20 +37,15 @@
audioDevice::audioDevice( const sample_rate_t _sample_rate,
const ch_cnt_t _channels, mixer * _mixer ) :
m_sampleRate( _sample_rate ),
audioDevice::audioDevice( const ch_cnt_t _channels, mixer * _mixer ) :
m_sampleRate( _mixer->processingSampleRate() ),
m_channels( _channels ),
m_mixer( _mixer ),
m_buffer( new surroundSampleFrame[getMixer()->framesPerPeriod()] )
{
int error;
if( ( m_srcState = src_new(
#ifdef HQ_SINC
SRC_SINC_BEST_QUALITY,
#else
SRC_SINC_FASTEST,
#endif
getMixer()->qualitySettings().libsrcInterpolation(),
SURROUND_CHANNELS, &error ) ) == NULL )
{
printf( "Error: src_new() failed in audio_device.cpp!\n" );
@@ -102,11 +97,12 @@ fpp_t audioDevice::getNextBuffer( surroundSampleFrame * _ab )
lock();
// now were safe to access the device
if( getMixer()->sampleRate() != m_sampleRate )
if( getMixer()->processingSampleRate() != m_sampleRate )
{
resample( b, frames, _ab, getMixer()->sampleRate(),
resample( b, frames, _ab, getMixer()->processingSampleRate(),
m_sampleRate );
frames = frames * m_sampleRate / getMixer()->sampleRate();
frames = frames * m_sampleRate /
getMixer()->processingSampleRate();
}
else
{
@@ -156,7 +152,7 @@ void audioDevice::renamePort( audioPort * )
void FASTCALL audioDevice::resample( const surroundSampleFrame * _src,
void audioDevice::resample( const surroundSampleFrame * _src,
const fpp_t _frames,
surroundSampleFrame * _dst,
const sample_rate_t _src_sr,
@@ -183,7 +179,7 @@ void FASTCALL audioDevice::resample( const surroundSampleFrame * _src,
Uint32 FASTCALL audioDevice::convertToS16( const surroundSampleFrame * _ab,
Uint32 audioDevice::convertToS16( const surroundSampleFrame * _ab,
const fpp_t _frames,
const float _master_gain,
int_sample_t * _output_buffer,
@@ -228,8 +224,7 @@ Uint32 FASTCALL audioDevice::convertToS16( const surroundSampleFrame * _ab,
void FASTCALL audioDevice::clearS16Buffer( int_sample_t * _outbuf,
const fpp_t _frames )
void audioDevice::clearS16Buffer( int_sample_t * _outbuf, const fpp_t _frames )
{
#ifdef LMMS_DEBUG
assert( _outbuf != NULL );

View File

@@ -40,13 +40,15 @@ audioFileDevice::audioFileDevice( const sample_rate_t _sample_rate,
const bitrate_t _min_bitrate,
const bitrate_t _max_bitrate,
mixer * _mixer ) :
audioDevice( _sample_rate, _channels, _mixer ),
audioDevice( _channels, _mixer ),
m_outputFile( _file ),
m_useVbr( _use_vbr ),
m_nomBitrate( _nom_bitrate ),
m_minBitrate( _min_bitrate ),
m_maxBitrate( _max_bitrate )
{
setSampleRate( _sample_rate );
if( m_outputFile.open( QFile::WriteOnly | QFile::Truncate ) == FALSE )
{
QMessageBox::critical( NULL,

View File

@@ -48,9 +48,8 @@
audioJACK::audioJACK( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, tLimit<int>( configManager::inst()->value(
audioJACK::audioJACK( bool & _success_ful, mixer * _mixer ) :
audioDevice( tLimit<int>( configManager::inst()->value(
"audiojack", "channels" ).toInt(),
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
_mixer ),
@@ -114,9 +113,7 @@ audioJACK::audioJACK( const sample_rate_t _sample_rate, bool & _success_ful,
if( jack_get_sample_rate( m_client ) != sampleRate() )
{
SAMPLE_RATES[0] = jack_get_sample_rate( m_client );
SAMPLE_RATES[1] = 2 * SAMPLE_RATES[0];
setSampleRate( SAMPLE_RATES[0] );
setSampleRate( jack_get_sample_rate( m_client ) );
}
for( Uint8 ch = 0; ch < channels(); ++ch )

View File

@@ -79,9 +79,8 @@
audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, tLimit<ch_cnt_t>(
audioOSS::audioOSS( bool & _success_ful, mixer * _mixer ) :
audioDevice( tLimit<ch_cnt_t>(
configManager::inst()->value( "audiooss", "channels" ).toInt(),
DEFAULT_CHANNELS, SURROUND_CHANNELS ),
_mixer ),
@@ -180,31 +179,14 @@ audioOSS::audioOSS( const sample_rate_t _sample_rate, bool & _success_ful,
}
if( value != sampleRate() )
{
//printf( "Soundcard uses different sample-rate than LMMS "
// "does!\n" );
int q = 0;
if( sampleRate() == SAMPLE_RATES[1] )
{
q = 1;
}
if( sampleRate() == 44100 || sampleRate() == 88200 )
{
SAMPLE_RATES[0] = 48000;
SAMPLE_RATES[1] = 96000;
}
else
{
SAMPLE_RATES[0] = 44100;
SAMPLE_RATES[1] = 88200;
}
setSampleRate( SAMPLE_RATES[q] );
value = sampleRate();
value = getMixer()->baseSampleRate();
if ( ioctl( m_audioFD, SNDCTL_DSP_SPEED, &value ) < 0 )
{
perror( "SNDCTL_DSP_SPEED" );
printf( "Couldn't set audio frequency\n" );
return;
}
setSampleRate( value );
}
_success_ful = TRUE;

View File

@@ -5,7 +5,7 @@
* surround-audio-buffers into RAM, maybe later
* also harddisk
*
* 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
*
@@ -34,11 +34,10 @@
audioSampleRecorder::audioSampleRecorder( const sample_rate_t _sample_rate,
const ch_cnt_t _channels,
audioSampleRecorder::audioSampleRecorder( const ch_cnt_t _channels,
bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, _channels, _mixer ),
audioDevice( _channels, _mixer ),
m_buffers()
{
_success_ful = TRUE;

View File

@@ -3,7 +3,7 @@
/*
* audio_sdl.cpp - device-class that performs PCM-output via SDL
*
* 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
*
@@ -41,9 +41,8 @@
audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful,
mixer * _mixer ) :
audioDevice( _sample_rate, DEFAULT_CHANNELS, _mixer ),
audioSDL::audioSDL( bool & _success_ful, mixer * _mixer ) :
audioDevice( DEFAULT_CHANNELS, _mixer ),
m_outBuf( new surroundSampleFrame[getMixer()->framesPerPeriod()] ),
m_convertedBuf_pos( 0 ),
m_convertEndian( FALSE ),
@@ -62,7 +61,7 @@ audioSDL::audioSDL( const sample_rate_t _sample_rate, bool & _success_ful,
return;
}
m_audioHandle.freq = _sample_rate;
m_audioHandle.freq = sampleRate();
m_audioHandle.format = AUDIO_S16SYS; // we want it in byte-order
// of system, so we don't have
// to convert the buffers

View File

@@ -170,7 +170,7 @@ void bbTrackContainer::updateBBTrack( trackContentObject * _tco )
void bbTrackContainer::play( void )
{
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
if( engine::getSong()->playMode() != song::Mode_PlayBB )
{
@@ -182,7 +182,7 @@ void bbTrackContainer::play( void )
engine::getSong()->pause();
}
}
else if( engine::getSong()->paused() )
else if( engine::getSong()->isPaused() )
{
engine::getSong()->resumeFromPause();
}

View File

@@ -1,8 +1,8 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* controller.cpp - implementation of class controller which handles remote-control
* of automatableModels
* controller.cpp - implementation of class controller which handles
* remote-control of automatableModels
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail.com>
*
@@ -82,8 +82,7 @@ unsigned int controller::runningFrames()
// Get position in seconds
float controller::runningTime()
{
return s_frames /
engine::getMixer()->sampleRate() ;
return s_frames / engine::getMixer()->processingSampleRate();
}

View File

@@ -155,7 +155,7 @@ void engine::destroy( void )
void engine::updateFramesPerTick( void )
{
s_framesPerTick = s_mixer->sampleRate() * 60.0f * 4 /
s_framesPerTick = s_mixer->processingSampleRate() * 60.0f * 4 /
DefaultTicksPerTact / s_song->getTempo();
}

View File

@@ -380,7 +380,7 @@ void envelopeAndLFOParameters::updateSampleVars( void )
engine::getMixer()->lock();
const float frames_per_env_seg = SECS_PER_ENV_SEGMENT *
engine::getMixer()->sampleRate();
engine::getMixer()->processingSampleRate();
// TODO: Remove the expKnobVals, time should be linear
const f_cnt_t predelay_frames = static_cast<f_cnt_t>(
frames_per_env_seg *
@@ -464,7 +464,7 @@ void envelopeAndLFOParameters::updateSampleVars( void )
const float frames_per_lfo_oscillation = SECS_PER_LFO_OSCILLATION *
engine::getMixer()->sampleRate();
engine::getMixer()->processingSampleRate();
m_lfoPredelayFrames = static_cast<f_cnt_t>( frames_per_lfo_oscillation *
expKnobVal( m_lfoPredelayModel.value() ) );
m_lfoAttackFrames = static_cast<f_cnt_t>( frames_per_lfo_oscillation *

View File

@@ -364,7 +364,7 @@ void arpeggiator::processNote( notePlayHandle * _n )
// number of frames that every note should be played
const f_cnt_t arp_frames = (f_cnt_t)( m_arpTimeModel.value() / 1000.0f *
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
const f_cnt_t gated_frames = (f_cnt_t)( m_arpGateModel.value() *
arp_frames / 100.0f );

View File

@@ -162,7 +162,7 @@ void instrumentSoundShaping::processAudioBuffer( sampleFrame * _ab,
if( _n->m_filter == NULL )
{
_n->m_filter = new basicFilters<>(
engine::getMixer()->sampleRate() );
engine::getMixer()->processingSampleRate() );
}
_n->m_filter->setFilterType( m_filterModel.value() );

View File

@@ -1,8 +1,8 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* lfo_controller.cpp - implementation of class controller which handles remote-control
* of automatableModels
* lfo_controller.cpp - implementation of class controller which handles
* remote-control of automatableModels
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail.com>
*
@@ -79,7 +79,8 @@ float lfoController::value( int _offset )
// The new duration in frames
// (Samples/Second) / (periods/second) = (Samples/cycle)
int newDuration = engine::getMixer()->sampleRate() / m_lfoSpeedModel.value();
int newDuration = engine::getMixer()->processingSampleRate() /
m_lfoSpeedModel.value();
m_phaseOffset = m_lfoPhaseModel.value() * newDuration / 360.0;
@@ -117,8 +118,9 @@ float lfoController::value( int _offset )
// 44100 frames/sec
return m_lfoBaseModel.value() + ( m_lfoAmountModel.value() *
sinf( TWO_PI * float( ( frame+m_phaseOffset ) * m_lfoSpeedModel.value() ) /
engine::getMixer()->sampleRate() ) / 2.0f );
sinf( TWO_PI * float( ( frame+m_phaseOffset ) *
m_lfoSpeedModel.value() ) /
engine::getMixer()->processingSampleRate() ) / 2.0f );
}

View File

@@ -65,8 +65,6 @@
sample_rate_t SAMPLE_RATES[QUALITY_LEVELS] = { 44100, 44100*2 } ;
#define ALIGN_SIZE 64
@@ -255,8 +253,12 @@ mixer::mixer( void ) :
m_multiThreaded( QThread::idealThreadCount() > 1 ),
m_workers(),
m_numWorkers( m_multiThreaded ? QThread::idealThreadCount() : 0 ),
m_workerSem( m_numWorkers ),
m_qualityLevel( DEFAULT_QUALITY_LEVEL ),
m_workerSem( m_numWorkers ),
m_qualitySettings( qualitySettings::Interpolation_Linear,
qualitySettings::Oversampling_None,
FALSE, // sample-exact controllers
FALSE // alias-free oscillators
),
m_masterGain( 1.0f ),
m_audioDev( NULL ),
m_oldAudioDev( NULL ),
@@ -372,6 +374,37 @@ void mixer::stopProcessing( void )
sample_rate_t mixer::baseSampleRate( void ) const
{
sample_rate_t sr =
configManager::inst()->value( "mixer", "samplerate" ).toInt();
if( sr < 44100 )
{
sr = 44100;
}
return( sr );
}
sample_rate_t mixer::outputSampleRate( void ) const
{
return( m_audioDev != NULL ? m_audioDev->sampleRate() :
baseSampleRate() );
}
sample_rate_t mixer::processingSampleRate( void ) const
{
return( outputSampleRate() * m_qualitySettings.sampleRateMultiplier() );
}
bool mixer::criticalXRuns( void ) const
{
return( ( m_cpuLoad >= 99 &&
@@ -610,8 +643,8 @@ if( COND_NPH )
envelopeAndLFOParameters::triggerLFO();
controller::triggerFrameCounter();
const float new_cpu_load = timer.elapsed() / 10000.0f * sampleRate() /
m_framesPerPeriod;
const float new_cpu_load = timer.elapsed() / 10000.0f *
processingSampleRate() / m_framesPerPeriod;
m_cpuLoad = tLimit( (int) ( new_cpu_load * 0.1f + m_cpuLoad * 0.9f ), 0,
100 );
@@ -643,7 +676,7 @@ void mixer::clear( void )
void FASTCALL mixer::bufferToPort( const sampleFrame * _buf,
void mixer::bufferToPort( const sampleFrame * _buf,
const fpp_t _frames,
const f_cnt_t _offset,
stereoVolumeVector _vv,
@@ -695,8 +728,7 @@ void FASTCALL mixer::bufferToPort( const sampleFrame * _buf,
void FASTCALL mixer::clearAudioBuffer( sampleFrame * _ab,
const f_cnt_t _frames,
void mixer::clearAudioBuffer( sampleFrame * _ab, const f_cnt_t _frames,
const f_cnt_t _offset )
{
memset( _ab+_offset, 0, sizeof( *_ab ) * _frames );
@@ -705,8 +737,7 @@ void FASTCALL mixer::clearAudioBuffer( sampleFrame * _ab,
#ifndef DISABLE_SURROUND
void FASTCALL mixer::clearAudioBuffer( surroundSampleFrame * _ab,
const f_cnt_t _frames,
void mixer::clearAudioBuffer( surroundSampleFrame * _ab, const f_cnt_t _frames,
const f_cnt_t _offset )
{
memset( _ab+_offset, 0, sizeof( *_ab ) * _frames );
@@ -756,25 +787,23 @@ float mixer::peakValueRight( sampleFrame * _ab, const f_cnt_t _frames )
void mixer::setHighQuality( bool _hq_on )
void mixer::changeQuality( const struct qualitySettings & _qs )
{
// don't delete the audio-device
stopProcessing();
// set new quality-level...
m_qualityLevel = ( _hq_on == TRUE ) ? HIGH_QUALITY_LEVEL :
DEFAULT_QUALITY_LEVEL;
m_qualitySettings = _qs;
startProcessing();
emit( sampleRateChanged() );
emit sampleRateChanged();
emit qualitySettingsChanged();
}
void FASTCALL mixer::setAudioDevice( audioDevice * _dev, bool _hq )
void mixer::setAudioDevice( audioDevice * _dev )
{
stopProcessing();
@@ -791,7 +820,6 @@ void FASTCALL mixer::setAudioDevice( audioDevice * _dev, bool _hq )
m_audioDev = _dev;
}
m_qualityLevel = _hq ? HIGH_QUALITY_LEVEL : DEFAULT_QUALITY_LEVEL;
emit sampleRateChanged();
startProcessing();
@@ -808,17 +836,8 @@ void mixer::restoreAudioDevice( void )
delete m_audioDev;
m_audioDev = m_oldAudioDev;
for( Uint8 qli = DEFAULT_QUALITY_LEVEL;
qli < QUALITY_LEVELS; ++qli )
{
if( SAMPLE_RATES[qli] == m_audioDev->sampleRate() )
{
m_qualityLevel =
static_cast<qualityLevels>( qli );
emit sampleRateChanged();
break;
}
}
emit sampleRateChanged();
m_oldAudioDev = NULL;
startProcessing();
}
@@ -849,7 +868,6 @@ void mixer::removePlayHandles( track * _track )
audioDevice * mixer::tryAudioDevices( void )
{
bool success_ful = FALSE;
@@ -859,8 +877,7 @@ audioDevice * mixer::tryAudioDevices( void )
#ifdef ALSA_SUPPORT
if( dev_name == audioALSA::name() || dev_name == "" )
{
dev = new audioALSA( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful, this );
dev = new audioALSA( success_ful, this );
if( success_ful )
{
m_audioDevName = audioALSA::name();
@@ -874,8 +891,7 @@ audioDevice * mixer::tryAudioDevices( void )
#ifdef OSS_SUPPORT
if( dev_name == audioOSS::name() || dev_name == "" )
{
dev = new audioOSS( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful, this );
dev = new audioOSS( success_ful, this );
if( success_ful )
{
m_audioDevName = audioOSS::name();
@@ -889,8 +905,7 @@ audioDevice * mixer::tryAudioDevices( void )
#ifdef JACK_SUPPORT
if( dev_name == audioJACK::name() || dev_name == "" )
{
dev = new audioJACK( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful, this );
dev = new audioJACK( success_ful, this );
if( success_ful )
{
m_audioDevName = audioJACK::name();
@@ -904,8 +919,7 @@ audioDevice * mixer::tryAudioDevices( void )
#ifdef SDL_AUDIO_SUPPORT
if( dev_name == audioSDL::name() || dev_name == "" )
{
dev = new audioSDL( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL],
success_ful, this );
dev = new audioSDL( success_ful, this );
if( success_ful )
{
m_audioDevName = audioSDL::name();
@@ -929,8 +943,7 @@ audioDevice * mixer::tryAudioDevices( void )
m_audioDevName = audioDummy::name();
return( new audioDummy( SAMPLE_RATES[m_qualityLevel], success_ful,
this ) );
return( new audioDummy( success_ful, this ) );
}

View File

@@ -55,7 +55,7 @@ oscillator::oscillator( const intModel & _wave_shape_model,
void oscillator::update( sampleFrame * _ab, const fpp_t _frames,
const ch_cnt_t _chnl )
{
if( m_freq >= engine::getMixer()->sampleRate()/2 )
if( m_freq >= engine::getMixer()->processingSampleRate() / 2 )
{
mixer::clearAudioBuffer( _ab, _frames );
return;

View File

@@ -88,7 +88,7 @@ sampleBuffer::sampleBuffer( const QString & _audio_file,
m_amplification( 1.0f ),
m_reversed( FALSE ),
m_frequency( BaseFreq ),
m_sampleRate( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL] )
m_sampleRate( engine::getMixer()->baseSampleRate() )
{
#ifdef SDL_SDL_SOUND_H
// init sound-file-system of SDL
@@ -117,7 +117,7 @@ sampleBuffer::sampleBuffer( const sampleFrame * _data, const f_cnt_t _frames ) :
m_amplification( 1.0f ),
m_reversed( FALSE ),
m_frequency( BaseFreq ),
m_sampleRate( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL] )
m_sampleRate( engine::getMixer()->baseSampleRate() )
{
if( _frames > 0 )
{
@@ -148,7 +148,7 @@ sampleBuffer::sampleBuffer( const f_cnt_t _frames ) :
m_amplification( 1.0f ),
m_reversed( FALSE ),
m_frequency( BaseFreq ),
m_sampleRate( SAMPLE_RATES[DEFAULT_QUALITY_LEVEL] )
m_sampleRate( engine::getMixer()->baseSampleRate() )
{
if( _frames > 0 )
{
@@ -205,7 +205,7 @@ void sampleBuffer::update( bool _keep_settings )
char * f = qstrdup( file.toAscii().constData() );
int_sample_t * buf = NULL;
ch_cnt_t channels = DEFAULT_CHANNELS;
sample_rate_t samplerate = SAMPLE_RATES[DEFAULT_QUALITY_LEVEL];
sample_rate_t samplerate = engine::getMixer()->baseSampleRate();
m_frames = 0;
@@ -279,7 +279,7 @@ m_data[frame][chnl] = buf[idx] * fac;
delete[] buf;
normalize_sample_rate( samplerate, _keep_settings );
normalizeSampleRate( samplerate, _keep_settings );
}
else
{
@@ -314,14 +314,14 @@ m_data[frame][chnl] = buf[idx] * fac;
void sampleBuffer::normalize_sample_rate( const sample_rate_t _src_sr,
void sampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
bool _keep_settings )
{
// do samplerate-conversion to our default-samplerate
if( _src_sr != SAMPLE_RATES[DEFAULT_QUALITY_LEVEL] )
if( _src_sr != engine::getMixer()->baseSampleRate() )
{
sampleBuffer * resampled = resample( this, _src_sr,
SAMPLE_RATES[DEFAULT_QUALITY_LEVEL] );
engine::getMixer()->baseSampleRate() );
delete[] m_data;
m_frames = resampled->frames();
m_data = new sampleFrame[m_frames];
@@ -588,8 +588,8 @@ bool FASTCALL sampleBuffer::play( sampleFrame * _ab, handleState * _state,
return( FALSE );
}
const double freq_factor = (double) _freq / (double) m_frequency
* m_sampleRate / engine::getMixer()->sampleRate();
const double freq_factor = (double) _freq / (double) m_frequency *
m_sampleRate / engine::getMixer()->processingSampleRate();
// calculate how many frames we have in requested pitch
const f_cnt_t total_frames_for_current_pitch = static_cast<f_cnt_t>( (

View File

@@ -161,8 +161,8 @@ bool samplePlayHandle::isFromTrack( const track * _track ) const
f_cnt_t samplePlayHandle::totalFrames( void ) const
{
return( ( m_sampleBuffer->endFrame() - m_sampleBuffer->startFrame() ) *
( engine::getMixer()->sampleRate() /
SAMPLE_RATES[DEFAULT_QUALITY_LEVEL] ) );
( engine::getMixer()->processingSampleRate() /
engine::getMixer()->baseSampleRate() ) );
}

View File

@@ -607,7 +607,7 @@ void song::startExport( void )
void song::stopExport( void )
void song::cancelExport( void )
{
stop();
m_exporting = FALSE;

View File

@@ -614,7 +614,7 @@ void automationEditor::keyPressEvent( QKeyEvent * _ke )
break;
case Qt::Key_Space:
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
stop();
}
@@ -1641,12 +1641,12 @@ void automationEditor::play( void )
m_playButton->setIcon( embed::getIconPixmap(
"pause" ) );
}
else if( engine::getSong()->playing() )
else if( engine::getSong()->isPlaying() )
{
engine::getSong()->pause();
m_playButton->setIcon( embed::getIconPixmap( "play" ) );
}
else if( engine::getSong()->paused() )
else if( engine::getSong()->isPaused() )
{
engine::getSong()->resumeFromPause();
m_playButton->setIcon( embed::getIconPixmap(
@@ -1662,7 +1662,7 @@ void automationEditor::play( void )
}
else if( inBBEditor() )
{
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
m_playButton->setIcon( embed::getIconPixmap( "play" ) );
}
@@ -1675,12 +1675,12 @@ void automationEditor::play( void )
}
else
{
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
engine::getSong()->pause();
m_playButton->setIcon( embed::getIconPixmap( "play" ) );
}
else if( engine::getSong()->paused() )
else if( engine::getSong()->isPaused() )
{
engine::getSong()->resumeFromPause();
m_playButton->setIcon( embed::getIconPixmap(
@@ -1979,7 +1979,7 @@ void automationEditor::deleteSelectedValues( void )
void automationEditor::updatePosition( const midiTime & _t )
{
if( ( engine::getSong()->playing() &&
if( ( engine::getSong()->isPlaying() &&
engine::getSong()->playMode() ==
song::Mode_PlayAutomationPattern ) ||
m_scrollBack == TRUE )

View File

@@ -162,7 +162,7 @@ void bbEditor::removeBBView( int _bb )
void bbEditor::play( void )
{
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
if( engine::getSong()->playMode() != song::Mode_PlayBB )
{
@@ -178,7 +178,7 @@ void bbEditor::play( void )
"play" ) );
}
}
else if( engine::getSong()->paused() )
else if( engine::getSong()->isPaused() )
{
engine::getSong()->resumeFromPause();
m_playButton->setIcon( embed::getIconPixmap( "pause" ) );
@@ -217,7 +217,7 @@ void bbEditor::keyPressEvent( QKeyEvent * _ke )
{
if ( _ke->key() == Qt::Key_Space )
{
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
stop();
}

View File

@@ -242,7 +242,7 @@ void exportProjectDialog::keyPressEvent( QKeyEvent * _ke )
{
if( _ke->key() == Qt::Key_Escape )
{
if( engine::getSong()->exporting() == FALSE )
if( engine::getSong()->isExporting() == FALSE )
{
accept();
}
@@ -258,7 +258,7 @@ void exportProjectDialog::keyPressEvent( QKeyEvent * _ke )
void exportProjectDialog::closeEvent( QCloseEvent * _ce )
{
if( engine::getSong()->exporting() == TRUE )
if( engine::getSong()->isExporting() == TRUE )
{
abortProjectExport();
_ce->ignore();
@@ -308,7 +308,7 @@ void exportProjectDialog::exportBtnClicked( void )
bool success_ful = FALSE;
audioFileDevice * dev = fileEncodeDevices[idx].m_getDevInst(
DEFAULT_SAMPLE_RATE,
44100,
DEFAULT_CHANNELS,
success_ful,
m_fileName,
@@ -357,7 +357,7 @@ void exportProjectDialog::exportBtnClicked( void )
engine::getMixer()->setAudioDevice( dev, m_hqmCb->model()->value() );
engine::getMixer()->setAudioDevice( dev );//, m_hqmCb->model()->value() );
engine::getSong()->startExport();
delete m_hqmCb;
@@ -365,8 +365,8 @@ void exportProjectDialog::exportBtnClicked( void )
song::playPos & pp = engine::getSong()->getPlayPos(
song::Mode_PlaySong );
while( engine::getSong()->exportDone() == FALSE &&
engine::getSong()->exporting() == TRUE
while( engine::getSong()->isExportDone() == FALSE &&
engine::getSong()->isExporting() == TRUE
&& !m_deleteFile )
{
dev->processNextBuffer();
@@ -392,7 +392,7 @@ void exportProjectDialog::exportBtnClicked( void )
void exportProjectDialog::cancelBtnClicked( void )
{
// is song-export-thread active?
if( engine::getSong()->exporting() == TRUE )
if( engine::getSong()->isExporting() == TRUE )
{
// then dispose abort of export
abortProjectExport();
@@ -429,7 +429,7 @@ void exportProjectDialog::finishProjectExport( void )
engine::getMainWindow()->resetWindowTitle();
}
engine::getSong()->stopExport();
engine::getSong()->cancelExport();
// if we rendered file from command line, quit after export
if( file_to_render != "" )

View File

@@ -542,8 +542,8 @@ void listView::mouseReleaseEvent( QMouseEvent * _me )
samplePlayHandle * s = dynamic_cast<samplePlayHandle *>(
m_previewPlayHandle );
if( s->totalFrames() - s->framesDone() <=
static_cast<f_cnt_t>(
engine::getMixer()->sampleRate() * 3 ) )
static_cast<f_cnt_t>( engine::getMixer()->
processingSampleRate() * 3 ) )
{
s->setDoneMayReturnTrue( TRUE );
m_previewPlayHandle = NULL;

View File

@@ -779,7 +779,7 @@ void pianoRoll::keyPressEvent( QKeyEvent * _ke )
break;
case Qt::Key_Space:
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
stop();
}
@@ -1087,7 +1087,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
// was there an action where should be played the note?
if( play_note == TRUE && m_recording == FALSE &&
engine::getSong()->playing() == FALSE )
engine::getSong()->isPlaying() == FALSE )
{
m_lastKey = key_num;
m_pattern->getInstrumentTrack()->processInEvent(
@@ -1165,7 +1165,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
m_action != SELECT_NOTES &&
m_action != MOVE_SELECTION &&
m_recording == FALSE &&
engine::getSong()->playing() == FALSE )
engine::getSong()->isPlaying() == FALSE )
{
m_lastKey = key_num;
m_pattern->getInstrumentTrack()->processInEvent(
@@ -1217,7 +1217,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
}
if( shortNote != m_currentNote &&
engine::getSong()->playing() == FALSE )
engine::getSong()->isPlaying() == FALSE )
{
if( m_currentNote != NULL ) {
m_pattern->getInstrumentTrack()->processInEvent(
@@ -2139,7 +2139,7 @@ void pianoRoll::play( void )
return;
}
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
if( engine::getSong()->playMode() != song::Mode_PlayPattern )
{
@@ -2154,7 +2154,7 @@ void pianoRoll::play( void )
m_playButton->setIcon( embed::getIconPixmap( "play" ) );
}
}
else if( engine::getSong()->paused() )
else if( engine::getSong()->isPaused() )
{
engine::getSong()->resumeFromPause();
m_playButton->setIcon( embed::getIconPixmap( "pause" ) );
@@ -2171,7 +2171,7 @@ void pianoRoll::play( void )
void pianoRoll::record( void )
{
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
stop();
}
@@ -2526,7 +2526,7 @@ void pianoRoll::deleteSelectedNotes( void )
void pianoRoll::updatePosition( const midiTime & _t )
{
if( ( engine::getSong()->playing() &&
if( ( engine::getSong()->isPlaying() &&
engine::getSong()->playMode() ==
song::Mode_PlayPattern ) ||
m_scrollBack == TRUE )

View File

@@ -748,7 +748,7 @@ void setupDialog::setBufferSize( int _value )
m_bufSizeLbl->setText( tr( "Frames: %1\nLatency: %2 ms" ).arg(
m_bufferSize ).arg(
1000.0f * m_bufferSize /
engine::getMixer()->sampleRate(),
engine::getMixer()->processingSampleRate(),
0, 'f', 1 ) );
}

View File

@@ -429,7 +429,7 @@ void songEditor::keyPressEvent( QKeyEvent * _ke )
}
else if( _ke->key() == Qt::Key_Space )
{
if( m_s->playing() )
if( m_s->isPlaying() )
{
m_s->stop();
}
@@ -598,7 +598,7 @@ void songEditor::masterPitchReleased( void )
void songEditor::updatePosition( const midiTime & _t )
{
if( ( m_s->m_playing && m_s->m_playMode == song::Mode_PlaySong ) ||
if( ( m_s->isPlaying() && m_s->m_playMode == song::Mode_PlaySong ) ||
m_scrollBack == TRUE )
{
const int w = width() - DEFAULT_SETTINGS_WIDGET_WIDTH

View File

@@ -501,7 +501,7 @@ void envelopeAndLFOView::paintEvent( QPaintEvent * )
int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2;
const float frames_for_graph = SECS_PER_LFO_OSCILLATION *
engine::getMixer()->sampleRate() / 10;
engine::getMixer()->baseSampleRate() / 10;
const float lfo_gray_amount = 1.0f - fabsf( m_lfoAmountKnob->value() );
p.setPen( QPen( QColor( static_cast<int>( 96 * lfo_gray_amount ),

View File

@@ -551,7 +551,7 @@ bool FASTCALL instrumentTrack::play( const midiTime & _start,
{
cur_start -= p->startPosition();
}
if( p->frozen() && engine::getSong()->exporting() == FALSE )
if( p->frozen() && !engine::getSong()->isExporting() )
{
if( cur_start > 0 )
{

View File

@@ -397,7 +397,7 @@ void pattern::clear( void )
void pattern::freeze( void )
{
if( engine::getSong()->playing() )
if( engine::getSong()->isPlaying() )
{
QMessageBox::information( 0, tr( "Cannot freeze pattern" ),
tr( "The pattern currently "
@@ -663,11 +663,9 @@ void patternFreezeThread::run( void )
// mixer::restoreAudioDevice(...) deletes old audio-dev and thus
// audioSampleRecorder would be destroyed two times...
audioSampleRecorder * freeze_recorder = new audioSampleRecorder(
engine::getMixer()->sampleRate(),
DEFAULT_CHANNELS, b,
engine::getMixer() );
engine::getMixer()->setAudioDevice( freeze_recorder,
engine::getMixer()->highQuality() );
engine::getMixer()->setAudioDevice( freeze_recorder );
// prepare stuff for playing correct things later
engine::getSong()->playPattern( m_pattern, FALSE );
@@ -777,7 +775,7 @@ patternView::~patternView()
engine::getPianoRoll()->setCurrentPattern( NULL );
// we have to have the song-editor to stop playing if it played
// us before
if( engine::getSong()->playing() &&
if( engine::getSong()->isPlaying() &&
engine::getSong()->playMode() ==
song::Mode_PlayPattern )
{