rewrote FLP import filter, various coding style fixes (stable backport)

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/branches/lmms/stable-0.4@1842 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-11-21 23:22:36 +00:00
parent 1381709a58
commit 98371cb148
40 changed files with 2732 additions and 970 deletions

View File

@@ -113,43 +113,27 @@ chordCreator::chord chordCreator::s_chordTable[] =
{ chordCreator::tr( "m-Maj13" ), { 0, 3, 7, 11, 14, 21, -1 } },
{ chordCreator::tr( "Major" ), { 0, 2, 4, 5, 7, 9, 11, -1 } },
{ chordCreator::tr( "Harmonic minor" ), { 0, 2, 3, 5, 7, 8,
11, -1 } },
{ chordCreator::tr( "Melodic minor" ), { 0, 2, 3, 5, 7, 9,
11, -1 } },
{ chordCreator::tr( "Whole tone" ), { 0, 2, 4, 6, 8, 10,
-1 } },
{ chordCreator::tr( "Diminished" ), { 0, 2, 3, 5, 6, 8, 9,
11, -1 } },
{ chordCreator::tr( "Major pentatonic" ), { 0, 2, 4, 7, 10,
-1 } },
{ chordCreator::tr( "Minor pentatonic" ), { 0, 3, 5, 7, 10,
-1 } },
{ chordCreator::tr( "Harmonic minor" ), { 0, 2, 3, 5, 7, 8, 11, -1 } },
{ chordCreator::tr( "Melodic minor" ), { 0, 2, 3, 5, 7, 9, 11, -1 } },
{ chordCreator::tr( "Whole tone" ), { 0, 2, 4, 6, 8, 10, -1 } },
{ chordCreator::tr( "Diminished" ), { 0, 2, 3, 5, 6, 8, 9, 11, -1 } },
{ chordCreator::tr( "Major pentatonic" ), { 0, 2, 4, 7, 10, -1 } },
{ chordCreator::tr( "Minor pentatonic" ), { 0, 3, 5, 7, 10, -1 } },
{ chordCreator::tr( "Jap in sen" ), { 0, 1, 5, 7, 10, -1 } },
{ chordCreator::tr( "Major bebop" ), { 0, 2, 4, 5, 7, 8, 9,
11, -1 } },
{ chordCreator::tr( "Dominant bebop" ), { 0, 2, 4, 5, 7, 9,
10, 11, -1 } },
{ chordCreator::tr( "Major bebop" ), { 0, 2, 4, 5, 7, 8, 9, 11, -1 } },
{ chordCreator::tr( "Dominant bebop" ), { 0, 2, 4, 5, 7, 9, 10, 11, -1 } },
{ chordCreator::tr( "Blues" ), { 0, 3, 5, 6, 7, 10, -1 } },
{ chordCreator::tr( "Arabic" ), { 0, 1, 4, 5, 7, 8, 11, -1 } },
{ chordCreator::tr( "Enigmatic" ), { 0, 1, 4, 6, 8, 10, 11,
-1 } },
{ chordCreator::tr( "Neopolitan" ), { 0, 1, 3, 5, 7, 9, 11,
-1 } },
{ chordCreator::tr( "Neopolitan minor" ), { 0, 1, 3, 5, 7, 9,
11, -1 } },
{ chordCreator::tr( "Hungarian minor" ), { 0, 2, 3, 6, 7, 9,
11, -1 } },
{ chordCreator::tr( "Enigmatic" ), { 0, 1, 4, 6, 8, 10, 11, -1 } },
{ chordCreator::tr( "Neopolitan" ), { 0, 1, 3, 5, 7, 9, 11, -1 } },
{ chordCreator::tr( "Neopolitan minor" ), { 0, 1, 3, 5, 7, 9, 11, -1 } },
{ chordCreator::tr( "Hungarian minor" ), { 0, 2, 3, 6, 7, 9, 11, -1 } },
{ chordCreator::tr( "Dorian" ), { 0, 2, 3, 5, 7, 9, 10, -1 } },
{ chordCreator::tr( "Phrygolydian" ), { 0, 1, 3, 5, 7, 8, 10,
-1 } },
{ chordCreator::tr( "Phrygolydian" ), { 0, 1, 3, 5, 7, 8, 10, -1 } },
{ chordCreator::tr( "Lydian" ), { 0, 2, 4, 6, 7, 9, 11, -1 } },
{ chordCreator::tr( "Mixolydian" ), { 0, 2, 4, 5, 7, 9, 10,
-1 } },
{ chordCreator::tr( "Aeolian" ), { 0, 2, 3, 5, 7, 8, 10,
-1 } },
{ chordCreator::tr( "Locrian" ), { 0, 1, 3, 5, 6, 8, 10,
-1 } },
{ chordCreator::tr( "Mixolydian" ), { 0, 2, 4, 5, 7, 9, 10, -1 } },
{ chordCreator::tr( "Aeolian" ), { 0, 2, 3, 5, 7, 8, 10, -1 } },
{ chordCreator::tr( "Locrian" ), { 0, 1, 3, 5, 6, 8, 10, -1 } },
{ "", { -1, -1 } }

View File

@@ -53,6 +53,7 @@
#include "config_mgr.h"
#include "embed.h"
#include "engine.h"
#include "import_filter.h"
#include "lmms_style.h"
#include "main_window.h"
#include "project_renderer.h"
@@ -84,7 +85,9 @@ int main( int argc, char * * argv )
// intialize RNG
srand( getpid() + time( 0 ) );
bool core_only = FALSE;
bool core_only = false;
bool exit_after_import = false;
QString file_to_load, file_to_save, file_to_import, render_out;
for( int i = 1; i < argc; ++i )
{
@@ -93,7 +96,7 @@ int main( int argc, char * * argv )
( QString( argv[i] ) == "--help" ||
QString( argv[i] ) == "-h" ) ) )
{
core_only = TRUE;
core_only = true;
break;
}
}
@@ -102,10 +105,9 @@ int main( int argc, char * * argv )
new QCoreApplication( argc, argv ) :
new QApplication( argc, argv ) ;
QString file_to_load, file_to_save, render_out;
mixer::qualitySettings qs( mixer::qualitySettings::Mode_HighQuality );
projectRenderer::outputSettings os( 44100, FALSE, 160,
projectRenderer::outputSettings os( 44100, false, 160,
projectRenderer::Depth_16Bit );
projectRenderer::ExportFileFormats eff = projectRenderer::WaveFile;
@@ -300,6 +302,17 @@ int main( int argc, char * * argv )
}
++i;
}
else if( argc > i &&
( QString( argv[i] ) == "--import" ) )
{
file_to_import = argv[i+1];
++i;
// exit after import? (only for debugging)
if( argc > i && QString( argv[i+1] ) == "-e" )
{
exit_after_import = true;
}
}
else
{
if( argv[i][0] == '-' )
@@ -390,11 +403,21 @@ int main( int argc, char * * argv )
srand( getpid() + time( 0 ) );
// we try to load given file
if( file_to_load != "" )
if( !file_to_load.isEmpty() )
{
engine::getMainWindow()->showMaximized();
engine::getSong()->loadProject( file_to_load );
}
else if( !file_to_import.isEmpty() )
{
importFilter::import( file_to_import,
engine::getSong() );
if( exit_after_import )
{
return 0;
}
engine::getMainWindow()->showMaximized();
}
else
{
engine::getSong()->createNewProject();
@@ -404,7 +427,7 @@ int main( int argc, char * * argv )
else
{
// we're going to render our song
engine::init( FALSE );
engine::init( false );
printf( "loading project...\n" );
engine::getSong()->loadProject( file_to_load );
printf( "done\n" );

View File

@@ -39,6 +39,7 @@
#include "embed.h"
#include "engine.h"
#include "gui_templates.h"
#include "import_filter.h"
#include "instrument.h"
#include "instrument_track.h"
#include "main_window.h"
@@ -488,7 +489,10 @@ void fileBrowserTreeWidget::mouseMoveEvent( QMouseEvent * _me )
break;
case fileItem::MidiFile:
new stringPairDrag( "midifile",
// don't allow dragging FLP-files as FLP import filter clears project
// without asking
// case fileItem::FlpFile:
new stringPairDrag( "importedproject",
f->fullName(),
embed::getIconPixmap(
"midi_file" ),
@@ -571,11 +575,23 @@ void fileBrowserTreeWidget::handleFile( fileItem * f, instrumentTrack * _it )
instrumentTrack::removeMidiPortNode( mmp );
_it->setSimpleSerializing();
_it->loadSettings( mmp.content().toElement() );
break;
}
case fileItem::ImportAsProject:
if( f->type() == fileItem::FlpFile &&
!engine::getMainWindow()->mayChangeProject() )
{
break;
}
importFilter::import( f->fullName(),
engine::getSong() );
break;
case fileItem::NotSupported:
default:
break;
}
engine::getMixer()->unlock();
}
@@ -592,7 +608,8 @@ void fileBrowserTreeWidget::activateListItem( QTreeWidgetItem * _item,
return;
}
if( f->handling() == fileItem::LoadAsProject )
if( f->handling() == fileItem::LoadAsProject ||
f->handling() == fileItem::ImportAsProject )
{
handleFile( f, NULL );
}
@@ -963,17 +980,20 @@ void fileItem::determineFileType( void )
else if( ext == "mid" )
{
m_type = MidiFile;
m_handling = ImportAsProject;
}
else if( ext == "flp" )
{
m_type = FlpFile;
m_handling = ImportAsProject;
}
else
{
m_type = UnknownFile;
}
if( !ext.isEmpty() && engine::pluginFileHandling().contains( ext ) )
if( m_handling == NotSupported &&
!ext.isEmpty() && engine::pluginFileHandling().contains( ext ) )
{
m_handling = LoadByPlugin;
// classify as sample if not classified by anything yet but can

View File

@@ -79,7 +79,7 @@ trackContainerView::trackContainerView( trackContainer * _tc ) :
m_scrollArea->show();
m_rubberBand->hide();
setAcceptDrops( TRUE );
setAcceptDrops( true );
connect( engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ),
this, SLOT( realignTracks() ) );
@@ -273,7 +273,7 @@ const trackView * trackContainerView::trackViewAt( const int _y ) const
bool trackContainerView::allowRubberband( void ) const
{
return( FALSE );
return( false );
}
@@ -304,7 +304,7 @@ void trackContainerView::clearAllTracks( void )
void trackContainerView::undoStep( journalEntry & _je )
{
#if 0
saveJournallingState( FALSE );
saveJournallingState( false );
switch( _je.actionID() )
{
case AddTrack:
@@ -326,7 +326,7 @@ void trackContainerView::undoStep( journalEntry & _je )
case RemoveTrack:
{
multimediaProject mmp(
_je.data().toMap()["state"].toString(), FALSE );
_je.data().toMap()["state"].toString(), false );
track::create( mmp.content().firstChild().toElement(),
m_tc );
break;
@@ -362,8 +362,8 @@ void trackContainerView::redoStep( journalEntry & _je )
void trackContainerView::dragEnterEvent( QDragEnterEvent * _dee )
{
stringPairDrag::processDragEnterEvent( _dee,
QString( "presetfile,sampledata,samplefile,instrument,midifile,"
"track_%1,track_%2" ).
QString( "presetfile,sampledata,samplefile,instrument,"
"importedproject,track_%1,track_%2" ).
arg( track::InstrumentTrack ).
arg( track::SampleTrack ) );
}
@@ -382,7 +382,7 @@ void trackContainerView::dropEvent( QDropEvent * _de )
track::create( track::InstrumentTrack,
m_tc ) );
it->loadInstrument( value );
//it->toggledInstrumentTrackButton( TRUE );
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
else if( /*type == "sampledata" || */type == "samplefile" )
@@ -396,7 +396,7 @@ void trackContainerView::dropEvent( QDropEvent * _de )
value )];
instrument * i = it->loadInstrument( iname );
i->loadFile( value );
//it->toggledInstrumentTrackButton( TRUE );
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
else if( type == "presetfile" )
@@ -407,17 +407,17 @@ void trackContainerView::dropEvent( QDropEvent * _de )
m_tc ) );
it->loadTrackSpecificSettings( mmp.content().firstChild().
toElement() );
//it->toggledInstrumentTrackButton( TRUE );
//it->toggledInstrumentTrackButton( true );
_de->accept();
}
else if( type == "midifile" )
else if( type == "importedproject" )
{
importFilter::import( value, m_tc );
_de->accept();
}
else if( type.left( 6 ) == "track_" )
{
multimediaProject mmp( value, FALSE );
multimediaProject mmp( value, false );
track::create( mmp.content().firstChild().toElement(), m_tc );
_de->accept();
}
@@ -429,7 +429,7 @@ void trackContainerView::dropEvent( QDropEvent * _de )
void trackContainerView::mousePressEvent( QMouseEvent * _me )
{
if( allowRubberband() == TRUE )
if( allowRubberband() == true )
{
m_origin = m_scrollArea->mapFromParent( _me->pos() );
m_rubberBand->setGeometry( QRect( m_origin, QSize() ) );
@@ -443,7 +443,7 @@ void trackContainerView::mousePressEvent( QMouseEvent * _me )
void trackContainerView::mouseMoveEvent( QMouseEvent * _me )
{
if( rubberBandActive() == TRUE )
if( rubberBandActive() == true )
{
m_rubberBand->setGeometry( QRect( m_origin,
m_scrollArea->mapFromParent( _me->pos() ) ).

View File

@@ -68,8 +68,8 @@ pattern::pattern( instrumentTrack * _instrument_track ) :
m_patternType( BeatPattern ),
m_steps( midiTime::stepsPerTact() ),
m_frozenPattern( NULL ),
m_freezing( FALSE ),
m_freezeAborted( FALSE )
m_freezing( false ),
m_freezeAborted( false )
{
setName( _instrument_track->name() );
init();
@@ -84,7 +84,7 @@ pattern::pattern( const pattern & _pat_to_copy ) :
m_patternType( _pat_to_copy.m_patternType ),
m_steps( _pat_to_copy.m_steps ),
m_frozenPattern( NULL ),
m_freezeAborted( FALSE )
m_freezeAborted( false )
{
for( noteVector::const_iterator it = _pat_to_copy.m_notes.begin();
it != _pat_to_copy.m_notes.end(); ++it )
@@ -121,7 +121,7 @@ void pattern::init( void )
{
connect( engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ),
this, SLOT( changeTimeSignature() ) );
saveJournallingState( FALSE );
saveJournallingState( false );
ensureBeatNotes();
@@ -136,7 +136,7 @@ midiTime pattern::length( void ) const
{
if( m_patternType == BeatPattern )
{
return( beatPatternLength() );
return beatPatternLength();
}
tick max_length = midiTime::ticksPerTact();
@@ -150,8 +150,8 @@ midiTime pattern::length( void ) const
( *it )->endPos() );
}
}
return( midiTime( max_length ).nextFullTact() *
midiTime::ticksPerTact() );
return midiTime( max_length ).nextFullTact() *
midiTime::ticksPerTact();
}
@@ -178,8 +178,7 @@ midiTime pattern::beatPatternLength( void ) const
midiTime::stepsPerTact() ;
}
return( midiTime( max_length ).nextFullTact() *
midiTime::ticksPerTact() );
return midiTime( max_length ).nextFullTact() * midiTime::ticksPerTact();
}
@@ -225,7 +224,7 @@ note * pattern::addNote( const note & _new_note, const bool _quant_pos )
updateBBTrack();
return( new_note );
return new_note;
}
@@ -266,7 +265,7 @@ note * pattern::rearrangeNote( const note * _note_to_proc,
note copy_of_note( *_note_to_proc );
removeNote( _note_to_proc );
return( addNote( copy_of_note, _quant_pos ) );
return addNote( copy_of_note, _quant_pos );
}
@@ -290,6 +289,23 @@ void pattern::clearNotes( void )
void pattern::setStep( int _step, bool _enabled )
{
for( noteVector::iterator it = m_notes.begin(); it != m_notes.end();
++it )
{
if( ( *it )->pos() == _step*DefaultTicksPerTact/16 &&
( *it )->length() <= 0 )
{
( *it )->setLength( _enabled ?
-DefaultTicksPerTact : 0 );
}
}
}
void pattern::setType( PatternTypes _new_pattern_type )
{
if( _new_pattern_type == BeatPattern ||
@@ -460,7 +476,7 @@ void pattern::unfreeze( void )
void pattern::abortFreeze( void )
{
m_freezeAborted = TRUE;
m_freezeAborted = true;
}
@@ -505,7 +521,7 @@ void pattern::removeSteps( int _n )
trackContentObjectView * pattern::createView( trackView * _tv )
{
return( new patternView( this, _tv ) );
return new patternView( this, _tv );
}
@@ -517,7 +533,7 @@ void pattern::ensureBeatNotes( void )
// make sure, that all step-note exist
for( int i = 0; i < m_steps; ++i )
{
bool found = FALSE;
bool found = false;
for( noteVector::iterator it = m_notes.begin();
it != m_notes.end(); ++it )
{
@@ -526,15 +542,15 @@ void pattern::ensureBeatNotes( void )
midiTime::stepsPerTact() &&
( *it )->length() <= 0 )
{
found = TRUE;
found = true;
break;
}
}
if( found == FALSE )
if( found == false )
{
addNote( note( midiTime( 0 ), midiTime( i *
midiTime::ticksPerTact() /
midiTime::stepsPerTact() ) ), FALSE );
midiTime::stepsPerTact() ) ), false );
}
}
}
@@ -560,10 +576,10 @@ bool pattern::empty( void )
{
if( ( *it )->length() != 0 )
{
return( FALSE );
return false;
}
}
return( TRUE );
return true;
}
@@ -609,12 +625,12 @@ patternFreezeStatusDialog::patternFreezeStatusDialog( QThread * _thread ) :
m_progress( 0 )
{
setWindowTitle( tr( "Freezing pattern..." ) );
setModal( TRUE );
setModal( true );
m_progressBar = new QProgressBar( this );
m_progressBar->setGeometry( 10, 10, 200, 24 );
m_progressBar->setMaximum( 100 );
m_progressBar->setTextVisible( FALSE );
m_progressBar->setTextVisible( false );
m_progressBar->show();
m_cancelBtn = new QPushButton( embed::getIconPixmap( "cancel" ),
tr( "Cancel" ), this );
@@ -629,7 +645,7 @@ patternFreezeStatusDialog::patternFreezeStatusDialog( QThread * _thread ) :
this, SLOT( updateProgress() ) );
update_timer->start( 100 );
setAttribute( Qt::WA_DeleteOnClose, TRUE );
setAttribute( Qt::WA_DeleteOnClose, true );
connect( this, SIGNAL( aborted() ), this, SLOT( reject() ) );
}
@@ -726,20 +742,20 @@ void patternFreezeThread::run( void )
engine::getMixer()->setAudioDevice( freeze_recorder );
// prepare stuff for playing correct things later
engine::getSong()->playPattern( m_pattern, FALSE );
engine::getSong()->playPattern( m_pattern, false );
song::playPos & ppp = engine::getSong()->getPlayPos(
song::Mode_PlayPattern );
ppp.setTicks( 0 );
ppp.setCurrentFrame( 0 );
ppp.m_timeLineUpdate = FALSE;
ppp.m_timeLineUpdate = false;
m_pattern->m_freezeAborted = FALSE;
m_pattern->m_freezing = TRUE;
m_pattern->m_freezeAborted = false;
m_pattern->m_freezing = true;
// now render everything
while( ppp < m_pattern->length() &&
m_pattern->m_freezeAborted == FALSE )
m_pattern->m_freezeAborted == false )
{
freeze_recorder->processNextBuffer();
m_statusDlg->setProgress( ppp * 100 / m_pattern->length() );
@@ -747,20 +763,20 @@ void patternFreezeThread::run( void )
m_statusDlg->setProgress( 100 );
// render tails
while( engine::getMixer()->hasPlayHandles() &&
m_pattern->m_freezeAborted == FALSE )
m_pattern->m_freezeAborted == false )
{
freeze_recorder->processNextBuffer();
}
m_pattern->m_freezing = FALSE;
m_pattern->m_freezing = false;
// reset song-editor settings
engine::getSong()->stop();
ppp.m_timeLineUpdate = TRUE;
ppp.m_timeLineUpdate = true;
// create final sample-buffer if freezing was successful
if( m_pattern->m_freezeAborted == FALSE )
if( m_pattern->m_freezeAborted == false )
{
freeze_recorder->createSampleBuffer(
&m_pattern->m_frozenPattern );
@@ -781,7 +797,7 @@ patternView::patternView( pattern * _pattern, trackView * _parent ) :
trackContentObjectView( _pattern, _parent ),
m_pat( _pattern ),
m_paintPixmap(),
m_needsUpdate( TRUE )
m_needsUpdate( true )
{
if( s_stepBtnOn == NULL )
{
@@ -813,7 +829,7 @@ patternView::patternView( pattern * _pattern, trackView * _parent ) :
}
setFixedHeight( parentWidget()->height() - 2 );
setAutoResizeEnabled( FALSE );
setAutoResizeEnabled( false );
toolTip::add( this,
tr( "double-click to open this pattern in piano-roll\n"
@@ -847,7 +863,7 @@ patternView::~patternView()
void patternView::update( void )
{
m_needsUpdate = TRUE;
m_needsUpdate = true;
m_pat->changeLength( m_pat->length() );
trackContentObjectView::update();
}
@@ -923,20 +939,20 @@ void patternView::constructContextMenu( QMenu * _cm )
this, SLOT( changeName() ) );
_cm->addSeparator();
bool freeze_separator = FALSE;
bool freeze_separator = false;
if( !( m_pat->m_instrumentTrack->isMuted() || m_pat->isMuted() ) )
{
_cm->addAction( embed::getIconPixmap( "freeze" ),
m_pat->m_frozenPattern ? tr( "Refreeze" ) :
tr( "Freeze" ),
m_pat, SLOT( freeze() ) );
freeze_separator = TRUE;
freeze_separator = true;
}
if( m_pat->m_frozenPattern )
{
_cm->addAction( embed::getIconPixmap( "unfreeze" ),
tr( "Unfreeze" ), m_pat, SLOT( unfreeze() ) );
freeze_separator = TRUE;
freeze_separator = true;
}
if( freeze_separator )
{
@@ -1018,7 +1034,7 @@ void patternView::mousePressEvent( QMouseEvent * _me )
}
else if( m_pat->m_frozenPattern != NULL &&
_me->button() == Qt::LeftButton &&
engine::getMainWindow()->isShiftPressed() == TRUE )
engine::getMainWindow()->isShiftPressed() == true )
{
QString s;
new stringPairDrag( "sampledata",
@@ -1093,7 +1109,7 @@ void patternView::wheelEvent( QWheelEvent * _we )
void patternView::paintEvent( QPaintEvent * )
{
if( m_needsUpdate == FALSE )
if( m_needsUpdate == false )
{
QPainter p( this );
p.drawPixmap( 0, 0, m_paintPixmap );
@@ -1102,9 +1118,9 @@ void patternView::paintEvent( QPaintEvent * )
m_pat->changeLength( m_pat->length() );
m_needsUpdate = FALSE;
m_needsUpdate = false;
if( m_paintPixmap.isNull() == TRUE || m_paintPixmap.size() != size() )
if( m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() )
{
m_paintPixmap = QPixmap( size() );
}