From 9dcb62c6306dd1227520c5cb1062dde79e50a189 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 16 May 2009 15:08:40 +0200 Subject: [PATCH 1/6] NotePlayHandle: use public method for accessing pitch model Do not use private m_pitchModel member variable of InstrumentTrack even if NotePlayHandle is a friend class. Instead use the already existing InstrumentTrack::pitchModel() method. --- src/core/note_play_handle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index 5996ed4f3..df7fdddae 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -463,7 +463,7 @@ void notePlayHandle::updateFrequency( void ) ( key() - m_instrumentTrack->baseNoteModel()->value() + engine::getSong()->masterPitch() ) / 12.0f; m_frequency = BaseFreq * powf( 2.0f, pitch + - m_instrumentTrack->m_pitchModel.value() / ( 100 * 12.0f ) ); + m_instrumentTrack->pitchModel()->value() / ( 100 * 12.0f ) ); m_unpitchedFrequency = BaseFreq * powf( 2.0f, pitch ); for( notePlayHandleVector::iterator it = m_subNotes.begin(); From 24353ca248a545eb8ba90995d448fc03846cebfc Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 16 May 2009 15:14:47 +0200 Subject: [PATCH 2/6] PianoRoll: removed unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed unused variable volumeHandles in PianoRoll::computeSelectedNotes(bool) which as a side-effect also fixes /usr/include/qt4/QtCore/qvector.h: In member function ‘void PianoRoll::computeSelectedNotes(bool)’: /usr/include/qt4/QtCore/qvector.h:421: warning: dereferencing pointer ‘’ does break strict-aliasing rules /usr/include/qt4/QtCore/qvector.h:114: note: initialized from here --- src/gui/piano_roll.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/piano_roll.cpp b/src/gui/piano_roll.cpp index fd45c1dda..67c3c1d34 100644 --- a/src/gui/piano_roll.cpp +++ b/src/gui/piano_roll.cpp @@ -1775,8 +1775,6 @@ void pianoRoll::computeSelectedNotes(bool shift) { const noteVector & notes = m_pattern->notes(); - QPolygon volumeHandles; - for( noteVector::const_iterator it = notes.begin(); it != notes.end(); ++it ) { From 41907a7ebf39e388cda289422e8185eea7d9bb6e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 16 May 2009 16:56:17 +0200 Subject: [PATCH 3/6] InstrumentTrack: added support for changing pitch range Added a new LCD spinbox which allows to control the range of the pitch knob. This way it's possible to extend the range of the pitch knob up to 24 semitones in each direction. --- include/instrument_track.h | 3 ++ src/tracks/instrument_track.cpp | 85 +++++++++++++++++++++------------ 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/include/instrument_track.h b/include/instrument_track.h index 8d700c417..785d098fc 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -202,6 +202,7 @@ protected: protected slots: void updateBaseNote( void ); void updatePitch( void ); + void updatePitchRange( void ); private: @@ -219,6 +220,7 @@ private: floatModel m_volumeModel; floatModel m_panningModel; floatModel m_pitchModel; + intModel m_pitchRangeModel; intModel m_effectChannelModel; @@ -379,6 +381,7 @@ private: knob * m_volumeKnob; knob * m_panningKnob; knob * m_pitchKnob; + lcdSpinBox * m_pitchRange; lcdSpinBox * m_effectChannelNumber; QPushButton * m_saveSettingsBtn; diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index 5f7033f1a..5fcc3c47a 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -104,6 +104,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : m_panningModel( DefaultPanning, PanningLeft, PanningRight, 0.1f, this, tr( "Panning" ) ), m_pitchModel( 0, -100, 100, 1, this, tr( "Pitch" ) ), + m_pitchRangeModel( 1, 1, 24, this, tr( "Pitch range" ) ), m_effectChannelModel( 0, 0, NumFxChannels, this, tr( "FX channel" ) ), m_instrument( NULL ), m_soundShaping( this ), @@ -116,6 +117,8 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : this, SLOT( updateBaseNote() ) ); connect( &m_pitchModel, SIGNAL( dataChanged() ), this, SLOT( updatePitch() ) ); + connect( &m_pitchRangeModel, SIGNAL( dataChanged() ), + this, SLOT( updatePitchRange() ) ); for( int i = 0; i < NumKeys; ++i ) @@ -523,6 +526,15 @@ void instrumentTrack::updatePitch( void ) +void instrumentTrack::updatePitchRange( void ) +{ + const int r = m_pitchRangeModel.value(); + m_pitchModel.setRange( -100 * r, 100 * r ); +} + + + + int instrumentTrack::masterKey( int _midi_key ) const { int key = m_baseNoteModel.value() - engine::getSong()->masterPitch(); @@ -688,6 +700,7 @@ void instrumentTrack::saveTrackSpecificSettings( QDomDocument & _doc, m_volumeModel.saveSettings( _doc, _this, "vol" ); m_panningModel.saveSettings( _doc, _this, "pan" ); m_pitchModel.saveSettings( _doc, _this, "pitch" ); + m_pitchRangeModel.saveSettings( _doc, _this, "pitchrange" ); m_effectChannelModel.saveSettings( _doc, _this, "fxch" ); m_baseNoteModel.saveSettings( _doc, _this, "basenote" ); @@ -731,6 +744,7 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) m_panningModel.loadSettings( _this, "pan" ); } + m_pitchRangeModel.loadSettings( _this, "pitchrange" ); m_pitchModel.loadSettings( _this, "pitch" ); m_effectChannelModel.loadSettings( _this, "fxch" ); @@ -1128,18 +1142,22 @@ void instrumentTrackView::midiConfigChanged( void ) class fxLineLcdSpinBox : public lcdSpinBox { - public: - fxLineLcdSpinBox( int _num_digits, QWidget * _parent, +public: + fxLineLcdSpinBox( int _num_digits, QWidget * _parent, const QString & _name ) : - lcdSpinBox( _num_digits, _parent, _name ) {} + lcdSpinBox( _num_digits, _parent, _name ) + { + } - protected: - virtual void mouseDoubleClickEvent ( QMouseEvent * _me ) - { - engine::getFxMixerView()->setCurrentFxLine( model()->value() ); - //engine::getFxMixerView()->raise(); - } -}; + +protected: + virtual void mouseDoubleClickEvent ( QMouseEvent * _me ) + { + engine::getFxMixerView()->setCurrentFxLine( model()->value() ); + //engine::getFxMixerView()->raise(); + } + +} ; @@ -1167,16 +1185,29 @@ instrumentTrackWindow::instrumentTrackWindow( instrumentTrackView * _itv ) : m_nameLineEdit = new QLineEdit( m_generalSettingsWidget ); m_nameLineEdit->setFont( pointSize<8>( m_nameLineEdit->font() ) ); - m_nameLineEdit->setGeometry( 10, 16, 230, 18 ); + m_nameLineEdit->setGeometry( 10, 16, 196, 20 ); connect( m_nameLineEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( textChanged( const QString & ) ) ); + m_saveSettingsBtn = new QPushButton( embed::getIconPixmap( + "project_save" ), "", + m_generalSettingsWidget ); + m_saveSettingsBtn->setGeometry( 216, 14, 24, 24 ); + connect( m_saveSettingsBtn, SIGNAL( clicked() ), this, + SLOT( saveSettingsBtnClicked() ) ); + toolTip::add( m_saveSettingsBtn, + tr( "Save instrument track settings in a preset file" ) ); + m_saveSettingsBtn->setWhatsThis( + tr( "Click here, if you want to save current channel settings " + "in a preset-file. Later you can load this preset by " + "double-clicking it in the preset-browser." ) ); + // setup volume-knob m_volumeKnob = new knob( knobBright_26, m_generalSettingsWidget, tr( "Instrument volume" ) ); m_volumeKnob->setVolumeKnob( true ); - m_volumeKnob->move( 10, 44 ); + m_volumeKnob->move( 8, 46 ); m_volumeKnob->setHintText( tr( "Volume:" ) + " ", "%" ); m_volumeKnob->setLabel( tr( "VOL" ) ); @@ -1187,7 +1218,7 @@ instrumentTrackWindow::instrumentTrackWindow( instrumentTrackView * _itv ) : m_panningKnob = new knob( knobBright_26, m_generalSettingsWidget, tr( "Panning" ) ); m_panningKnob->move( m_volumeKnob->x() + - m_volumeKnob->width() + 16, 44 ); + m_volumeKnob->width() + 12, 46 ); m_panningKnob->setHintText( tr( "Panning:" ) + " ", "" ); m_panningKnob->setLabel( tr( "PAN" ) ); @@ -1195,32 +1226,23 @@ instrumentTrackWindow::instrumentTrackWindow( instrumentTrackView * _itv ) : m_pitchKnob = new knob( knobBright_26, m_generalSettingsWidget, tr( "Pitch" ) ); m_pitchKnob->move( m_panningKnob->x() + - m_panningKnob->width() + 16, 44 ); + m_panningKnob->width() + 24, 46 ); m_pitchKnob->setHintText( tr( "Pitch:" ) + " ", " " + tr( "cents" ) ); m_pitchKnob->setLabel( tr( "PITCH" ) ); + m_pitchRange = new lcdSpinBox( 2, m_generalSettingsWidget, + tr( "Pitch range (semitones)" ) ); + m_pitchRange->setLabel( tr( "RANGE" ) ); + m_pitchRange->move( m_pitchKnob->x() + + m_pitchKnob->width() + 8, 46 ); + // setup spinbox for selecting FX-channel m_effectChannelNumber = new fxLineLcdSpinBox( 2, m_generalSettingsWidget, tr( "FX channel" ) ); m_effectChannelNumber->setLabel( tr( "FX CHNL" ) ); - m_effectChannelNumber->move( m_pitchKnob->x() + - m_pitchKnob->width() + 16, 44 ); - - m_saveSettingsBtn = new QPushButton( embed::getIconPixmap( - "project_save" ), "", - m_generalSettingsWidget ); - m_saveSettingsBtn->setGeometry( m_effectChannelNumber->x() + - m_effectChannelNumber->width() + 20, 44, - 32, 32 ); - connect( m_saveSettingsBtn, SIGNAL( clicked() ), this, - SLOT( saveSettingsBtnClicked() ) ); - toolTip::add( m_saveSettingsBtn, - tr( "Save current channel settings in a preset-file" ) ); - m_saveSettingsBtn->setWhatsThis( - tr( "Click here, if you want to save current channel settings " - "in a preset-file. Later you can load this preset by " - "double-clicking it in the preset-browser." ) ); + m_effectChannelNumber->move( m_pitchRange->x() + + m_pitchRange->width() + 24, 46 ); m_tabWidget = new tabWidget( "", this ); @@ -1307,6 +1329,7 @@ void instrumentTrackWindow::modelChanged( void ) if( m_track->getInstrument() && m_track->getInstrument()->isBendable() ) { m_pitchKnob->setModel( &m_track->m_pitchModel ); + m_pitchRange->setModel( &m_track->m_pitchRangeModel ); m_pitchKnob->show(); } else From f514dfdbb343d490f4e6331df2daddd91dbd85e0 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 16 May 2009 17:17:54 +0200 Subject: [PATCH 4/6] InstrumentTrack: made pitch range model publicly accessible Added InstrumentTrack::pitchRangeModel() in order to allow other classes to access pitch range model. --- include/instrument_track.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/instrument_track.h b/include/instrument_track.h index 785d098fc..199b5539a 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -161,11 +161,6 @@ public: // simple helper for removing midiport-XML-node when loading presets static void removeMidiPortNode( multimediaProject & _mmp ); - floatModel * pitchModel( void ) - { - return &m_pitchModel; - } - floatModel * volumeModel( void ) { return &m_volumeModel; @@ -176,6 +171,16 @@ public: return &m_panningModel; } + floatModel * pitchModel( void ) + { + return &m_pitchModel; + } + + intModel * pitchRangeModel( void ) + { + return &m_pitchRangeModel; + } + intModel * effectChannelModel( void ) { return &m_effectChannelModel; From c86f7b5104360feb596f420706aa56221df6bf5c Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 16 May 2009 17:20:20 +0200 Subject: [PATCH 5/6] TripleOscillator: dynamically change range of fine detuning knobs Similiar to the pitch knob of a instrument track, the range of the fine detuning knobs in TripleOscillator is now changed dynamically as well. This allows new kind of sounds by hardsyncing with a detuning of up to +/- 2400 cents. --- .../triple_oscillator/triple_oscillator.cpp | 26 +++++++++++++++---- plugins/triple_oscillator/triple_oscillator.h | 11 ++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/plugins/triple_oscillator/triple_oscillator.cpp b/plugins/triple_oscillator/triple_oscillator.cpp index a628eb284..1d87c9d76 100644 --- a/plugins/triple_oscillator/triple_oscillator.cpp +++ b/plugins/triple_oscillator/triple_oscillator.cpp @@ -1,7 +1,7 @@ /* * triple_oscillator.cpp - powerful instrument with three oscillators * - * Copyright (c) 2004-2008 Tobias Doerffel + * Copyright (c) 2004-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -244,8 +244,13 @@ tripleOscillator::tripleOscillator( instrumentTrack * _instrument_track ) : } + updateAllPitchRange(); + connect( engine::getMixer(), SIGNAL( sampleRateChanged() ), this, SLOT( updateAllDetuning() ) ); + connect( getInstrumentTrack()->pitchRangeModel(), + SIGNAL( dataChanged() ), + this, SLOT( updateAllPitchRange() ) ); } @@ -333,7 +338,7 @@ void tripleOscillator::loadSettings( const QDomElement & _this ) QString tripleOscillator::nodeName( void ) const { - return( tripleoscillator_plugin_descriptor.name ); + return tripleoscillator_plugin_descriptor.name; } @@ -432,7 +437,7 @@ void tripleOscillator::deleteNotePluginData( notePlayHandle * _n ) pluginView * tripleOscillator::instantiateView( QWidget * _parent ) { - return( new tripleOscillatorView( this, _parent ) ); + return new tripleOscillatorView( this, _parent ); } @@ -450,6 +455,18 @@ void tripleOscillator::updateAllDetuning( void ) +void tripleOscillator::updateAllPitchRange( void ) +{ + const int range = getInstrumentTrack()->pitchRangeModel()->value(); + for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) + { + m_osc[i]->updatePitchRange( range ); + } +} + + + + class tripleOscKnob : public knob { public: @@ -854,8 +871,7 @@ extern "C" // neccessary for getting instance out of shared lib plugin * PLUGIN_EXPORT lmms_plugin_main( model *, void * _data ) { - return( new tripleOscillator( - static_cast( _data ) ) ); + return new tripleOscillator( static_cast( _data ) ); } } diff --git a/plugins/triple_oscillator/triple_oscillator.h b/plugins/triple_oscillator/triple_oscillator.h index c9c5aebdc..45af8e108 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-2008 Tobias Doerffel + * Copyright (c) 2004-2009 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -49,6 +49,12 @@ public: oscillatorObject( model * _parent, int _idx ); virtual ~oscillatorObject(); + void updatePitchRange( int _range ) + { + m_fineLeftModel.setRange( -100 * _range, 100 * _range ); + m_fineRightModel.setRange( -100 * _range, 100 * _range ); + } + private: void applyPhaseRandomness( void ); @@ -113,7 +119,7 @@ public: virtual f_cnt_t desiredReleaseFrames( void ) const { - return( 128 ); + return 128; } virtual pluginView * instantiateView( QWidget * _parent ); @@ -121,6 +127,7 @@ public: protected slots: void updateAllDetuning( void ); + void updateAllPitchRange( void ); private: From 55548d58c096d9f8cd997129c8993dea0498f543 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 17 May 2009 00:00:16 +0200 Subject: [PATCH 6/6] AutomationRecorder: instantiate even in console-only mode Always create an instance of AutomationRecorder in Engine class as it is not related to GUI at all. Fixes crash when rendering a project in console-only mode. --- src/core/engine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/engine.cpp b/src/core/engine.cpp index 8cbd31a8e..30bdef596 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -121,6 +121,8 @@ void engine::init( const bool _has_gui ) s_midiControlListener = new MidiControlListener(); + s_automationRecorder = new AutomationRecorder; + if( s_hasGUI ) { s_mainWindow = new mainWindow; @@ -131,7 +133,6 @@ void engine::init( const bool _has_gui ) s_bbEditor = new bbEditor( s_bbTrackContainer ); s_pianoRoll = new pianoRoll; s_automationEditor = new automationEditor; - s_automationRecorder = new AutomationRecorder; s_mainWindow->finalize(); }