From af22d396128d1becd487fa451bff4aee39535da7 Mon Sep 17 00:00:00 2001 From: Dave French Date: Sat, 10 Jan 2015 17:11:17 +0000 Subject: [PATCH 1/2] Proposed fix for 1345 Exclude Tracks from master pitch --- include/InstrumentTrack.h | 3 +++ src/core/NotePlayHandle.cpp | 3 ++- src/tracks/InstrumentTrack.cpp | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 8bb9bd526..1264eb038 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -56,6 +56,7 @@ class DataFile; class PluginView; class TabWidget; class TrackLabelButton; +class LedCheckBox; class EXPORT InstrumentTrack : public Track, public MidiEventProcessor @@ -250,6 +251,7 @@ private: FloatModel m_pitchModel; IntModel m_pitchRangeModel; IntModel m_effectChannelModel; + BoolModel m_useMasterPitchModel; FadeButton *m_fb; @@ -414,6 +416,7 @@ private: Knob * m_pitchKnob; LcdSpinBox* m_pitchRangeSpinBox; LcdSpinBox * m_effectChannelNumber; + LedCheckBox * m_useMasterPitchBox; // tab-widget with all children diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index e2d3e743d..19ec0517a 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -509,10 +509,11 @@ bool NotePlayHandle::operator==( const NotePlayHandle & _nph ) const void NotePlayHandle::updateFrequency() { + int mp = m_instrumentTrack->m_useMasterPitchModel.value() ? Engine::getSong()->masterPitch() : 0; const float pitch = ( key() - m_instrumentTrack->baseNoteModel()->value() + - Engine::getSong()->masterPitch() + + mp + m_baseDetuning->value() ) / 12.0f; m_frequency = BaseFreq * powf( 2.0f, pitch + m_instrumentTrack->pitchModel()->value() / ( 100 * 12.0f ) ); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index f2e14fee5..810eba2a8 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -109,6 +109,7 @@ InstrumentTrack::InstrumentTrack( TrackContainer* tc ) : m_pitchModel( 0, MinPitchDefault, MaxPitchDefault, 1, this, tr( "Pitch" ) ), m_pitchRangeModel( 1, 1, 24, this, tr( "Pitch range" ) ), m_effectChannelModel( 0, 0, 0, this, tr( "FX channel" ) ), + m_useMasterPitchModel( true, this, tr( "Master Pitch") ), m_instrument( NULL ), m_soundShaping( this ), m_arpeggio( this ), @@ -139,7 +140,9 @@ InstrumentTrack::InstrumentTrack( TrackContainer* tc ) : int InstrumentTrack::baseNote() const { - return m_baseNoteModel.value() - Engine::getSong()->masterPitch(); + int mp = m_useMasterPitchModel.value() ? Engine::getSong()->masterPitch() : 0; + + return m_baseNoteModel.value() - mp; } @@ -550,6 +553,7 @@ void InstrumentTrack::updatePitchRange() int InstrumentTrack::masterKey( int _midi_key ) const { + int key = baseNote(); return tLimit( _midi_key - ( key - DefaultKey ), 0, NumKeys ); } @@ -700,6 +704,7 @@ void InstrumentTrack::saveTrackSpecificSettings( QDomDocument& doc, QDomElement m_effectChannelModel.saveSettings( doc, thisElement, "fxch" ); m_baseNoteModel.saveSettings( doc, thisElement, "basenote" ); + m_useMasterPitchModel.saveSettings( doc, thisElement, "usemasterpitch"); if( m_instrument != NULL ) { @@ -731,6 +736,7 @@ void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement m_effectChannelModel.setRange( 0, Engine::fxMixer()->numChannels()-1 ); m_effectChannelModel.loadSettings( thisElement, "fxch" ); m_baseNoteModel.loadSettings( thisElement, "basenote" ); + m_useMasterPitchModel.loadSettings( thisElement, "usemasterpitch"); // clear effect-chain just in case we load an old preset without FX-data m_audioPort.effects()->clear(); @@ -1211,6 +1217,14 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : basicControlsLayout->addWidget( m_pitchRangeSpinBox ); basicControlsLayout->addStretch(); + //setup checkbox for use master pitch + m_useMasterPitchBox = new LedCheckBox( this, tr( "Use master pitch" ),LedCheckBox::Green ); + m_useMasterPitchBox->setModel( &m_track->m_useMasterPitchModel ); + m_useMasterPitchBox->setToolTip( "Master Pitch" ); + + basicControlsLayout->addWidget( m_useMasterPitchBox ); + basicControlsLayout->addStretch(); + // setup spinbox for selecting FX-channel m_effectChannelNumber = new fxLineLcdSpinBox( 2, NULL, tr( "FX channel" ) ); m_effectChannelNumber->setLabel( tr( "FX" ) ); From 83baea6605b6d6f74f599b7ca862d14f56f7c94e Mon Sep 17 00:00:00 2001 From: Dave French Date: Sat, 10 Jan 2015 19:05:40 +0000 Subject: [PATCH 2/2] 1345 moved LedCheckBox to MISC tab --- include/InstrumentMidiIOView.h | 14 +++++++++++ include/InstrumentTrack.h | 6 ++++- src/gui/widgets/InstrumentMidiIOView.cpp | 30 +++++++++++++++++++++++- src/tracks/InstrumentTrack.cpp | 12 ++++------ 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/include/InstrumentMidiIOView.h b/include/InstrumentMidiIOView.h index d9bcf3843..c45dbfa5f 100644 --- a/include/InstrumentMidiIOView.h +++ b/include/InstrumentMidiIOView.h @@ -34,6 +34,8 @@ class GroupBox; class LcdSpinBox; class QToolButton; +class LedCheckBox; +class InstrumentTrack; class InstrumentMidiIOView : public QWidget, public ModelView @@ -63,4 +65,16 @@ private: } ; +class InstrumentMiscView : public QWidget +{ + Q_OBJECT +public: + InstrumentMiscView( InstrumentTrack *it, QWidget* parent ); + ~InstrumentMiscView(); + +private: + LedCheckBox * m_useMasterPitchBox; + +}; + #endif diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 1264eb038..16536c081 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -49,6 +49,7 @@ class FadeButton; class Instrument; class InstrumentTrackWindow; class InstrumentMidiIOView; +class InstrumentMiscView; class Knob; class LcdSpinBox; class midiPortMenu; @@ -268,6 +269,7 @@ private: friend class InstrumentTrackWindow; friend class NotePlayHandle; friend class FlpImport; + friend class InstrumentMiscView; } ; @@ -416,7 +418,7 @@ private: Knob * m_pitchKnob; LcdSpinBox* m_pitchRangeSpinBox; LcdSpinBox * m_effectChannelNumber; - LedCheckBox * m_useMasterPitchBox; + // tab-widget with all children @@ -427,6 +429,8 @@ private: InstrumentFunctionArpeggioView* m_arpeggioView; InstrumentMidiIOView * m_midiView; EffectRackView * m_effectView; + InstrumentMiscView *m_miscView; + // test-piano at the bottom of every instrument-settings-window PianoView * m_pianoView; diff --git a/src/gui/widgets/InstrumentMidiIOView.cpp b/src/gui/widgets/InstrumentMidiIOView.cpp index 212610110..6b330a707 100644 --- a/src/gui/widgets/InstrumentMidiIOView.cpp +++ b/src/gui/widgets/InstrumentMidiIOView.cpp @@ -37,7 +37,9 @@ #include "MidiClient.h" #include "Mixer.h" #include "ToolTip.h" - +#include "InstrumentTrack.h" +#include "LedCheckbox.h" +#include "QLabel" InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : @@ -201,3 +203,29 @@ void InstrumentMidiIOView::modelChanged() } } + + +InstrumentMiscView::InstrumentMiscView(InstrumentTrack *it, QWidget *parent) : + QWidget( parent ) +{ + QVBoxLayout* layout = new QVBoxLayout( this ); + layout->setMargin( 5 ); + + QHBoxLayout* masterPitchLayout = new QHBoxLayout( this ); + + //setup checkbox for use master pitch + m_useMasterPitchBox = new LedCheckBox( this, tr( "Use master pitch" ),LedCheckBox::Green ); + m_useMasterPitchBox->setModel( &it->m_useMasterPitchModel ); + m_useMasterPitchBox->setToolTip( "Master Pitch" ); + masterPitchLayout->addWidget( m_useMasterPitchBox ); + + QLabel *label = new QLabel ( tr ("Use Master Pitch " ), this ); + masterPitchLayout->addWidget( label ); + layout->addLayout( masterPitchLayout ); + layout->addStretch(); +} + +InstrumentMiscView::~InstrumentMiscView() +{ + +} diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 810eba2a8..cb28142eb 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -1217,13 +1217,6 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : basicControlsLayout->addWidget( m_pitchRangeSpinBox ); basicControlsLayout->addStretch(); - //setup checkbox for use master pitch - m_useMasterPitchBox = new LedCheckBox( this, tr( "Use master pitch" ),LedCheckBox::Green ); - m_useMasterPitchBox->setModel( &m_track->m_useMasterPitchModel ); - m_useMasterPitchBox->setToolTip( "Master Pitch" ); - - basicControlsLayout->addWidget( m_useMasterPitchBox ); - basicControlsLayout->addStretch(); // setup spinbox for selecting FX-channel m_effectChannelNumber = new fxLineLcdSpinBox( 2, NULL, tr( "FX channel" ) ); @@ -1273,10 +1266,15 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : // FX tab m_effectView = new EffectRackView( m_track->m_audioPort.effects(), m_tabWidget ); + // MISC tab + m_miscView = new InstrumentMiscView( m_track, m_tabWidget ); + + m_tabWidget->addTab( m_ssView, tr( "ENV/LFO" ), 1 ); m_tabWidget->addTab( instrumentFunctions, tr( "FUNC" ), 2 ); m_tabWidget->addTab( m_effectView, tr( "FX" ), 3 ); m_tabWidget->addTab( m_midiView, tr( "MIDI" ), 4 ); + m_tabWidget->addTab( m_miscView, tr( "MISC" ), 5 ); // setup piano-widget m_pianoView = new PianoView( this );