merged note's tone and octave-property into one key-property which makes us save calculations in a lot of places and also shrinks sizes of XML-files, renamed various note-related constants and enums to match current coding-style

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@806 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-03-22 13:24:43 +00:00
parent 1809db2ed0
commit c31dbd6a09
35 changed files with 382 additions and 436 deletions

View File

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

View File

@@ -287,8 +287,8 @@ invalid_format:
it->addTCO( p );
// init keys
int keys[NOTES_PER_OCTAVE * OCTAVES][2];
for( int j = 0; j < NOTES_PER_OCTAVE * OCTAVES; ++j )
int keys[NumKeys][2];
for( int j = 0; j < NumKeys; ++j )
{
keys[j][0] = -1;
}
@@ -302,8 +302,7 @@ invalid_format:
switch( ev.m_type )
{
case NOTE_ON:
if( ev.key() >=
NOTES_PER_OCTAVE * OCTAVES )
if( ev.key() >= NumKeys )
{
continue;
}
@@ -316,15 +315,12 @@ invalid_format:
}
case NOTE_OFF:
if( ev.key() <
NOTES_PER_OCTAVE * OCTAVES &&
if( ev.key() < NumKeys &&
keys[ev.key()][0] >= 0 )
{
note n( midiTime( ( ( tick - keys[ev.key()][0] ) * multiplier ) / divisor ),
midiTime( ( keys[ev.key()][0] * multiplier ) / divisor ),
(tones)( ev.key() % NOTES_PER_OCTAVE ),
(octaves)( ev.key() / NOTES_PER_OCTAVE ),
keys[ev.key()][1] * 100 / 128 );
ev.key(), keys[ev.key()][1] * 100 / 128 );
p->addNote( n, FALSE );
keys[ev.key()][0] = -1;
}

View File

@@ -76,8 +76,8 @@ QPixmap * organicInstrumentView::s_artwork = NULL;
organicInstrument::organicInstrument( instrumentTrack * _channel_track ) :
instrument( _channel_track, &organic_plugin_descriptor ),
m_modulationAlgo( oscillator::SignalMix ),
m_fx1Knob( 0.0f, 0.0f, 0.99f, 0.01f , this ),
m_volKnob( 100.0f, 0.0f, 200.0f, 1.0f, this )
m_fx1Model( 0.0f, 0.0f, 0.99f, 0.01f , this ),
m_volModel( 100.0f, 0.0f, 200.0f, 1.0f, this )
{
m_numOscillators = 8;
@@ -88,13 +88,13 @@ organicInstrument::organicInstrument( instrumentTrack * _channel_track ) :
m_osc[i]->m_numOscillators = m_numOscillators;
// Connect events
connect( &m_osc[i]->m_oscKnob, SIGNAL( dataChanged() ),
connect( &m_osc[i]->m_oscModel, SIGNAL( dataChanged() ),
m_osc[i], SLOT ( oscButtonChanged() ) );
connect( &m_osc[i]->m_volKnob, SIGNAL( dataChanged() ),
connect( &m_osc[i]->m_volModel, SIGNAL( dataChanged() ),
m_osc[i], SLOT( updateVolume() ) );
connect( &m_osc[i]->m_panKnob, SIGNAL( dataChanged() ),
connect( &m_osc[i]->m_panModel, SIGNAL( dataChanged() ),
m_osc[i], SLOT( updateVolume() ) );
connect( &m_osc[i]->m_detuneKnob, SIGNAL( dataChanged() ),
connect( &m_osc[i]->m_detuneModel, SIGNAL( dataChanged() ),
m_osc[i], SLOT( updateDetuning() ) );
m_osc[i]->updateVolume();
@@ -135,19 +135,19 @@ organicInstrument::~organicInstrument()
void organicInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "num_osc", QString::number( m_numOscillators ) );
m_fx1Knob.saveSettings( _doc, _this, "foldback" );
m_volKnob.saveSettings( _doc, _this, "vol" );
m_fx1Model.saveSettings( _doc, _this, "foldback" );
m_volModel.saveSettings( _doc, _this, "vol" );
for( int i = 0; i < m_numOscillators; ++i )
{
QString is = QString::number( i );
m_osc[i]->m_volKnob.saveSettings( _doc, _this, "vol" + is );
m_osc[i]->m_panKnob.saveSettings( _doc, _this, "pan" + is );
m_osc[i]->m_volModel.saveSettings( _doc, _this, "vol" + is );
m_osc[i]->m_panModel.saveSettings( _doc, _this, "pan" + is );
_this.setAttribute( "harmonic" + is, QString::number(
powf( 2.0f, m_osc[i]->m_harmonic ) ) );
m_osc[i]->m_detuneKnob.saveSettings( _doc, _this, "detune"
m_osc[i]->m_detuneModel.saveSettings( _doc, _this, "detune"
+ is );
m_osc[i]->m_oscKnob.saveSettings( _doc, _this, "wavetype"
m_osc[i]->m_oscModel.saveSettings( _doc, _this, "wavetype"
+ is );
}
}
@@ -163,14 +163,14 @@ void organicInstrument::loadSettings( const QDomElement & _this )
for( int i = 0; i < m_numOscillators; ++i )
{
QString is = QString::number( i );
m_osc[i]->m_volKnob.loadSettings( _this, "vol" + is );
m_osc[i]->m_detuneKnob.loadSettings( _this, "detune" + is );
m_osc[i]->m_panKnob.loadSettings( _this, "pan" + is );
m_osc[i]->m_oscKnob.loadSettings( _this, "wavetype" + is );
m_osc[i]->m_volModel.loadSettings( _this, "vol" + is );
m_osc[i]->m_detuneModel.loadSettings( _this, "detune" + is );
m_osc[i]->m_panModel.loadSettings( _this, "pan" + is );
m_osc[i]->m_oscModel.loadSettings( _this, "wavetype" + is );
}
m_volKnob.loadSettings( _this, "vol" );
m_fx1Knob.loadSettings( _this, "foldback" );
m_volModel.loadSettings( _this, "vol" );
m_fx1Model.loadSettings( _this, "foldback" );
}
@@ -265,13 +265,13 @@ void organicInstrument::playNote( notePlayHandle * _n, bool )
// -- fx section --
// fxKnob is [0;1]
float t = m_fx1Knob.value();
float t = m_fx1Model.value();
for (int i=0 ; i < frames ; i++)
{
buf[i][0] = waveshape( buf[i][0], t ) * m_volKnob.value()
buf[i][0] = waveshape( buf[i][0], t ) * m_volModel.value()
/ 100.0f;
buf[i][1] = waveshape( buf[i][1], t ) * m_volKnob.value()
buf[i][1] = waveshape( buf[i][1], t ) * m_volModel.value()
/ 100.0f;
}
@@ -322,15 +322,13 @@ void organicInstrument::randomiseSettings( void )
for( int i = 0; i < m_numOscillators; i++ )
{
m_osc[i]->m_volKnob.setValue( intRand( 0, 100 ) );
m_osc[i]->m_volModel.setValue( intRand( 0, 100 ) );
m_osc[i]->m_detuneKnob.setValue( intRand( -5, 5 ) );
m_osc[i]->m_detuneModel.setValue( intRand( -5, 5 ) );
m_osc[i]->m_panKnob.setValue(
//(int)gaussRand(PANNING_LEFT, PANNING_RIGHT,1,0)
0 );
m_osc[i]->m_panModel.setValue( 0 );
m_osc[i]->m_oscKnob.setValue( intRand( 0, 5 ) );
m_osc[i]->m_oscModel.setValue( intRand( 0, 5 ) );
}
}
@@ -421,8 +419,8 @@ void organicInstrumentView::modelChanged( void )
m_numOscillators = oi->m_numOscillators;
m_fx1Knob->setModel( &oi->m_fx1Knob );
m_volKnob->setModel( &oi->m_volKnob );
m_fx1Knob->setModel( &oi->m_fx1Model );
m_volKnob->setModel( &oi->m_volModel );
// TODO: Delete existing oscKnobs if they exist
@@ -465,30 +463,26 @@ void organicInstrumentView::modelChanged( void )
// Attach to models
m_oscKnobs[i].m_volKnob->setModel(
&oi->m_osc[i]->m_volKnob );
&oi->m_osc[i]->m_volModel );
m_oscKnobs[i].m_oscKnob->setModel(
&oi->m_osc[i]->m_oscKnob );
&oi->m_osc[i]->m_oscModel );
m_oscKnobs[i].m_panKnob->setModel(
&oi->m_osc[i]->m_panKnob );
&oi->m_osc[i]->m_panModel );
m_oscKnobs[i].m_detuneKnob->setModel(
&oi->m_osc[i]->m_detuneKnob );
/*connect( m_oscKnobs[i].m_userWaveButton,
SIGNAL( doubleClicked() ),
t->m_osc[i], SLOT( oscUserDefWaveDblClick() ) );
*/
&oi->m_osc[i]->m_detuneModel );
}
}
oscillatorObject::oscillatorObject( model * _parent, track * _track ) :
model( _parent ),
m_waveShape( oscillator::SineWave, 0, oscillator::NumWaveShapes-1, 1, this ),
m_oscKnob( 0.0f, 0.0f, 5.0f, 1.0f, this ),
m_volKnob( 100.0f, 0.0f, 100.0f, 1.0f, this ),
m_panKnob( DEFAULT_PANNING, PANNING_LEFT, PANNING_RIGHT, 1.0f, this ),
m_detuneKnob( 0.0f, -100.0f, 100.0f, 1.0f, this )
m_oscModel( 0.0f, 0.0f, 5.0f, 1.0f, this ),
m_volModel( 100.0f, 0.0f, 100.0f, 1.0f, this ),
m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this ),
m_detuneModel( 0.0f, -100.0f, 100.0f, 1.0f, this )
{
}
@@ -515,7 +509,7 @@ void oscillatorObject::oscButtonChanged( void )
oscillator::ExponentialWave
} ;
m_waveShape.setValue( shapes[(int)roundf( m_oscKnob.value() )] );
m_waveShape.setValue( shapes[(int)roundf( m_oscModel.value() )] );
}
@@ -524,10 +518,10 @@ void oscillatorObject::oscButtonChanged( void )
void oscillatorObject::updateVolume( void )
{
m_volumeLeft = ( 1.0f - m_panKnob.value() / (float)PANNING_RIGHT )
* m_volKnob.value() / m_numOscillators / 100.0f;
m_volumeRight = ( 1.0f + m_panKnob.value() / (float)PANNING_RIGHT )
* m_volKnob.value() / m_numOscillators / 100.0f;
m_volumeLeft = ( 1.0f - m_panModel.value() / (float)PanningRight )
* m_volModel.value() / m_numOscillators / 100.0f;
m_volumeRight = ( 1.0f + m_panModel.value() / (float)PanningRight )
* m_volModel.value() / m_numOscillators / 100.0f;
}
@@ -536,10 +530,10 @@ void oscillatorObject::updateVolume( void )
void oscillatorObject::updateDetuning( void )
{
m_detuningLeft = powf( 2.0f, m_harmonic
+ (float)m_detuneKnob.value() / 100.0f )
+ (float)m_detuneModel.value() / 100.0f )
/ engine::getMixer()->sampleRate();
m_detuningRight = powf( 2.0f, m_harmonic
- (float)m_detuneKnob.value() / 100.0f )
- (float)m_detuneModel.value() / 100.0f )
/ engine::getMixer()->sampleRate();
}
@@ -564,7 +558,7 @@ plugin * lmms_plugin_main( model *, void * _data )
* - 32.692 Hz in the bass to 5919.85 Hz of treble in a Hammond organ
* => implement harmonic foldback
*
m_osc[i].m_oscKnob->setInitValue( 0.0f );
m_osc[i].m_oscModel->setInitValue( 0.0f );
* - randomize preset
*/

View File

@@ -46,10 +46,10 @@ class oscillatorObject : public model
private:
int m_numOscillators;
intModel m_waveShape;
floatModel m_oscKnob;
floatModel m_volKnob;
floatModel m_panKnob;
floatModel m_detuneKnob;
floatModel m_oscModel;
floatModel m_volModel;
floatModel m_panModel;
floatModel m_detuneModel;
float m_harmonic;
float m_volumeLeft;
@@ -123,8 +123,8 @@ private:
const intModel m_modulationAlgo;
floatModel m_fx1Knob;
floatModel m_volKnob;
floatModel m_fx1Model;
floatModel m_volModel;
virtual pluginView * instantiateView( QWidget * _parent );

View File

@@ -69,10 +69,10 @@ plugin::descriptor tripleoscillator_plugin_descriptor =
oscillatorObject::oscillatorObject( model * _parent, track * _track ) :
model( _parent ),
m_volumeModel( DEFAULT_VOLUME / NUM_OF_OSCILLATORS,
MIN_VOLUME, MAX_VOLUME, 1.0f, this ),
m_panModel( DEFAULT_PANNING, PANNING_LEFT, PANNING_RIGHT, 1.0f, this ),
m_coarseModel( 0, -2 * NOTES_PER_OCTAVE, 2 * NOTES_PER_OCTAVE,
m_volumeModel( DefaultVolume / NUM_OF_OSCILLATORS,
MinVolume, MaxVolume, 1.0f, this ),
m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this ),
m_coarseModel( 0, -2 * KeysPerOctave, 2 * KeysPerOctave,
1.0f, this ),
m_fineLeftModel( 0.0f, -100.0f, 100.0f, 1.0f, this ),
m_fineRightModel( 0.0f, -100.0f, 100.0f, 1.0f, this ),
@@ -159,7 +159,7 @@ void oscillatorObject::updateVolume( void )
if( m_panModel.value() >= 0.0f )
{
const float panningFactorLeft = 1.0f - m_panModel.value()
/ (float)PANNING_RIGHT;
/ (float)PanningRight;
m_volumeLeft = panningFactorLeft * m_volumeModel.value() /
100.0f;
m_volumeRight = m_volumeModel.value() / 100.0f;
@@ -168,7 +168,7 @@ void oscillatorObject::updateVolume( void )
{
m_volumeLeft = m_volumeModel.value() / 100.0f;
const float panningFactorRight = 1.0f + m_panModel.value()
/ (float)PANNING_RIGHT;
/ (float)PanningRight;
m_volumeRight = panningFactorRight * m_volumeModel.value() /
100.0f;
}
@@ -768,9 +768,6 @@ tripleOscillatorView::tripleOscillatorView( instrument * _instrument,
wsbg->addButton( white_noise_btn );
wsbg->addButton( uwb );
/* connect( m_osc[i].m_usrWaveBtn, SIGNAL( doubleClicked() ),
&m_osc[i], SLOT( oscUserDefWaveDblClick() ) );*/
m_oscKnobs[i] = oscillatorKnobs( vk, pk, ck, flk, frk, pok,
spdk, uwb, wsbg );

View File

@@ -73,7 +73,7 @@ vestigeInstrument::vestigeInstrument( instrumentTrack * _instrument_track ) :
m_plugin( NULL ),
m_pluginMutex()
{
for( int i = 0; i < NOTES; ++i )
for( int i = 0; i < NumKeys; ++i )
{
m_runningNotes[i] = 0;
}
@@ -486,7 +486,7 @@ void vestigeInstrumentView::noteOffAll( void )
m_vi->m_pluginMutex.lock();
if( m_vi->m_plugin != NULL )
{
for( int key = 0; key < OCTAVES * NOTES_PER_OCTAVE; ++key )
for( int key = 0; key < NumKeys; ++key )
{
m_vi->m_plugin->enqueueMidiEvent( midiEvent( NOTE_OFF, 0,
key, 0 ), 0 );

View File

@@ -87,7 +87,7 @@ public:
private:
void closePlugin( void );
int m_runningNotes[NOTES];
int m_runningNotes[NumKeys];
remoteVSTPlugin * m_plugin;

View File

@@ -1,7 +1,7 @@
/*
* vibed.cpp - combination of PluckedStringSynth and BitInvader
*
* 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
*
@@ -77,7 +77,8 @@ vibed::vibed( instrumentTrack * instrument_track ) :
for( Uint8 harm = 0; harm < 9; harm++ )
{
knob = new knobModel( DEFAULT_VOLUME, MIN_VOLUME, MAX_VOLUME, 1.0f, this );
knob = new knobModel( DefaultVolume, MinVolume, MaxVolume,
1.0f, this );
m_volumeKnobs.append( knob );
knob = new knobModel( 0.0f, 0.0f, 0.05f, 0.001f, this );

View File

@@ -1,6 +1,7 @@
/* vibed_strings.h -
/*
* vibed.h - combination of PluckedStringSynth and BitInvader
*
* 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
*