- faster oscillator

- tempo-based arpeggiator and LFOs
- bug-fixes
- added another Moog-filter


git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@14 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2005-10-06 08:24:23 +00:00
parent 6ba478ff6b
commit 5d9e7fe0ed
21 changed files with 832 additions and 130 deletions

View File

@@ -53,7 +53,7 @@
#include "knob.h"
#include "tooltip.h"
#include "gui_templates.h"
#include "tempo_sync_knob.h"
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -286,7 +286,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track,
"The selected arpeggio will be played within specified "
"amount of octaves." ) );
m_arpTimeKnob = new knob( knobBright_26, m_arpGroupBox,
m_arpTimeKnob = new tempoSyncKnob( knobBright_26, m_arpGroupBox,
tr( "Arpeggio time" ) );
m_arpTimeKnob->setLabel( tr( "TIME" ) );
m_arpTimeKnob->setRange( 10.0, 1000.0, 1.0 );
@@ -634,6 +634,9 @@ void arpAndChordsTabWidget::saveSettings( QDomDocument & _doc,
m_arpGateKnob->value() ) );
elw_de.setAttribute( "arpdir", QString::number(
m_arpDirection ) );
elw_de.setAttribute( "arpsyncmode", QString::number(
( int ) m_arpTimeKnob->getSyncMode() ) );
_parent.appendChild( elw_de );
}
@@ -661,6 +664,8 @@ void arpAndChordsTabWidget::loadSettings( const QDomElement & _this )
m_arpGateKnob->setValue( _this.attribute( "arpgate" ).toFloat() );
m_arpDirection = static_cast<arpDirections>(
_this.attribute( "arpdir" ).toInt() );
m_arpTimeKnob->setSyncMode(
( tempoSyncMode ) _this.attribute( "arpsyncmode" ).toInt() );
m_arpGroupBox->setState( m_arpDirection != OFF &&
!_this.attribute( "arpdisabled" ).toInt() );

View File

@@ -59,7 +59,7 @@
#include "tooltip.h"
#include "gui_templates.h"
#include "led_checkbox.h"
#include "tempo_sync_knob.h"
// how long should be each envelope-segment maximal (e.g. attack)?
const float SECS_PER_ENV_SEGMENT = 5.0f;
@@ -297,7 +297,8 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
connect( m_lfoAttackKnob, SIGNAL( valueChanged( float ) ), this,
SLOT( updateAfterKnobChange( float ) ) );
m_lfoSpeedKnob = new knob( knobBright_26, this, tr( "LFO-speed" ) );
m_lfoSpeedKnob = new tempoSyncKnob( knobBright_26, this, tr( "LFO-speed" ) ,
20000.0 );
m_lfoSpeedKnob->setLabel( tr( "SPD" ) );
m_lfoSpeedKnob->setRange( 0.01, 1.0, 0.0001 );
m_lfoSpeedKnob->setValue( 0.1, TRUE );
@@ -584,6 +585,8 @@ void envelopeAndLFOWidget::saveSettings( QDomDocument & ,
m_x100Cb->isChecked() ) );
_parent.setAttribute( "ctlenvamt", QString::number(
m_controlEnvAmountCb->isChecked() ) );
_parent.setAttribute( "lfosyncmode", QString::number(
( int ) m_lfoSpeedKnob->getSyncMode() ) );
}
@@ -609,6 +612,8 @@ void envelopeAndLFOWidget::loadSettings( const QDomElement & _this )
m_x100Cb->setChecked( _this.attribute( "x100" ).toInt() );
m_controlEnvAmountCb->setChecked( _this.attribute(
"ctlenvamt" ).toInt() );
m_lfoSpeedKnob->setSyncMode( ( tempoSyncMode ) _this.attribute(
"lfosyncmode" ).toInt() );
switch( m_lfoShape )
{

View File

@@ -153,8 +153,10 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track,
m_filterComboBox->addItem( tr( "Notch" ) );
m_filterComboBox->addItem( tr( "Allpass" ) );
m_filterComboBox->addItem( tr( "Moog" ) );
m_filterComboBox->addItem( tr( "Moog 2" ) );
m_filterComboBox->addItem( tr( "2x LowPass" ) );
m_filterComboBox->addItem( tr( "2x Moog" ) );
m_filterComboBox->addItem( tr( "2x Moog 2" ) );
#ifdef QT4
m_filterComboBox->setWhatsThis(
@@ -269,7 +271,7 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
int old_filter_cut = 0;
int old_filter_res = 0;
basicFilters<>::filterTypes filter = static_cast<basicFilters<>::filterTypes>( m_filterComboBox->
basicFilters<>::filterTypes filter = basicFilters<>::getFilterType( m_filterComboBox->
#ifdef QT4
currentIndex()
#else

View File

@@ -1918,6 +1918,7 @@ void pianoRoll::keyReleaseEvent( QKeyEvent * )
void pianoRoll::wheelEvent( QWheelEvent * _we )
{
_we->accept();
if( m_controlPressed )
{
if( _we->delta() > 0 )

View File

@@ -609,6 +609,7 @@ void songEditor::scrolled( int _new_pos )
void songEditor::wheelEvent( QWheelEvent * _we )
{
_we->accept();
if( m_controlPressed )
{
if( _we->delta() > 0 )
@@ -757,6 +758,7 @@ void songEditor::setBPM( int _new_bpm )
{
m_bpmSpinBox->setValue( tLimit( _new_bpm, MIN_BPM, MAX_BPM ) );
setModified();
emit bpmChanged( _new_bpm );
}
@@ -1332,6 +1334,13 @@ float songEditor::framesPerTact( void ) const
int songEditor::getBPM( void )
{
return( m_bpmSpinBox->value() );
}
bool songEditor::mayChangeProject( void )
{

View File

@@ -166,7 +166,9 @@ void lcdSpinBox::mouseReleaseEvent( QMouseEvent * _me )
void lcdSpinBox::wheelEvent( QWheelEvent * _we )
{
_we->accept();
setValue( value() + _we->delta() / 120 * m_step );
emit valueChanged( value() );
}

View File

@@ -94,7 +94,7 @@ void ledCheckBox::paintEvent( QPaintEvent * )
QPainter p( this );
#else
QPixmap draw_pm( rect().size() );
draw_pm.fill( this, rect().topLeft() );
//draw_pm.fill( this, rect().topLeft() );
QPainter p( &draw_pm, this );
#endif

View File

@@ -207,6 +207,7 @@ void tabWidget::paintEvent( QPaintEvent * _pe )
void tabWidget::wheelEvent( QWheelEvent * _we )
{
_we->accept();
int dir = ( _we->delta() > 0 ) ? 1 : -1;
int tab = m_activeTab;
while( tab > -1 && static_cast<csize>( tab ) < m_widgets.count() )

View File

@@ -0,0 +1,385 @@
/*
* tempo_sync_knob.h - adds bpm to ms conversion for knob class
*
* This file is derived from the knob-widget by Tobias Doerffel
*
* Linux MultiMedia Studio
* Copyright (c) 2004-2005 Danny McRae <khjklujn@yahoo.com>
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "qt3support.h"
#ifdef QT4
#include <QPainter>
#include <QPalette>
#include <QBitmap>
#include <QLabel>
#include <QStatusBar>
#include <QMouseEvent>
#include <QMenu>
#include <QStatusBar>
#include <QFontMetrics>
#include <QApplication>
#else
#include <qlabel.h>
#include <qpopupmenu.h>
#define addSeparator insertSeparator
#define addMenu insertItem
#endif
#ifndef __USE_XOPEN
#define __USE_XOPEN
#endif
#include "tempo_sync_knob.h"
#include "song_editor.h"
#include "midi_device.h"
#include "embed.h"
#include "tooltip.h"
#include "config_mgr.h"
#include "text_float.h"
const int WHEEL_DELTA = 120;
tempoSyncKnob::tempoSyncKnob( int _knob_num, QWidget * _parent, const QString & _name,
float _scale ) :
knob( _knob_num, _parent, _name ),
m_tempoSyncMode( NO_SYNC ),
m_scale( _scale ),
m_tempoSyncIcon( embed::getIconPixmap( "xclock" ) ),
m_tempoSyncDescription( tr( "Tempo Sync" ) ),
m_tempoLastSyncMode( NO_SYNC )
{
connect( songEditor::inst(), SIGNAL( bpmChanged( int ) ),
this, SLOT( calculateTempoSyncTime( int ) ) );
}
tempoSyncKnob::~tempoSyncKnob()
{
}
void tempoSyncKnob::contextMenuEvent( QContextMenuEvent * )
{
QMenu contextMenu( this );
#ifdef QT4
contextMenu.setTitle( accessibleName() );
#else
QLabel * caption = new QLabel( "<font color=white><b>" +
QString( accessibleName() ) + "</b></font>", this );
caption->setPaletteBackgroundColor( QColor( 0, 0, 192 ) );
caption->setAlignment( Qt::AlignCenter );
contextMenu.addAction( caption );
#endif
contextMenu.addAction( embed::getIconPixmap( "reload" ),
tr( "&Reset (%1%2)" ).arg( m_initValue ).arg(
m_hintTextAfterValue ),
this, SLOT( reset() ) );
contextMenu.addSeparator();
contextMenu.addAction( embed::getIconPixmap( "edit_copy" ),
tr( "&Copy value (%1%2)" ).arg( value() ).arg(
m_hintTextAfterValue ),
this, SLOT( copyValue() ) );
contextMenu.addAction( embed::getIconPixmap( "edit_paste" ),
tr( "&Paste value (%1%2)"
).arg( s_copiedValue ).arg(
m_hintTextAfterValue ),
this, SLOT( pasteValue() ) );
contextMenu.addSeparator();
QMenu * syncMenu = new QMenu( this );
int menuId;
menuId = syncMenu->addAction( embed::getIconPixmap( "note_none" ),
tr( "No Sync" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) NO_SYNC );
menuId = syncMenu->addAction( embed::getIconPixmap( "note_double_whole" ),
tr( "Eight beats" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) DOUBLE_WHOLE_NOTE );
menuId = syncMenu->addAction( embed::getIconPixmap( "note_whole" ),
tr( "Whole note" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) WHOLE_NOTE );
menuId = syncMenu->addAction( embed::getIconPixmap( "note_half" ),
tr( "Half note" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) HALF_NOTE );
menuId = syncMenu->addAction( embed::getIconPixmap( "note_quarter" ),
tr( "Quarter note" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) QUARTER_NOTE );
menuId = syncMenu->addAction( embed::getIconPixmap( "note_eighth" ),
tr( "8th note" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) EIGHTH_NOTE );
menuId = syncMenu->addAction( embed::getIconPixmap( "note_sixteenth" ),
tr( "16th note" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) SIXTEENTH_NOTE );
menuId = syncMenu->addAction( embed::getIconPixmap( "note_thirtysecond" ),
tr( "32nd note" ),
this, SLOT( setTempoSync( int ) ) );
syncMenu->setItemParameter( menuId, ( int ) THIRTYSECOND_NOTE );
contextMenu.addMenu( m_tempoSyncIcon, m_tempoSyncDescription, syncMenu );
contextMenu.addSeparator();
contextMenu.addAction( tr( "Connect to MIDI-device" ), this,
SLOT( connectToMidiDevice() ) );
contextMenu.addSeparator();
contextMenu.addAction( embed::getIconPixmap( "help" ), tr( "&Help" ),
this, SLOT( displayHelp() ) );
contextMenu.exec( QCursor::pos() );
delete syncMenu;
}
void tempoSyncKnob::mouseMoveEvent( QMouseEvent * _me )
{
if( m_scrollMode == ScrMouse )
{
m_tempoSyncMode = NO_SYNC;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
setPosition( _me->pos() );
if( value() != m_prevValue )
{
emit sliderMoved( value() );
}
if( !configManager::inst()->value( "knobs", "classicalusability"
).toInt() )
{
QCursor::setPos( mapToGlobal( m_origMousePos ) );
}
}
songEditor::inst()->setModified();
s_textFloat->setText( m_hintTextBeforeValue +
QString::number( value() ) +
m_hintTextAfterValue );
}
void tempoSyncKnob::wheelEvent( QWheelEvent * _me )
{
_me->accept();
const int inc = _me->delta() / WHEEL_DELTA;
incPages( inc );
m_tempoSyncMode = NO_SYNC;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
songEditor::inst()->setModified();
s_textFloat->reparent( this );
s_textFloat->setText( m_hintTextBeforeValue +
QString::number( value() ) +
m_hintTextAfterValue );
s_textFloat->move( mapTo( topLevelWidget(), QPoint( 0, 0 ) ) +
QPoint( m_knobPixmap->width() + 2, 0 ) );
s_textFloat->setVisibilityTimeOut( 1000 );
toolTip::add( this, m_hintTextBeforeValue+QString::number( value() ) +
m_hintTextAfterValue );
if( value() != m_prevValue )
{
emit sliderMoved( value() );
}
}
void tempoSyncKnob::setTempoSync( int _note_type )
{
m_tempoSyncMode = ( tempoSyncMode ) _note_type;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
songEditor::inst()->setModified();
}
void tempoSyncKnob::calculateTempoSyncTime( int _bpm )
{
float conversionFactor = 1.0;
if( m_tempoSyncMode )
{
switch( m_tempoSyncMode )
{
case DOUBLE_WHOLE_NOTE:
m_tempoSyncDescription = tr( "Synced to Eight Beats" );
m_tempoSyncIcon = embed::getIconPixmap( "note_double_whole" );
conversionFactor = 0.125;
break;
case WHOLE_NOTE:
m_tempoSyncDescription = tr( "Synced to Whole Note" );
m_tempoSyncIcon = embed::getIconPixmap( "note_whole" );
conversionFactor = 0.25;
break;
case HALF_NOTE:
m_tempoSyncDescription = tr( "Synced to Half Note" );
m_tempoSyncIcon = embed::getIconPixmap( "note_half" );
conversionFactor = 0.5;
break;
case QUARTER_NOTE:
m_tempoSyncDescription = tr( "Synced to Quarter Note" );
m_tempoSyncIcon = embed::getIconPixmap( "note_quarter" );
conversionFactor = 1.0;
break;
case EIGHTH_NOTE:
m_tempoSyncDescription = tr( "Synced to 8th Note" );
m_tempoSyncIcon = embed::getIconPixmap( "note_eighth" );
conversionFactor = 2.0;
break;
case SIXTEENTH_NOTE:
m_tempoSyncDescription = tr( "Synced to 16th Note" );
m_tempoSyncIcon = embed::getIconPixmap( "note_sixteenth" );
conversionFactor = 4.0;
break;
case THIRTYSECOND_NOTE:
m_tempoSyncDescription = tr( "Synced to 32nd Note" );
m_tempoSyncIcon = embed::getIconPixmap( "note_thirtysecond" );
conversionFactor = 8.0;
break;
default:
printf( "arpAndChordsTabWidget::calculateTempoSyncTime: invalid tempoSyncMode" );
break;
}
setValue( 60000.0 / ( _bpm * conversionFactor * m_scale ),
FALSE );
}
else
{
m_tempoSyncDescription = tr( "Tempo Sync" );
m_tempoSyncIcon = embed::getIconPixmap( "xclock" );
}
if( m_tempoSyncMode != m_tempoLastSyncMode )
{
emit syncModeChanged( m_tempoSyncMode );
emit syncDescriptionChanged( m_tempoSyncDescription );
emit syncIconChanged();
}
m_tempoLastSyncMode = m_tempoSyncMode;
}
tempoSyncMode tempoSyncKnob::getSyncMode( void )
{
return( m_tempoSyncMode );
}
void tempoSyncKnob::setSyncMode( tempoSyncMode _new_mode )
{
m_tempoSyncMode = _new_mode;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
}
float tempoSyncKnob::getScale( void )
{
return( m_scale );
}
void tempoSyncKnob::setScale( float _new_scale )
{
m_scale = _new_scale;
calculateTempoSyncTime( songEditor::inst()->getBPM() );
emit scaleChanged( _new_scale );
}
const QString & tempoSyncKnob::getSyncDescription( void )
{
return( m_tempoSyncDescription );
}
void tempoSyncKnob::setSyncDescription( const QString & _new_description )
{
m_tempoSyncDescription = _new_description;
emit syncDescriptionChanged( _new_description );
}
const QPixmap & tempoSyncKnob::getSyncIcon( void )
{
return( m_tempoSyncIcon );
}
void tempoSyncKnob::setSyncIcon( const QPixmap & _new_icon )
{
m_tempoSyncIcon = _new_icon;
emit syncIconChanged();
}
#ifndef QT4
#undef addSeparator
#endif
#include "tempo_sync_knob.moc"