traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src core/AudioClip.cpp core/AudioClip....


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src core/AudioClip.cpp core/AudioClip....
Date: Thu, 29 Nov 2007 11:04:08 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/11/29 11:04:08

Modified files:
        src/core       : AudioClip.cpp AudioClip.h Project.cpp Project.h 
                         Song.cpp Song.h 
        src/traverso/songcanvas: AudioClipView.cpp 
        src/traverso/widgets: ResourcesWidget.cpp 

Log message:
        * do an 'autosave' when a recording finished, don't emit the save 
action to the GUI, we don't want to bother the user with autosaves.
        Implemented for j_ack, our beloved and most active beta-tester :)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.154&r2=1.155
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.h?cvsroot=traverso&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.cpp?cvsroot=traverso&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.h?cvsroot=traverso&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.161&r2=1.162
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.h?cvsroot=traverso&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.118&r2=1.119
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/widgets/ResourcesWidget.cpp?cvsroot=traverso&r1=1.38&r2=1.39

Patches:
Index: core/AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -b -r1.154 -r1.155
--- core/AudioClip.cpp  26 Nov 2007 16:02:13 -0000      1.154
+++ core/AudioClip.cpp  29 Nov 2007 11:04:07 -0000      1.155
@@ -419,6 +419,7 @@
        Q_ASSERT(m_readSource);
        
        AudioBus* bus = m_song->get_clip_render_bus();
+       bus->silence_buffers(nframes);
        AudioBus* sendbus = m_song->get_render_bus();
        
        TimeRef mix_pos;
@@ -426,33 +427,41 @@
        audio_sample_t* mixdown[channelcount];
 
 
+       int outputRate = m_readSource->get_output_rate();
        TimeRef transportLocation = m_song->get_transport_location();
-       TimeRef upperRange = transportLocation + TimeRef(nframes, get_rate());
+       TimeRef upperRange = transportLocation + TimeRef(nframes, outputRate);
+       
        
        if ( (m_trackStartLocation < upperRange) && (m_trackEndLocation > 
transportLocation) ) {
+               // FIXME wrong calculation!
                if (transportLocation < m_trackStartLocation) {
-                       uint offset = (m_trackStartLocation - 
transportLocation).to_frame(get_rate());
+                       uint offset = (m_trackStartLocation - 
transportLocation).to_frame(outputRate);
                        mix_pos = m_sourceStartLocation;
+//                     printf("offset %d\n", offset);
                        
                        for (int chan=0; chan<bus->get_channel_count(); ++chan) 
{
-                               mixdown[chan] = bus->get_buffer(chan, nframes) 
+ offset;
+                               audio_sample_t* buf = bus->get_buffer(chan, 
nframes);
+                               mixdown[chan] = buf + offset;
                        }
                        nframes = nframes - offset;
                } else {
                        mix_pos = (transportLocation - m_trackStartLocation + 
m_sourceStartLocation);
+//                     printf("else: Setting mix pos to start location %d\n", 
mix_pos.to_frame(96000));
                        
                        for (int chan=0; chan<bus->get_channel_count(); ++chan) 
{
                                mixdown[chan] = bus->get_buffer(chan, nframes);
                        }
                }
                if (m_trackEndLocation < upperRange) {
-                       nframes -= (upperRange - 
m_trackEndLocation).to_frame(get_rate());
+                       nframes -= (upperRange - 
m_trackEndLocation).to_frame(outputRate);
+//                     printf("if (m_trackEndLocation < upperRange): nframes 
%d\n", nframes);
                }
        } else {
                return 0;
        }
 
 
+//     printf("Setting mix pos to start location %d\n", 
mix_pos.to_frame(outputRate));
        int read_frames = 0;
 
 
@@ -468,9 +477,14 @@
        }
        
        if (read_frames <= 0) {
+//             printf("read_frames == 0\n");
                return 0;
        }
        
+       if (read_frames != nframes) {
+//             printf("read_frames, nframes %d, %d\n", read_frames, nframes);
+       }               
+       
 
        apill_foreach(FadeCurve* fade, FadeCurve, m_fades) {
                fade->process(mixdown, read_frames, channelcount);
@@ -480,11 +494,11 @@
        m_fader->process_gain(mixdown, mix_pos, endlocation, read_frames, 
channelcount);
        
        if (channelcount == 1) {
-               Mixer::mix_buffers_no_gain(sendbus->get_buffer(0, read_frames), 
bus->get_buffer(0, read_frames), read_frames);
-               Mixer::mix_buffers_no_gain(sendbus->get_buffer(1, read_frames), 
bus->get_buffer(0, read_frames), read_frames);
+               Mixer::mix_buffers_no_gain(sendbus->get_buffer(0, nframes), 
bus->get_buffer(0, nframes), nframes);
+               Mixer::mix_buffers_no_gain(sendbus->get_buffer(1, nframes), 
bus->get_buffer(0, nframes), nframes);
        } else if (channelcount == 2) {
-               Mixer::mix_buffers_no_gain(sendbus->get_buffer(0, read_frames), 
bus->get_buffer(0, read_frames), read_frames);
-               Mixer::mix_buffers_no_gain(sendbus->get_buffer(1, read_frames), 
bus->get_buffer(1, read_frames), read_frames);
+               Mixer::mix_buffers_no_gain(sendbus->get_buffer(0, nframes), 
bus->get_buffer(0, nframes), nframes);
+               Mixer::mix_buffers_no_gain(sendbus->get_buffer(1, nframes), 
bus->get_buffer(1, nframes), nframes);
        }
        
        return 1;
@@ -623,12 +637,18 @@
 
 Command* AudioClip::reset_fade_in()
 {
+       if (fadeIn) {
        return new FadeRange(this, fadeIn, 1.0);
+       }
+       return 0;
 }
 
 Command* AudioClip::reset_fade_out()
 {
+       if (fadeOut) {
        return new FadeRange(this, fadeOut, 1.0);
+       }
+       return 0;
 }
 
 Command* AudioClip::reset_fade_both()
@@ -720,7 +740,7 @@
        
        resources_manager()->set_source_for_clip(this, m_readSource);
        
-       emit recordingFinished();
+       emit recordingFinished(this);
 }
 
 void AudioClip::finish_recording()

Index: core/AudioClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- core/AudioClip.h    26 Nov 2007 16:02:13 -0000      1.69
+++ core/AudioClip.h    29 Nov 2007 11:04:07 -0000      1.70
@@ -168,7 +168,7 @@
        void trackEndLocationChanged();
        void fadeAdded(FadeCurve*);
        void fadeRemoved(FadeCurve*);
-       void recordingFinished();
+       void recordingFinished(AudioClip*);
 
 public slots:
        void finish_recording();

Index: core/Project.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- core/Project.cpp    22 Nov 2007 15:07:02 -0000      1.63
+++ core/Project.cpp    29 Nov 2007 11:04:07 -0000      1.64
@@ -250,7 +250,7 @@
 }
 
 
-int Project::save()
+int Project::save(bool autosave)
 {
        PENTER;
        QDomDocument doc("Project");
@@ -268,7 +268,10 @@
        QTextStream stream(&data);
        doc.save(stream, 4);
        data.close();
+       
+       if (!autosave) {
        info().information( tr("Project %1 saved ").arg(m_title) );
+       }
        
        pm().start_incremental_backup(m_title);
 

Index: core/Project.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- core/Project.h      24 Oct 2007 18:11:40 -0000      1.28
+++ core/Project.h      29 Nov 2007 11:04:08 -0000      1.29
@@ -92,7 +92,7 @@
        bool is_save_to_close() const;
        bool is_recording() const;
        
-       int save();
+       int save(bool autosave=false);
        int load(QString projectfile = "");
        int export_project(ExportSpecification* spec);
        int start_export(ExportSpecification* spec);

Index: core/Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -b -r1.161 -r1.162
--- core/Song.cpp       27 Nov 2007 18:38:02 -0000      1.161
+++ core/Song.cpp       29 Nov 2007 11:04:08 -0000      1.162
@@ -1292,6 +1292,15 @@
                        if (track->armed()) {
                                AudioClip* clip = track->init_recording();
                                if (clip) {
+                                       // For autosave purposes, we connect 
the recordingfinished
+                                       // signal to the 
clip_finished_recording() slot, and add this
+                                       // clip to our recording clip list.
+                                       // At the time the cliplist is empty, 
we're sure the recording 
+                                       // session is finished, at which time 
an autosave makes sense.
+                                       connect(clip, 
SIGNAL(recordingFinished(AudioClip*)), 
+                                               this, 
SLOT(clip_finished_recording(AudioClip*)));
+                                       m_recordingClips.append(clip);
+                                       
                                        group->add_command(new 
AddRemoveClip(clip, AddRemoveClip::ADD));
                                        clipcount++;
                                }
@@ -1304,6 +1313,21 @@
        m_readyToRecord = true;
 }
 
+void Song::clip_finished_recording(AudioClip * clip)
+{
+       if (!m_recordingClips.removeAll(clip)) {
+               PERROR("clip %s was not in recording clip list, cannot remove 
it!", QS_C(clip->get_name()));
+       }
+       
+       if (m_recordingClips.isEmpty()) {
+               // seems we finished recording completely now
+               // all clips have set their resulting ReadSource
+               // length and whatsoever, let's do an autosave:
+               m_project->save(true);
+       }
+}
+
+
 void Song::set_transport_pos(TimeRef location)
 {
 #if defined (THREAD_CHECK)

Index: core/Song.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- core/Song.h 22 Nov 2007 15:47:12 -0000      1.74
+++ core/Song.h 29 Nov 2007 11:04:08 -0000      1.75
@@ -157,6 +157,7 @@
 
 private:
        APILinkedList           m_tracks;
+       QList<AudioClip*>       m_recordingClips;
        Project*                m_project;
        WriteSource*            m_exportSource;
        AudioBus*               m_playBackBus;
@@ -268,6 +269,7 @@
        void handle_diskio_writebuffer_overrun();
        void handle_diskio_readbuffer_underrun();
        void prepare_recording();
+       void clip_finished_recording(AudioClip* clip);
 };
 
 inline float Song::get_gain() const

Index: traverso/songcanvas/AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -b -r1.118 -r1.119
--- traverso/songcanvas/AudioClipView.cpp       13 Nov 2007 13:09:46 -0000      
1.118
+++ traverso/songcanvas/AudioClipView.cpp       29 Nov 2007 11:04:08 -0000      
1.119
@@ -99,7 +99,7 @@
        
        if (m_clip->recording_state() == AudioClip::RECORDING) {
                start_recording();
-               connect(m_clip, SIGNAL(recordingFinished()), this, 
SLOT(finish_recording()));
+               connect(m_clip, SIGNAL(recordingFinished(AudioClip*)), this, 
SLOT(finish_recording()));
        }
        
 //     setFlags(ItemIsSelectable | ItemIsMovable);

Index: traverso/widgets/ResourcesWidget.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/widgets/ResourcesWidget.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- traverso/widgets/ResourcesWidget.cpp        23 Nov 2007 15:39:28 -0000      
1.38
+++ traverso/widgets/ResourcesWidget.cpp        29 Nov 2007 11:04:08 -0000      
1.39
@@ -416,7 +416,7 @@
        , m_clip(clip)
 {
        setData(0, Qt::UserRole, clip->get_id());
-       connect(clip, SIGNAL(recordingFinished()), this, 
SLOT(clip_state_changed()));
+       connect(clip, SIGNAL(recordingFinished(AudioClip*)), this, 
SLOT(clip_state_changed()));
        connect(clip, SIGNAL(stateChanged()), this, SLOT(clip_state_changed()));
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]