~ubuntu-branches/ubuntu/precise/lmms/precise-updates

« back to all changes in this revision

Viewing changes to src/tracks/InstrumentTrack.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Артём Попов
  • Date: 2011-02-14 20:58:36 UTC
  • mfrom: (1.1.10 upstream) (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110214205836-2u41xus1d2mj8nfz
Tags: 0.4.10-1ubuntu1
* Merge from debian unstable (LP: #718801).  Remaining changes:
  - Replace build-dep on libwine-dev with wine1.2-dev to build
    against the newer Wine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * InstrumentTrack.cpp - implementation of instrument-track-class
3
3
 *                        (window + data-structures)
4
4
 *
5
 
 * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
5
 * Copyright (c) 2004-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6
6
 *
7
7
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8
8
 *
40
40
 
41
41
#include "InstrumentTrack.h"
42
42
#include "AudioPort.h"
43
 
#include "automation_pattern.h"
 
43
#include "AutomationPattern.h"
44
44
#include "bb_track.h"
45
45
#include "config_mgr.h"
 
46
#include "ControllerConnection.h"
46
47
#include "debug.h"
47
48
#include "EffectChain.h"
48
49
#include "EffectRackView.h"
631
632
                // get all notes from the given pattern...
632
633
                const NoteVector & notes = p->notes();
633
634
                // ...and set our index to zero
634
 
                NoteVector::ConstIterator it = notes.begin();
 
635
                NoteVector::ConstIterator nit = notes.begin();
635
636
#if LMMS_SINGERBOT_SUPPORT
636
637
                int note_idx = 0;
637
638
#endif
643
644
                if( cur_start > 0 )
644
645
                {
645
646
                        // skip notes which are posated before start-tact
646
 
                        while( it != notes.end() && ( *it )->pos() < cur_start )
 
647
                        while( nit != notes.end() && ( *nit )->pos() < cur_start )
647
648
                        {
648
649
#if LMMS_SINGERBOT_SUPPORT
649
 
                                if( ( *it )->length() != 0 )
 
650
                                if( ( *nit )->length() != 0 )
650
651
                                {
651
652
                                        ++note_idx;
652
653
                                }
653
654
#endif
654
 
                                ++it;
 
655
                                ++nit;
655
656
                        }
656
657
                }
657
658
 
658
659
                note * cur_note;
659
 
                while( it != notes.end() &&
660
 
                                        ( cur_note = *it )->pos() == cur_start )
 
660
                while( nit != notes.end() &&
 
661
                                        ( cur_note = *nit )->pos() == cur_start )
661
662
                {
662
663
                        if( cur_note->length() != 0 )
663
664
                        {
680
681
                                ++note_idx;
681
682
#endif
682
683
                        }
683
 
                        ++it;
 
684
                        ++nit;
684
685
                }
685
686
        }
686
687
        return played_a_note;
812
813
                        // compat code - if node-name doesn't match any known
813
814
                        // one, we assume that it is an instrument-plugin
814
815
                        // which we'll try to load
815
 
                        else if( automationPattern::classNodeName() !=
816
 
                                                        node.nodeName() &&
 
816
                        else if( AutomationPattern::classNodeName() != node.nodeName() &&
 
817
                                        ControllerConnection::classNodeName() != node.nodeName() &&
817
818
                                        !node.toElement().hasAttribute( "id" ) )
818
819
                        {
819
820
                                delete m_instrument;
858
859
// #### ITV:
859
860
 
860
861
 
861
 
QQueue<InstrumentTrackWindow *> InstrumentTrackView::s_windows;
 
862
QQueue<InstrumentTrackWindow *> InstrumentTrackView::s_windowCache;
862
863
 
863
864
 
864
865
 
969
970
 
970
971
 
971
972
 
 
973
InstrumentTrackWindow * InstrumentTrackView::topLevelInstrumentTrackWindow()
 
974
{
 
975
        InstrumentTrackWindow * w = NULL;
 
976
        foreach( QMdiSubWindow * sw,
 
977
                                engine::mainWindow()->workspace()->subWindowList(
 
978
                                                                                        QMdiArea::ActivationHistoryOrder ) )
 
979
        {
 
980
                if( sw->isVisible() && sw->widget()->inherits( "InstrumentTrackWindow" ) )
 
981
                {
 
982
                        w = qobject_cast<InstrumentTrackWindow *>( sw->widget() );
 
983
                }
 
984
        }
 
985
 
 
986
        return w;
 
987
}
 
988
 
 
989
 
 
990
 
972
991
// TODO: Add windows to free list on freeInstrumentTrackWindow. 
973
992
// But, don't NULL m_window or disconnect signals.  This will allow windows 
974
993
// that are being show/hidden frequently to stay connected.
977
996
        if( m_window != NULL )
978
997
        {
979
998
                m_lastPos = m_window->parentWidget()->pos();
980
 
                if( s_windows.count() < INSTRUMENT_WINDOW_CACHE_SIZE )
 
999
 
 
1000
                if( configManager::inst()->value( "ui",
 
1001
                                                                                "oneinstrumenttrackwindow" ).toInt() ||
 
1002
                                                s_windowCache.count() < INSTRUMENT_WINDOW_CACHE_SIZE )
981
1003
                {
982
1004
                        model()->setHook( NULL );
 
1005
                        m_window->setInstrumentTrackView( NULL );
983
1006
                        m_window->parentWidget()->hide();
984
1007
                        m_window->setModel(
985
1008
                                engine::dummyTrackContainer()->
986
1009
                                                dummyInstrumentTrack() );
987
1010
                        m_window->updateInstrumentView();
988
 
                        s_windows.enqueue( m_window );
 
1011
                        s_windowCache << m_window;
989
1012
                }
990
1013
                else
991
1014
                {
999
1022
 
1000
1023
 
1001
1024
 
1002
 
void InstrumentTrackView::cleanupWindowPool()
 
1025
void InstrumentTrackView::cleanupWindowCache()
1003
1026
{
1004
 
        while( s_windows.count() )
 
1027
        while( !s_windowCache.isEmpty() )
1005
1028
        {
1006
 
                delete s_windows.dequeue();
 
1029
                delete s_windowCache.dequeue();
1007
1030
        }
1008
1031
}
1009
1032
 
1015
1038
        if( m_window != NULL )
1016
1039
        {
1017
1040
        }
1018
 
        else if( !s_windows.isEmpty() )
 
1041
        else if( !s_windowCache.isEmpty() )
1019
1042
        {
1020
 
                m_window = s_windows.dequeue();
 
1043
                m_window = s_windowCache.dequeue();
1021
1044
                
1022
1045
                m_window->setInstrumentTrackView( this );
1023
1046
                m_window->setModel( model() );
1024
1047
                m_window->updateInstrumentView();
1025
1048
                model()->setHook( m_window );
1026
1049
 
1027
 
                if( m_lastPos.x() > 0 || m_lastPos.y() > 0 )
 
1050
                if( configManager::inst()->
 
1051
                                                        value( "ui", "oneinstrumenttrackwindow" ).toInt() )
 
1052
                {
 
1053
                        s_windowCache << m_window;
 
1054
                }
 
1055
                else if( m_lastPos.x() > 0 || m_lastPos.y() > 0 )
1028
1056
                {
1029
1057
                        m_window->parentWidget()->move( m_lastPos );
1030
1058
                }
1032
1060
        else
1033
1061
        {
1034
1062
                m_window = new InstrumentTrackWindow( this );
 
1063
                if( configManager::inst()->
 
1064
                                                        value( "ui", "oneinstrumenttrackwindow" ).toInt() )
 
1065
                {
 
1066
                        // first time, an InstrumentTrackWindow is opened
 
1067
                        s_windowCache << m_window;
 
1068
                }
1035
1069
        }
1036
1070
                
1037
1071
        return m_window;
1246
1280
        m_tabWidget->addTab( m_midiView, tr( "MIDI" ), 4 );
1247
1281
 
1248
1282
        // setup piano-widget
1249
 
        m_pianoView= new PianoView( this );
 
1283
        m_pianoView = new PianoView( this );
1250
1284
        m_pianoView->setFixedSize( INSTRUMENT_WIDTH, PIANO_HEIGHT );
1251
1285
 
1252
1286
        vlayout->addWidget( m_generalSettingsWidget );
1277
1311
 
1278
1312
InstrumentTrackWindow::~InstrumentTrackWindow()
1279
1313
{
 
1314
        InstrumentTrackView::s_windowCache.removeAll( this );
 
1315
 
1280
1316
        delete m_instrumentView;
 
1317
 
1281
1318
        if( engine::mainWindow()->workspace() )
1282
1319
        {
1283
1320
                parentWidget()->hide();
1288
1325
 
1289
1326
 
1290
1327
 
 
1328
void InstrumentTrackWindow::setInstrumentTrackView( InstrumentTrackView * _tv )
 
1329
{
 
1330
        if( m_itv && _tv )
 
1331
        {
 
1332
                m_itv->m_tlb->setChecked( false );
 
1333
        }
 
1334
        m_itv = _tv;
 
1335
}
 
1336
 
 
1337
 
 
1338
 
 
1339
 
1291
1340
void InstrumentTrackWindow::modelChanged()
1292
1341
{
1293
1342
        m_track = castModel<InstrumentTrack>();
1294
1343
 
1295
1344
        m_nameLineEdit->setText( m_track->name() );
1296
1345
 
1297
 
        disconnect( m_track, SIGNAL( nameChanged() ) );
1298
 
        disconnect( m_track, SIGNAL( instrumentChanged() ) );
 
1346
        m_track->disconnect( SIGNAL( nameChanged() ), this );
 
1347
        m_track->disconnect( SIGNAL( instrumentChanged() ), this );
1299
1348
 
1300
1349
        connect( m_track, SIGNAL( nameChanged() ),
1301
1350
                        this, SLOT( updateName() ) );