diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index f3581ab32..acfb6b02f 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -46,11 +46,13 @@ #include "audio_file_processor.h" +#include "engine.h" #include "song_editor.h" #include "instrument_track.h" #include "note_play_handle.h" #include "interpolation.h" #include "file_browser.h" +#include "gui_templates.h" #include "pixmap_button.h" #include "knob.h" #include "tooltip.h" @@ -294,15 +296,11 @@ void audioFileProcessor::saveSettings( QDomDocument & _doc, QString s; _this.setAttribute( "sampledata", m_sampleBuffer.toBase64( s ) ); } - _this.setAttribute( "sframe", QString::number( - m_sampleBuffer.startFrame() / - (float)m_sampleBuffer.frames() ) ); - _this.setAttribute( "eframe", QString::number( - m_sampleBuffer.endFrame() / - (float)m_sampleBuffer.frames() ) ); m_reverseButton->saveSettings( _doc, _this, "reversed" ); m_loopButton->saveSettings( _doc, _this, "looped" ); m_ampKnob->saveSettings( _doc, _this, "amp" ); + m_startKnob->saveSettings( _doc, _this, "sframe" ); + m_endKnob->saveSettings( _doc, _this, "eframe" ); } @@ -318,11 +316,14 @@ void audioFileProcessor::loadSettings( const QDomElement & _this ) { m_sampleBuffer.loadFromBase64( _this.attribute( "srcdata" ) ); } - setStartAndEndKnob( _this.attribute( "sframe" ).toFloat(), - _this.attribute( "eframe" ).toFloat() ); m_reverseButton->loadSettings( _this, "reversed" ); m_loopButton->loadSettings( _this, "looped" ); m_ampKnob->loadSettings( _this, "amp" ); + m_startKnob->loadSettings( _this, "sframe" ); + m_endKnob->loadSettings( _this, "eframe" ); + + startKnobChanged( m_startKnob->value() ); + endKnobChanged( m_endKnob->value() ); } @@ -354,10 +355,8 @@ QString audioFileProcessor::nodeName( void ) const Uint32 audioFileProcessor::getBeatLen( notePlayHandle * _n ) const { - const float freq_factor = BASE_FREQ / - ( getInstrumentTrack()->frequency( _n ) * - DEFAULT_SAMPLE_RATE / - engine::getMixer()->sampleRate() ); + const float freq_factor = BASE_FREQ / _n->frequency() * + engine::getMixer()->sampleRate() / DEFAULT_SAMPLE_RATE; return( static_cast( floorf( ( m_sampleBuffer.endFrame() - m_sampleBuffer.startFrame() ) * @@ -382,7 +381,8 @@ void audioFileProcessor::setAudioFile( const QString & _audio_file, bool _rename // else we don't touch the channel-name, because the user named it self m_sampleBuffer.setAudioFile( _audio_file ); - setStartAndEndKnob( 0.0f, 1.0f ); + startKnobChanged( m_startKnob->value() ); + endKnobChanged( m_endKnob->value() ); } @@ -394,16 +394,13 @@ void audioFileProcessor::playNote( notePlayHandle * _n, bool ) const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); sampleFrame * buf = new sampleFrame[frames]; - // calculate frequency of note - const float note_freq = getInstrumentTrack()->frequency( _n ); - if( !_n->m_pluginData ) { _n->m_pluginData = new handleState( _n->hasDetuningInfo() ); } if( m_sampleBuffer.play( buf, (handleState *)_n->m_pluginData, - frames, note_freq, + frames, _n->frequency(), m_loopButton->isChecked() ) == TRUE ) { getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); @@ -654,27 +651,6 @@ void audioFileProcessor::ampKnobChanged( float _val ) -void audioFileProcessor::setStartAndEndKnob( float _s, float _e ) -{ -/* // because the signal-handlers of valuechanges of start- and end-knob - // do range checking, depending on value of the other knob, we have to - // disconnect the signal-handlers, set then the values, connect again - // and then let the changes take effect... - m_startKnob->disconnect(); - m_endKnob->disconnect();*/ - m_startKnob->setValue( _s ); - m_endKnob->setValue( _e ); -/* connect( m_startKnob, SIGNAL( valueChanged( float ) ), this, - SLOT( startKnobChanged( float ) ) ); - connect( m_endKnob, SIGNAL( valueChanged( float ) ), this, - SLOT( endKnobChanged( float ) ) );*/ - startKnobChanged( _s ); - endKnobChanged( _e ); -} - - - - void audioFileProcessor::startKnobChanged( float _new_value ) { if( _new_value < m_endKnob->value() ) diff --git a/plugins/audio_file_processor/audio_file_processor.h b/plugins/audio_file_processor/audio_file_processor.h index 9e2ae6efa..53cb1b03c 100644 --- a/plugins/audio_file_processor/audio_file_processor.h +++ b/plugins/audio_file_processor/audio_file_processor.h @@ -130,7 +130,6 @@ private: void updateSample( void ); - void FASTCALL setStartAndEndKnob( float _s, float _e ); } ; diff --git a/plugins/bass_booster/bassbooster_control_dialog.cpp b/plugins/bass_booster/bassbooster_control_dialog.cpp index b7d978761..9de8af121 100644 --- a/plugins/bass_booster/bassbooster_control_dialog.cpp +++ b/plugins/bass_booster/bassbooster_control_dialog.cpp @@ -23,7 +23,7 @@ */ -#ifdef QT4 +#ifndef QT3 #include diff --git a/plugins/bit_invader/bit_invader.cpp b/plugins/bit_invader/bit_invader.cpp index d24d15815..cd56df2cf 100644 --- a/plugins/bit_invader/bit_invader.cpp +++ b/plugins/bit_invader/bit_invader.cpp @@ -53,6 +53,8 @@ using namespace std; #include "bit_invader.h" +#include "base64.h" +#include "engine.h" #include "instrument_track.h" #include "note_play_handle.h" #include "templates.h" @@ -62,7 +64,6 @@ using namespace std; #include "song_editor.h" #include "oscillator.h" #include "sample_buffer.h" -#include "base64.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" @@ -685,17 +686,18 @@ void bitInvader::playNote( notePlayHandle * _n, bool ) if ( _n->totalFramesPlayed() == 0 ) { - float freq = getInstrumentTrack()->frequency( _n ); - float factor; - if (!normalize) { - factor = 1.0; - } else { + if( !normalize ) + { + factor = 1.0f; + } + else + { factor = normalizeFactor; } - - _n->m_pluginData = new bSynth( sample_shape, sample_length,freq - , interpolation, factor, + + _n->m_pluginData = new bSynth( sample_shape, sample_length, + _n->frequency(), interpolation, factor, engine::getMixer()->sampleRate() ); } diff --git a/plugins/flp_import/flp_import.cpp b/plugins/flp_import/flp_import.cpp index b4791c59c..528e5040c 100644 --- a/plugins/flp_import/flp_import.cpp +++ b/plugins/flp_import/flp_import.cpp @@ -24,27 +24,28 @@ #include "flp_import.h" -#include "project_notes.h" +#include "arp_and_chords_tab_widget.h" +#include "basic_filters.h" #include "bb_editor.h" -#include "song_editor.h" #include "bb_track.h" -#include "track_container.h" -#include "instrument_track.h" -#include "pattern.h" -#include "project_journal.h" -#include "instrument.h" +#include "combobox.h" #include "config_mgr.h" +#include "debug.h" +#include "engine.h" #include "envelope_tab_widget.h" #include "envelope_and_lfo_widget.h" +#include "group_box.h" +#include "instrument.h" +#include "instrument_track.h" #include "knob.h" #include "oscillator.h" -#include "basic_filters.h" -#include "combobox.h" -#include "group_box.h" -#include "arp_and_chords_tab_widget.h" -#include "tempo_sync_knob.h" +#include "pattern.h" #include "piano_widget.h" -#include "debug.h" +#include "project_journal.h" +#include "project_notes.h" +#include "song_editor.h" +#include "tempo_sync_knob.h" +#include "track_container.h" #ifdef QT4 @@ -480,7 +481,7 @@ bool flpImport::tryImport( trackContainer * _tc ) case FLP_MiddleNote: data += 8; it->setBaseNote( data ); - it->m_pianoWidget->update(); + it->getPianoWidget()->update(); break; case FLP_DelayReso: @@ -828,7 +829,7 @@ bool flpImport::tryImport( trackContainer * _tc ) { continue; } - p->setNoteAt( pos / 4, note( -64, pos ) ); + p->addNote( note( -64, pos ), FALSE ); } // now process all notes diff --git a/plugins/kicker/kicker.cpp b/plugins/kicker/kicker.cpp index 7c90b4e8d..84ebe5f1a 100644 --- a/plugins/kicker/kicker.cpp +++ b/plugins/kicker/kicker.cpp @@ -39,10 +39,11 @@ #include "kicker.h" +#include "engine.h" #include "instrument_track.h" +#include "knob.h" #include "note_play_handle.h" #include "sweep_oscillator.h" -#include "knob.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" diff --git a/plugins/ladspa_base/ladspa_control.cpp b/plugins/ladspa_base/ladspa_control.cpp index cc2c9af7f..665951f9a 100644 --- a/plugins/ladspa_base/ladspa_control.cpp +++ b/plugins/ladspa_base/ladspa_control.cpp @@ -39,8 +39,9 @@ #include "ladspa_control.h" #include "automatable_object_templates.h" #include "ladspa_base.h" -#include "tooltip.h" +#include "led_checkbox.h" #include "tempo_sync_knob.h" +#include "tooltip.h" ladspaControl::ladspaControl( QWidget * _parent, @@ -66,7 +67,7 @@ ladspaControl::ladspaControl( QWidget * _parent, if( _link ) { - m_link = new ledCheckBox( "", this, "", m_track ); + m_link = new ledCheckBox( "", this, NULL, NULL ); m_link->setChecked( FALSE ); connect( m_link, SIGNAL( toggled( bool ) ), this, SLOT( portLink( bool ) ) ); @@ -195,26 +196,20 @@ LADSPA_Data ladspaControl::getValue( void ) { LADSPA_Data value = 0.0f; - if( m_processLock.tryLock() ) + switch( m_port->data_type ) { - switch( m_port->data_type ) - { - case TOGGLED: - value = static_cast( - m_toggle->isChecked() ); - break; - case INTEGER: - case FLOAT: - case TIME: - value = static_cast( - m_knob->value() ); - break; - default: - printf( - "ladspaControl::getValue BAD BAD BAD\n" ); - break; - } - m_processLock.unlock(); + case TOGGLED: + value = static_cast( + m_toggle->isChecked() ); + break; + case INTEGER: + case FLOAT: + case TIME: + value = static_cast( m_knob->value() ); + break; + default: + printf( "ladspaControl::getValue BAD BAD BAD\n" ); + break; } return( value ); @@ -225,8 +220,6 @@ LADSPA_Data ladspaControl::getValue( void ) void ladspaControl::setValue( LADSPA_Data _value ) { - m_processLock.lock(); - switch( m_port->data_type ) { case TOGGLED: @@ -243,8 +236,6 @@ void ladspaControl::setValue( LADSPA_Data _value ) printf("ladspaControl::setValue BAD BAD BAD\n"); break; } - - m_processLock.unlock(); } @@ -254,8 +245,6 @@ void FASTCALL ladspaControl::saveSettings( QDomDocument & _doc, QDomElement & _this, const QString & _name ) { - m_processLock.lock(); - if( m_link != NULL ) { m_link->saveSettings( _doc, _this, _name + "link" ); @@ -274,8 +263,6 @@ void FASTCALL ladspaControl::saveSettings( QDomDocument & _doc, printf("ladspaControl::saveSettings BAD BAD BAD\n"); break; } - - m_processLock.unlock(); } @@ -283,8 +270,6 @@ void FASTCALL ladspaControl::saveSettings( QDomDocument & _doc, void FASTCALL ladspaControl::loadSettings( const QDomElement & _this, const QString & _name ) { - m_processLock.lock(); - if( m_link != NULL ) { m_link->loadSettings( _this, _name + "link" ); @@ -303,8 +288,6 @@ void FASTCALL ladspaControl::loadSettings( const QDomElement & _this, printf("ladspaControl::loadSettings BAD BAD BAD\n"); break; } - - m_processLock.unlock(); } @@ -312,8 +295,6 @@ void FASTCALL ladspaControl::loadSettings( const QDomElement & _this, void FASTCALL ladspaControl::linkControls( ladspaControl * _control ) { - m_processLock.lock(); - switch( m_port->data_type ) { case TOGGLED: @@ -327,8 +308,6 @@ void FASTCALL ladspaControl::linkControls( ladspaControl * _control ) default: break; } - - m_processLock.unlock(); } @@ -352,8 +331,6 @@ void ladspaControl::knobChange( float _value ) void FASTCALL ladspaControl::unlinkControls( ladspaControl * _control ) { - m_processLock.lock(); - switch( m_port->data_type ) { case TOGGLED: @@ -367,8 +344,6 @@ void FASTCALL ladspaControl::unlinkControls( ladspaControl * _control ) default: break; } - - m_processLock.unlock(); } diff --git a/plugins/ladspa_base/ladspa_control.h b/plugins/ladspa_base/ladspa_control.h index eae86d2ea..59001487b 100644 --- a/plugins/ladspa_base/ladspa_control.h +++ b/plugins/ladspa_base/ladspa_control.h @@ -31,22 +31,32 @@ #include #include -#include #else #include -#include #include #endif +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_LADSPA_H +#include +#else +#include "ladspa-1.1.h" +#endif + + #include "journalling_object.h" -#include "track.h" -#include "knob.h" -#include "led_checkbox.h" -#include "ladspa_manager.h" + + +class knob; +class ledCheckBox; +class track; typedef struct portDescription port_desc_t; @@ -107,8 +117,6 @@ private: ledCheckBox * m_link; ledCheckBox * m_toggle; knob * m_knob; - - QMutex m_processLock; }; #endif diff --git a/plugins/ladspa_base/ladspa_manager.cpp b/plugins/ladspa_base/ladspa_manager.cpp index 75c986289..273ac2b6b 100644 --- a/plugins/ladspa_base/ladspa_manager.cpp +++ b/plugins/ladspa_base/ladspa_manager.cpp @@ -132,6 +132,15 @@ ladspaManager::ladspaManager( void ) ladspaManager::~ladspaManager() { + for( ladspaManagerMapType::iterator it = m_ladspaManagerMap.begin(); + it != m_ladspaManagerMap.end(); ++it ) + { +#ifndef QT3 + delete it.value(); +#else + delete it.data(); +#endif + } } @@ -158,10 +167,17 @@ void FASTCALL ladspaManager::addPlugins( const QString & _file ) { const LADSPA_Descriptor * descriptor; - long pluginIndex = 0; - - while( ( descriptor = _descriptor_func( pluginIndex ) ) != NULL ) + + for( long pluginIndex = 0; + ( descriptor = _descriptor_func( pluginIndex ) ) != NULL; + ++pluginIndex ) { + ladspa_key_t key( QString( descriptor->Label ), _file ); + if( m_ladspaManagerMap.contains( key ) ) + { + continue; + } + ladspaManagerDescription * plugIn = new ladspaManagerDescription; plugIn->descriptorFunction = _descriptor_func; @@ -188,9 +204,7 @@ void FASTCALL ladspaManager::addPlugins( plugIn->type = OTHER; } - ladspa_key_t key( QString( descriptor->Label ), _file ); m_ladspaManagerMap[key] = plugIn; - ++pluginIndex; } } diff --git a/plugins/ladspa_base/ladspa_manager.h b/plugins/ladspa_base/ladspa_manager.h index 654f2bace..7f171e3c4 100644 --- a/plugins/ladspa_base/ladspa_manager.h +++ b/plugins/ladspa_base/ladspa_manager.h @@ -365,8 +365,6 @@ private: ladspaManagerMapType; ladspaManagerMapType m_ladspaManagerMap; l_sortable_plugin_t m_sortedPlugins; - - friend class engine; } ; diff --git a/plugins/ladspa_effect/Makefile.am b/plugins/ladspa_effect/Makefile.am index 37dcd0c5f..69e29273b 100644 --- a/plugins/ladspa_effect/Makefile.am +++ b/plugins/ladspa_effect/Makefile.am @@ -1,6 +1,8 @@ AUTOMAKE_OPTIONS = foreign 1.4 +if SHIP_CAPS SUBDIRS = caps +endif INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/lib -I. -I../ladspa_base/ diff --git a/plugins/ladspa_effect/ladspa_control_dialog.cpp b/plugins/ladspa_effect/ladspa_control_dialog.cpp index ef1c5ecea..9f26d0434 100644 --- a/plugins/ladspa_effect/ladspa_control_dialog.cpp +++ b/plugins/ladspa_effect/ladspa_control_dialog.cpp @@ -161,8 +161,8 @@ ladspaControlDialog::ladspaControlDialog( QWidget * _parent, QHBoxLayout * center = new QHBoxLayout(); m_mainLay->addLayout( center ); #endif - m_stereoLink = new ledCheckBox( tr( "Link Channels" ), this, "", - m_track ); + m_stereoLink = new ledCheckBox( tr( "Link Channels" ), this, + NULL, NULL ); connect( m_stereoLink, SIGNAL( toggled( bool ) ), this, SLOT( link( bool ) ) ); m_stereoLink->setChecked( TRUE ); diff --git a/plugins/ladspa_effect/ladspa_control_dialog.h b/plugins/ladspa_effect/ladspa_control_dialog.h index 62c328167..cbeff4165 100644 --- a/plugins/ladspa_effect/ladspa_control_dialog.h +++ b/plugins/ladspa_effect/ladspa_control_dialog.h @@ -2,7 +2,7 @@ * ladspa_control_dialog.h - dialog for displaying and editing control port * values for LADSPA plugins * - * Copyright (c) 2006 Danny McRae + * Copyright (c) 2006-2007 Danny McRae * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -42,7 +42,6 @@ #include "effect_control_dialog.h" #include "ladspa_control.h" -#include "track.h" #include "led_checkbox.h" diff --git a/plugins/ladspa_effect/ladspa_effect.cpp b/plugins/ladspa_effect/ladspa_effect.cpp index 1fc191d22..6265f3fde 100644 --- a/plugins/ladspa_effect/ladspa_effect.cpp +++ b/plugins/ladspa_effect/ladspa_effect.cpp @@ -315,8 +315,6 @@ ladspaEffect::~ladspaEffect() return; } - lock(); - for( ch_cnt_t proc = 0; proc < getProcessorCount(); proc++ ) { m_ladspa->deactivate( m_key, m_handles[proc] ); @@ -330,8 +328,6 @@ ladspaEffect::~ladspaEffect() } m_ports.clear(); m_handles.clear(); - - unlock(); } @@ -340,8 +336,7 @@ ladspaEffect::~ladspaEffect() bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf, const fpab_t _frames ) { - if( !isOkay() || dontRun() || !isRunning() || - isBypassed() || !tryLock() ) + if( !isOkay() || dontRun() || !isRunning() || isBypassed() ) { return( FALSE ); } @@ -463,7 +458,6 @@ bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf, resetBufferCount(); } - unlock(); return( isRunning() ); } @@ -476,9 +470,7 @@ void FASTCALL ladspaEffect::setControl( Uint16 _control, LADSPA_Data _value ) { return; } - lock(); m_controls[_control]->value = _value; - unlock(); } diff --git a/plugins/lb302/lb302.cpp b/plugins/lb302/lb302.cpp index 61ef37cc8..51a376d98 100644 --- a/plugins/lb302/lb302.cpp +++ b/plugins/lb302/lb302.cpp @@ -42,11 +42,12 @@ #include "lb302.h" -#include "instrument_track.h" +#include "engine.h" #include "instrument_play_handle.h" +#include "instrument_track.h" +#include "knob.h" #include "note_play_handle.h" #include "templates.h" -#include "knob.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" @@ -142,6 +143,17 @@ lb302FilterIIR2::lb302FilterIIR2(lb302FilterState* p_fs) : }; + + + +lb302FilterIIR2::~lb302FilterIIR2() +{ + delete m_dist; +} + + + + void lb302FilterIIR2::recalc() { lb302Filter::recalc(); @@ -685,9 +697,6 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) if ( _n->totalFramesPlayed() <= lastFramesPlayed ) { - float freq = getInstrumentTrack()->frequency( _n ); - - // TODO: Try moving to the if() below if(deadToggle->value()==0) { sample_cnt = 0; @@ -695,7 +704,7 @@ void lb302Synth::playNote( notePlayHandle * _n, bool ) } // Adjust inc on SampRate change or detuning change - vco_inc = freq*vco_detune/LB_HZ; // TODO: Use actual sampling rate. + vco_inc = _n->frequency()*vco_detune/LB_HZ; // TODO: Use actual sampling rate. // Initiate Slide // TODO: Break out into function, should be called again on detuneChanged diff --git a/plugins/lb302/lb302.h b/plugins/lb302/lb302.h index 84981c69a..fc2eb9a33 100644 --- a/plugins/lb302/lb302.h +++ b/plugins/lb302/lb302.h @@ -32,9 +32,10 @@ #ifndef _LB302_H_ #define _LB302_H_ +#include "effect_lib.h" #include "instrument.h" #include "led_checkbox.h" -#include "effect_lib.h" +#include "mixer.h" #include @@ -76,6 +77,7 @@ class lb302FilterIIR2 : public lb302Filter { public: lb302FilterIIR2(lb302FilterState* p_fs); + virtual ~lb302FilterIIR2(); virtual void recalc(); virtual void envRecalc(); diff --git a/plugins/organic/organic.cpp b/plugins/organic/organic.cpp index 270783241..fa0224b9e 100644 --- a/plugins/organic/organic.cpp +++ b/plugins/organic/organic.cpp @@ -51,17 +51,18 @@ using namespace std; #include "organic.h" +#include "engine.h" #include "instrument_track.h" -#include "note_play_handle.h" -#include "templates.h" #include "knob.h" -#include "pixmap_button.h" -#include "tooltip.h" +#include "note_play_handle.h" #include "oscillator.h" +#include "pixmap_button.h" +#include "templates.h" +#include "tooltip.h" +#include "volume_knob.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" -#include "volume_knob.h" extern "C" @@ -100,122 +101,109 @@ organicInstrument::organicInstrument( instrumentTrack * _channel_track ) : specialBgHandlingWidget( PLUGIN_NAME::getIconPixmap( "artwork" ) ), m_modulationAlgo( oscillator::MIX ) { - - m_num_oscillators = 8; - m_osc = new oscillatorData[m_num_oscillators]; + m_osc = new oscillatorObject[m_num_oscillators]; - m_osc[0].harmonic = log2f( 0.5f ); // one octave below - m_osc[1].harmonic = log2f( 0.75f ); // a fifth below - m_osc[2].harmonic = log2f( 1.0f ); // base freq - m_osc[3].harmonic = log2f( 2.0f ); // first overtone - m_osc[4].harmonic = log2f( 3.0f ); // second overtone - m_osc[5].harmonic = log2f( 4.0f ); // . - m_osc[6].harmonic = log2f( 5.0f ); // . - m_osc[7].harmonic = log2f( 6.0f ); // . + m_osc[0].m_harmonic = log2f( 0.5f ); // one octave below + m_osc[1].m_harmonic = log2f( 0.75f ); // a fifth below + m_osc[2].m_harmonic = log2f( 1.0f ); // base freq + m_osc[3].m_harmonic = log2f( 2.0f ); // first overtone + m_osc[4].m_harmonic = log2f( 3.0f ); // second overtone + m_osc[5].m_harmonic = log2f( 4.0f ); // . + m_osc[6].m_harmonic = log2f( 5.0f ); // . + m_osc[7].m_harmonic = log2f( 6.0f ); // . for (int i=0; i < m_num_oscillators; i++) { - m_osc[i].waveShape = oscillator::SIN_WAVE; + m_osc[i].m_num_oscillators = m_num_oscillators; // setup volume-knob - m_osc[i].oscKnob = new knob( knobGreen_17, this, tr( - "Osc %1 waveform" ).arg( i+1 ), + m_osc[i].m_oscKnob = new knob( knobGreen_17, this, tr( + "Osc %1 waveform" ).arg( i + 1 ), _channel_track ); - m_osc[i].oscKnob->move( 25+i*20, 90 ); - m_osc[i].oscKnob->setRange( 0.0f, 5.0f, 0.25f ); - m_osc[i].oscKnob->setInitValue( 0.0f ); - m_osc[i].oscKnob->setHintText( tr( "Osc %1 waveform:" ).arg( - i+1 ) + " ", "%" ); + m_osc[i].m_oscKnob->move( 25 + i * 20, 90 ); + m_osc[i].m_oscKnob->setRange( 0.0f, 5.0f, 0.25f ); + m_osc[i].m_oscKnob->setInitValue( 0.0f ); + m_osc[i].m_oscKnob->setHintText( tr( "Osc %1 waveform:" ).arg( + i + 1 ) + " ", "%" ); - connect( m_osc[i].oscKnob, SIGNAL( valueChanged( float ) ), - this, SLOT (oscButtonChanged( void ) ) - ); + connect( m_osc[i].m_oscKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT ( oscButtonChanged() ) ); // setup volume-knob - m_osc[i].volKnob = new volumeKnob( knobGreen_17, this, tr( - "Osc %1 volume" ).arg( i+1 ), + m_osc[i].m_volKnob = new volumeKnob( knobGreen_17, this, tr( + "Osc %1 volume" ).arg( i + 1 ), _channel_track ); - m_osc[i].volKnob->setData( i ); - m_osc[i].volKnob->move( 25+i*20, 110 ); - m_osc[i].volKnob->setRange( 0, 100, 1.0f ); - m_osc[i].volKnob->setInitValue( 100 ); - m_osc[i].volKnob->setHintText( tr( "Osc %1 volume:" ).arg( - i+1 ) + " ", "%" ); + m_osc[i].m_volKnob->move( 25 + i * 20, 110 ); + m_osc[i].m_volKnob->setRange( 0, 100, 1.0f ); + m_osc[i].m_volKnob->setInitValue( 100 ); + m_osc[i].m_volKnob->setHintText( tr( "Osc %1 volume:" ).arg( + i + 1 ) + " ", "%" ); // setup panning-knob - m_osc[i].panKnob = new knob( knobGreen_17, this, + m_osc[i].m_panKnob = new knob( knobGreen_17, this, tr( "Osc %1 panning" ).arg( i + 1 ), _channel_track ); - m_osc[i].panKnob->setData( i ); - m_osc[i].panKnob->move( 25+i*20, 130 ); - m_osc[i].panKnob->setRange( PANNING_LEFT, PANNING_RIGHT, 1.0f ); - m_osc[i].panKnob->setInitValue( DEFAULT_PANNING ); - m_osc[i].panKnob->setHintText( tr("Osc %1 panning:").arg( i+1 ) - + " ", "" ); + m_osc[i].m_panKnob->move( 25 + i * 20, 130 ); + m_osc[i].m_panKnob->setRange( PANNING_LEFT, PANNING_RIGHT, + 1.0f ); + m_osc[i].m_panKnob->setInitValue( DEFAULT_PANNING ); + m_osc[i].m_panKnob->setHintText( tr("Osc %1 panning:").arg( + i + 1 ) + " ", "" ); // setup knob for left fine-detuning - m_osc[i].detuneKnob = new knob( knobGreen_17, this, - tr( "Osc %1 fine detuning left" ).arg( i+1 ), + m_osc[i].m_detuneKnob = new knob( knobGreen_17, this, + tr( "Osc %1 fine detuning left" ).arg( i + 1 ), _channel_track ); - m_osc[i].detuneKnob->setData( i ); - m_osc[i].detuneKnob->move( 25+i*20, 150 ); - m_osc[i].detuneKnob->setRange( -100.0f, 100.0f, 1.0f ); - m_osc[i].detuneKnob->setInitValue( 0.0f ); - m_osc[i].detuneKnob->setHintText( tr( "Osc %1 fine detuning " + m_osc[i].m_detuneKnob->move( 25 + i * 20, 150 ); + m_osc[i].m_detuneKnob->setRange( -100.0f, 100.0f, 1.0f ); + m_osc[i].m_detuneKnob->setInitValue( 0.0f ); + m_osc[i].m_detuneKnob->setHintText( tr( "Osc %1 fine detuning " "left:" ).arg( i + 1 ) + " ", " " + tr( "cents" ) ); - connect( m_osc[i].volKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateVolume( const QVariant & ) ) ); - connect( m_osc[i].panKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateVolume( const QVariant & ) ) ); - updateVolume( i ); - - connect( m_osc[i].detuneKnob, - SIGNAL ( valueChanged( const QVariant & ) ), - this, SLOT( updateDetuning( const QVariant & ) ) ); - updateDetuning( i ); + connect( m_osc[i].m_volKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateVolume() ) ); + connect( m_osc[i].m_panKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateVolume() ) ); + m_osc[i].updateVolume(); + connect( m_osc[i].m_detuneKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateDetuning() ) ); + m_osc[i].updateDetuning(); } connect( engine::getMixer(), SIGNAL( sampleRateChanged() ), - this, SLOT( updateAllDetuning() ) ); + this, SLOT( updateAllDetuning() ) ); - // setup knob for FX1 - fx1Knob = new knob( knobGreen_17, this, tr( "FX1" ), - _channel_track ); - fx1Knob->move( 20, 200 ); - fx1Knob->setRange( 0.0f, 0.99f, 0.01f ); - fx1Knob->setInitValue( 0.0f); - - // setup volume-knob - volKnob = new knob( knobGreen_17, this, tr( - "Osc %1 volume" ).arg( 1 ), - _channel_track ); - volKnob->move( 50, 200 ); - volKnob->setRange( 0, 200, 1.0f ); - volKnob->setInitValue( 100 ); - volKnob->setHintText( tr( "Osc %1 volume:" ).arg( - 1 ) + " ", "%" ); - - // randomise - m_randBtn = new pixmapButton( this, tr( "Randomise" ), - _channel_track ); - m_randBtn->move( 100, 200 ); - m_randBtn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( + // setup knob for FX1 + m_fx1Knob = new knob( knobGreen_17, this, tr( "FX1" ), _channel_track ); + m_fx1Knob->move( 20, 200 ); + m_fx1Knob->setRange( 0.0f, 0.99f, 0.01f ); + m_fx1Knob->setInitValue( 0.0f); + + // setup volume-knob + m_volKnob = new knob( knobGreen_17, this, tr( "Osc %1 volume" ).arg( + 1 ), _channel_track ); + m_volKnob->move( 50, 200 ); + m_volKnob->setRange( 0, 200, 1.0f ); + m_volKnob->setInitValue( 100 ); + m_volKnob->setHintText( tr( "Osc %1 volume:" ).arg( 1 ) + " ", "%" ); + + // randomise + m_randBtn = new pixmapButton( this, tr( "Randomise" ), _channel_track ); + m_randBtn->move( 100, 200 ); + m_randBtn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "randomise_pressed" ) ); - m_randBtn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( - "randomise" ) ); - //m_randBtn->setMask( QBitmap( PLUGIN_NAME::getIconPixmap( "btn_mask" ). - // createHeuristicMask() ) ); + m_randBtn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( + "randomise" ) ); + //m_randBtn->setMask( QBitmap( PLUGIN_NAME::getIconPixmap( "btn_mask" ). + // createHeuristicMask() ) ); - connect( m_randBtn, SIGNAL ( clicked() ), - this, SLOT( randomiseSettings() ) ); + connect( m_randBtn, SIGNAL ( clicked() ), + this, SLOT( randomiseSettings() ) ); if( s_artwork == NULL ) @@ -239,8 +227,10 @@ organicInstrument::organicInstrument( instrumentTrack * _channel_track ) : + organicInstrument::~organicInstrument() { + delete[] m_osc; } @@ -249,18 +239,20 @@ organicInstrument::~organicInstrument() void organicInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) { _this.setAttribute( "num_osc", QString::number( m_num_oscillators ) ); - fx1Knob->saveSettings( _doc, _this, "foldback" ); - volKnob->saveSettings( _doc, _this, "vol" ); + m_fx1Knob->saveSettings( _doc, _this, "foldback" ); + m_volKnob->saveSettings( _doc, _this, "vol" ); for( int i = 0; i < m_num_oscillators; ++i ) { QString is = QString::number( i ); - m_osc[i].volKnob->saveSettings( _doc, _this, "vol" + is ); - m_osc[i].panKnob->saveSettings( _doc, _this, "pan" + is ); + m_osc[i].m_volKnob->saveSettings( _doc, _this, "vol" + is ); + m_osc[i].m_panKnob->saveSettings( _doc, _this, "pan" + is ); _this.setAttribute( "harmonic" + is, QString::number( - powf( 2.0f, m_osc[i].harmonic ) ) ); - m_osc[i].detuneKnob->saveSettings( _doc, _this, "detune" + is ); - m_osc[i].oscKnob->saveSettings( _doc, _this, "wavetype" + is ); + powf( 2.0f, m_osc[i].m_harmonic ) ) ); + m_osc[i].m_detuneKnob->saveSettings( _doc, _this, "detune" + + is ); + m_osc[i].m_oscKnob->saveSettings( _doc, _this, "wavetype" + + is ); } } @@ -275,16 +267,14 @@ void organicInstrument::loadSettings( const QDomElement & _this ) for( int i = 0; i < m_num_oscillators; ++i ) { QString is = QString::number( i ); - m_osc[i].volKnob->loadSettings( _this, "vol" + is ); - m_osc[i].detuneKnob->loadSettings( _this, "detune" + is ); - m_osc[i].panKnob->loadSettings( _this, "pan" + is ); - m_osc[i].oscKnob->loadSettings( _this, "wavetype" + is ); + 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 ); } - volKnob->loadSettings( _this, "vol" ); - fx1Knob->loadSettings( _this, "foldback" ); - - oscButtonChanged(); + m_volKnob->loadSettings( _this, "vol" ); + m_fx1Knob->loadSettings( _this, "foldback" ); } @@ -303,57 +293,58 @@ void organicInstrument::playNote( notePlayHandle * _n, bool ) oscillator * oscs_l[m_num_oscillators]; oscillator * oscs_r[m_num_oscillators]; - for( Sint8 i = m_num_oscillators-1; i >= 0; --i ) + for( Sint8 i = m_num_oscillators - 1; i >= 0; --i ) { // randomize the phaseOffset [0,1) - m_osc[i].phaseOffsetLeft = rand() + m_osc[i].m_phaseOffsetLeft = rand() / ( RAND_MAX + 1.0f ); - m_osc[i].phaseOffsetRight = rand() + m_osc[i].m_phaseOffsetRight = rand() / ( RAND_MAX + 1.0f ); // initialise ocillators - if (i == (m_num_oscillators-1)) { + if( i == m_num_oscillators - 1 ) + { // create left oscillator oscs_l[i] = new oscillator( - &m_osc[i].waveShape, - &m_modulationAlgo, - &_n->m_frequency, - &m_osc[i].detuningLeft, - &m_osc[i].phaseOffsetLeft, - &m_osc[i].volumeLeft ); + m_osc[i].m_waveShape, + m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningLeft, + m_osc[i].m_phaseOffsetLeft, + m_osc[i].m_volumeLeft ); // create right oscillator oscs_r[i] = new oscillator( - &m_osc[i].waveShape, - &m_modulationAlgo, - &_n->m_frequency, - &m_osc[i].detuningRight, - &m_osc[i].phaseOffsetRight, - &m_osc[i].volumeRight ); - - } else { + m_osc[i].m_waveShape, + m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningRight, + m_osc[i].m_phaseOffsetRight, + m_osc[i].m_volumeRight ); + } + else + { // create left oscillator oscs_l[i] = new oscillator( - &m_osc[i].waveShape, - &m_modulationAlgo, - &_n->m_frequency, - &m_osc[i].detuningLeft, - &m_osc[i].phaseOffsetLeft, - &m_osc[i].volumeLeft, - oscs_l[i + 1] ); + m_osc[i].m_waveShape, + m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningLeft, + m_osc[i].m_phaseOffsetLeft, + m_osc[i].m_volumeLeft, + oscs_l[i + 1] ); // create right oscillator oscs_r[i] = new oscillator( - &m_osc[i].waveShape, - &m_modulationAlgo, - &_n->m_frequency, - &m_osc[i].detuningRight, - &m_osc[i].phaseOffsetRight, - &m_osc[i].volumeRight, - oscs_r[i + 1] ); - + m_osc[i].m_waveShape, + m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningRight, + m_osc[i].m_phaseOffsetRight, + m_osc[i].m_volumeRight, + oscs_r[i + 1] ); } @@ -361,8 +352,7 @@ void organicInstrument::playNote( notePlayHandle * _n, bool ) _n->m_pluginData = new oscPtr; static_cast( _n->m_pluginData )->oscLeft = oscs_l[0]; - static_cast< oscPtr *>( _n->m_pluginData )->oscRight = - oscs_r[0]; + static_cast( _n->m_pluginData )->oscRight = oscs_r[0]; } oscillator * osc_l = static_cast( _n->m_pluginData )->oscLeft; @@ -379,13 +369,13 @@ void organicInstrument::playNote( notePlayHandle * _n, bool ) // -- fx section -- // fxKnob is [0;1] - float t = fx1Knob->value(); + float t = m_fx1Knob->value(); for (int i=0 ; i < frames ; i++) { - buf[i][0] = waveshape( buf[i][0], t ) * volKnob->value() + buf[i][0] = waveshape( buf[i][0], t ) * m_volKnob->value() / 100.0f; - buf[i][1] = waveshape( buf[i][1], t ) * volKnob->value() + buf[i][1] = waveshape( buf[i][1], t ) * m_volKnob->value() / 100.0f; } @@ -418,102 +408,33 @@ void organicInstrument::deleteNotePluginData( notePlayHandle * _n ) } */ + + + float inline organicInstrument::waveshape(float in, float amount) { - float k = 2.0f*amount/(1.0f-amount); + float k = 2.0f * amount / ( 1.0f - amount ); - return (1.0f + k) * - in / (1.0f + k * fabs( in )); + return( ( 1.0f + k ) * in / ( 1.0f + k * fabs( in ) ) ); } -void organicInstrument::oscButtonChanged( ) -{ - - for (int i = 0; i < m_num_oscillators; i++) - { - float value = m_osc[i].oscKnob->value(); - - if ( value <= 0.5 ) { - m_osc[i].waveShape = oscillator::SIN_WAVE; - continue; - } - - if ( value <= 1.5 ) { - m_osc[i].waveShape = oscillator::SAW_WAVE; - continue; - } - if ( value <= 2.5 ) { - m_osc[i].waveShape = oscillator::SQUARE_WAVE; - continue; - } - - if ( value <= 3.5 ) { - m_osc[i].waveShape = oscillator::TRIANGLE_WAVE; - continue; - } - - if ( value <= 4.5 ) { - m_osc[i].waveShape = oscillator::MOOG_SAW_WAVE; - continue; - } - - m_osc[i].waveShape = oscillator::EXP_WAVE; - - } -} -void organicInstrument::randomiseSettings() + +void organicInstrument::randomiseSettings( void ) { - - for (int i=0; i < m_num_oscillators; i++) + for( int i = 0; i < m_num_oscillators; i++ ) { - m_osc[i].volKnob->setValue( - intRand(0,100) - ); - - m_osc[i].detuneKnob->setValue( - intRand(-5, 5) - ); - - m_osc[i].panKnob->setValue( + m_osc[i].m_volKnob->setValue( intRand( 0, 100 ) ); + + m_osc[i].m_detuneKnob->setValue( intRand( -5, 5 ) ); + + m_osc[i].m_panKnob->setValue( //(int)gaussRand(PANNING_LEFT, PANNING_RIGHT,1,0) - 0 - ); - - m_osc[i].oscKnob->setValue( - intRand(0, 5) - ); + 0 ); + + m_osc[i].m_oscKnob->setValue( intRand( 0, 5 ) ); } - -} - - - - -void organicInstrument::updateVolume( const QVariant & _data ) -{ - const int _i = _data.toInt(); - m_osc[_i].volumeLeft = - ( 1.0f - m_osc[_i].panKnob->value() / (float)PANNING_RIGHT ) - * m_osc[_i].volKnob->value() / m_num_oscillators / 100.0f; - m_osc[_i].volumeRight = - ( 1.0f + m_osc[_i].panKnob->value() / (float)PANNING_RIGHT ) - * m_osc[_i].volKnob->value() / m_num_oscillators / 100.0f; -} - - - - -void organicInstrument::updateDetuning( const QVariant & _data ) -{ - const int _i = _data.toInt(); - m_osc[_i].detuningLeft = powf( 2.0f, m_osc[_i].harmonic - + (float)m_osc[_i].detuneKnob->value() / 100.0f ) - / engine::getMixer()->sampleRate(); - m_osc[_i].detuningRight = powf( 2.0f, m_osc[_i].harmonic - - (float)m_osc[_i].detuneKnob->value() / 100.0f ) - / engine::getMixer()->sampleRate(); } @@ -523,7 +444,7 @@ void organicInstrument::updateAllDetuning( void ) { for( int i = 0; i < m_num_oscillators; ++i ) { - updateDetuning( i ); + m_osc[i].updateDetuning(); } } @@ -534,8 +455,69 @@ int organicInstrument::intRand( int min, int max ) { // int randn = min+int((max-min)*rand()/(RAND_MAX + 1.0)); // cout << randn << endl; - int randn = ( rand() % (max-min) ) + min ; - return randn; + int randn = ( rand() % (max - min) ) + min; + return( randn ); +} + + + + + + + + +oscillatorObject::oscillatorObject( void ) : + m_waveShape( oscillator::SIN_WAVE ) +{ +} + + + + +oscillatorObject::~oscillatorObject() +{ +} + + + + +void oscillatorObject::oscButtonChanged( void ) +{ + static oscillator::waveShapes shapes[] = + { + oscillator::SIN_WAVE, + oscillator::SAW_WAVE, + oscillator::SQUARE_WAVE, + oscillator::TRIANGLE_WAVE, + oscillator::MOOG_SAW_WAVE, + oscillator::EXP_WAVE + } ; + + m_waveShape = shapes[(int)roundf( m_oscKnob->value() )]; +} + + + + +void oscillatorObject::updateVolume( void ) +{ + m_volumeLeft = ( 1.0f - m_panKnob->value() / (float)PANNING_RIGHT ) + * m_volKnob->value() / m_num_oscillators / 100.0f; + m_volumeRight = ( 1.0f + m_panKnob->value() / (float)PANNING_RIGHT ) + * m_volKnob->value() / m_num_oscillators / 100.0f; +} + + + + +void oscillatorObject::updateDetuning( void ) +{ + m_detuningLeft = powf( 2.0f, m_harmonic + + (float)m_detuneKnob->value() / 100.0f ) + / engine::getMixer()->sampleRate(); + m_detuningRight = powf( 2.0f, m_harmonic + - (float)m_detuneKnob->value() / 100.0f ) + / engine::getMixer()->sampleRate(); } diff --git a/plugins/organic/organic.h b/plugins/organic/organic.h index 2de31e5f6..41a6c2485 100644 --- a/plugins/organic/organic.h +++ b/plugins/organic/organic.h @@ -1,7 +1,7 @@ /* * organic.h - additive synthesizer for organ-like sounds * - * Copyright (c) 2006 Andreas Brandmaier + * Copyright (c) 2006-2007 Andreas Brandmaier * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -40,6 +40,43 @@ class pixmapButton; class volumeKnob; +class oscillatorObject : public QObject +{ + Q_OBJECT +private: + int m_num_oscillators; + oscillator::waveShapes m_waveShape; + knob * m_oscKnob; + volumeKnob * m_volKnob; + knob * m_panKnob; + knob * m_detuneKnob; + + float m_harmonic; + float m_volumeLeft; + float m_volumeRight; + // normalized detuning -> x/sampleRate + float m_detuningLeft; + float m_detuningRight; + // normalized offset -> x/360 + float m_phaseOffsetLeft; + float m_phaseOffsetRight; + + oscillatorObject( void ); + virtual ~oscillatorObject(); + + friend class organicInstrument; + + +private slots: + void oscButtonChanged( void ); + void updateVolume( void ); + void updateDetuning( void ); + +} ; + + + + class organicInstrument : public instrument, public specialBgHandlingWidget { Q_OBJECT @@ -62,12 +99,10 @@ public: public slots: + void randomiseSettings( void ); - void oscButtonChanged( void ); - void randomiseSettings(); private: - float inline waveshape(float in, float amount); @@ -81,25 +116,7 @@ private: int m_num_oscillators; - struct oscillatorData - { - oscillator::waveShapes waveShape; - knob * oscKnob; - volumeKnob * volKnob; - knob * panKnob; - knob * detuneKnob; - float harmonic; - float volumeLeft; - float volumeRight; - // normalized detuning -> x/sampleRate - float detuningLeft; - float detuningRight; - // normalized offset -> x/360 - float phaseOffsetLeft; - float phaseOffsetRight; - }; - - oscillatorData* m_osc; + oscillatorObject * m_osc; struct oscPtr { @@ -109,14 +126,12 @@ private: const oscillator::modulationAlgos m_modulationAlgo; - knob * fx1Knob; - knob * volKnob; - pixmapButton * m_randBtn; + knob * m_fx1Knob; + knob * m_volKnob; + pixmapButton * m_randBtn; + private slots: - - void updateVolume( const QVariant & _i ); - void updateDetuning( const QVariant & _i ); void updateAllDetuning( void ); } ; diff --git a/plugins/patman/patman.cpp b/plugins/patman/patman.cpp index fd1da1413..1b9da5d44 100644 --- a/plugins/patman/patman.cpp +++ b/plugins/patman/patman.cpp @@ -42,7 +42,9 @@ #include "patman.h" #include "endian_handling.h" +#include "engine.h" #include "file_browser.h" +#include "gui_templates.h" #include "note_play_handle.h" #include "pixmap_button.h" #include "song_editor.h" @@ -214,15 +216,14 @@ void patmanSynth::playNote( notePlayHandle * _n, bool ) const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); sampleFrame * buf = new sampleFrame[frames]; - float freq = getInstrumentTrack()->frequency( _n ); - if( !_n->m_pluginData ) { select_sample( _n ); } handle_data * hdata = (handle_data *)_n->m_pluginData; - float play_freq = hdata->tuned ? freq : hdata->sample->frequency(); + float play_freq = hdata->tuned ? _n->frequency() : + hdata->sample->frequency(); if( hdata->sample->play( buf, hdata->state, frames, play_freq, m_loopButton->isChecked() ) ) @@ -639,7 +640,7 @@ void patmanSynth::unload_current_patch( void ) void patmanSynth::select_sample( notePlayHandle * _n ) { - float freq = getInstrumentTrack()->frequency( _n ); + const float freq = _n->frequency(); float min_dist = HUGE_VALF; sampleBuffer * sample = NULL; diff --git a/plugins/plucked_string_synth/plucked_string_synth.cpp b/plugins/plucked_string_synth/plucked_string_synth.cpp index 04d88e57b..939d56484 100644 --- a/plugins/plucked_string_synth/plucked_string_synth.cpp +++ b/plugins/plucked_string_synth/plucked_string_synth.cpp @@ -37,10 +37,11 @@ #include "plucked_string_synth.h" +#include "engine.h" #include "instrument_track.h" +#include "knob.h" #include "note_play_handle.h" #include "templates.h" -#include "knob.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" @@ -136,9 +137,9 @@ void pluckedStringSynth::playNote( notePlayHandle * _n, bool ) { if ( _n->totalFramesPlayed() == 0 ) { - float freq = getInstrumentTrack()->frequency( _n ); - _n->m_pluginData = new pluckSynth( freq, m_pickKnob->value(), - m_pickupKnob->value(), + _n->m_pluginData = new pluckSynth( _n->frequency(), + m_pickKnob->value(), + m_pickupKnob->value(), engine::getMixer()->sampleRate() ); } @@ -196,13 +197,11 @@ pluckSynth::delayLine * FASTCALL pluckSynth::initDelayLine( int _len ) void FASTCALL pluckSynth::freeDelayLine( delayLine * _dl ) { - if( _dl && _dl->data ) + if( _dl ) { delete[] _dl->data; + delete[] _dl; } - - _dl->data = NULL; - delete[] _dl; } diff --git a/plugins/polyb302/polyb302.cpp b/plugins/polyb302/polyb302.cpp index 48ab195f7..bce2f1e5e 100644 --- a/plugins/polyb302/polyb302.cpp +++ b/plugins/polyb302/polyb302.cpp @@ -30,6 +30,7 @@ #include "polyb302.h" +#include "engine.h" #include "knob.h" #include "led_checkbox.h" #include "note_play_handle.h" @@ -325,9 +326,8 @@ polyb302Synth::polyb302Synth( instrumentTrack * _track ) : m_vcf_dec_knob->setHintText( tr( "Decay:" ) + " ", "" ); m_vcf_dec_knob->setLabel( tr( "DEC" ) ); - m_slideToggle = new ledCheckBox( "Slide", this, tr( "Slide" ), _track ); - m_slideToggle->move( 10, 200 ); - +// m_slideToggle = new ledCheckBox( "Slide", this, tr( "Slide" ), _track ); +// m_slideToggle->move( 10, 180 ); // m_accentToggle = new ledCheckBox( "Accent", this, // tr( "Accent" ), @@ -335,10 +335,7 @@ polyb302Synth::polyb302Synth( instrumentTrack * _track ) : // m_accentToggle->move( 10, 200 ); // m_accentToggle->setDisabled(true); - -// m_deadToggle = new ledCheckBox( "Dead", this, -// tr( "Dead" ), -// _track ); +// m_deadToggle = new ledCheckBox( "Dead", this, tr( "Dead" ), _track ); // m_deadToggle->move( 10, 220 ); m_db24Toggle = new ledCheckBox( "24dB/oct", this, @@ -383,7 +380,7 @@ polyb302Synth::polyb302Synth( instrumentTrack * _track ) : m_wave_knob->setLabel( tr( "WAVE" ) ); -#ifdef QT4 +#ifndef QT3 setAutoFillBackground( TRUE ); QPalette pal; pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( @@ -433,7 +430,7 @@ void polyb302Synth::saveSettings( QDomDocument & _doc, QDomElement & _this ) m_dist_knob->saveSettings( _doc, _this, "dist" ); m_slide_dec_knob->saveSettings( _doc, _this, "slide_dec" ); - m_slideToggle->saveSettings( _doc, _this, "slide" ); +// m_slideToggle->saveSettings( _doc, _this, "slide" ); // m_deadToggle->saveSettings( _doc, _this, "dead" ); m_db24Toggle->saveSettings( _doc, _this, "db24"); } @@ -453,7 +450,7 @@ void polyb302Synth::loadSettings( const QDomElement & _this ) m_wave_knob->loadSettings( _this, "shape" ); m_slide_dec_knob->loadSettings( _this, "slide_dec" ); - m_slideToggle->loadSettings( _this, "slide" ); +// m_slideToggle->loadSettings( _this, "slide" ); // m_deadToggle->loadSettings( _this, "dead" ); m_db24Toggle->loadSettings( _this, "db24" ); } @@ -500,8 +497,6 @@ void polyb302Synth::playNote( notePlayHandle * _n, bool ) hstate = (handleState *)_n->m_pluginData; } - float freq = getInstrumentTrack()->frequency( _n ); - if( _n->totalFramesPlayed() <= hstate->m_lastFramesPlayed ) { // TODO: Try moving to the if() below @@ -533,12 +528,12 @@ void polyb302Synth::playNote( notePlayHandle * _n, bool ) // End break-out // Slide note, save inc for next note - if (m_slideToggle->value()) - { - hstate->m_vco_slideinc = hstate->m_vco_inc; +// if( m_slideToggle->value() ) +// { +// hstate->m_vco_slideinc = hstate->m_vco_inc; // May need to equal m_vco_slidebase+m_vco_slide if last // note slid - } +// } hstate->recalcFilter(); @@ -549,7 +544,7 @@ void polyb302Synth::playNote( notePlayHandle * _n, bool ) hstate->m_vcf->playNote(); // Ensure envelope is recalculated hstate->m_vcf_envpos = ENVINC; - + // Double Check hstate->m_vca_mode = 0; hstate->m_vca_a = 0.0; @@ -559,7 +554,7 @@ void polyb302Synth::playNote( notePlayHandle * _n, bool ) const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); sampleFrame * buf = new sampleFrame[frames]; - hstate->process( buf, frames, freq ); + hstate->process( buf, frames, _n->frequency() ); getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); delete[] buf; @@ -652,7 +647,7 @@ void polyb302Synth::waveChanged( float ) -polyb302Synth::handleState::handleState( polyb302Synth * _synth ) +polyb302Synth::handleState::handleState( const polyb302Synth * _synth ) { m_vco_inc = 0.0; m_vco_c = 0; @@ -672,11 +667,11 @@ polyb302Synth::handleState::handleState( polyb302Synth * _synth ) m_vca_mode = 2; m_vca_a = 0; - //m_vca_attack = 1.0 - 0.94406088; - m_vca_attack = 1.0 - 0.96406088; - m_vca_decay = 0.99897516; + //m_vca_attack = 1.0 - 0.94406088; + m_vca_attack = 1.0 - 0.96406088; + m_vca_decay = 0.99897516; - m_vco_shape = SAWTOOTH; + m_vco_shape = SAWTOOTH; // Experimenting between original (0.5) and 1.0 m_vca_a0 = 0.5; diff --git a/plugins/polyb302/polyb302.h b/plugins/polyb302/polyb302.h index 2d2a2a947..1e7d8d87e 100644 --- a/plugins/polyb302/polyb302.h +++ b/plugins/polyb302/polyb302.h @@ -32,8 +32,9 @@ #ifndef _POLYB302_H_ #define _POLYB302_H_ -#include "instrument.h" #include "effect_lib.h" +#include "instrument.h" +#include "mixer.h" class knob; @@ -163,7 +164,7 @@ private: class handleState { public: - handleState( polyb302Synth * _synth ); + handleState( const polyb302Synth * _synth ); virtual ~handleState(); enum vco_shape_t { @@ -212,7 +213,7 @@ private: int m_sample_cnt; // TODO: split synth slots - polyb302Synth * m_synth; + const polyb302Synth * m_synth; void recalcFilter( void ); @@ -236,7 +237,7 @@ private: knob * m_dist_knob; knob * m_wave_knob; - ledCheckBox * m_slideToggle; +// ledCheckBox * m_slideToggle; // ledCheckBox * m_accentToggle; // ledCheckBox * m_deadToggle; ledCheckBox * m_db24Toggle; diff --git a/plugins/singerbot/singerbot.cpp b/plugins/singerbot/singerbot.cpp index 161684368..16cfb1a44 100644 --- a/plugins/singerbot/singerbot.cpp +++ b/plugins/singerbot/singerbot.cpp @@ -42,10 +42,10 @@ #endif #include "singerbot.h" +#include "engine.h" #include "instrument_track.h" #include "note_play_handle.h" #include "pattern.h" -#include "sample_buffer.h" #include "song_editor.h" #undef SINGLE_SOURCE_COMPILE @@ -146,7 +146,6 @@ singerBot::~singerBot() void singerBot::playNote( notePlayHandle * _n, bool ) { const Uint32 frames = engine::getMixer()->framesPerAudioBuffer(); - sampleFrame * buf = new sampleFrame[frames]; if( !_n->m_pluginData ) { @@ -154,16 +153,14 @@ void singerBot::playNote( notePlayHandle * _n, bool ) } handle_data * hdata = (handle_data *)_n->m_pluginData; - sampleBuffer * sample_buffer = hdata->remaining_frames ? - readWave( hdata ) : new sampleBuffer( NULL, 0 ); - - sampleBuffer::handleState hstate; - - if( sample_buffer->play( buf, &hstate, frames ) ) + if( hdata->remaining_frames <= 0 ) { - getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); + return; } - sharedObject::unref( sample_buffer ); + + sampleFrame * buf = new sampleFrame[frames]; + play( buf, hdata, frames ); + getInstrumentTrack()->processAudioBuffer( buf, frames, _n ); delete[] buf; } @@ -173,14 +170,8 @@ void singerBot::playNote( notePlayHandle * _n, bool ) void singerBot::deleteNotePluginData( notePlayHandle * _n ) { handle_data * hdata = (handle_data *)_n->m_pluginData; - if( hdata->wave ) - { - delete hdata->wave; - } - if( hdata->resampling_state ) - { - src_delete( hdata->resampling_state ); - } + delete hdata->wave; + src_delete( hdata->resampling_state ); delete hdata; } @@ -264,7 +255,7 @@ void singerBot::createWave( notePlayHandle * _n ) return; } - hdata->frequency = getInstrumentTrack()->frequency( _n ); + hdata->frequency = _n->frequency(); hdata->duration = _n->length() > 0 ? _n->length() * 60.0f * BEATS_PER_TACT / 64.0f / engine::getSongEditor()->getTempo() : @@ -294,8 +285,6 @@ void singerBot::createWave( notePlayHandle * _n ) src_strerror( error ) ); } - hdata->resampling_data.src_ratio = engine::getMixer()->sampleRate() - / (double)hdata->wave->sample_rate(); hdata->resampling_data.end_of_input = 0; hdata->remaining_frames = hdata->wave->num_samples(); } @@ -303,53 +292,74 @@ void singerBot::createWave( notePlayHandle * _n ) -sampleBuffer * singerBot::readWave( handle_data * _hdata ) +void singerBot::play( sampleFrame * _ab, handle_data * _hdata, + const fpab_t _frames ) { - f_cnt_t frames = engine::getMixer()->framesPerAudioBuffer(); - f_cnt_t offset = _hdata->wave->num_samples() - _hdata->remaining_frames; + const f_cnt_t offset = _hdata->wave->num_samples() + - _hdata->remaining_frames; - const float fac = 1.0f / OUTPUT_SAMPLE_MULTIPLIER; - f_cnt_t fragment_size = tMin( _hdata->remaining_frames, - 1 + (f_cnt_t)ceil( frames - / _hdata->resampling_data.src_ratio ) ); - sample_t * wave_samples = new sample_t[fragment_size]; + const double ratio = engine::getMixer()->sampleRate() + / (double)_hdata->wave->sample_rate(); - for( f_cnt_t frame = 0; frame < fragment_size; ++frame ) + const f_cnt_t margin = 2; + f_cnt_t fragment_size = (f_cnt_t)( _frames / ratio ) + margin; + + sample_t * sample_fragment = new sample_t[fragment_size]; + + if( fragment_size <= _hdata->remaining_frames ) { - wave_samples[frame] = _hdata->wave->a( offset + frame ) * fac; + for( f_cnt_t frame = 0; frame < fragment_size; ++frame ) + { + sample_fragment[frame] = _hdata->wave->a( offset + + frame ) + / OUTPUT_SAMPLE_MULTIPLIER; + } + } + else + { + for( f_cnt_t frame = 0; frame < _hdata->remaining_frames; + ++frame ) + { + sample_fragment[frame] = _hdata->wave->a( offset + + frame ) + / OUTPUT_SAMPLE_MULTIPLIER; + } + memset( sample_fragment + _hdata->remaining_frames, 0, + ( fragment_size - _hdata->remaining_frames ) + * sizeof( sample_t ) ); } - sample_t * mono_data = new sample_t[frames]; - memset( mono_data, 0, sizeof( sample_t ) * frames ); + sample_t * data = new sample_t[_frames]; - _hdata->resampling_data.data_in = wave_samples; - _hdata->resampling_data.data_out = mono_data; + _hdata->resampling_data.data_in = sample_fragment; + _hdata->resampling_data.data_out = data; _hdata->resampling_data.input_frames = fragment_size; - _hdata->resampling_data.output_frames = frames; + _hdata->resampling_data.output_frames = _frames; + _hdata->resampling_data.src_ratio = ratio; int error = src_process( _hdata->resampling_state, &_hdata->resampling_data ); if( error ) { - printf( "%s: src_process() error: %s\n", __FILE__, + printf( "%s: error while resampling: %s\n", __FILE__, src_strerror( error ) ); } + if( _hdata->resampling_data.output_frames_gen != _frames ) + { + printf( "%s: not enough frames: %ld / %d\n", __FILE__, + _hdata->resampling_data.output_frames_gen, _frames ); + } + _hdata->remaining_frames -= _hdata->resampling_data.input_frames_used; - sampleFrame * data = new sampleFrame[frames]; - - for( f_cnt_t frame = 0; frame < frames; ++frame ) + for( f_cnt_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) { - data[frame][chnl] = mono_data[frame]; + _ab[frame][chnl] = data[frame]; } } - sampleBuffer * buffer = new sampleBuffer( data, frames ); - _hdata->remaining_frames -= _hdata->resampling_data.input_frames_used; - delete[] wave_samples; - delete[] mono_data; + delete[] sample_fragment; delete[] data; - return( buffer ); } @@ -420,6 +430,15 @@ void singerBot::synThread::run( void ) m_synth_semaphore++; #endif text_to_wave(); + if( !m_data->wave ) + { + // Damaged SIOD environment? Retrying... + text_to_wave(); + if( !m_data->wave ) + { + printf( "Unsupported frequency?\n" ); + } + } #ifndef QT3 m_handle_semaphore.release(); #else @@ -447,7 +466,7 @@ void singerBot::synThread::text_to_wave( void ) festival_eval_command( "(set! word " + quote_string( m_data->text, "\"", "\\", 1 ) + ")" ); - festival_eval_command( + if( festival_eval_command( "(begin" " (set! my_utt (eval (list 'Utterance 'Text word)))" " (get_segment my_utt)" @@ -469,18 +488,13 @@ void singerBot::synThread::text_to_wave( void ) " (Duration my_utt)" " ))" " (Int_Targets my_utt)" - ")" ); + ")" ) - if( festival_eval_command( + && festival_eval_command( " (Wave_Synth my_utt)" ) ) { m_data->wave = get_wave( "my_utt" ); } - else - { - // Unsupported frequency - m_data->wave = NULL; - } } diff --git a/plugins/singerbot/singerbot.h b/plugins/singerbot/singerbot.h index 84db55fa4..367fa5f65 100644 --- a/plugins/singerbot/singerbot.h +++ b/plugins/singerbot/singerbot.h @@ -26,7 +26,7 @@ #ifndef _SINGERBOT_H #define _SINGERBOT_H -#ifdef QT4 +#ifndef QT3 #include @@ -40,12 +40,12 @@ #include #include "instrument.h" +#include "mixer.h" class EST_Wave; class QTextEdit; class sampleBuffer; -class EST_String; class singerBot : public instrument @@ -75,7 +75,7 @@ private: typedef struct { EST_Wave * wave; - int remaining_frames; + f_cnt_t remaining_frames; float frequency; float duration; const char * text; @@ -136,7 +136,8 @@ private: bool m_words_dirty; void createWave( notePlayHandle * _n ); - sampleBuffer * readWave( handle_data * _hdata ); + void play( sampleFrame * _ab, handle_data * _hdata, + const fpab_t _frames ); void updateWords( void ); } ; diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp index 5938d127b..e34af0ce9 100644 --- a/plugins/stk/mallets/mallets.cpp +++ b/plugins/stk/mallets/mallets.cpp @@ -40,10 +40,12 @@ #include "TubeBell.h" #include "mallets.h" +#include "engine.h" +#include "gui_templates.h" #include "instrument_track.h" +#include "knob.h" #include "note_play_handle.h" #include "templates.h" -#include "knob.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" @@ -390,7 +392,7 @@ void mallets::playNote( notePlayHandle * _n, bool ) { int p = m_presets->value(); - float freq = getInstrumentTrack()->frequency( _n ); + const float freq = _n->frequency(); if ( _n->totalFramesPlayed() == 0 ) { float vel = static_cast( _n->getVolume() ) / 100.0f; diff --git a/plugins/stk/mallets/mallets.h b/plugins/stk/mallets/mallets.h index a862fa0a8..2e3de34c8 100644 --- a/plugins/stk/mallets/mallets.h +++ b/plugins/stk/mallets/mallets.h @@ -29,10 +29,10 @@ #include "Instrmnt.h" -#include "instrument.h" #include "combobox.h" +#include "instrument.h" #include "led_checkbox.h" -#include "track.h" +#include "mixer.h" class knob; class notePlayHandle; diff --git a/plugins/triple_oscillator/triple_oscillator.cpp b/plugins/triple_oscillator/triple_oscillator.cpp index 6da5522bc..22965523e 100644 --- a/plugins/triple_oscillator/triple_oscillator.cpp +++ b/plugins/triple_oscillator/triple_oscillator.cpp @@ -44,20 +44,21 @@ #include "triple_oscillator.h" -#include "song_editor.h" -#include "instrument_track.h" -#include "note_play_handle.h" -#include "knob.h" -#include "debug.h" -#include "tooltip.h" -#include "sample_buffer.h" #include "automatable_button.h" +#include "debug.h" +#include "engine.h" +#include "instrument_track.h" +#include "knob.h" +#include "note_play_handle.h" #include "pixmap_button.h" +#include "sample_buffer.h" +#include "song_editor.h" +#include "tooltip.h" +#include "volume_knob.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" -#include "volume_knob.h" extern "C" @@ -81,16 +82,8 @@ plugin::descriptor tripleoscillator_plugin_descriptor = tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : - instrument( _channel_track, &tripleoscillator_plugin_descriptor ), - m_modulationAlgo1( oscillator::MIX ), - m_modulationAlgo2( oscillator::MIX ), - m_modulationAlgo3( oscillator::MIX ) + instrument( _channel_track, &tripleoscillator_plugin_descriptor ) { - for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) - { - m_osc[i].m_sampleBuffer = new sampleBuffer; - } - #ifdef QT4 setAutoFillBackground( TRUE ); QPalette pal; @@ -166,10 +159,10 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : m_mod1BtnGrp->addButton( mix_osc1_btn ); m_mod1BtnGrp->addButton( sync_osc1_btn ); m_mod1BtnGrp->addButton( fm_osc1_btn ); - m_mod1BtnGrp->setInitValue( m_modulationAlgo1 ); + m_mod1BtnGrp->setInitValue( m_osc[0].m_modulationAlgo ); connect( m_mod1BtnGrp, SIGNAL( valueChanged( int ) ), - this, SLOT( mod1Ch( int ) ) ); + &m_osc[0], SLOT( modCh( int ) ) ); pixmapButton * pm_osc2_btn = new pixmapButton( this, NULL, NULL ); @@ -237,31 +230,27 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : m_mod2BtnGrp->addButton( mix_osc2_btn ); m_mod2BtnGrp->addButton( sync_osc2_btn ); m_mod2BtnGrp->addButton( fm_osc2_btn ); - m_mod2BtnGrp->setInitValue( m_modulationAlgo2 ); + m_mod2BtnGrp->setInitValue( m_osc[1].m_modulationAlgo ); connect( m_mod2BtnGrp, SIGNAL( valueChanged( int ) ), - this, SLOT( mod2Ch( int ) ) ); + &m_osc[1], SLOT( modCh( int ) ) ); for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) { - // reset current m_osc-structure - m_osc[i].waveShape = oscillator::SIN_WAVE; - // setup volume-knob - m_osc[i].volKnob = new volumeKnob( knobSmall_17, this, tr( + m_osc[i].m_volKnob = new volumeKnob( knobSmall_17, this, tr( "Osc %1 volume" ).arg( i+1 ), _channel_track ); - m_osc[i].volKnob->setData( i ); - m_osc[i].volKnob->move( 6, 104+i*50 ); - m_osc[i].volKnob->setRange( MIN_VOLUME, MAX_VOLUME, 1.0f ); - m_osc[i].volKnob->setInitValue( DEFAULT_VOLUME + m_osc[i].m_volKnob->move( 6, 104 + i * 50 ); + m_osc[i].m_volKnob->setRange( MIN_VOLUME, MAX_VOLUME, 1.0f ); + m_osc[i].m_volKnob->setInitValue( DEFAULT_VOLUME / NUM_OF_OSCILLATORS ); - m_osc[i].volKnob->setHintText( tr( "Osc %1 volume:" ).arg( + m_osc[i].m_volKnob->setHintText( tr( "Osc %1 volume:" ).arg( i+1 ) + " ", "%" ); #ifdef QT4 - m_osc[i].volKnob->setWhatsThis( + m_osc[i].m_volKnob->setWhatsThis( #else - QWhatsThis::add( m_osc[i].volKnob, + QWhatsThis::add( m_osc[i].m_volKnob, #endif tr( "With this knob you can set the volume of " "oscillator %1. When setting a value of 0 the " @@ -270,19 +259,20 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "here.").arg( i+1 ) ); // setup panning-knob - m_osc[i].panKnob = new knob( knobSmall_17, this, + m_osc[i].m_panKnob = new knob( knobSmall_17, this, tr( "Osc %1 panning" ).arg( i + 1 ), _channel_track ); - m_osc[i].panKnob->setData( i ); - m_osc[i].panKnob->move( 33, 104+i*50 ); - m_osc[i].panKnob->setRange( PANNING_LEFT, PANNING_RIGHT, 1.0f ); - m_osc[i].panKnob->setInitValue( DEFAULT_PANNING ); - m_osc[i].panKnob->setHintText( tr("Osc %1 panning:").arg( i+1 ) + m_osc[i].m_panKnob->move( 33, 104 + i * 50 ); + m_osc[i].m_panKnob->setRange( PANNING_LEFT, PANNING_RIGHT, + 1.0f ); + m_osc[i].m_panKnob->setInitValue( DEFAULT_PANNING ); + m_osc[i].m_panKnob->setHintText( tr("Osc %1 panning:").arg( + i + 1 ) + " ", "" ); #ifdef QT4 - m_osc[i].panKnob->setWhatsThis( + m_osc[i].m_panKnob->setWhatsThis( #else - QWhatsThis::add( m_osc[i].panKnob, + QWhatsThis::add( m_osc[i].m_panKnob, #endif tr( "With this knob you can set the panning of the " "oscillator %1. A value of -100 means 100% " @@ -290,21 +280,20 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "output right.").arg( i+1 ) ); // setup coarse-knob - m_osc[i].coarseKnob = new knob( knobSmall_17, this, + m_osc[i].m_coarseKnob = new knob( knobSmall_17, this, tr( "Osc %1 coarse detuning" ).arg( i + 1 ), _channel_track ); - m_osc[i].coarseKnob->setData( i ); - m_osc[i].coarseKnob->move( 66, 104 + i * 50 ); - m_osc[i].coarseKnob->setRange( -2 * NOTES_PER_OCTAVE, + m_osc[i].m_coarseKnob->move( 66, 104 + i * 50 ); + m_osc[i].m_coarseKnob->setRange( -2 * NOTES_PER_OCTAVE, 2 * NOTES_PER_OCTAVE, 1.0f ); - m_osc[i].coarseKnob->setInitValue( 0.0f ); - m_osc[i].coarseKnob->setHintText( tr( "Osc %1 coarse detuning:" - ).arg( i + 1 ) + " ", + m_osc[i].m_coarseKnob->setInitValue( 0.0f ); + m_osc[i].m_coarseKnob->setHintText( + tr( "Osc %1 coarse detuning:" ).arg( i + 1 ) + " ", " " + tr( "semitones" ) ); #ifdef QT4 - m_osc[i].coarseKnob->setWhatsThis( + m_osc[i].m_coarseKnob->setWhatsThis( #else - QWhatsThis::add( m_osc[i].coarseKnob, + QWhatsThis::add( m_osc[i].m_coarseKnob, #endif tr( "With this knob you can set the coarse detuning of " "oscillator %1. You can detune the oscillator " @@ -313,21 +302,20 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : arg( i + 1 ) ); // setup knob for left fine-detuning - m_osc[i].fineLKnob = new knob( knobSmall_17, this, + m_osc[i].m_fineLKnob = new knob( knobSmall_17, this, tr( "Osc %1 fine detuning left" ).arg( i+1 ), _channel_track ); - m_osc[i].fineLKnob->setData( i ); - m_osc[i].fineLKnob->move( 90, 104 + i * 50 ); - m_osc[i].fineLKnob->setRange( -100.0f, 100.0f, 1.0f ); - m_osc[i].fineLKnob->setInitValue( 0.0f ); - m_osc[i].fineLKnob->setHintText( tr( "Osc %1 fine detuning " + m_osc[i].m_fineLKnob->move( 90, 104 + i * 50 ); + m_osc[i].m_fineLKnob->setRange( -100.0f, 100.0f, 1.0f ); + m_osc[i].m_fineLKnob->setInitValue( 0.0f ); + m_osc[i].m_fineLKnob->setHintText( tr( "Osc %1 fine detuning " "left:" ).arg( i + 1 ) + " ", " " + tr( "cents" ) ); #ifdef QT4 - m_osc[i].fineLKnob->setWhatsThis( + m_osc[i].m_fineLKnob->setWhatsThis( #else - QWhatsThis::add( m_osc[i].fineLKnob, + QWhatsThis::add( m_osc[i].m_fineLKnob, #endif tr( "With this knob you can set the fine detuning of " "oscillator %1 for the left channel. The fine-" @@ -336,21 +324,20 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "\"fat\" sounds." ).arg( i + 1 ) ); // setup knob for right fine-detuning - m_osc[i].fineRKnob = new knob( knobSmall_17, this, + m_osc[i].m_fineRKnob = new knob( knobSmall_17, this, tr( "Osc %1 fine detuning right" ).arg( i + 1 ), _channel_track ); - m_osc[i].fineRKnob->setData( i ); - m_osc[i].fineRKnob->move( 110, 104 + i * 50 ); - m_osc[i].fineRKnob->setRange( -100.0f, 100.0f, 1.0f ); - m_osc[i].fineRKnob->setInitValue( 0.0f ); - m_osc[i].fineRKnob->setHintText( tr( "Osc %1 fine detuning " + m_osc[i].m_fineRKnob->move( 110, 104 + i * 50 ); + m_osc[i].m_fineRKnob->setRange( -100.0f, 100.0f, 1.0f ); + m_osc[i].m_fineRKnob->setInitValue( 0.0f ); + m_osc[i].m_fineRKnob->setHintText( tr( "Osc %1 fine detuning " "right:").arg( i + 1 ) + " ", " " + tr( "cents" ) ); #ifdef QT4 - m_osc[i].fineRKnob->setWhatsThis( + m_osc[i].m_fineRKnob->setWhatsThis( #else - QWhatsThis::add( m_osc[i].fineRKnob, + QWhatsThis::add( m_osc[i].m_fineRKnob, #endif tr( "With this knob you can set the fine detuning of " "oscillator %1 for the right channel. The " @@ -359,22 +346,21 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "\"fat\" sounds." ).arg( i+1 ) ); // setup phase-offset-knob - m_osc[i].phaseOffsetKnob = new knob( knobSmall_17, this, + m_osc[i].m_phaseOffsetKnob = new knob( knobSmall_17, this, tr( "Osc %1 phase-" "offset" ).arg( i+1 ), _channel_track ); - m_osc[i].phaseOffsetKnob->setData( i ); - m_osc[i].phaseOffsetKnob->move( 142, 104 + i * 50 ); - m_osc[i].phaseOffsetKnob->setRange( 0.0f, 360.0f, 1.0f ); - m_osc[i].phaseOffsetKnob->setInitValue( 0.0f ); - m_osc[i].phaseOffsetKnob->setHintText( tr( "Osc %1 phase-" + m_osc[i].m_phaseOffsetKnob->move( 142, 104 + i * 50 ); + m_osc[i].m_phaseOffsetKnob->setRange( 0.0f, 360.0f, 1.0f ); + m_osc[i].m_phaseOffsetKnob->setInitValue( 0.0f ); + m_osc[i].m_phaseOffsetKnob->setHintText( tr( "Osc %1 phase-" "offset:" ). arg( i + 1 ) + " ", " " + tr( "degrees" ) ); #ifdef QT4 - m_osc[i].phaseOffsetKnob->setWhatsThis( + m_osc[i].m_phaseOffsetKnob->setWhatsThis( #else - QWhatsThis::add( m_osc[i].phaseOffsetKnob, + QWhatsThis::add( m_osc[i].m_phaseOffsetKnob, #endif tr( "With this knob you can set the phase-offset of " "oscillator %1. That means you can move the " @@ -386,25 +372,24 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : ).arg( i+1 ) ); // setup stereo-phase-detuning-knob - m_osc[i].stereoPhaseDetuningKnob = new knob( knobSmall_17, this, - tr( "Osc %1 stereo phase-" + m_osc[i].m_stereoPhaseDetuningKnob = new knob( knobSmall_17, + this, tr( "Osc %1 stereo phase-" "detuning" ).arg( i+1 ), _channel_track ); - m_osc[i].stereoPhaseDetuningKnob->setData( i ); - m_osc[i].stereoPhaseDetuningKnob->move( 166, 104 + i * 50 ); - m_osc[i].stereoPhaseDetuningKnob->setRange( 0.0f, 360.0f, + m_osc[i].m_stereoPhaseDetuningKnob->move( 166, 104 + i * 50 ); + m_osc[i].m_stereoPhaseDetuningKnob->setRange( 0.0f, 360.0f, 1.0f ); - m_osc[i].stereoPhaseDetuningKnob->setInitValue( 0.0f ); - m_osc[i].stereoPhaseDetuningKnob->setHintText( tr("Osc %1 " + m_osc[i].m_stereoPhaseDetuningKnob->setInitValue( 0.0f ); + m_osc[i].m_stereoPhaseDetuningKnob->setHintText( tr("Osc %1 " "stereo phase-" "detuning:" ). arg( i + 1 ) + " ", " " + tr( "degrees" ) ); #ifdef QT4 - m_osc[i].stereoPhaseDetuningKnob->setWhatsThis( + m_osc[i].m_stereoPhaseDetuningKnob->setWhatsThis( #else - QWhatsThis::add( m_osc[i].stereoPhaseDetuningKnob, + QWhatsThis::add( m_osc[i].m_stereoPhaseDetuningKnob, #endif tr( "With this knob you can set the stereo phase-" "detuning of oscillator %1. The stereo phase-" @@ -414,43 +399,32 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : "stereo-sounds." ).arg( i+1 ) ); // Connect knobs with oscillators' inputs - connect( m_osc[i].volKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateVolume( const QVariant & ) ) ); - connect( m_osc[i].panKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateVolume( const QVariant & ) ) ); - updateVolume( i ); + connect( m_osc[i].m_volKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateVolume() ) ); + connect( m_osc[i].m_panKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateVolume() ) ); + m_osc[i].updateVolume(); - connect( m_osc[i].coarseKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateDetuningLeft( const QVariant & ) ) ); - connect( m_osc[i].coarseKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateDetuningRight( const QVariant & ) ) ); - connect( m_osc[i].fineLKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateDetuningLeft( const QVariant & ) ) ); - connect( m_osc[i].fineRKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, SLOT( updateDetuningRight( const QVariant & ) ) ); - updateDetuningLeft( i ); - updateDetuningRight( i ); + connect( m_osc[i].m_coarseKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateDetuningLeft() ) ); + connect( m_osc[i].m_coarseKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateDetuningRight() ) ); + connect( m_osc[i].m_fineLKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateDetuningLeft() ) ); + connect( m_osc[i].m_fineRKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updateDetuningRight() ) ); + m_osc[i].updateDetuningLeft(); + m_osc[i].updateDetuningRight(); - connect( m_osc[i].phaseOffsetKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, - SLOT( updatePhaseOffsetLeft( const QVariant & ) ) ); - connect( m_osc[i].phaseOffsetKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, - SLOT( updatePhaseOffsetRight( const QVariant & ) ) ); - connect( m_osc[i].stereoPhaseDetuningKnob, - SIGNAL( valueChanged( const QVariant & ) ), - this, - SLOT( updatePhaseOffsetLeft( const QVariant & ) ) ); - updatePhaseOffsetLeft( i ); - updatePhaseOffsetRight( i ); + connect( m_osc[i].m_phaseOffsetKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updatePhaseOffsetLeft() ) ); + connect( m_osc[i].m_phaseOffsetKnob, SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updatePhaseOffsetRight() ) ); + connect( m_osc[i].m_stereoPhaseDetuningKnob, + SIGNAL( valueChanged() ), + &m_osc[i], SLOT( updatePhaseOffsetLeft() ) ); + m_osc[i].updatePhaseOffsetLeft(); + m_osc[i].updatePhaseOffsetRight(); pixmapButton * sin_wave_btn = new pixmapButton( this, NULL, NULL ); @@ -530,55 +504,32 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : tr( "Click here if you want a white-noise for " "current oscillator." ) ); - m_osc[i].usrWaveBtn = new pixmapButton( this, NULL, NULL ); - m_osc[i].usrWaveBtn->move( 233, 120+i*50 ); - m_osc[i].usrWaveBtn->setActiveGraphic( embed::getIconPixmap( + m_osc[i].m_usrWaveBtn = new pixmapButton( this, NULL, NULL ); + m_osc[i].m_usrWaveBtn->move( 233, 120+i*50 ); + m_osc[i].m_usrWaveBtn->setActiveGraphic( embed::getIconPixmap( "usr_wave_active" ) ); - m_osc[i].usrWaveBtn->setInactiveGraphic( embed::getIconPixmap( + m_osc[i].m_usrWaveBtn->setInactiveGraphic( embed::getIconPixmap( "usr_wave_inactive" ) ); - toolTip::add( m_osc[i].usrWaveBtn, + toolTip::add( m_osc[i].m_usrWaveBtn, tr( "Click here if you want a user-defined " "wave-shape for current oscillator." ) ); - m_osc[i].waveBtnGrp = new automatableButtonGroup( this, + m_osc[i].m_waveBtnGrp = new automatableButtonGroup( this, tr( "Osc %1 wave shape" ).arg( i + 1 ), _channel_track ); - m_osc[i].waveBtnGrp->addButton( sin_wave_btn ); - m_osc[i].waveBtnGrp->addButton( triangle_wave_btn ); - m_osc[i].waveBtnGrp->addButton( saw_wave_btn ); - m_osc[i].waveBtnGrp->addButton( sqr_wave_btn ); - m_osc[i].waveBtnGrp->addButton( moog_saw_wave_btn ); - m_osc[i].waveBtnGrp->addButton( exp_wave_btn ); - m_osc[i].waveBtnGrp->addButton( white_noise_btn ); - m_osc[i].waveBtnGrp->addButton( m_osc[i].usrWaveBtn ); + m_osc[i].m_waveBtnGrp->addButton( sin_wave_btn ); + m_osc[i].m_waveBtnGrp->addButton( triangle_wave_btn ); + m_osc[i].m_waveBtnGrp->addButton( saw_wave_btn ); + m_osc[i].m_waveBtnGrp->addButton( sqr_wave_btn ); + m_osc[i].m_waveBtnGrp->addButton( moog_saw_wave_btn ); + m_osc[i].m_waveBtnGrp->addButton( exp_wave_btn ); + m_osc[i].m_waveBtnGrp->addButton( white_noise_btn ); + m_osc[i].m_waveBtnGrp->addButton( m_osc[i].m_usrWaveBtn ); - if( i == 0 ) - { - connect( m_osc[i].waveBtnGrp, - SIGNAL( valueChanged( int ) ), - this, SLOT( osc0WaveCh( int ) ) ); - connect( m_osc[i].usrWaveBtn, - SIGNAL( doubleClicked() ), this, - SLOT( osc0UserDefWaveDblClick() ) ); - } - else if( i == 1 ) - { - connect( m_osc[i].waveBtnGrp, - SIGNAL( valueChanged( int ) ), - this, SLOT( osc1WaveCh( int ) ) ); - connect( m_osc[i].usrWaveBtn, - SIGNAL( doubleClicked() ), this, - SLOT( osc1UserDefWaveDblClick() ) ); - } - else if( i == 2 ) - { - connect( m_osc[i].waveBtnGrp, - SIGNAL( valueChanged( int ) ), - this, SLOT( osc2WaveCh( int ) ) ); - connect( m_osc[i].usrWaveBtn, - SIGNAL( doubleClicked() ), this, - SLOT( osc2UserDefWaveDblClick() ) ); - } + connect( m_osc[i].m_waveBtnGrp, SIGNAL( valueChanged( int ) ), + &m_osc[i], SLOT( oscWaveCh( int ) ) ); + connect( m_osc[i].m_usrWaveBtn, SIGNAL( doubleClicked() ), + &m_osc[i], SLOT( oscUserDefWaveDblClick() ) ); } connect( engine::getMixer(), SIGNAL( sampleRateChanged() ), @@ -590,10 +541,6 @@ tripleOscillator::tripleOscillator( instrumentTrack * _channel_track ) : tripleOscillator::~tripleOscillator() { - for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) - { - delete m_osc[i].m_sampleBuffer; - } } @@ -607,16 +554,17 @@ void tripleOscillator::saveSettings( QDomDocument & _doc, QDomElement & _this ) for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) { QString is = QString::number( i ); - m_osc[i].volKnob->saveSettings( _doc, _this, "vol" + is ); - m_osc[i].panKnob->saveSettings( _doc, _this, "pan" + is ); - m_osc[i].coarseKnob->saveSettings( _doc, _this, "coarse" + is ); - m_osc[i].fineLKnob->saveSettings( _doc, _this, "finel" + is ); - m_osc[i].fineRKnob->saveSettings( _doc, _this, "finer" + is ); - m_osc[i].phaseOffsetKnob->saveSettings( _doc, _this, + m_osc[i].m_volKnob->saveSettings( _doc, _this, "vol" + is ); + m_osc[i].m_panKnob->saveSettings( _doc, _this, "pan" + is ); + m_osc[i].m_coarseKnob->saveSettings( _doc, _this, "coarse" + + is ); + m_osc[i].m_fineLKnob->saveSettings( _doc, _this, "finel" + is ); + m_osc[i].m_fineRKnob->saveSettings( _doc, _this, "finer" + is ); + m_osc[i].m_phaseOffsetKnob->saveSettings( _doc, _this, "phoffset" + is ); - m_osc[i].stereoPhaseDetuningKnob->saveSettings( _doc, _this, + m_osc[i].m_stereoPhaseDetuningKnob->saveSettings( _doc, _this, "stphdetun" + is ); - m_osc[i].waveBtnGrp->saveSettings( _doc, _this, + m_osc[i].m_waveBtnGrp->saveSettings( _doc, _this, "wavetype" + is ); _this.setAttribute( "userwavefile" + is, m_osc[i].m_sampleBuffer->audioFile() ); @@ -634,18 +582,18 @@ void tripleOscillator::loadSettings( const QDomElement & _this ) for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) { QString is = QString::number( i ); - m_osc[i].volKnob->loadSettings( _this, "vol" + is ); - m_osc[i].panKnob->loadSettings( _this, "pan" + is ); - m_osc[i].coarseKnob->loadSettings( _this, "coarse" + is ); - m_osc[i].fineLKnob->loadSettings( _this, "finel" + is ); - m_osc[i].fineRKnob->loadSettings( _this, "finer" + is ); - m_osc[i].phaseOffsetKnob->loadSettings( _this, + m_osc[i].m_volKnob->loadSettings( _this, "vol" + is ); + m_osc[i].m_panKnob->loadSettings( _this, "pan" + is ); + m_osc[i].m_coarseKnob->loadSettings( _this, "coarse" + is ); + m_osc[i].m_fineLKnob->loadSettings( _this, "finel" + is ); + m_osc[i].m_fineRKnob->loadSettings( _this, "finer" + is ); + m_osc[i].m_phaseOffsetKnob->loadSettings( _this, "phoffset" + is ); - m_osc[i].stereoPhaseDetuningKnob->loadSettings( _this, + m_osc[i].m_stereoPhaseDetuningKnob->loadSettings( _this, "stphdetun" + is ); m_osc[i].m_sampleBuffer->setAudioFile( _this.attribute( "userwavefile" + is ) ); - m_osc[i].waveBtnGrp->loadSettings( _this, "wavetype" + is ); + m_osc[i].m_waveBtnGrp->loadSettings( _this, "wavetype" + is ); } } @@ -682,45 +630,45 @@ void tripleOscillator::playNote( notePlayHandle * _n, bool ) oscillator * oscs_l[NUM_OF_OSCILLATORS]; oscillator * oscs_r[NUM_OF_OSCILLATORS]; - for( Sint8 i = NUM_OF_OSCILLATORS-1; i >= 0; --i ) + for( Sint8 i = NUM_OF_OSCILLATORS - 1; i >= 0; --i ) { - // the third oscs needs no sub-oscs... - if( i == 2 ) + // the last oscs needs no sub-oscs... + if( i == NUM_OF_OSCILLATORS - 1 ) { oscs_l[i] = new oscillator( - &m_osc[i].waveShape, - &m_modulationAlgo3, - &_n->m_frequency, - &m_osc[i].detuningLeft, - &m_osc[i].phaseOffsetLeft, - &m_osc[i].volumeLeft ); + m_osc[i].m_waveShape, + m_osc[i].m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningLeft, + m_osc[i].m_phaseOffsetLeft, + m_osc[i].m_volumeLeft ); oscs_r[i] = new oscillator( - &m_osc[i].waveShape, - &m_modulationAlgo3, - &_n->m_frequency, - &m_osc[i].detuningRight, - &m_osc[i].phaseOffsetRight, - &m_osc[i].volumeRight ); + m_osc[i].m_waveShape, + m_osc[i].m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningRight, + m_osc[i].m_phaseOffsetRight, + m_osc[i].m_volumeRight ); } else { oscs_l[i] = new oscillator( - &m_osc[i].waveShape, - getModulationAlgo( i + 1 ), - &_n->m_frequency, - &m_osc[i].detuningLeft, - &m_osc[i].phaseOffsetLeft, - &m_osc[i].volumeLeft, - oscs_l[i + 1] ); + m_osc[i].m_waveShape, + m_osc[i].m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningLeft, + m_osc[i].m_phaseOffsetLeft, + m_osc[i].m_volumeLeft, + oscs_l[i + 1] ); oscs_r[i] = new oscillator( - &m_osc[i].waveShape, - getModulationAlgo( i + 1 ), - &_n->m_frequency, - &m_osc[i].detuningRight, - &m_osc[i].phaseOffsetRight, - &m_osc[i].volumeRight, - oscs_r[i + 1] ); + m_osc[i].m_waveShape, + m_osc[i].m_modulationAlgo, + _n->frequency(), + m_osc[i].m_detuningRight, + m_osc[i].m_phaseOffsetRight, + m_osc[i].m_volumeRight, + oscs_r[i + 1] ); } oscs_l[i]->setUserWave( m_osc[i].m_sampleBuffer ); @@ -764,185 +712,127 @@ void tripleOscillator::deleteNotePluginData( notePlayHandle * _n ) -void tripleOscillator::osc0WaveCh( int _n ) -{ - m_osc[0].waveShape = static_cast( _n ); -} - - - - -void tripleOscillator::osc1WaveCh( int _n ) -{ - m_osc[1].waveShape = static_cast( _n ); -} - - - - -void tripleOscillator::osc2WaveCh( int _n ) -{ - m_osc[2].waveShape = static_cast( _n ); -} - - - - -void tripleOscillator::mod1Ch( int _n ) -{ - m_modulationAlgo1 = static_cast( _n ); -} - - - - -void tripleOscillator::mod2Ch( int _n ) -{ - m_modulationAlgo2 = static_cast( _n ); -} - - - - -void tripleOscillator::osc0UserDefWaveDblClick( void ) -{ - QString af = m_osc[0].m_sampleBuffer->openAudioFile(); - if( af != "" ) - { - m_osc[0].m_sampleBuffer->setAudioFile( af ); - toolTip::add( m_osc[0].usrWaveBtn, - m_osc[0].m_sampleBuffer->audioFile() ); - } -} - - - -void tripleOscillator::osc1UserDefWaveDblClick( void ) -{ - QString af = m_osc[1].m_sampleBuffer->openAudioFile(); - if( af != "" ) - { - m_osc[1].m_sampleBuffer->setAudioFile( af ); - toolTip::add( m_osc[1].usrWaveBtn, - m_osc[1].m_sampleBuffer->audioFile() ); - } -} - - - -void tripleOscillator::osc2UserDefWaveDblClick( void ) -{ - QString af = m_osc[2].m_sampleBuffer->openAudioFile(); - if( af != "" ) - { - m_osc[2].m_sampleBuffer->setAudioFile( af ); - toolTip::add( m_osc[2].usrWaveBtn, - m_osc[2].m_sampleBuffer->audioFile() ); - } -} - - - - -void tripleOscillator::updateVolume( const QVariant & _data ) -{ - const int _i = _data.toInt(); - float panningFactorLeft; - float panningFactorRight; - - if( m_osc[_i].panKnob->value() >= 0.0f ) - { - panningFactorLeft = 1.0f - m_osc[_i].panKnob->value() - / (float)PANNING_RIGHT; - panningFactorRight = 1.0f; - } - else - { - panningFactorLeft = 1.0f; - panningFactorRight = 1.0f + m_osc[_i].panKnob->value() - / (float)PANNING_RIGHT; - } - - m_osc[_i].volumeLeft = panningFactorLeft * m_osc[_i].volKnob->value() - / 100.0f; - m_osc[_i].volumeRight = panningFactorRight * m_osc[_i].volKnob->value() - / 100.0f; -} - - - - -void tripleOscillator::updateDetuningLeft( const QVariant & _data ) -{ - const int _i = _data.toInt(); - m_osc[_i].detuningLeft = powf( 2.0f, ( - (float)m_osc[_i].coarseKnob->value() * 100.0f + - (float)m_osc[_i].fineLKnob->value() ) / 1200.0f ) - / engine::getMixer()->sampleRate(); -} - - - - -void tripleOscillator::updateDetuningRight( const QVariant & _data ) -{ - const int _i = _data.toInt(); - m_osc[_i].detuningRight = powf( 2.0f, ( - (float)m_osc[_i].coarseKnob->value() * 100.0f + - (float)m_osc[_i].fineRKnob->value() ) / 1200.0f ) - / engine::getMixer()->sampleRate(); -} - - - - void tripleOscillator::updateAllDetuning( void ) { for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) { - updateDetuningLeft( i ); - updateDetuningRight( i ); + m_osc[i].updateDetuningLeft(); + m_osc[i].updateDetuningRight(); } } -void tripleOscillator::updatePhaseOffsetLeft( const QVariant & _data ) + + + + +oscillatorObject::oscillatorObject( void ) : + m_waveShape( oscillator::SIN_WAVE ), + m_sampleBuffer( new sampleBuffer ), + m_modulationAlgo( oscillator::MIX ) { - const int _i = _data.toInt(); - m_osc[_i].phaseOffsetLeft = ( m_osc[_i].phaseOffsetKnob->value() + - m_osc[_i].stereoPhaseDetuningKnob->value() ) / 360.0f; } -void tripleOscillator::updatePhaseOffsetRight( const QVariant & _data ) +oscillatorObject::~oscillatorObject() { - const int _i = _data.toInt(); - m_osc[_i].phaseOffsetRight = m_osc[_i].phaseOffsetKnob->value() - / 360.0f; + sharedObject::unref( m_sampleBuffer ); } -oscillator::modulationAlgos * tripleOscillator::getModulationAlgo( int _n ) +void oscillatorObject::oscWaveCh( int _n ) { - if( _n == 1 ) + m_waveShape = static_cast( _n ); +} + + + + +void oscillatorObject::oscUserDefWaveDblClick( void ) +{ + QString af = m_sampleBuffer->openAudioFile(); + if( af != "" ) { - return( &m_modulationAlgo1 ); + m_sampleBuffer->setAudioFile( af ); + toolTip::add( m_usrWaveBtn, m_sampleBuffer->audioFile() ); + } +} + + + + +void oscillatorObject::modCh( int _n ) +{ + m_modulationAlgo = static_cast( _n ); +} + + + + +void oscillatorObject::updateVolume( void ) +{ + if( m_panKnob->value() >= 0.0f ) + { + float panningFactorLeft = 1.0f - m_panKnob->value() + / (float)PANNING_RIGHT; + m_volumeLeft = panningFactorLeft * m_volKnob->value() / 100.0f; + m_volumeRight = m_volKnob->value() / 100.0f; } else { - return( &m_modulationAlgo2 ); + m_volumeLeft = m_volKnob->value() / 100.0f; + float panningFactorRight = 1.0f + m_panKnob->value() + / (float)PANNING_RIGHT; + m_volumeRight = panningFactorRight * m_volKnob->value() + / 100.0f; } } +void oscillatorObject::updateDetuningLeft( void ) +{ + m_detuningLeft = powf( 2.0f, ( (float)m_coarseKnob->value() * 100.0f + + (float)m_fineLKnob->value() ) / 1200.0f ) + / engine::getMixer()->sampleRate(); +} + + + + +void oscillatorObject::updateDetuningRight( void ) +{ + m_detuningRight = powf( 2.0f, ( (float)m_coarseKnob->value() * 100.0f + + (float)m_fineRKnob->value() ) / 1200.0f ) + / engine::getMixer()->sampleRate(); +} + + + + +void oscillatorObject::updatePhaseOffsetLeft( void ) +{ + m_phaseOffsetLeft = ( m_phaseOffsetKnob->value() + + m_stereoPhaseDetuningKnob->value() ) / 360.0f; +} + + + + +void oscillatorObject::updatePhaseOffsetRight( void ) +{ + m_phaseOffsetRight = m_phaseOffsetKnob->value() / 360.0f; +} + + + extern "C" { diff --git a/plugins/triple_oscillator/triple_oscillator.h b/plugins/triple_oscillator/triple_oscillator.h index ba38e1bb9..547ee190c 100644 --- a/plugins/triple_oscillator/triple_oscillator.h +++ b/plugins/triple_oscillator/triple_oscillator.h @@ -2,7 +2,7 @@ * triple_oscillator.h - declaration of class tripleOscillator a powerful * instrument-plugin with 3 oscillators * - * Copyright (c) 2004-2006 Tobias Doerffel + * Copyright (c) 2004-2007 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -41,6 +41,55 @@ class volumeKnob; const int NUM_OF_OSCILLATORS = 3; +class oscillatorObject : public QObject +{ + Q_OBJECT +private: + oscillator::waveShapes m_waveShape; + volumeKnob * m_volKnob; + knob * m_panKnob; + knob * m_coarseKnob; + knob * m_fineLKnob; + knob * m_fineRKnob; + knob * m_phaseOffsetKnob; + knob * m_stereoPhaseDetuningKnob; + automatableButtonGroup * m_waveBtnGrp; + pixmapButton * m_usrWaveBtn; + sampleBuffer * m_sampleBuffer; + oscillator::modulationAlgos m_modulationAlgo; + + float m_volumeLeft; + float m_volumeRight; + // normalized detuning -> x/sampleRate + float m_detuningLeft; + float m_detuningRight; + // normalized offset -> x/360 + float m_phaseOffsetLeft; + float m_phaseOffsetRight; + + oscillatorObject( void ); + virtual ~oscillatorObject(); + + friend class tripleOscillator; + + +private slots: + void oscWaveCh( int _n ); + void oscUserDefWaveDblClick( void ); + + void modCh( int _n ); + + void updateVolume( void ); + void updateDetuningLeft( void ); + void updateDetuningRight( void ); + void updatePhaseOffsetLeft( void ); + void updatePhaseOffsetRight( void ); + +} ; + + + + class tripleOscillator : public instrument { Q_OBJECT @@ -64,49 +113,13 @@ public: protected slots: - void osc0WaveCh( int _n ); - void osc1WaveCh( int _n ); - void osc2WaveCh( int _n ); - void osc0UserDefWaveDblClick( void ); - void osc1UserDefWaveDblClick( void ); - void osc2UserDefWaveDblClick( void ); - - void mod1Ch( int _n ); - void mod2Ch( int _n ); - - void updateVolume( const QVariant & _i ); - void updateDetuningLeft( const QVariant & _i ); - void updateDetuningRight( const QVariant & _i ); void updateAllDetuning( void ); - void updatePhaseOffsetLeft( const QVariant & _i ); - void updatePhaseOffsetRight( const QVariant & _i ); private: instrumentTrack * m_instrumentTrack; - struct oscillatorData - { - oscillator::waveShapes waveShape; - volumeKnob * volKnob; - knob * panKnob; - knob * coarseKnob; - knob * fineLKnob; - knob * fineRKnob; - knob * phaseOffsetKnob; - knob * stereoPhaseDetuningKnob; - automatableButtonGroup * waveBtnGrp; - pixmapButton * usrWaveBtn; - sampleBuffer * m_sampleBuffer; - float volumeLeft; - float volumeRight; - // normalized detuning -> x/sampleRate - float detuningLeft; - float detuningRight; - // normalized offset -> x/360 - float phaseOffsetLeft; - float phaseOffsetRight; - } m_osc[NUM_OF_OSCILLATORS]; + oscillatorObject m_osc[NUM_OF_OSCILLATORS]; struct oscPtr { @@ -114,13 +127,6 @@ private: oscillator * oscRight; } ; - - oscillator::modulationAlgos * FASTCALL getModulationAlgo( int _n ); - - oscillator::modulationAlgos m_modulationAlgo1; - oscillator::modulationAlgos m_modulationAlgo2; - const oscillator::modulationAlgos m_modulationAlgo3; - automatableButtonGroup * m_mod1BtnGrp; automatableButtonGroup * m_mod2BtnGrp; diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 964f78973..7054c8878 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -23,6 +23,8 @@ */ +#include "vestige.h" + #include "qt3support.h" #ifdef QT4 @@ -49,17 +51,18 @@ #endif -#include "instrument_track.h" -#include "note_play_handle.h" -#include "mixer.h" +#include "engine.h" +#include "gui_templates.h" #include "instrument_play_handle.h" -#include "pixmap_button.h" -#include "tooltip.h" -#include "spc_bg_hndl_widget.h" -#include "vestige.h" -#include "text_float.h" -#include "song_editor.h" +#include "instrument_track.h" #include "lvsl_client.h" +#include "mixer.h" +#include "note_play_handle.h" +#include "pixmap_button.h" +#include "song_editor.h" +#include "spc_bg_hndl_widget.h" +#include "text_float.h" +#include "tooltip.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" @@ -167,6 +170,7 @@ vestigeInstrument::vestigeInstrument( instrumentTrack * _instrument_track ) : vestigeInstrument::~vestigeInstrument() { + engine::getMixer()->removePlayHandles( getInstrumentTrack() ); closePlugin(); } diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index 7ffa39fa0..6574baee6 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -1,7 +1,7 @@ /* * vestige.h - instrument VeSTige for hosting VST-plugins * - * Copyright (c) 2005-2006 Tobias Doerffel + * Copyright (c) 2005-2007 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -26,10 +26,8 @@ #ifndef _VESTIGE_H #define _VESTIGE_H -#include "instrument.h" -#include "midi.h" -#ifdef QT4 +#ifndef QT3 #include @@ -40,6 +38,9 @@ #endif +#include "instrument.h" +#include "midi.h" +#include "note.h" #include "spc_bg_hndl_widget.h" diff --git a/plugins/vibed/impulse_editor.cpp b/plugins/vibed/impulse_editor.cpp index d2054665e..1fedb82e0 100644 --- a/plugins/vibed/impulse_editor.cpp +++ b/plugins/vibed/impulse_editor.cpp @@ -46,10 +46,12 @@ #endif #include "impulse_editor.h" -#include "vibed.h" -#include "tooltip.h" +#include "embed.h" +#include "engine.h" #include "oscillator.h" #include "song_editor.h" +#include "tooltip.h" +#include "vibed.h" impulseEditor::impulseEditor( QWidget * _parent, int _x, int _y, track * _track, diff --git a/plugins/vibed/vibed.cpp b/plugins/vibed/vibed.cpp index aff5978dd..f824690e6 100644 --- a/plugins/vibed/vibed.cpp +++ b/plugins/vibed/vibed.cpp @@ -45,19 +45,20 @@ #include "vibed.h" -#include "note_play_handle.h" +#include "base64.h" +#include "engine.h" #include "instrument_track.h" -#include "templates.h" #include "knob.h" -#include "tooltip.h" +#include "note_play_handle.h" #include "oscillator.h" #include "string_container.h" -#include "base64.h" +#include "templates.h" +#include "tooltip.h" +#include "volume.h" +#include "volume_knob.h" #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" -#include "volume_knob.h" -#include "volume.h" extern "C" @@ -549,12 +550,9 @@ void vibed::playNote( notePlayHandle * _n, bool ) { if ( _n->totalFramesPlayed() == 0 ) { - float freq = getInstrumentTrack()->frequency( _n ); - - _n->m_pluginData = new stringContainer( - freq, - engine::getMixer()->sampleRate(), - m_sampleLength ); + _n->m_pluginData = new stringContainer( _n->frequency(), + engine::getMixer()->sampleRate(), + m_sampleLength ); for( Uint8 i = 0; i < 9; ++i ) { diff --git a/plugins/vibed/vibrating_string.cpp b/plugins/vibed/vibrating_string.cpp index 995d7f7ca..5051f4c3e 100644 --- a/plugins/vibed/vibrating_string.cpp +++ b/plugins/vibed/vibrating_string.cpp @@ -123,13 +123,11 @@ vibratingString::delayLine * FASTCALL vibratingString::initDelayLine( void FASTCALL vibratingString::freeDelayLine( delayLine * _dl ) { - if( _dl && _dl->data ) + if( _dl ) { delete[] _dl->data; + delete[] _dl; } - - _dl->data = NULL; - delete[] _dl; } diff --git a/plugins/vst_effect/vst_control_dialog.cpp b/plugins/vst_effect/vst_control_dialog.cpp index 5bac50a6e..378b57d1c 100644 --- a/plugins/vst_effect/vst_control_dialog.cpp +++ b/plugins/vst_effect/vst_control_dialog.cpp @@ -1,7 +1,7 @@ /* * vst_control_dialog.cpp - dialog for displaying GUI of VST-effect-plugin * - * Copyright (c) 2006 Tobias Doerffel + * Copyright (c) 2006-2007 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -23,14 +23,12 @@ */ -#ifdef QT4 +#ifndef QT3 -#include #include #else -#include #include #endif diff --git a/plugins/vst_effect/vst_effect.cpp b/plugins/vst_effect/vst_effect.cpp index 4d62367ff..b27800776 100644 --- a/plugins/vst_effect/vst_effect.cpp +++ b/plugins/vst_effect/vst_effect.cpp @@ -23,7 +23,7 @@ */ -#ifdef QT4 +#ifndef QT3 #include diff --git a/plugins/vst_effect/vst_subplugin_features.cpp b/plugins/vst_effect/vst_subplugin_features.cpp index 8c453f541..d9eacbc00 100644 --- a/plugins/vst_effect/vst_subplugin_features.cpp +++ b/plugins/vst_effect/vst_subplugin_features.cpp @@ -25,7 +25,7 @@ */ -#ifdef QT4 +#ifndef QT3 #include #include