bugfixes and more

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@139 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-05-29 13:08:08 +00:00
parent 260e8cf59f
commit 60e2442405
11 changed files with 3297 additions and 70 deletions

View File

@@ -1,4 +1,22 @@
2006-5-26 Javier Serrano Polo <jasp00/dot/terra/dot/es>
2006-05-29 Javier Serrano Polo <jasp00/dot/terra/dot/es>
* src/core/arp_and_chords_tab_widget.cpp:
fixed integer-overflow
* include/oscillator.h:
* include/sample_buffer.h:
* plugins/organic/organic.cpp:
* plugins/triple_oscillator/triple_oscillator.cpp:
* src/core/envelope_and_lfo_widget.cpp:
* src/lib/oscillator.cpp:
- several segfault-fixes when while playing note
- volume-knob-changes take effect immediately
* data/locale/ca.ts:
added catalan translation
2006-05-26 Javier Serrano Polo <jasp00/dot/terra/dot/es>
* src/lib/sample_buffer.cpp:
corrected the calculation of f1 in play to prevent it from shifting
the start_frame out of bounds when resampling.
@@ -7,7 +25,8 @@
* src/lib/mmp.cpp:
changed the xml output to use UTF8 encoding instead of ascii.
2006-5-23 Danny McRae <khjklujn/at/users/dot/sourceforge/dot/net>
2006-05-23 Danny McRae <khjklujn/at/users/dot/sourceforge/dot/net>
* include/oscillator.h:
FM mixing sometimes calculates a negative "time" for the sampling
which causes bad things to happen when pulling the data out of

View File

@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(lmms, 0.1.4-cvs20060520, tobydox/at/users/dot/sourceforge/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060520)
AC_INIT(lmms, 0.1.4-cvs20060529, tobydox/at/users/dot/sourceforge/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060529)
AM_CONFIG_HEADER(config.h)

BIN
data/locale/ca.qm Normal file

Binary file not shown.

3184
data/locale/ca.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -35,8 +35,9 @@
#endif
#include "mixer.h"
#include "interpolation.h"
#include "sample_buffer.h"
#include "lmms_constants.h"
#include "volume_knob.h"
// fwd-decl because we need it for the typedef below...
@@ -47,9 +48,6 @@ typedef void ( oscillator:: * oscFuncPtr )
const ch_cnt_t _chnl );
const sampleFrame ZERO_FRAME = { 0.0f, 0.0f } ;
class oscillator
{
public:
@@ -72,6 +70,7 @@ public:
oscillator( const modulationAlgos _modulation_algo, const float _freq,
const Sint16 _phase_offset, const float _volume_factor,
const volumeKnob * _volume_knob,
const sample_rate_t _sample_rate,
oscillator * _m_subOsc ) FASTCALL;
virtual ~oscillator()
@@ -79,19 +78,9 @@ public:
delete m_subOsc;
}
inline void setUserWave( const sampleFrame * _data,
const f_cnt_t _frames )
inline void setUserWave( sampleBuffer * _wave )
{
if( m_userWaveFrames > 0 )
{
m_userWaveData = _data;
m_userWaveFrames = _frames;
}
else
{
m_userWaveData = &ZERO_FRAME;
m_userWaveFrames = 1;
}
m_userWave = _wave;
}
inline void update( sampleFrame * _ab, const fpab_t _frames,
@@ -114,6 +103,7 @@ public:
const float _freq,
const Sint16 _phase_offset,
const float _volume_factor,
const volumeKnob * _volume_knob,
const sample_rate_t _sample_rate,
oscillator * _m_subOsc = NULL );
inline bool syncOk( void )
@@ -192,38 +182,34 @@ public:
RAND_MAX ) ) );
}
static inline sample_t userWaveSample( const float _sample,
const sampleFrame * _user_wave,
const f_cnt_t _user_wave_frames )
{
const float frame = fraction( fabs( _sample ) ) * _user_wave_frames;
const f_cnt_t f1 = static_cast<f_cnt_t>( frame );
const f_cnt_t f2 = ( f1 + 1 ) % _user_wave_frames;
return( linearInterpolate( _user_wave[f1][0],
_user_wave[f2][0],
fraction( frame ) ) );
}
inline sample_t userWaveSample( const float _sample )
{
return( userWaveSample( _sample, m_userWaveData,
m_userWaveFrames ) );
if( m_userWave->frames() > 0 )
{
return( m_userWave->userWaveSample( _sample ) );
}
else
{
return( 0.0f );
}
}
protected:
float m_freq;
float m_volumeFactor;
const volumeKnob * m_volumeKnob;
Sint16 m_phaseOffset;
const sample_rate_t m_sampleRate;
oscillator * m_subOsc;
f_cnt_t m_sample;
float m_oscCoeff;
sampleFrame const * m_userWaveData;
f_cnt_t m_userWaveFrames;
sampleBuffer * m_userWave;
oscFuncPtr m_callUpdate;
float volumeFactor( void );
virtual void FASTCALL updateNoSub( sampleFrame * _ab,
const fpab_t _frames,
const ch_cnt_t _chnl ) = 0;

View File

@@ -51,6 +51,7 @@
#include "mixer.h"
#include "interpolation.h"
#include "types.h"
@@ -149,6 +150,24 @@ public:
_dst_sr, _buf->eng() ) );
}
static inline float fraction( const float _sample )
{
return( _sample - static_cast<int>( _sample ) );
}
inline sample_t userWaveSample( const float _sample )
{
m_dataMutex.lock();
const float frame = fraction( fabs( _sample ) ) * m_frames;
const f_cnt_t f1 = static_cast<f_cnt_t>( frame );
const f_cnt_t f2 = ( f1 + 1 ) % m_frames;
sample_t waveSample = linearInterpolate( m_data[f1][0],
m_data[f2][0],
fraction( frame ) );
m_dataMutex.unlock();
return( waveSample );
}
public slots:
void setAudioFile( const QString & _audio_file );

View File

@@ -298,7 +298,7 @@ void organicInstrument::playNote( notePlayHandle * _n )
{
// volume
float volume = m_osc[i].volKnob->value() / 100.0 / m_num_oscillators ;
float volume = 1.0 / m_num_oscillators ;
float volume_l = volume * ( m_osc[i].panKnob->value() +
PANNING_RIGHT ) / 100.0f;
float volume_r = volume * ( PANNING_RIGHT -
@@ -334,7 +334,8 @@ void organicInstrument::playNote( notePlayHandle * _n )
oscillator::MIX,
freq_l,
phase_l,
volume_l,
volume_l,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate() );
// create right oscillator
oscs_r[i] = oscillator::createOsc(
@@ -342,7 +343,8 @@ void organicInstrument::playNote( notePlayHandle * _n )
oscillator::MIX,
freq_r,
phase_r,
volume_r,
volume_r,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate() );
} else {
@@ -352,7 +354,8 @@ void organicInstrument::playNote( notePlayHandle * _n )
oscillator::MIX,
freq_l,
phase_l,
volume_l,
volume_l,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate(),
oscs_l[i + 1] );
// create right oscillator
@@ -361,7 +364,8 @@ void organicInstrument::playNote( notePlayHandle * _n )
oscillator::MIX,
freq_r,
phase_r,
volume_r,
volume_r,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate(),
oscs_r[i + 1] );

View File

@@ -633,9 +633,6 @@ void tripleOscillator::playNote( notePlayHandle * _n )
vol_fac_r = 1.0f;
}
vol_fac_l *= m_osc[i].volKnob->value() / 100.0f;
vol_fac_r *= m_osc[i].volKnob->value() / 100.0f;
// the third oscs needs no sub-oscs...
if( i == 2 )
{
@@ -646,7 +643,8 @@ void tripleOscillator::playNote( notePlayHandle * _n )
static_cast<int>(
m_osc[i].phaseOffsetKnob->value() +
m_osc[i].stereoPhaseDetuningKnob->value() ),
vol_fac_l,
vol_fac_l,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate() );
oscs_r[i] = oscillator::createOsc(
m_osc[i].waveShape,
@@ -654,7 +652,8 @@ void tripleOscillator::playNote( notePlayHandle * _n )
freq*osc_detuning_r,
static_cast<int>(
m_osc[i].phaseOffsetKnob->value() ),
vol_fac_r,
vol_fac_r,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate() );
}
else
@@ -666,7 +665,8 @@ void tripleOscillator::playNote( notePlayHandle * _n )
static_cast<int>(
m_osc[i].phaseOffsetKnob->value() +
m_osc[i].stereoPhaseDetuningKnob->value() ),
vol_fac_l,
vol_fac_l,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate(),
oscs_l[i + 1] );
oscs_r[i] = oscillator::createOsc(
@@ -675,7 +675,8 @@ void tripleOscillator::playNote( notePlayHandle * _n )
freq*osc_detuning_r,
static_cast<int>(
m_osc[i].phaseOffsetKnob->value() ),
vol_fac_r,
vol_fac_r,
m_osc[i].volKnob,
eng()->getMixer()->sampleRate(),
oscs_r[i + 1] );
}
@@ -683,11 +684,9 @@ void tripleOscillator::playNote( notePlayHandle * _n )
if( m_osc[i].waveShape == oscillator::USER_DEF_WAVE )
{
oscs_l[i]->setUserWave(
m_osc[i].m_sampleBuffer->data(),
m_osc[i].m_sampleBuffer->frames() );
m_osc[i].m_sampleBuffer );
oscs_r[i]->setUserWave(
m_osc[i].m_sampleBuffer->data(),
m_osc[i].m_sampleBuffer->frames() );
m_osc[i].m_sampleBuffer );
}
}

View File

@@ -516,7 +516,7 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
cnphv.first()->totalFramesPlayed() :
_n->totalFramesPlayed() ) + arp_frames - 1;
// used for loop
fpab_t frames_processed = 0;
f_cnt_t frames_processed = 0;
while( frames_processed < eng()->getMixer()->framesPerAudioBuffer() )
{

View File

@@ -858,9 +858,8 @@ void envelopeAndLFOWidget::paintEvent( QPaintEvent * )
val = oscillator::squareSample( phase );
break;
case USER:
val = oscillator::userWaveSample( phase,
m_userWave.data(),
m_userWave.frames() );
val = m_userWave.userWaveSample(
phase );
}
if( static_cast<f_cnt_t>( cur_sample ) <=
m_lfoAttackFrames )
@@ -1058,9 +1057,7 @@ void envelopeAndLFOWidget::updateSampleVars( void )
break;
case USER:
m_lfoShapeData[frame] =
oscillator::userWaveSample( phase,
m_userWave.data(),
m_userWave.frames() );
m_userWave.userWaveSample( phase );
break;
case SIN:
default:

View File

@@ -31,16 +31,16 @@
oscillator::oscillator( const modulationAlgos _modulation_algo,
const float _freq, const Sint16 _phase_offset,
const float _volume_factor,
const float _volume_factor, const volumeKnob * _volume_knob,
const sample_rate_t _sample_rate,
oscillator * _sub_osc ) :
m_freq( _freq ),
m_volumeFactor( _volume_factor ),
m_volumeKnob( _volume_knob ),
m_phaseOffset( _phase_offset ),
m_sampleRate( _sample_rate ),
m_subOsc( _sub_osc ),
m_userWaveData( &ZERO_FRAME ),
m_userWaveFrames( 1 )
m_userWave( NULL )
{
if( m_subOsc != NULL )
{
@@ -72,6 +72,13 @@ oscillator::oscillator( const modulationAlgos _modulation_algo,
float oscillator::volumeFactor( void )
{
return( m_volumeFactor * m_volumeKnob->value() / 100.0f );
}
// if we have no sub-osc, we can't do any modulation... just get our samples
#define defineNoSubUpdateFor(x,getSampleFunction) \
void x::updateNoSub( sampleFrame * _ab, const fpab_t _frames, \
@@ -80,7 +87,7 @@ void x::updateNoSub( sampleFrame * _ab, const fpab_t _frames, \
for( fpab_t frame = 0; frame < _frames; ++frame ) \
{ \
_ab[frame][_chnl] = getSampleFunction( ++m_sample * \
m_oscCoeff ) * m_volumeFactor; \
m_oscCoeff ) * volumeFactor(); \
} \
}
@@ -96,13 +103,13 @@ void x::updateFM( sampleFrame * _ab, const fpab_t _frames, \
_ab[frame][_chnl] = getSampleFunction( ++m_sample * \
m_oscCoeff + \
_ab[frame][_chnl] ) * \
m_volumeFactor; \
volumeFactor(); \
/* following line is REAL FM */ \
/* float new_freq = powf( 2.0, _ab[frame][_chnl] ); \
_ab[frame][_chnl] = getSampleFunction( ++m_sample*((m_freq * \
new_freq )/mixer::inst()->sampleRate() )) * m_volumeFactor; \
new_freq )/mixer::inst()->sampleRate() )) * volumeFactor(); \
_ab[frame][_chnl] = getSampleFunction( ++m_sample*(m_oscCoeff *\
_ab[frame][_chnl] )) * m_volumeFactor;*/ \
_ab[frame][_chnl] )) * volumeFactor();*/ \
} \
}
@@ -116,7 +123,7 @@ void x::updateAM( sampleFrame * _ab, const fpab_t _frames, \
for( fpab_t frame = 0; frame < _frames; ++frame ) \
{ \
_ab[frame][_chnl] *= getSampleFunction( ++m_sample * \
m_oscCoeff ) * m_volumeFactor; \
m_oscCoeff ) * volumeFactor(); \
} \
}
@@ -130,7 +137,7 @@ void x::updateMix( sampleFrame * _ab, const fpab_t _frames, \
for( fpab_t frame = 0; frame < _frames; ++frame ) \
{ \
_ab[frame][_chnl] += getSampleFunction( ++m_sample * \
m_oscCoeff ) * m_volumeFactor; \
m_oscCoeff ) * volumeFactor(); \
} \
}
@@ -148,7 +155,7 @@ void x::updateSync( sampleFrame * _ab, const fpab_t _frames, \
sync(); \
} \
_ab[frame][_chnl] = getSampleFunction( ++m_sample * \
m_oscCoeff ) * m_volumeFactor; \
m_oscCoeff ) * volumeFactor(); \
} \
}
@@ -161,10 +168,12 @@ public: \
inline x( const modulationAlgos modulation_algo, \
const float _freq, \
const Sint16 _phase_offset, const float _volume_factor, \
const volumeKnob * _volume_knob, \
const sample_rate_t _sample_rate, \
oscillator * _sub_osc ) : \
oscillator( modulation_algo, _freq, _phase_offset, \
_volume_factor, _sample_rate, _sub_osc ) \
_volume_factor, _volume_knob, \
_sample_rate, _sub_osc ) \
{ \
} \
virtual ~x() \
@@ -208,6 +217,7 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape,
const float _freq,
const Sint16 _phase_offset,
const float _volume_factor,
const volumeKnob * _volume_knob,
const sample_rate_t _sample_rate,
oscillator * _sub_osc )
{
@@ -216,38 +226,47 @@ oscillator * oscillator::createOsc( const waveShapes _wave_shape,
case SIN_WAVE:
return( new sinWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
case TRIANGLE_WAVE:
return( new triangleWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
case SAW_WAVE:
return( new sawWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
case SQUARE_WAVE:
return( new squareWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
case MOOG_SAW_WAVE:
return( new moogSawWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
case EXP_WAVE:
return( new expWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
case WHITE_NOISE_WAVE:
return( new noiseWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
case USER_DEF_WAVE:
return( new userWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
default:
return( new sinWaveOsc( _modulation_algo, _freq,
_phase_offset, _volume_factor,
_volume_knob,
_sample_rate, _sub_osc ) );
}