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

« back to all changes in this revision

Viewing changes to src/core/song.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:
1
1
/*
2
2
 * song.cpp - root of the model tree
3
3
 *
4
 
 * Copyright (c) 2004-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
 
4
 * Copyright (c) 2004-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5
5
 *
6
6
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
7
7
 *
31
31
#include <math.h>
32
32
 
33
33
#include "song.h"
34
 
#include "automation_track.h"
35
 
#include "automation_editor.h"
 
34
#include "AutomationTrack.h"
 
35
#include "AutomationEditor.h"
36
36
#include "bb_editor.h"
37
37
#include "bb_track.h"
38
38
#include "bb_track_container.h"
68
68
 
69
69
song::song() :
70
70
        trackContainer(),
71
 
        m_globalAutomationTrack( dynamic_cast<automationTrack *>(
 
71
        m_globalAutomationTrack( dynamic_cast<AutomationTrack *>(
72
72
                                track::create( track::HiddenAutomationTrack,
73
73
                                                                this ) ) ),
74
74
        m_tempoModel( DefaultTempo, MinTempo, MaxTempo, this, tr( "Tempo" ) ),
708
708
 
709
709
 
710
710
 
711
 
automationPattern * song::tempoAutomationPattern()
 
711
AutomationPattern * song::tempoAutomationPattern()
712
712
{
713
 
        return automationPattern::globalAutomationPattern( &m_tempoModel );
 
713
        return AutomationPattern::globalAutomationPattern( &m_tempoModel );
714
714
}
715
715
 
716
716
 
744
744
 
745
745
        engine::fxMixer()->clear();
746
746
 
747
 
        if( engine::getAutomationEditor() )
 
747
        if( engine::automationEditor() )
748
748
        {
749
 
                engine::getAutomationEditor()->setCurrentPattern( NULL );
 
749
                engine::automationEditor()->setCurrentPattern( NULL );
750
750
        }
751
 
        automationPattern::globalAutomationPattern( &m_tempoModel )->clear();
752
 
        automationPattern::globalAutomationPattern( &m_masterVolumeModel )->
 
751
 
 
752
        m_tempoModel.reset();
 
753
        m_masterVolumeModel.reset();
 
754
        m_masterPitchModel.reset();
 
755
        m_timeSigModel.reset();
 
756
 
 
757
        AutomationPattern::globalAutomationPattern( &m_tempoModel )->clear();
 
758
        AutomationPattern::globalAutomationPattern( &m_masterVolumeModel )->
753
759
                                                                        clear();
754
 
        automationPattern::globalAutomationPattern( &m_masterPitchModel )->
 
760
        AutomationPattern::globalAutomationPattern( &m_masterPitchModel )->
755
761
                                                                        clear();
756
762
 
757
763
        engine::getMixer()->unlock();
933
939
                                                        node.toElement() );
934
940
                                }
935
941
                                else if( node.nodeName() ==
936
 
                                        engine::getAutomationEditor()->
 
942
                                        engine::automationEditor()->
937
943
                                                                nodeName() )
938
944
                                {
939
 
                                        engine::getAutomationEditor()->
 
945
                                        engine::automationEditor()->
940
946
                                                restoreState( node.toElement() );
941
947
                                }
942
948
                                else if( node.nodeName() ==
968
974
        ControllerConnection::finalizeConnections();
969
975
 
970
976
        // resolve all IDs so that autoModels are automated
971
 
        automationPattern::resolveAllIDs();
 
977
        AutomationPattern::resolveAllIDs();
972
978
 
973
979
 
974
980
        engine::getMixer()->unlock();
977
983
 
978
984
        engine::projectJournal()->setJournalling( true );
979
985
 
 
986
        emit projectLoaded();
 
987
 
980
988
        m_loadingProject = false;
981
989
        m_modified = false;
982
990
 
984
992
        {
985
993
                engine::mainWindow()->resetWindowTitle();
986
994
        }
987
 
        if( engine::getSongEditor() )
988
 
        {
989
 
                engine::getSongEditor()->scrolled( 0 );
990
 
        }
991
995
}
992
996
 
993
997
 
994
 
 
995
 
 
996
 
// save current song
997
 
bool song::saveProject()
 
998
// only save current song as _filename and do nothing else
 
999
bool song::saveProjectFile( const QString & _filename )
998
1000
{
999
1001
        multimediaProject mmp( multimediaProject::SongProject );
1000
1002
 
1003
1005
        m_masterVolumeModel.saveSettings( mmp, mmp.head(), "mastervol" );
1004
1006
        m_masterPitchModel.saveSettings( mmp, mmp.head(), "masterpitch" );
1005
1007
 
1006
 
 
1007
1008
        saveState( mmp, mmp.content() );
1008
1009
 
1009
1010
        m_globalAutomationTrack->saveState( mmp, mmp.content() );
1012
1013
        {
1013
1014
                engine::getControllerRackView()->saveState( mmp, mmp.content() );
1014
1015
                engine::getPianoRoll()->saveState( mmp, mmp.content() );
1015
 
                engine::getAutomationEditor()->saveState( mmp, mmp.content() );
 
1016
                engine::automationEditor()->saveState( mmp, mmp.content() );
1016
1017
                engine::getProjectNotes()->
1017
1018
                        SerializingObject::saveState( mmp, mmp.content() );
1018
1019
                m_playPos[Mode_PlaySong].m_timeLine->saveState(
1021
1022
 
1022
1023
        saveControllerStates( mmp, mmp.content() );
1023
1024
 
 
1025
    return mmp.writeFile( _filename );
 
1026
}
 
1027
 
 
1028
 
 
1029
 
 
1030
// save current song and update the gui
 
1031
bool song::guiSaveProject()
 
1032
{
 
1033
        multimediaProject mmp( multimediaProject::SongProject );
1024
1034
        m_fileName = mmp.nameWithExtension( m_fileName );
1025
 
        if( mmp.writeFile( m_fileName ) == true && engine::hasGUI() )
 
1035
        if( saveProjectFile( m_fileName ) && engine::hasGUI() )
1026
1036
        {
1027
1037
                textFloat::displayMessage( tr( "Project saved" ),
1028
1038
                                        tr( "The project %1 is now saved."
1049
1059
 
1050
1060
 
1051
1061
// save current song in given filename
1052
 
bool song::saveProjectAs( const QString & _file_name )
 
1062
bool song::guiSaveProjectAs( const QString & _file_name )
1053
1063
{
1054
1064
        QString o = m_oldFileName;
1055
1065
        m_oldFileName = m_fileName;
1056
1066
        m_fileName = _file_name;
1057
 
        if( saveProject() == false )
 
1067
        if( guiSaveProject() == false )
1058
1068
        {
1059
1069
                m_fileName = m_oldFileName;
1060
1070
                m_oldFileName = o;