Merged my own and Toby's changes from last week.

Modified Files:
 	ChangeLog Makefile.am TODO
 	data/presets/TripleOscillator/Makefile include/base64.h
 	include/config_mgr.h include/file_browser.h
 	include/instrument_track.h include/knob.h include/mixer.h
 	include/mmp.h include/sample_buffer.h include/sample_track.h
 	include/setup_dialog.h include/spc_bg_hndl_widget.h
 	plugins/audio_file_processor/audio_file_processor.cpp
 	plugins/audio_file_processor/audio_file_processor.h
 	plugins/bit_invader/bit_invader.cpp
 	plugins/organic/organic.cpp plugins/organic/organic.h
 	plugins/plucked_string_synth/plucked_string_synth.cpp
 	plugins/triple_oscillator/triple_oscillator.cpp
 	plugins/triple_oscillator/triple_oscillator.h
 	plugins/vestige/lvsl_client.cpp plugins/vestige/vestige.cpp
 	plugins/vibed/impulse_editor.cpp
 	plugins/vibed/nine_button_selector.cpp
 	plugins/vibed/nine_button_selector.h plugins/vibed/vibed.cpp
 	plugins/vibed/vibed.h src/lmms_single_source.cpp
 	src/core/bb_editor.cpp src/core/config_mgr.cpp
 	src/core/file_browser.cpp src/core/main_window.cpp
 	src/core/midi_tab_widget.cpp src/core/mixer.cpp
 	src/core/piano_roll.cpp src/core/setup_dialog.cpp
 	src/core/song_editor.cpp src/core/track.cpp src/lib/mmp.cpp
 	src/lib/sample_buffer.cpp src/tracks/instrument_track.cpp
 	src/tracks/sample_track.cpp src/widgets/fade_button.cpp
 	src/widgets/group_box.cpp src/widgets/lcd_spinbox.cpp
 	src/widgets/project_notes.cpp src/widgets/tab_widget.cpp
 	src/widgets/text_float.cpp src/widgets/tool_button.cpp
 Added Files:
 	data/themes/blue_scene/auto_limit.png
 	data/themes/default/auto_limit.png include/volume_knob.h
 	src/widgets/volume_knob.cpp


git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@131 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Danny McRae
2006-04-17 14:09:06 +00:00
parent 9faabaaf0d
commit 703adaf6a3
55 changed files with 941 additions and 186 deletions

View File

@@ -70,9 +70,10 @@ bbEditor::bbEditor( engine * _engine ) :
m_toolBar->setFixedHeight( 32 );
m_toolBar->move( 0, 0 );
#ifdef QT4
m_toolBar->setAutoFillBackground( TRUE );
QPalette pal;
pal.setBrush( QPalette::Background, QBrush(
embed::getIconPixmap( "toolbar_bg" ) ) );
pal.setBrush( m_toolBar->backgroundRole(),
embed::getIconPixmap( "toolbar_bg" ) );
m_toolBar->setPalette( pal );
#else
m_toolBar->setPaletteBackgroundPixmap( embed::getIconPixmap(

View File

@@ -108,7 +108,7 @@ void mkPath( const QString & _path )
/*
void linkFile( const QString & _src, const QString & _dst )
{
#ifdef QT4
@@ -149,7 +149,7 @@ void copyFile( const QString & _src, const QString & _dst )
}
#endif
}
*/
@@ -596,9 +596,9 @@ void configManager::accept( void )
}
}
mkPath( projectsDir() );
mkPath( samplesDir() );
mkPath( presetsDir() );
mkPath( userProjectsDir() );
mkPath( userSamplesDir() );
mkPath( userPresetsDir() );
/* processFilesRecursively( m_dataDir + "samples/", m_workingDir +
"samples/",
m_samplesCopyRB->isChecked() ?

View File

@@ -170,7 +170,8 @@ void fileBrowser::addItems( const QString & _path )
{
QString cur_file = files[files.size() - i - 1];
if( cur_file[0] != '.' &&
!QFileInfo( _path + "/" + cur_file ).isDir()
QFileInfo( _path + QDir::separator() +
cur_file ).isDir() == FALSE
#ifdef QT4
// TBD
#else
@@ -188,7 +189,8 @@ void fileBrowser::addItems( const QString & _path )
{
QString cur_file = files[files.size() - i - 1];
if( cur_file[0] != '.' &&
QFileInfo( _path + "/" + cur_file ).isDir() )
QFileInfo( _path + QDir::separator() +
cur_file ).isDir() )
{
QListViewItem * item = m_l->findItem( cur_file, 0 );
if( item == NULL )
@@ -744,13 +746,13 @@ bool directory::addItems( const QString & _path )
QString cur_file = files[files.size() - i - 1];
#ifdef QT4
if( cur_file[0] != '.' && !QFileInfo(
thisDir.absolutePath() + "/" +
thisDir.absolutePath() + QDir::separator() +
cur_file ).isDir() &&
thisDir.match( m_filter, cur_file.toLower() )
/*QDir::match( FILE_FILTER, cur_file )*/ )
#else
if( cur_file[0] != '.' && !QFileInfo(
thisDir.absPath() + "/" +
thisDir.absPath() + QDir::separator() +
cur_file ).isDir() &&
thisDir.match( m_filter, cur_file.lower() )
/*QDir::match( FILE_FILTER, cur_file )*/ )
@@ -766,11 +768,11 @@ bool directory::addItems( const QString & _path )
QString cur_file = files[files.size() - i - 1];
#ifdef QT4
if( cur_file[0] != '.' && QFileInfo(
thisDir.absolutePath() + "/" +
thisDir.absolutePath() + QDir::separator() +
cur_file ).isDir() )
#else
if( cur_file[0] != '.' && QFileInfo(
thisDir.absPath() + "/" +
thisDir.absPath() + QDir::separator() +
cur_file ).isDir() )
#endif
{

View File

@@ -126,26 +126,26 @@ mainWindow::mainWindow( engine * _engine ) :
int id = 0;
QString wdir = configManager::inst()->workingDir();
side_bar->appendTab( new pluginBrowser( splitter, eng() ), ++id );
side_bar->appendTab( new fileBrowser( configManager::inst()->dataDir()+
PROJECTS_PATH + "*" +
wdir+PROJECTS_PATH,
side_bar->appendTab( new fileBrowser(
configManager::inst()->factoryProjectsDir() + "*" +
configManager::inst()->userProjectsDir(),
"*.mmp *.xml *.mid *.flp",
tr( "My projects" ),
embed::getIconPixmap( "project_file" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( configManager::inst()->dataDir()+
SAMPLES_PATH + "*" +
wdir+SAMPLES_PATH,
side_bar->appendTab( new fileBrowser(
configManager::inst()->factorySamplesDir() + "*" +
configManager::inst()->userSamplesDir(),
"*.wav *.ogg *.au"
"*.voc *.aif *.aiff *.flac *.raw",
tr( "My samples" ),
embed::getIconPixmap( "sound_file" ),
splitter, eng() ),
++id );
side_bar->appendTab( new fileBrowser( configManager::inst()->dataDir()+
PRESETS_PATH + "*" +
wdir+PRESETS_PATH,
side_bar->appendTab( new fileBrowser(
configManager::inst()->factoryPresetsDir() + "*" +
configManager::inst()->userPresetsDir(),
"*.cs.xml", tr( "My presets" ),
embed::getIconPixmap( "preset_file" ),
splitter, eng() ),
@@ -184,9 +184,10 @@ mainWindow::mainWindow( engine * _engine ) :
m_toolBar->setFixedHeight( 64 );
m_toolBar->move( 0, 0 );
#ifdef QT4
m_toolBar->setAutoFillBackground( TRUE );
QPalette pal;
pal.setBrush( m_toolBar->backgroundRole(), QBrush(
embed::getIconPixmap( "main_toolbar_bg" ) ) );
pal.setBrush( m_toolBar->backgroundRole(),
embed::getIconPixmap( "main_toolbar_bg" ) );
m_toolBar->setPalette( pal );
#else
m_toolBar->setPaletteBackgroundPixmap(
@@ -264,7 +265,7 @@ void mainWindow::finalize( void )
this, SLOT( createNewProject() ),
m_toolBar );
QDir d( configManager::inst()->projectsDir() + "templates" );
QDir d( configManager::inst()->factoryProjectsDir() + "templates" );
QStringList templates = d.entryList(
#ifdef QT4
QStringList( "*.mpt" ),
@@ -668,7 +669,8 @@ void mainWindow::createNewProjectFromTemplate( int _idx )
eng()->getSongEditor()->mayChangeProject() == TRUE )
{
eng()->getSongEditor()->createNewProjectFromTemplate(
configManager::inst()->projectsDir() + "templates/" +
configManager::inst()->factoryProjectsDir() +
"templates/" +
m_templatesMenu->text( _idx ) + ".mpt" );
}
#endif
@@ -690,7 +692,7 @@ void mainWindow::openProject( void )
this, "", TRUE );
ofd.setWindowTitle( tr( "Open project" ) );
#endif
ofd.setDirectory( configManager::inst()->projectsDir() );
ofd.setDirectory( configManager::inst()->userProjectsDir() );
ofd.setFileMode( QFileDialog::ExistingFiles );
if( ofd.exec () == QDialog::Accepted &&
!ofd.selectedFiles().isEmpty() )
@@ -746,7 +748,7 @@ bool mainWindow::saveProjectAs( void )
}
else
{
sfd.setDirectory( configManager::inst()->projectsDir() );
sfd.setDirectory( configManager::inst()->userProjectsDir() );
}
if( sfd.exec () == QFileDialog::Accepted &&

View File

@@ -310,6 +310,7 @@ void midiTabWidget::loadSettings( const QDomElement & _this )
if( ( *it )->isChecked() !=
( rp.indexOf( ( *it )->text() ) != -1 ) )
{
( *it )->setChecked( TRUE );
activatedReadablePort( *it );
}
}
@@ -340,6 +341,7 @@ void midiTabWidget::loadSettings( const QDomElement & _this )
if( ( *it )->isChecked() !=
( wp.indexOf( ( *it )->text() ) != -1 ) )
{
( *it )->setChecked( TRUE );
activatedWriteablePort( *it );
}
}
@@ -418,6 +420,7 @@ void midiTabWidget::midiPortModeToggled( bool )
{
if( ( *it )->isChecked() == TRUE )
{
( *it )->setChecked( FALSE );
activatedReadablePort( *it );
}
}
@@ -441,6 +444,7 @@ void midiTabWidget::midiPortModeToggled( bool )
{
if( ( *it )->isChecked() == TRUE )
{
( *it )->setChecked( FALSE );
activatedWriteablePort( *it );
}
}
@@ -494,6 +498,7 @@ void midiTabWidget::readablePortsChanged( void )
{
#ifdef QT4
QAction * item = m_readablePorts->addAction( *it );
item->setCheckable( TRUE );
if( selected_ports.indexOf( *it ) != -1 )
{
item->setChecked( TRUE );
@@ -545,6 +550,7 @@ void midiTabWidget::writeablePortsChanged( void )
{
#ifdef QT4
QAction * item = m_writeablePorts->addAction( *it );
item->setCheckable( TRUE );
if( selected_ports.indexOf( *it ) != -1 )
{
item->setChecked( TRUE );
@@ -566,13 +572,12 @@ void midiTabWidget::writeablePortsChanged( void )
void midiTabWidget::activatedReadablePort( QAction * _item )
{
// make sure, MIDI-port is configured for input
if( _item->isChecked() == FALSE &&
if( _item->isChecked() == TRUE &&
m_midiPort->mode() != midiPort::INPUT &&
m_midiPort->mode() != midiPort::DUPLEX )
{
m_receiveCheckBox->setChecked( TRUE );
}
_item->setChecked( !_item->isChecked() );
eng()->getMixer()->getMIDIClient()->subscribeReadablePort( m_midiPort,
_item->text(), !_item->isChecked() );
}
@@ -583,13 +588,12 @@ void midiTabWidget::activatedReadablePort( QAction * _item )
void midiTabWidget::activatedWriteablePort( QAction * _item )
{
// make sure, MIDI-port is configured for output
if( _item->isChecked() == FALSE &&
if( _item->isChecked() == TRUE &&
m_midiPort->mode() != midiPort::OUTPUT &&
m_midiPort->mode() != midiPort::DUPLEX )
{
m_sendCheckBox->setChecked( TRUE );
}
_item->setChecked( !_item->isChecked() );
eng()->getMixer()->getMIDIClient()->subscribeWriteablePort( m_midiPort,
_item->text(), !_item->isChecked() );
}

View File

@@ -63,8 +63,8 @@ mixer::mixer( engine * _engine ) :
QObject(),
engineObject( _engine ),
m_framesPerAudioBuffer( DEFAULT_BUFFER_SIZE ),
m_curBuf( NULL ),
m_nextBuf( NULL ),
m_readBuf( NULL ),
m_writeBuf( NULL ),
m_cpuLoad( 0 ),
m_qualityLevel( DEFAULT_QUALITY_LEVEL ),
m_masterGain( 1.0f ),
@@ -86,15 +86,16 @@ mixer::mixer( engine * _engine ) :
QString::number( m_framesPerAudioBuffer ) );
}
m_curBuf = bufferAllocator::alloc<surroundSampleFrame>(
m_framesPerAudioBuffer );
m_nextBuf = bufferAllocator::alloc<surroundSampleFrame>(
m_framesPerAudioBuffer );
// now clear our two output-buffers before using them...
clearAudioBuffer( m_curBuf, m_framesPerAudioBuffer );
clearAudioBuffer( m_nextBuf, m_framesPerAudioBuffer );
for( Uint8 i = 0; i < 3; i++ )
{
m_readBuf = bufferAllocator::alloc<surroundSampleFrame>(
m_framesPerAudioBuffer );
clearAudioBuffer( m_readBuf, m_framesPerAudioBuffer );
m_bufferPool.push_back( m_readBuf );
}
setClipScaling( FALSE );
}
@@ -105,8 +106,10 @@ mixer::~mixer()
delete m_audioDev;
delete m_midiClient;
bufferAllocator::free( m_curBuf );
bufferAllocator::free( m_nextBuf );
for( Uint8 i = 0; i < 3; i++ )
{
bufferAllocator::free( m_bufferPool[i] );
}
}
@@ -146,6 +149,47 @@ bool mixer::criticalXRuns( void ) const
void mixer::setClipScaling( bool _state )
{
m_mixMutex.lock();
m_scaleClip = _state;
if( _state )
{
m_poolDepth = 3;
m_readBuffer = 0;
m_analBuffer = m_readBuffer + 1;
m_writeBuffer = m_poolDepth - 1;
for( ch_cnt_t chnl=0; chnl < m_audioDev->channels(); ++chnl )
{
m_clipped[chnl] = FALSE;
m_halfStart[chnl] = m_framesPerAudioBuffer;
m_maxClip[chnl] = 1.0f;
m_previousSample[chnl] = 0.0;
m_newBuffer[chnl] = FALSE;
}
for( Uint8 i = 0; i < 3; i++ )
{
m_readBuf = m_bufferPool[i];
clearAudioBuffer( m_readBuf, m_framesPerAudioBuffer );
}
}
else
{
m_poolDepth = 2;
m_readBuffer = 0;
m_writeBuffer = 1;
m_analBuffer = 1;
}
m_mixMutex.unlock();
}
const surroundSampleFrame * mixer::renderNextBuffer( void )
{
microTimer timer;
@@ -190,10 +234,21 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
// now swap the buffers... current buffer becomes next (last)
// buffer and the next buffer becomes current (first) buffer
qSwap( m_curBuf, m_nextBuf );
// qSwap( m_curBuf, m_nextBuf );
m_writeBuffer++;
m_writeBuffer %= m_poolDepth;
m_readBuffer++;
m_readBuffer %= m_poolDepth;
m_analBuffer++;
m_analBuffer %= m_poolDepth;
m_writeBuf = m_bufferPool[m_writeBuffer];
m_readBuf = m_bufferPool[m_readBuffer];
// clear last audio-buffer
clearAudioBuffer( m_curBuf, m_framesPerAudioBuffer );
clearAudioBuffer( m_writeBuf, m_framesPerAudioBuffer );
// if( criticalXRuns() == FALSE )
{
@@ -223,19 +278,19 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
{
if( ( *it )->m_bufferUsage != audioPort::NONE )
{
processBuffer( ( *it )->firstBuffer(),
( *it )->nextFxChannel() );
processBuffer(
( *it )->firstBuffer(),
( *it )->nextFxChannel() );
( *it )->nextPeriod();
}
}
}
emit nextAudioBuffer( m_curBuf, m_framesPerAudioBuffer );
emit nextAudioBuffer( m_readBuf, m_framesPerAudioBuffer );
m_mixMutex.unlock();
// and trigger LFOs
envelopeAndLFOWidget::triggerLFO( eng() );
@@ -244,7 +299,7 @@ const surroundSampleFrame * mixer::renderNextBuffer( void )
m_cpuLoad = tLimit( (int) ( new_cpu_load * 0.1f + m_cpuLoad * 0.9f ), 0,
100 );
return( m_curBuf );
return( m_readBuf );
}
@@ -303,7 +358,7 @@ void FASTCALL mixer::bufferToPort( const sampleFrame * _buf,
for( fpab_t frame = start_frame; frame < loop1_frame; ++frame )
{
for( ch_cnt_t chnl = 0; chnl < SURROUND_CHANNELS; ++chnl )
for( ch_cnt_t chnl = 0; chnl < m_audioDev->channels(); ++chnl )
{
_port->firstBuffer()[frame][chnl] +=
_buf[frame - start_frame][chnl %
@@ -319,7 +374,7 @@ void FASTCALL mixer::bufferToPort( const sampleFrame * _buf,
m_framesPerAudioBuffer );
for( fpab_t frame = 0; frame < end_frame; ++frame )
{
for( ch_cnt_t chnl = 0; chnl < SURROUND_CHANNELS;
for( ch_cnt_t chnl = 0; chnl < m_audioDev->channels();
++chnl )
{
_port->secondBuffer()[frame][chnl] +=
@@ -569,13 +624,93 @@ void mixer::processBuffer( const surroundSampleFrame * _buf,
fx_ch_t/* _fx_chnl */ )
{
// TODO: effect-implementation
for( fpab_t frame = 0; frame < m_framesPerAudioBuffer; ++frame )
if( m_scaleClip )
{
for( ch_cnt_t chnl = 0; chnl < SURROUND_CHANNELS; ++chnl )
for( ch_cnt_t chnl=0;
chnl < m_audioDev->channels();
++chnl )
{
m_curBuf[frame][chnl] += _buf[frame][chnl];
m_newBuffer[chnl] = TRUE;
}
}
for( fpab_t frame = 0; frame < m_framesPerAudioBuffer; ++frame )
{
for( ch_cnt_t chnl = 0; chnl < m_audioDev->channels(); ++chnl )
{
m_writeBuf[frame][chnl] += _buf[frame][chnl];
if( m_scaleClip )
{
scaleClip( frame, chnl );
}
}
}
}
void FASTCALL mixer::scaleClip( fpab_t _frame, ch_cnt_t _chnl )
{
// Check for zero crossing
if( ( m_writeBuf[_frame][_chnl] >=0 &&
m_previousSample[_chnl] < 0 ) ||
( m_writeBuf[_frame][_chnl] <=0 &&
m_previousSample[_chnl] > 0 ) )
{
// if a clip occurred between the zero
// crossings, scale the half-wave
if( m_clipped[_chnl] )
{
if( m_newBuffer[_chnl] )
{
for( fpab_t i = m_halfStart[_chnl];
i < m_framesPerAudioBuffer;
i++ )
{
m_bufferPool[m_analBuffer][i][_chnl] /=
m_maxClip[_chnl];
}
for( fpab_t i = 0;
i < _frame;
i++ )
{
m_writeBuf[i][_chnl] /=
m_maxClip[_chnl];
}
}
else
{
for( fpab_t i = m_halfStart[_chnl];
i < _frame;
i++ )
{
m_writeBuf[i][_chnl] /= m_maxClip[_chnl];
}
}
}
m_halfStart[_chnl] = _frame;
m_clipped[_chnl] = FALSE;
m_newBuffer[_chnl] = FALSE;
m_maxClip[_chnl] = 1.0;
}
// check for clip
if( fabs( m_writeBuf[_frame][_chnl] ) > 1.0f )
{
m_clipped[_chnl] = TRUE;
if( fabs( m_writeBuf[_frame][_chnl] ) >
m_maxClip[_chnl] )
{
m_maxClip[_chnl] = fabs(
m_writeBuf[_frame][_chnl] );
}
}
m_previousSample[_chnl] = m_writeBuf[_frame][_chnl];
}

View File

@@ -209,9 +209,10 @@ pianoRoll::pianoRoll( engine * _engine ) :
m_toolBar->setFixedHeight( 32 );
m_toolBar->move( 0, 0 );
#ifdef QT4
m_toolBar->setAutoFillBackground( TRUE );
QPalette pal;
pal.setBrush( m_toolBar->backgroundRole(), QBrush(
embed::getIconPixmap( "toolbar_bg" ) ) );
pal.setBrush( m_toolBar->backgroundRole(),
embed::getIconPixmap( "toolbar_bg" ) );
m_toolBar->setPalette( pal );
#else
m_toolBar->setPaletteBackgroundPixmap( embed::getIconPixmap(

View File

@@ -111,6 +111,8 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
m_noWizard( configManager::inst()->value( "app", "nowizard" ).toInt() ),
m_noMsgAfterSetup( configManager::inst()->value( "app",
"nomsgaftersetup" ).toInt() ),
m_displaydBV( configManager::inst()->value( "app",
"displaydbv" ).toInt() ),
m_workingDir( configManager::inst()->workingDir() ),
m_vstDir( configManager::inst()->vstDir() ),
m_artworkDir( configManager::inst()->artworkDir() ),
@@ -187,7 +189,7 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
tabWidget * misc_tw = new tabWidget( tr( "MISC" ), general );
misc_tw->setFixedHeight( 110 );
misc_tw->setFixedHeight( 128 );
ledCheckBox * disable_tooltips = new ledCheckBox(
tr( "Disable tooltips (no spurious "
@@ -238,6 +240,14 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
this, SLOT( toggleNoMsgAfterSetup( bool ) ) );
ledCheckBox * dbv = new ledCheckBox(
tr( "Display volume as dbV " ),
misc_tw, eng() );
dbv->move( 10, 108 );
dbv->setChecked( m_displaydBV );
connect( dbv, SIGNAL( toggled( bool ) ),
this, SLOT( toggleDisplaydBV( bool ) ) );
gen_layout->addWidget( bufsize_tw );
gen_layout->addSpacing( 10 );
gen_layout->addWidget( misc_tw );
@@ -635,6 +645,8 @@ void setupDialog::accept( void )
QString::number( m_noWizard ) );
configManager::inst()->setValue( "app", "nomsgaftersetup",
QString::number( m_noMsgAfterSetup ) );
configManager::inst()->setValue( "app", "displaydbv",
QString::number( m_displaydBV ) );
configManager::inst()->setValue( "ui",
"disablechannelactivityindicators",
QString::number( m_disableChActInd ) );
@@ -768,6 +780,14 @@ void setupDialog::toggleNoMsgAfterSetup( bool _enabled )
void setupDialog::toggleDisplaydBV( bool _enabled )
{
m_displaydBV = _enabled;
}
void setupDialog::toggleDisableChActInd( bool _disabled )
{
m_disableChActInd = _disabled;

View File

@@ -190,6 +190,16 @@ songEditor::songEditor( engine * _engine ) :
eng()->getMainWindow()->addWidgetToToolBar( hq_btn, 1, col );
toolButton * cp_btn = new toolButton( embed::getIconPixmap( "auto_limit" ),
tr( "Auto limiter" ),
NULL, NULL, tb );
cp_btn->setCheckable( TRUE );
connect( cp_btn, SIGNAL( toggled( bool ) ), eng()->getMixer(),
SLOT( setClipScaling( bool ) ) );
cp_btn->setFixedWidth( 30 );
eng()->getMainWindow()->addWidgetToToolBar( cp_btn, 1, col + 1 );
eng()->getMainWindow()->addSpacingToToolBar( 10 );
@@ -286,9 +296,10 @@ songEditor::songEditor( engine * _engine ) :
m_toolBar->setFixedHeight( 32 );
m_toolBar->move( 0, 0 );
#ifdef QT4
m_toolBar->setAutoFillBackground( TRUE );
QPalette pal;
pal.setBrush( m_toolBar->backgroundRole(), QBrush(
embed::getIconPixmap( "toolbar_bg" ) ) );
pal.setBrush( m_toolBar->backgroundRole(),
embed::getIconPixmap( "toolbar_bg" ) );
m_toolBar->setPalette( pal );
#else
m_toolBar->setPaletteBackgroundPixmap( embed::getIconPixmap(
@@ -1629,7 +1640,7 @@ void songEditor::importProject( void )
this, "", TRUE );
ofd.setWindowTitle( tr( "Import file" ) );
#endif
ofd.setDirectory( configManager::inst()->projectsDir() );
ofd.setDirectory( configManager::inst()->userProjectsDir() );
ofd.setFileMode( QFileDialog::ExistingFiles );
if( ofd.exec () == QDialog::Accepted && !ofd.selectedFiles().isEmpty() )
{

View File

@@ -576,6 +576,7 @@ trackContentWidget::trackContentWidget( trackWidget * _parent ) :
m_trackWidget( _parent )
{
#ifdef QT4
setAutoFillBackground( TRUE );
QPalette pal;
pal.setColor( backgroundRole(), QColor( 96, 96, 96 ) );
setPalette( pal );
@@ -1151,6 +1152,7 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) :
m_action( NONE )
{
#ifdef QT4
m_trackOperationsWidget.setAutoFillBackground( TRUE );
QPalette pal;
pal.setColor( m_trackOperationsWidget.backgroundRole(),
QColor( 128, 128, 128 ) );
@@ -1163,6 +1165,7 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) :
#ifdef QT4
m_trackSettingsWidget.setAutoFillBackground( TRUE );
pal.setColor( m_trackSettingsWidget.backgroundRole(),
QColor( 64, 64, 64 ) );
m_trackSettingsWidget.setPalette( pal );

View File

@@ -186,11 +186,7 @@ multimediaProject::~multimediaProject()
bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
{
QString xml = "<?xml version=\"1.0\"?>\n" + toString(
#if QT_VERSION >= 0x030100
2
#endif
);
bool clean_meta_nodes = FALSE;
QString fn = _fn;
if( type() == INSTRUMENT_TRACK_SETTINGS )
{
@@ -198,6 +194,7 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
{
fn += ".cs.xml";
}
clean_meta_nodes = TRUE;
}
else if( type() == SONG_PROJECT )
{
@@ -206,6 +203,7 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
{
fn += ".mmp";
}
clean_meta_nodes = TRUE;
}
else if( type() == SONG_PROJECT_TEMPLATE )
{
@@ -213,6 +211,12 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
{
fn += ".mpt";
}
clean_meta_nodes = TRUE;
}
if( clean_meta_nodes == TRUE )
{
cleanMetaNodes( documentElement() );
}
@@ -257,6 +261,11 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
).arg( fn ) );
return( FALSE );
}
QString xml = "<?xml version=\"1.0\"?>\n" + toString(
#if QT_VERSION >= 0x030100
2
#endif
);
#ifdef QT4
outfile.write( xml.toAscii().constData(), xml.length() );
#else
@@ -315,4 +324,31 @@ QString multimediaProject::typeName( projectTypes _project_type )
}
void multimediaProject::cleanMetaNodes( QDomElement _de )
{
QDomNode node = _de.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
{
if( node.toElement().attribute( "metadata" ).toInt() )
{
QDomNode ns = node.nextSibling();
_de.removeChild( node );
node = ns;
continue;
}
if( node.hasChildNodes() )
{
cleanMetaNodes( node.toElement() );
}
}
node = node.nextSibling();
}
}
#endif

View File

@@ -250,7 +250,12 @@ void sampleBuffer::update( bool _keep_settings )
// name
if( file[0] != '/' )
{
file = configManager::inst()->samplesDir() + file;
file = configManager::inst()->userSamplesDir() + file;
if( QFileInfo( file ).exists() == FALSE )
{
file =
configManager::inst()->factorySamplesDir() + m_audioFile;
}
}
const char * f =
#ifdef QT4
@@ -970,7 +975,12 @@ QString sampleBuffer::openAudioFile( void ) const
QString f = m_audioFile;
if( QFileInfo( f ).isRelative() )
{
f = configManager::inst()->samplesDir() + f;
f = configManager::inst()->userSamplesDir() + f;
if( QFileInfo( f ).exists() == FALSE )
{
f = configManager::inst()->factorySamplesDir() +
m_audioFile;
}
}
#ifdef QT4
dir = QFileInfo( f ).absolutePath();
@@ -980,7 +990,7 @@ QString sampleBuffer::openAudioFile( void ) const
}
else
{
dir = configManager::inst()->samplesDir();
dir = configManager::inst()->userSamplesDir();
}
// change dir to position of previously opened file
ofd.setDirectory( dir );
@@ -1031,19 +1041,7 @@ QString sampleBuffer::openAudioFile( void ) const
{
return( "" );
}
QString sf = ofd.selectedFiles()[0];
if( !QFileInfo( sf ).isRelative() )
{
#if QT_VERSION >= 0x030100
sf = sf.replace( configManager::inst()->samplesDir(),
"" );
#else
sf = sf.replace( QRegExp(
configManager::inst()->samplesDir() ),
"" );
#endif
}
return( sf );
return( tryToMakeRelative( ofd.selectedFiles()[0] ) );
}
return( "" );
@@ -1228,20 +1226,7 @@ sampleBuffer * sampleBuffer::resample( sampleFrame * _data,
void sampleBuffer::setAudioFile( const QString & _audio_file )
{
m_audioFile = _audio_file;
// try to make path of audio-file relative if it's posated
// within LMMS-working-dir
if( !QFileInfo( m_audioFile ).isRelative() )
{
#if QT_VERSION >= 0x030100
m_audioFile = m_audioFile.replace(
configManager::inst()->samplesDir(), "" );
#else
m_audioFile = m_audioFile.replace(
QRegExp( configManager::inst()->samplesDir() ),
"" );
#endif
}
m_audioFile = tryToMakeRelative( _audio_file );
update();
}
@@ -1470,6 +1455,28 @@ void sampleBuffer::deleteResamplingData( void * * _ptr )
}
QString sampleBuffer::tryToMakeRelative( const QString & _file )
{
if( QFileInfo( _file ).isRelative() == FALSE )
{
QString fsd = configManager::inst()->factorySamplesDir();
QString usd = configManager::inst()->userSamplesDir();
if( _file.contains( fsd ) )
{
return( QString( _file ).replace( fsd, "" ) );
}
else if( _file.contains( usd ) )
{
return( QString( _file ).replace( usd, "" ) );
}
}
return( _file );
}
#undef write
#undef read
#undef pos

View File

@@ -85,4 +85,5 @@
#include "src/widgets/nstate_button.cpp"
#include "src/widgets/lcd_spinbox.cpp"
#include "src/widgets/automatable_button.cpp"
#include "src/widgets/volume_knob.cpp"
#endif

View File

@@ -73,7 +73,6 @@
#include "note_play_handle.h"
#include "embed.h"
#include "fade_button.h"
#include "knob.h"
#include "lcd_spinbox.h"
#include "led_checkbox.h"
#include "piano_widget.h"
@@ -85,6 +84,7 @@
#include "debug.h"
#include "mmp.h"
#include "string_pair_drag.h"
#include "volume_knob.h"
const char * volume_help = QT_TRANSLATE_NOOP( "instrumentTrack",
@@ -148,7 +148,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
// creation of widgets for track-settings-widget
m_tswVolumeKnob = new knob( knobSmall_17, getTrackSettingsWidget(),
m_tswVolumeKnob = new volumeKnob( knobSmall_17, getTrackSettingsWidget(),
tr( "Channel volume" ), eng() );
m_tswVolumeKnob->setRange( MIN_VOLUME, MAX_VOLUME, 1.0f );
m_tswVolumeKnob->setInitValue( DEFAULT_VOLUME );
@@ -219,7 +219,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
// setup volume-knob
m_volumeKnob = new knob( knobBright_26, m_generalSettingsWidget,
m_volumeKnob = new volumeKnob( knobBright_26, m_generalSettingsWidget,
tr( "Channel volume" ), eng() );
m_volumeKnob->move( 10, 44 );
m_volumeKnob->setRange( MIN_VOLUME, MAX_VOLUME, 1.0f );
@@ -235,7 +235,7 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
tr( volume_help ) );
/* connect( m_volumeKnob, SIGNAL( valueChanged( float ) ), this,
SLOT( volValueChanged( float ) ) );*/
knob::linkObjects( m_tswVolumeKnob, m_volumeKnob );
volumeKnob::linkObjects( m_tswVolumeKnob, m_volumeKnob );
// setup surround-area
@@ -362,6 +362,10 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) :
_tc->updateAfterTrackAdd();
#ifndef QT3
setFixedWidth( CHANNEL_WIDTH );
resize( sizeHint() );
#endif
}
@@ -393,7 +397,7 @@ void instrumentTrack::saveSettingsBtnClicked( void )
sfd.setFilter( tr( "Channel-Settings-File (*.cs.xml)" ) );
#endif
QString preset_root = configManager::inst()->presetsDir();
QString preset_root = configManager::inst()->userPresetsDir();
if( !QDir( preset_root ).exists() )
{
QDir().mkdir( preset_root );

View File

@@ -372,7 +372,7 @@ sampleTrack::sampleTrack( trackContainer * _tc ) :
m_trackLabel->setGeometry( 26, 1, DEFAULT_SETTINGS_WIDGET_WIDTH-2, 29 );
m_trackLabel->show();
m_volumeKnob = new knob( knobSmall_17, getTrackSettingsWidget(),
m_volumeKnob = new volumeKnob( knobSmall_17, getTrackSettingsWidget(),
tr( "Channel volume" ), eng() );
m_volumeKnob->setRange( MIN_VOLUME, MAX_VOLUME, 1.0f );
m_volumeKnob->setInitValue( DEFAULT_VOLUME );

View File

@@ -116,7 +116,11 @@ void fadeButton::paintEvent( QPaintEvent * _pe )
QPainter p( &draw_pm, this );
#endif
p.setPen( QColor( 0, 0, 0 ) );
#ifndef QT3
p.drawRect( 0, 0, rect().right(), rect().bottom() );
#else
p.drawRect( rect() );
#endif
#ifndef QT4
// and blit all the drawn stuff on the screen...
bitBlt( this, rect().topLeft(), &draw_pm );

View File

@@ -65,6 +65,10 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent,
m_origHeight( height() ),
m_animating( FALSE )
{
#ifndef QT3
setAutoFillBackground( TRUE );
#endif
if( s_ledBg == NULL )
{
s_ledBg = new QPixmap( embed::getIconPixmap(
@@ -193,9 +197,11 @@ void groupBox::animate( void )
void groupBox::updatePixmap( void )
{
#ifndef QT3
const int c = 0;
QColor bg_color = QApplication::palette().color( QPalette::Active,
QPalette::Background );
#else
const int c = 1;
QColor bg_color = QApplication::palette().active().background();
#endif
QPixmap pm( size() );
@@ -205,7 +211,7 @@ void groupBox::updatePixmap( void )
// outer rect
p.setPen( bg_color.dark( 200 ) );
p.drawRect( 0, 0, width(), height() );
p.drawRect( 0, 0, width() - 1 + c, height() - 1 + c );
// brighter line at bottom/right
p.setPen( bg_color.light( 125 ) );
@@ -223,7 +229,7 @@ void groupBox::updatePixmap( void )
p.drawLine( 2 + s_ledBg->width(), 11, width() - 3, 11 );
// black inner rect
p.drawRect( 1, 1, width() - 2, height() - 2 );
p.drawRect( 1, 1, width() - 3 + c, height() - 3 + c );
//p.setPen( QColor( 255, 255, 255 ) );
@@ -238,7 +244,6 @@ void groupBox::updatePixmap( void )
#ifdef QT4
QPalette pal = palette();
pal.setBrush( backgroundRole(), QBrush( pm ) );
/* pal.setColor( QPalette::Background, QColor( 96, 96, 96 ) );*/
setPalette( pal );
#else
setPaletteBackgroundColor( bg_color.dark( 132 ) );

View File

@@ -59,6 +59,15 @@ lcdSpinBox::lcdSpinBox( int _min, int _max, int _num_digits,
m_number->setFrameShape( QFrame::Panel );
m_number->setFrameShadow( QFrame::Sunken );
m_number->setSegmentStyle( QLCDNumber::Flat );
#ifndef QT3
QPalette pal;
pal.setColor( QPalette::Light, Qt::gray );
pal.setColor( QPalette::Mid, Qt::darkGray );
pal.setColor( QPalette::Dark, Qt::black );
pal.setColor( m_number->backgroundRole(), Qt::black );
m_number->setPalette( pal );
m_number->setAutoFillBackground( TRUE );
#endif
setEnabled( TRUE );
// value is automatically limited to given range

View File

@@ -87,6 +87,7 @@ projectNotes::projectNotes( engine * _engine) :
m_edit = new QTextEdit( this );
#ifdef QT4
m_edit->setAutoFillBackground( TRUE );
QPalette pal;
pal.setColor( m_edit->backgroundRole(), QColor( 64, 64, 64 ) );
m_edit->setPalette( pal );

View File

@@ -63,6 +63,7 @@ tabWidget::tabWidget( const QString & _caption, QWidget * _parent ) :
setBackgroundMode( Qt::NoBackground );
#endif*/
#ifndef QT3
setAutoFillBackground( TRUE );
QColor bg_color = QApplication::palette().color( QPalette::Active,
QPalette::Background ).
dark( 132 );
@@ -98,7 +99,7 @@ void tabWidget::addTab( QWidget * _w, const QString & _name, int _idx )
m_widgets[_idx] = d;
_w->setFixedSize( width() - 4, height() - 14 );
_w->move( 2, 12 );
_w->show();
_w->hide();
if( m_widgets.contains( m_activeTab ) )
{
@@ -171,24 +172,27 @@ void tabWidget::paintEvent( QPaintEvent * _pe )
{
#ifdef QT4
QPainter p( this );
p.fillRect( 0, 0, width() - 1, height() - 1, QColor( 96, 96, 96 ) );
const int c = 0;
#else
QPixmap pm( size() );
pm.fill( QColor( 96, 96, 96 ) );
QPainter p( &pm );
const int c = 1;
#endif
bool big_tab_captions = ( m_caption == "" );
int add = big_tab_captions ? 1 : 0;
p.setPen( QColor( 64, 64, 64 ) );
p.drawRect( 0, 0, width(), height() );
p.drawRect( 0, 0, width() - 1 + c, height() - 1 + c );
p.setPen( QColor( 160, 160, 160 ) );
p.drawLine( width() - 1, 0, width() - 1, height() - 1 );
p.drawLine( 0, height() - 1, width() - 1, height() - 1 );
p.setPen( QColor( 0, 0, 0 ) );
p.drawRect( 1, 1, width() - 2, height() - 2 );
p.drawRect( 1, 1, width() - 3 + c, height() - 3 + c );
p.fillRect( 2, 2, width() - 4, 9 + add, QColor( 30, 45, 60 ) );
p.drawLine( 2, 11 + add, width() - 3, 11 + add );

View File

@@ -45,6 +45,7 @@
#include "text_float.h"
#include "gui_templates.h"
#include "main_window.h"
@@ -153,6 +154,16 @@ textFloat * textFloat::displayMessage( const QString & _msg, int _timeout,
{
#ifdef QT4
QWidget * mw = QApplication::activeWindow();
if( mw == NULL )
{
foreach( QWidget * w, QApplication::topLevelWidgets() )
{
if( mw == NULL || dynamic_cast<mainWindow *>( w ) )
{
mw = w;
}
}
}
#else
QWidget * mw = qApp->mainWidget();
if( mw == NULL )
@@ -215,7 +226,11 @@ void textFloat::paintEvent( QPaintEvent * _pe )
p.setFont( pointSize<8>( p.font() ) );
#ifndef QT3
p.drawRect( 0, 0, rect().right(), rect().bottom() );
#else
p.drawRect( rect() );
#endif
// p.setPen( Qt::black );
// small message?

View File

@@ -42,6 +42,9 @@ toolButton::toolButton( const QPixmap & _pixmap, const QString & _tooltip,
m_colorStandard( s_stdColor ),
m_colorHighlighted( s_hlColor )
{
#ifndef QT3
setAutoFillBackground( TRUE );
#endif
if( _receiver != NULL && _slot != NULL )
{
connect( this, SIGNAL( clicked() ), _receiver, _slot );

229
src/widgets/volume_knob.cpp Normal file
View File

@@ -0,0 +1,229 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* volume_knob.cpp - defines a knob that display it's value as either a
* percentage or in dbV.
*
* Copyright (c) 2006 Danny McRae <khjklujn/at/users.sourceforge.net>
*
* 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include <math.h>
#include "volume_knob.h"
volumeKnob::volumeKnob( int _knob_num, QWidget * _parent, const QString & _name,
engine * _engine ):
knob( _knob_num, _parent, _name, _engine )
{
}
volumeKnob::~volumeKnob()
{
}
//! Mouse press event handler
void volumeKnob::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton &&
eng()->getMainWindow()->isCtrlPressed() == FALSE )
{
setJournalling( FALSE );
m_oldValue = value();
const QPoint & p = _me->pos();
m_origMousePos = p;
if( configManager::inst()->value( "knobs",
"classicalusability").toInt() )
{
m_mouseOffset = getValue( p ) - value();
}
emit sliderPressed();
if( !configManager::inst()->value( "knobs", "classicalusability"
).toInt() )
{
QApplication::setOverrideCursor( Qt::BlankCursor );
}
s_textFloat->reparent( this );
QString val;
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
{
val = QString( " %1 dBV" ).arg(
20.0 * log10( value() / 100.0 ),
3, 'f', 2 );
}
else
{
val = QString( " %1%" ).arg( value(), 3, 'f', 0 );
}
s_textFloat->setText( m_hintTextBeforeValue + val );
s_textFloat->move( mapTo( topLevelWidget(), QPoint( 0, 0 ) ) +
QPoint( m_knobPixmap->width() + 2, 0 ) );
s_textFloat->show();
m_buttonPressed = TRUE;
}
else if( _me->button() == Qt::LeftButton &&
eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
new stringPairDrag( "float_value", QString::number( value() ),
QPixmap(), this, eng() );
}
else if( _me->button() == Qt::MidButton )
{
reset();
}
}
//! Mouse Move Event handler
void volumeKnob::mouseMoveEvent( QMouseEvent * _me )
{
if( m_buttonPressed == TRUE )
{
setPosition( _me->pos() );
emit sliderMoved( value() );
if( !configManager::inst()->value( "knobs",
"classicalusability").toInt() )
{
QCursor::setPos( mapToGlobal( m_origMousePos ) );
}
}
QString val;
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
{
val = QString( " %1 dBV" ).arg(
20.0 * log10( value() / 100.0 ),
3, 'f', 2 );
}
else
{
val = QString( " %1%" ).arg( value(), 3, 'f', 0 );
}
s_textFloat->setText( m_hintTextBeforeValue + val );
}
void volumeKnob::wheelEvent( QWheelEvent * _we )
{
_we->accept();
const int inc = ( _we->delta() > 0 ) ? 1 : -1;
incValue( inc );
s_textFloat->reparent( this );
QString val;
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
{
val = QString( " %1 dBV" ).arg(
20.0 * log10( value() / 100.0 ),
3, 'f', 2 );
}
else
{
val = QString( " %1%" ).arg( value(), 3, 'f', 0 );
}
s_textFloat->setText( m_hintTextBeforeValue + val );
s_textFloat->move( mapTo( topLevelWidget(), QPoint( 0, 0 ) ) +
QPoint( m_knobPixmap->width() + 2, 0 ) );
s_textFloat->setVisibilityTimeOut( 1000 );
emit sliderMoved( value() );
}
void volumeKnob::enterValue( void )
{
bool ok;
float new_val;
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
{
new_val = QInputDialog::getDouble(
#ifdef QT4
this,
#endif
accessibleName(),
tr( "Please enter a new value between "
"-96.0 dbV and 6.0 dbV:" ),
20.0 * log10( value() / 100.0 ),
-96.0, 6.0,
4, &ok
#ifndef QT4
, this
#endif
);
if( new_val <= -96.0 )
{
new_val = 0.0f;
}
else
{
new_val = pow( 10.0, ( new_val / 20.0 ) ) * 100.0;
}
}
else
{
new_val = QInputDialog::getDouble(
#ifdef QT4
this,
#endif
accessibleName(),
tr( "Please enter a new value between "
"%1 and %2:" ).arg(
minValue() ).arg( maxValue() ),
value(), minValue(), maxValue(),
4, &ok
#ifndef QT4
, this
#endif
);
}
if( ok )
{
setValue( new_val );
}
}
#include "volume_knob.moc"
#endif