From b1f31a036f8d1bf6f512ee9a4993b14ead7782df Mon Sep 17 00:00:00 2001 From: Danny McRae Date: Wed, 30 Aug 2006 20:06:53 +0000 Subject: [PATCH] user definable settings for tempo sync knobs git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@384 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 18 +++- Makefile.am | 3 + data/themes/blue_scene/dont_know.png | Bin 0 -> 664 bytes data/themes/default/dont_know.png | Bin 0 -> 716 bytes include/meter_dialog.h | 74 +++++++++++++++ include/tempo_sync_knob.h | 15 ++- src/core/arp_and_chords_tab_widget.cpp | 21 +++-- src/core/envelope_and_lfo_widget.cpp | 10 +- src/core/meter_dialog.cpp | 123 +++++++++++++++++++++++++ src/lmms_single_source.cpp | 1 + src/widgets/tempo_sync_knob.cpp | 100 +++++++++++++++++--- 11 files changed, 338 insertions(+), 27 deletions(-) create mode 100644 data/themes/blue_scene/dont_know.png create mode 100644 data/themes/default/dont_know.png create mode 100644 include/meter_dialog.h create mode 100644 src/core/meter_dialog.cpp diff --git a/ChangeLog b/ChangeLog index 75ad0c809..4f560e3de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,7 +6,23 @@ * src/core/ladspa_effect.cpp: corrected the labeling of "(ms)" which were showing up as "(ms))" - + + * Makefile.am: + * src/lmms_single_source.cpp: + * include/meter_dialog.h: + * src/core/meter_dialog.cpp: + * include/tempo_sync_knob.h: + * src/widgets/tempo_sync_knob: + added user definable settings for tempo sync + + * src/core/arp_and_chords_tab_widget.cpp: + - changed arp time knob to save using new tempo sync format + - fixed a bug that was preventing the arp groupbox state from + being restored properly + + * src/core/envelope_and_lfo_widget.cpp: + changed lfo time knob to save using new tempo sync format + 2006-08-28 Javier Serrano Polo * COPYING: diff --git a/Makefile.am b/Makefile.am index ca7b72a11..bfbb58501 100644 --- a/Makefile.am +++ b/Makefile.am @@ -80,6 +80,7 @@ lmms_MOC = \ ./mixer.moc \ ./name_label.moc \ ./nstate_button.moc \ + ./meter_dialog.moc \ ./midi_alsa_seq.moc \ ./midi_tab_widget.moc \ ./note_play_handle.moc \ @@ -157,6 +158,7 @@ lmms_SOURCES = \ $(srcdir)/src/core/ladspa_port_dialog.cpp \ $(srcdir)/src/core/main_window.cpp \ $(srcdir)/src/core/main.cpp \ + $(srcdir)/src/core/meter_dialog.cpp \ $(srcdir)/src/core/midi_tab_widget.cpp \ $(srcdir)/src/core/mixer.cpp \ $(srcdir)/src/core/name_label.cpp \ @@ -363,6 +365,7 @@ lmms_SOURCES = \ $(srcdir)/include/rack_view.h \ $(srcdir)/include/select_ladspa_dialog.h \ $(srcdir)/include/ladspa_effect.h \ + $(srcdir)/include/meter_dialog.h \ $(srcdir)/include/qxembed.h diff --git a/data/themes/blue_scene/dont_know.png b/data/themes/blue_scene/dont_know.png new file mode 100644 index 0000000000000000000000000000000000000000..652887f9d065a57e107f4c1ee899a1fbd43af015 GIT binary patch literal 664 zcmV;J0%!e+P)HrMw5884V z%hHVQv*eJ$$h}&v)^+L-Cy1zvFLZO;_qMTtrSPWkHhdc1%&upboGMNo>Ks7wM-k~y zUlHfpr{-mUWK~Xd%^;`&gAQCyKr4yG;Q8PE&B^LyT4B=bddK1 yMiuA)l*{Gh#&Ws*FR1;^0-W@<>;3*1xbzD|@&4tgS`1nM0000 z%?FC1;5a%CGk5OXbAB!6s!$#H@#7rMhx7ZL@7Hh~HPLPPHw>VF9Of~A@$qpy&$~Q3 zHv99^*w|g*?7PD2^1}D+p6dfts8lMiN~Kb{TrS65fOI;I8;hNSoj2+K=Xi^$HL0auxsT{K=*1f#2r}PSN;55bUceE{S$VdIYo|E?o3Th`DztWLBwjg z*>3=bcW27?PAz)VsXM7hiC>91wHCFCRRtghAR>`~7E#Sk&VRmLztZ@%Et~Kqu!{!4 z8Zg)+m8)PVRf)l=S*zI?y5HGkVbJj%UsU2)e2m3luo37SPK=Jt59cq+Q#%trtbM+H zed~sbw5W!ziXx$)(d(+9$}#L#(43cC*j*mdc(@}XRz$6cRQptpJV+{)`kyx)zy(f3 y9<{&$Kqix^{xOru{0iErS%4s_^+tISX#E3d6ECe)@d)_<0000 + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef _METER_DIALOG_H +#define _METER_DIALOG_H + +#ifdef QT4 + +#include + +#else + +#include + +#endif + + +#include "track.h" +#include "lcd_spinbox.h" + + +class meterDialog: public QWidget +{ + Q_OBJECT +public: + meterDialog( QWidget * _parent, track * _track ); + ~meterDialog(); + + void saveSettings( QDomDocument & _doc, QDomElement & _this, + const QString & _name ); + void loadSettings( const QDomElement & _this, + const QString & _name ); + + inline int getNumerator( void ) + { + return( m_numerator->value() ); + } + + inline int getDenominator( void ) + { + return( m_denominator->value() ); + } + +private: + lcdSpinBox * m_numerator; + lcdSpinBox * m_denominator; + +signals: + void numeratorChanged( int ); + void denominatorChanged( int ); +}; + +#endif diff --git a/include/tempo_sync_knob.h b/include/tempo_sync_knob.h index 1947461d2..d7d42e743 100644 --- a/include/tempo_sync_knob.h +++ b/include/tempo_sync_knob.h @@ -38,6 +38,7 @@ #include "knob.h" #include "types.h" +#include "meter_dialog.h" class QAction; @@ -56,7 +57,8 @@ public: QUARTER_NOTE, EIGHTH_NOTE, SIXTEENTH_NOTE, - THIRTYSECOND_NOTE + THIRTYSECOND_NOTE, + CUSTOM } ; @@ -65,6 +67,11 @@ public: float _scale = 1.0f ); virtual ~tempoSyncKnob(); + virtual void saveSettings( QDomDocument & _doc, QDomElement & _this, + const QString & _name ); + virtual void loadSettings( const QDomElement & _this, + const QString & _name ); + tempoSyncMode getSyncMode( void ); void setSyncMode( tempoSyncMode _new_mode ); @@ -77,7 +84,6 @@ public: const QPixmap & getSyncIcon( void ); void setSyncIcon( const QPixmap & _new_pix ); - signals: void syncModeChanged( tempoSyncMode _new_mode ); void scaleChanged( float _new_scale ); @@ -98,7 +104,8 @@ protected: protected slots: void calculateTempoSyncTime( bpm_t _bpm ); - + void updateCustom( int ); + void showCustom( void ); private: tempoSyncMode m_tempoSyncMode; @@ -107,7 +114,7 @@ private: QString m_tempoSyncDescription; tempoSyncMode m_tempoLastSyncMode; - + meterDialog * m_custom; } ; diff --git a/src/core/arp_and_chords_tab_widget.cpp b/src/core/arp_and_chords_tab_widget.cpp index dde42ef04..4a97b5cce 100644 --- a/src/core/arp_and_chords_tab_widget.cpp +++ b/src/core/arp_and_chords_tab_widget.cpp @@ -672,8 +672,6 @@ void arpAndChordsTabWidget::saveSettings( QDomDocument & _doc, m_arpTimeKnob->saveSettings( _doc, _this, "arptime" ); m_arpGateKnob->saveSettings( _doc, _this, "arpgate" ); m_arpDirectionBtnGrp->saveSettings( _doc, _this, "arpdir" ); - _this.setAttribute( "arpsyncmode", - ( int ) m_arpTimeKnob->getSyncMode() ); m_arpModeComboBox->saveSettings( _doc, _this, "arpmode" ); } @@ -695,19 +693,26 @@ void arpAndChordsTabWidget::loadSettings( const QDomElement & _this ) { m_arpDirectionBtnGrp->setInitValue( _this.attribute( "arpdir" ).toInt() - 1 ); + m_arpGroupBox->setState( + _this.attribute( "arpdir" ).toInt() != OFF && + !_this.attribute( "arpdisabled" ).toInt() ); } else { m_arpDirectionBtnGrp->loadSettings( _this, "arpdir" ); + m_arpGroupBox->setState( + !_this.attribute( "arpdisabled" ).toInt() ); + } + + // Keep compatibility with version 2.1 file format + if( _this.hasAttribute( "arpsyncmode" ) ) + { + m_arpTimeKnob->setSyncMode( + ( tempoSyncKnob::tempoSyncMode ) _this.attribute( + "arpsyncmode" ).toInt() ); } - m_arpTimeKnob->setSyncMode( - ( tempoSyncKnob::tempoSyncMode ) _this.attribute( - "arpsyncmode" ).toInt() ); m_arpModeComboBox->loadSettings( _this, "arpmode" ); - - m_arpGroupBox->setState( _this.attribute( "arpdir" ).toInt() != OFF && - !_this.attribute( "arpdisabled" ).toInt() ); } diff --git a/src/core/envelope_and_lfo_widget.cpp b/src/core/envelope_and_lfo_widget.cpp index 085de71a5..58dd44616 100644 --- a/src/core/envelope_and_lfo_widget.cpp +++ b/src/core/envelope_and_lfo_widget.cpp @@ -649,8 +649,6 @@ void envelopeAndLFOWidget::saveSettings( QDomDocument & _doc, m_lfoAmountKnob->saveSettings( _doc, _parent, "lamt" ); m_x100Cb->saveSettings( _doc, _parent, "x100" ); m_controlEnvAmountCb->saveSettings( _doc, _parent, "ctlenvamt" ); - _parent.setAttribute( "lfosyncmode", - ( int ) m_lfoSpeedKnob->getSyncMode() ); _parent.setAttribute( "userwavefile", m_userWave.audioFile() ); } @@ -675,9 +673,15 @@ void envelopeAndLFOWidget::loadSettings( const QDomElement & _this ) m_lfoAmountKnob->loadSettings( _this, "lamt" ); m_x100Cb->loadSettings( _this, "x100" ); m_controlEnvAmountCb->loadSettings( _this, "ctlenvamt" ); - m_lfoSpeedKnob->setSyncMode( + + // Keep compatibility with version 2.1 file format + if( _this.hasAttribute( "lfosyncmode" ) ) + { + m_lfoSpeedKnob->setSyncMode( ( tempoSyncKnob::tempoSyncMode ) _this.attribute( "lfosyncmode" ).toInt() ); + } + m_userWave.setAudioFile( _this.attribute( "userwavefile" ) ); m_busyMutex.unlock(); diff --git a/src/core/meter_dialog.cpp b/src/core/meter_dialog.cpp new file mode 100644 index 000000000..cefcfef81 --- /dev/null +++ b/src/core/meter_dialog.cpp @@ -0,0 +1,123 @@ +#ifndef SINGLE_SOURCE_COMPILE + +/* + * meter_dialog.cpp - diloag for entering meter settings + * + * Copyright (c) 2006 Danny McRae + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifdef QT4 + +#include +#include +#include + +#else + +#include +#include +#include + +#endif + +#include "meter_dialog.h" +#include "embed.h" +#include "gui_templates.h" + + +meterDialog::meterDialog( QWidget * _parent, track * _track ): + QWidget( _parent, "meterDialog" ) +{ + QVBoxLayout * vlayout = new QVBoxLayout( this ); + vlayout->setSpacing( 5 ); + vlayout->setMargin( 5 ); + + QWidget * num = new QWidget( this ); + QHBoxLayout * num_layout = new QHBoxLayout( num ); + num_layout->setSpacing( 10 ); + m_numerator = new lcdSpinBox( 1, 32, 2, num, + "", + _track->eng(), _track ); + connect( m_numerator, SIGNAL( valueChanged( int ) ), + this, SIGNAL( numeratorChanged( int ) ) ); + m_numerator->setValue( 4 ); + num_layout->addWidget( m_numerator ); + QLabel * num_label = new QLabel( num ); + num_label->setText( tr( "Meter Numerator" ) ); + QFont f = num_label->font(); + num_label->setFont( pointSize<7>( f ) ); + num_layout->addWidget( num_label ); + + QWidget * dem = new QWidget( this ); + QHBoxLayout * dem_layout = new QHBoxLayout( dem ); + dem_layout->setSpacing( 10 ); + m_denominator = new lcdSpinBox( 1, 32, 2, dem, + "", + _track->eng(), _track ); + connect( m_denominator, SIGNAL( valueChanged( int ) ), + this, SIGNAL( denominatorChanged( int ) ) ); + m_denominator->setValue( 4 ); + dem_layout->addWidget( m_denominator ); + QLabel * dem_label = new QLabel( dem ); + f = dem_label->font(); + dem_label->setFont( pointSize<7>( f ) ); + dem_label->setText( tr( "Meter Denominator" ) ); + dem_layout->addWidget( dem_label ); + + vlayout->addWidget( num ); + vlayout->addWidget( dem ); + + setFixedSize( dem_label->width() + m_denominator->width() + 10, + m_numerator->height() + m_denominator->height() + 15 ); +} + + + + +meterDialog::~meterDialog() +{ +} + + + + +void meterDialog::saveSettings( QDomDocument & _doc, QDomElement & _this, + const QString & _name ) +{ + m_numerator->saveSettings( _doc, _this, _name + "_numerator" ); + m_denominator->saveSettings( _doc, _this, _name + "_denominator" ); +} + + + + +void meterDialog::loadSettings( const QDomElement & _this, + const QString & _name ) +{ + m_numerator->loadSettings( _this, _name + "_numerator" ); + m_denominator->loadSettings( _this, _name + "_denominator" ); +} + + + +#include "meter_dialog.moc" + +#endif diff --git a/src/lmms_single_source.cpp b/src/lmms_single_source.cpp index 5de806a76..7166a3941 100644 --- a/src/lmms_single_source.cpp +++ b/src/lmms_single_source.cpp @@ -17,6 +17,7 @@ #include "src/lib/oscillator.cpp" #include "src/lib/clipboard.cpp" #include "src/lib/sample_buffer.cpp" +#include "src/core/meter_dialog.cpp" #include "src/core/ladspa_effect.cpp" #include "src/core/effect_chain.cpp" #include "src/core/effect.cpp" diff --git a/src/widgets/tempo_sync_knob.cpp b/src/widgets/tempo_sync_knob.cpp index 082c51144..0c9c9984a 100644 --- a/src/widgets/tempo_sync_knob.cpp +++ b/src/widgets/tempo_sync_knob.cpp @@ -49,8 +49,7 @@ #include "tempo_sync_knob.h" #include "song_editor.h" #include "embed.h" - - +#include "main_window.h" tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, @@ -65,7 +64,15 @@ tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, m_tempoLastSyncMode( NO_SYNC ) { connect( eng()->getSongEditor(), SIGNAL( tempoChanged( bpm_t ) ), - this, SLOT( calculateTempoSyncTime( bpm_t ) ) ); + this, SLOT( calculateTempoSyncTime( bpm_t ) ) ); + m_custom = new meterDialog( eng()->getMainWindow()->workspace(), + _track ); + connect( m_custom, SIGNAL( numeratorChanged( int ) ), + this, SLOT( updateCustom( int ) ) ); + connect( m_custom, SIGNAL( denominatorChanged( int ) ), + this, SLOT( updateCustom( int ) ) ); + m_custom->hide(); + m_custom->setWindowTitle( "Meter" ); } @@ -73,6 +80,7 @@ tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, tempoSyncKnob::~tempoSyncKnob() { + delete m_custom; } @@ -160,6 +168,10 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) syncMenu->addAction( embed::getIconPixmap( "note_thirtysecond" ), tr( "32nd note" ) )->setData( (int) THIRTYSECOND_NOTE ); + syncMenu->addAction( embed::getIconPixmap( "dont_know" ), + tr( "Custom..." ), + this, SLOT( showCustom( void ) ) + )->setData( (int) CUSTOM ); #else int menuId; menuId = syncMenu->addAction( embed::getIconPixmap( "note_none" ), @@ -168,43 +180,48 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) syncMenu->setItemParameter( menuId, ( int ) NO_SYNC ); if( limit / 0.125f <= maxValue() ) { - menuId = syncMenu->addAction( embed::getIconPixmap( - "note_double_whole" ), + menuId = syncMenu->addAction( + embed::getIconPixmap( "note_double_whole" ), tr( "Eight beats" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) DOUBLE_WHOLE_NOTE ); } if( limit / 0.25f <= maxValue() ) { - menuId = syncMenu->addAction( embed::getIconPixmap( "note_whole" ), + menuId = syncMenu->addAction( + embed::getIconPixmap( "note_whole" ), tr( "Whole note" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) WHOLE_NOTE ); } if( limit / 0.5f <= maxValue() ) { - menuId = syncMenu->addAction( embed::getIconPixmap( "note_half" ), + menuId = syncMenu->addAction( + embed::getIconPixmap( "note_half" ), tr( "Half note" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) HALF_NOTE ); } if( limit <= maxValue() ) { - menuId = syncMenu->addAction( embed::getIconPixmap( "note_quarter" ), + menuId = syncMenu->addAction( + embed::getIconPixmap( "note_quarter" ), tr( "Quarter note" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) QUARTER_NOTE ); } if( limit / 2.0f <= maxValue() ) { - menuId = syncMenu->addAction( embed::getIconPixmap( "note_eighth" ), + menuId = syncMenu->addAction( + embed::getIconPixmap( "note_eighth" ), tr( "8th note" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) EIGHTH_NOTE ); } if( limit / 4.0f <= maxValue() ) { - menuId = syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ), + menuId = syncMenu->addAction( + embed::getIconPixmap( "note_sixteenth" ), tr( "16th note" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) SIXTEENTH_NOTE ); @@ -214,6 +231,10 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) tr( "32nd note" ), this, SLOT( setTempoSync( int ) ) ); syncMenu->setItemParameter( menuId, ( int ) THIRTYSECOND_NOTE ); + menuId = syncMenu->addAction( embed::getIconPixmap( "dont_know" ), + tr( "Custom..." ), + this, SLOT( showCustom( void ) ) ); + syncMenu->setItemParameter( menuId, ( int ) CUSTOM ); contextMenu.addMenu( m_tempoSyncIcon, m_tempoSyncDescription, syncMenu ); @@ -228,7 +249,7 @@ void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) SLOT( openInAutomationEditor() ) ); contextMenu.addSeparator(); contextMenu.addAction( tr( "Connect to MIDI-device" ), this, - SLOT( connectToMidiDevice() ) ); + SLOT( connectToMidiDevice() ) ); contextMenu.addSeparator(); contextMenu.addAction( embed::getIconPixmap( "help" ), tr( "&Help" ), this, SLOT( displayHelp() ) ); @@ -277,6 +298,10 @@ void tempoSyncKnob::setTempoSync( QAction * ) { } void tempoSyncKnob::setTempoSync( int _note_type ) { m_tempoSyncMode = ( tempoSyncMode ) _note_type; + if( m_tempoSyncMode != CUSTOM ) + { + m_custom->hide(); + } calculateTempoSyncTime( eng()->getSongEditor()->getTempo() ); eng()->getSongEditor()->setModified(); } @@ -292,6 +317,19 @@ void tempoSyncKnob::calculateTempoSyncTime( bpm_t _bpm ) { switch( m_tempoSyncMode ) { + case CUSTOM: + m_tempoSyncDescription = tr( "Custom " ) + + "(" + + QString::number( m_custom->getNumerator() ) + + "/" + + QString::number( m_custom->getDenominator() ) + + ")"; + m_tempoSyncIcon = embed::getIconPixmap( + "dont_know" ); + conversionFactor = + static_cast( m_custom->getDenominator() ) / + static_cast( m_custom->getNumerator() ); + break; case DOUBLE_WHOLE_NOTE: m_tempoSyncDescription = tr( "Synced to Eight Beats" ); @@ -367,6 +405,29 @@ void tempoSyncKnob::calculateTempoSyncTime( bpm_t _bpm ) +void tempoSyncKnob::saveSettings( QDomDocument & _doc, QDomElement & _this, + const QString & _name ) +{ + _this.setAttribute( "syncmode", ( int ) getSyncMode() ); + automatableObject::saveSettings( _doc, _this, _name ); + m_custom->saveSettings( _doc, _this, _name ); +} + + + + +void tempoSyncKnob::loadSettings( const QDomElement & _this, + const QString & _name ) +{ + setSyncMode( ( tempoSyncMode ) _this.attribute( + "syncmode" ).toInt() ); + automatableObject::loadSettings( _this, _name ); + m_custom->loadSettings( _this, _name ); +} + + + + tempoSyncKnob::tempoSyncMode tempoSyncKnob::getSyncMode( void ) { return( m_tempoSyncMode ); @@ -435,6 +496,23 @@ void tempoSyncKnob::setSyncIcon( const QPixmap & _new_icon ) + +void tempoSyncKnob::updateCustom( int ) +{ + setTempoSync( CUSTOM ); +} + + + + +void tempoSyncKnob::showCustom( void ) +{ + m_custom->show(); + setTempoSync( CUSTOM ); +} + + + #ifndef QT4 #undef addSeparator #endif