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
This commit is contained in:
Danny McRae
2006-08-30 20:06:53 +00:00
parent c81e4b4642
commit b1f31a036f
11 changed files with 338 additions and 27 deletions

View File

@@ -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 <jasp00/at/terra/dot/es>
* COPYING:

View File

@@ -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

Binary file not shown.

Binary file not shown.

74
include/meter_dialog.h Normal file
View File

@@ -0,0 +1,74 @@
/*
* meter_dialog.h - diloag for entering meter settings
*
* Copyright (c) 2006 Danny McRae <khjklujn/at/yahoo.com>
*
* 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 <QtGui/QWidget>
#else
#include <qwidget.h>
#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

View File

@@ -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;
} ;

View File

@@ -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() );
}

View File

@@ -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();

123
src/core/meter_dialog.cpp Normal file
View File

@@ -0,0 +1,123 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* meter_dialog.cpp - diloag for entering meter settings
*
* Copyright (c) 2006 Danny McRae <khjklujn/at/yahoo.com>
*
* 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 <QtGui/QLayout>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
#else
#include <qlayout.h>
#include <qpushbutton.h>
#include <qlabel.h>
#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

View File

@@ -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"

View File

@@ -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<float>( m_custom->getDenominator() ) /
static_cast<float>( 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<float>::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<float>::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