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: Fri, 11 May 2007 13:09:23 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       07/05/11 13:09:23

Modified files:
        src/core       : AudioClip.cpp AudioClip.h AudioSource.cpp 
                         AudioSource.h MonoReader.cpp ReadSource.cpp 
                         ResourcesManager.cpp WriteSource.cpp 
                         WriteSource.h 
        src/traverso/songcanvas: TrackView.cpp 

Log message:
        * considerably cleaner way of managing write/readsources in AudioClip 
init recording
        * Related cleanups in resourcesmanager, read/write/audiosource...

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.88&r2=1.89
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.h?cvsroot=traverso&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioSource.cpp?cvsroot=traverso&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioSource.h?cvsroot=traverso&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/MonoReader.cpp?cvsroot=traverso&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.cpp?cvsroot=traverso&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ResourcesManager.cpp?cvsroot=traverso&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/WriteSource.cpp?cvsroot=traverso&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/WriteSource.h?cvsroot=traverso&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/TrackView.cpp?cvsroot=traverso&r1=1.32&r2=1.33

Patches:
Index: core/AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- core/AudioClip.cpp  10 May 2007 20:02:36 -0000      1.88
+++ core/AudioClip.cpp  11 May 2007 13:09:23 -0000      1.89
@@ -506,8 +506,12 @@
                channelcount = 1;
        }
 
-       qint64 newsourceid = create_id();
-       QString sourceid = QString::number(newsourceid);
+       ReadSource* rs = resources_manager()->create_recording_source(
+                               pm().get_project()->get_root_dir() + 
"/audiosources/",
+                               m_name, channelcount, m_song->get_id());
+       
+       resources_manager()->set_source_for_clip(this, rs);
+       QString sourceid = QString::number(rs->get_id());
        
        for (int chan=0; chan<captureBus->get_channel_count(); chan++) {
                if (chan == 0) {
@@ -526,29 +530,26 @@
                        channelnumber = chan;
                }
                
-               m_exportSpec = new ExportSpecification;
+               ExportSpecification* spec = new ExportSpecification;
 
-               m_exportSpec->exportdir = pm().get_project()->get_root_dir() + 
"/audiosources/";
-               m_exportSpec->format = SF_FORMAT_WAV;
-               m_exportSpec->data_width = 1;   // 1 means float
-               m_exportSpec->format |= SF_FORMAT_FLOAT;
-               m_exportSpec->channels = 1;
-               m_exportSpec->sample_rate = audiodevice().get_sample_rate();
-               m_exportSpec->src_quality = SRC_SINC_MEDIUM_QUALITY;
-               m_exportSpec->isRecording = true;
-               m_exportSpec->start_frame = 0;
-               m_exportSpec->end_frame = 0;
-               m_exportSpec->total_frames = 0;
-               m_exportSpec->blocksize = audiodevice().get_buffer_size();
-               m_exportSpec->name = m_name + "-" + sourceid;
-               m_exportSpec->dataF = captureBus->get_buffer( chan, 
audiodevice().get_buffer_size());
+               spec->exportdir = pm().get_project()->get_root_dir() + 
"/audiosources/";
+               spec->format = SF_FORMAT_WAV;
+               spec->data_width = 1;   // 1 means float
+               spec->format |= SF_FORMAT_FLOAT;
+               spec->channels = 1;
+               spec->sample_rate = audiodevice().get_sample_rate();
+               spec->src_quality = SRC_SINC_MEDIUM_QUALITY;
+               spec->isRecording = true;
+               spec->start_frame = 0;
+               spec->end_frame = 0;
+               spec->total_frames = 0;
+               spec->blocksize = audiodevice().get_buffer_size();
+               spec->name = m_name + "-" + sourceid;
+               spec->dataF = captureBus->get_buffer( chan, 
audiodevice().get_buffer_size());
 
-               WriteSource* ws = new WriteSource(m_exportSpec, channelnumber, 
channelcount);
+               WriteSource* ws = new WriteSource(spec, channelnumber, 
channelcount);
                ws->set_process_peaks( true );
                ws->set_recording( true );
-               // We had to create the id before creating the writesource, so 
-               // explicitely set it now, so it can be re-used for the 
resulting ReadSource!
-               ws->set_id(newsourceid);
 
                connect(ws, SIGNAL(exportFinished( WriteSource* )), 
                        this, SLOT(finish_write_source( WriteSource* )));
@@ -563,12 +564,6 @@
        
        init_gain_envelope();
        
-       ReadSource* rs;
-       rs = 
resources_manager()->create_recording_source(m_exportSpec->exportdir, 
m_exportSpec->name, channelcount, m_song->get_id());
-       rs->set_id(newsourceid);        
-       resources_manager()->set_source_for_clip(this, rs);
-       
-       
        connect(m_song, SIGNAL(transferStopped()), this, 
SLOT(finish_recording()));
 
        return 1;
@@ -689,16 +684,13 @@
        
        if (writeSources.isEmpty()) {
                Q_ASSERT(m_readSource);
-               delete m_exportSpec;
-               
                
                printf("finish: id %lld\n", get_id());
                if (m_readSource->set_file(m_readSource->get_filename()) < 0) {
                        PERROR("Setting file for ReadSource failed after 
finishing recording");
                }
                
-//             m_length = 0;
-               m_song->get_diskio()->register_read_source( m_readSource );
+               m_song->get_diskio()->register_read_source(m_readSource);
                m_recordingStatus = NO_RECORDING;
                
                emit recordingFinished();

Index: core/AudioClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- core/AudioClip.h    5 May 2007 20:43:58 -0000       1.46
+++ core/AudioClip.h    11 May 2007 13:09:23 -0000      1.47
@@ -144,7 +144,6 @@
        FadeCurve*              fadeIn;
        FadeCurve*              fadeOut;
        Curve*                  m_gainEnvelope;
-       ExportSpecification*    m_exportSpec;
        QDomNode                m_domNode;
        
        QString                 m_name;

Index: core/AudioSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioSource.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- core/AudioSource.cpp        3 May 2007 10:38:29 -0000       1.16
+++ core/AudioSource.cpp        11 May 2007 13:09:23 -0000      1.17
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: AudioSource.cpp,v 1.16 2007/05/03 10:38:29 r_sijrier Exp $
+$Id: AudioSource.cpp,v 1.17 2007/05/11 13:09:23 r_sijrier Exp $
 */
 
 
@@ -34,7 +34,7 @@
 // QMutex mutex;
 
 
-// This constructor is called during file import
+// This constructor is called at file import or recording
 AudioSource::AudioSource(const QString& dir, const QString& name)
        : m_dir(dir)
        , m_name(name)
@@ -170,11 +170,6 @@
        m_channelCount = count;
 }
 
-void AudioSource::set_id(qint64 id)
-{
-       m_id = id;
-}
-
 QString AudioSource::get_short_name() const
 {
        return m_shortName;

Index: core/AudioSource.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioSource.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- core/AudioSource.h  3 May 2007 10:38:29 -0000       1.13
+++ core/AudioSource.h  11 May 2007 13:09:23 -0000      1.14
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: AudioSource.h,v 1.13 2007/05/03 10:38:29 r_sijrier Exp $
+$Id: AudioSource.h,v 1.14 2007/05/11 13:09:23 r_sijrier Exp $
 */
 
 #ifndef AUDIOSOURCE_H
@@ -60,7 +60,6 @@
        int get_bit_depth() const;
        
        void set_channel_count(uint count);
-       void set_id(qint64 id);
        
 protected:
        uint            m_channelCount;

Index: core/MonoReader.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/MonoReader.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- core/MonoReader.cpp 10 May 2007 20:02:36 -0000      1.5
+++ core/MonoReader.cpp 11 May 2007 13:09:23 -0000      1.6
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: MonoReader.cpp,v 1.5 2007/05/10 20:02:36 r_sijrier Exp $
+$Id: MonoReader.cpp,v 1.6 2007/05/11 13:09:23 r_sijrier Exp $
 */
 
 
@@ -375,7 +375,6 @@
 {
        Q_ASSERT(!m_clip);
        m_clip = clip;
-       printf("mono reader clip id %lld\n", m_clip->get_id());
 }
 
 Peak* MonoReader::get_peak( )

Index: core/ReadSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- core/ReadSource.cpp 11 May 2007 11:16:32 -0000      1.30
+++ core/ReadSource.cpp 11 May 2007 13:09:23 -0000      1.31
@@ -61,7 +61,7 @@
        m_silent = (m_channelCount == 0);
 }      
 
-
+// constructor for file import
 ReadSource::ReadSource(const QString& dir, const QString& name)
        : AudioSource(dir, name)
        , m_refcount(0)
@@ -83,6 +83,7 @@
 }
 
 
+// Constructur for recorded audio.
 ReadSource::ReadSource(const QString& dir, const QString& name, int 
channelCount, int fileCount)
        : AudioSource(dir, name)
        , m_refcount(0)
@@ -93,6 +94,8 @@
        m_channelCount = channelCount;
        m_fileCount = fileCount;
        m_silent = false;
+       m_name = name  + "-" + QString::number(m_id);
+       m_fileName = m_dir + m_name;
 }
 
 

Index: core/ResourcesManager.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ResourcesManager.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- core/ResourcesManager.cpp   10 May 2007 20:02:36 -0000      1.13
+++ core/ResourcesManager.cpp   11 May 2007 13:09:23 -0000      1.14
@@ -383,10 +383,6 @@
 
 void ResourcesManager::set_clip_added(AudioClip * clip)
 {
-       if (clip->recording_state() != AudioClip::NO_RECORDING) {
-               return;
-       }
-       
        ReadSource* source = m_sources.value(clip->get_readsource_id());
        if (source) {
                source->unref(false);

Index: core/WriteSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/WriteSource.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- core/WriteSource.cpp        3 May 2007 20:05:07 -0000       1.20
+++ core/WriteSource.cpp        11 May 2007 13:09:23 -0000      1.21
@@ -36,22 +36,22 @@
 
 WriteSource::WriteSource( ExportSpecification * specification )
        : AudioSource(specification->exportdir, specification->name)
-       , spec(specification)
+       , m_spec(specification)
 {
        diskio = 0;
        m_buffer = 0;
-       prepare_export(spec);
+       prepare_export();
 }
 
 WriteSource::WriteSource( ExportSpecification * specification, int 
channelNumber, int superChannelCount )
-               : AudioSource(specification->exportdir, specification->name),
-               spec(specification),
-               m_channelNumber(channelNumber)
+       : AudioSource(specification->exportdir, specification->name)
+       , m_spec(specification)
+       , m_channelNumber(channelNumber)
 {
        diskio = 0;
        m_buffer = 0;
        m_channelCount = superChannelCount;
-       prepare_export(spec);
+       prepare_export();
 }
 
 WriteSource::~WriteSource()
@@ -65,11 +65,9 @@
                delete m_buffer;
        }
                
-       //FIXME spec can be owned by someone else!!!! (ExportWidget for example)
-/*     if (spec) {
-               delete spec;
-               spec = 0;
-       }*/
+       if (m_spec->isRecording) {
+               delete m_spec;
+       }
 }
 
 int WriteSource::process (nframes_t nframes)
@@ -91,12 +89,12 @@
 
                /* now do sample rate conversion */
 
-               if (sample_rate != (uint)spec->sample_rate) {
+               if (sample_rate != (uint)m_spec->sample_rate) {
 
                        int err;
 
                        src_data.output_frames = out_samples_max / channels;
-                       src_data.end_of_input = ((spec->pos + nframes) >= 
spec->end_frame);
+                       src_data.end_of_input = ((m_spec->pos + nframes) >= 
m_spec->end_frame);
                        src_data.data_out = dataF2;
 
                        if (leftover_frames > 0) {
@@ -109,7 +107,7 @@
 
                                        /* first time, append new data from 
dataF into the leftoverF buffer */
 
-                                       memcpy (leftoverF + (leftover_frames * 
channels), spec->dataF, nframes * channels * sizeof(float));
+                                       memcpy (leftoverF + (leftover_frames * 
channels), m_spec->dataF, nframes * channels * sizeof(float));
                                        src_data.input_frames = nframes + 
leftover_frames;
                                } else {
 
@@ -122,7 +120,7 @@
                                }
                        } else {
 
-                               src_data.data_in = spec->dataF;
+                               src_data.data_in = m_spec->dataF;
                                src_data.input_frames = nframes;
 
                        }
@@ -154,14 +152,14 @@
 
                        to_write = nframes;
                        leftover_frames = 0;
-                       float_buffer = spec->dataF;
+                       float_buffer = m_spec->dataF;
                }
 
                if (output_data) {
                        memset (output_data, 0, sample_bytes * to_write * 
channels);
                }
 
-               switch (spec->data_width) {
+               switch (m_spec->data_width) {
                case 8:
                case 16:
                case 24:
@@ -212,7 +210,7 @@
 
                /* and export to disk */
 
-               switch (spec->data_width) {
+               switch (m_spec->data_width) {
                case 8:
                        written = sf_write_raw (sf, (void*) output_data, 
to_write * channels);
                        break;
@@ -243,17 +241,17 @@
        return 0;
 }
 
-int WriteSource::prepare_export (ExportSpecification* spec)
+int WriteSource::prepare_export()
 {
        PENTER;
        
-       Q_ASSERT(spec->is_valid() == 1);
+       Q_ASSERT(m_spec->is_valid() == 1);
        
        char errbuf[256];
        GDitherSize dither_size;
 
        sample_rate = audiodevice().get_sample_rate();
-       channels = spec->channels;
+       channels = m_spec->channels;
        processPeaks = false;
        m_peak = 0;
        diskio = 0;
@@ -263,7 +261,7 @@
        src_state = 0;
        
 
-       switch (spec->data_width) {
+       switch (m_spec->data_width) {
        case 8:
                dither_size = GDither8bit;
                break;
@@ -283,10 +281,10 @@
 
        memset (&sfinfo, 0, sizeof(sfinfo));
 
-       sfinfo.format = spec->format;
-       sfinfo.samplerate = spec->sample_rate;
-       sfinfo.frames = spec->end_frame - spec->start_frame + 1;
-       sfinfo.channels = spec->channels;
+       sfinfo.format = m_spec->format;
+       sfinfo.samplerate = m_spec->sample_rate;
+       sfinfo.frames = m_spec->end_frame - m_spec->start_frame + 1;
+       sfinfo.channels = m_spec->channels;
 
        if (sf_format_check(&sfinfo) == false) {
                PWARN("sf_format_check returned false");
@@ -296,7 +294,7 @@
        /* XXX make sure we have enough disk space for the output */
 
        QString name = m_fileName;
-       if (spec->isRecording) {
+       if (m_spec->isRecording) {
                name.append("-ch" + QByteArray::number(m_channelNumber) + 
".wav");
        }
        
@@ -307,31 +305,31 @@
        }
 
 
-       if ((uint)spec->sample_rate != sample_rate) {
+       if ((uint)m_spec->sample_rate != sample_rate) {
                qDebug("Doing samplerate conversion");
                int err;
 
-               if ((src_state = src_new (spec->src_quality, channels, &err)) 
== 0) {
+               if ((src_state = src_new (m_spec->src_quality, channels, &err)) 
== 0) {
                        PWARN("cannot initialize sample rate conversion: %s", 
src_strerror (err));
                        return -1;
                }
 
-               src_data.src_ratio = spec->sample_rate / (double) sample_rate;
-               out_samples_max = (nframes_t) ceil (spec->blocksize * 
src_data.src_ratio * channels);
+               src_data.src_ratio = m_spec->sample_rate / (double) sample_rate;
+               out_samples_max = (nframes_t) ceil (m_spec->blocksize * 
src_data.src_ratio * channels);
                dataF2 = new audio_sample_t[out_samples_max];
 
-               max_leftover_frames = 4 * spec->blocksize;
+               max_leftover_frames = 4 * m_spec->blocksize;
                leftoverF = new audio_sample_t[max_leftover_frames * channels];
                leftover_frames = 0;
        } else {
-               out_samples_max = spec->blocksize * channels;
+               out_samples_max = m_spec->blocksize * channels;
        }
 
-       dither = gdither_new (spec->dither_type, channels, dither_size, 
spec->data_width);
+       dither = gdither_new (m_spec->dither_type, channels, dither_size, 
m_spec->data_width);
 
        /* allocate buffers where dithering and output will occur */
 
-       switch (spec->data_width) {
+       switch (m_spec->data_width) {
        case 8:
                sample_bytes = 1;
                break;
@@ -430,7 +428,7 @@
 
 int WriteSource::rb_file_write( nframes_t cnt )
 {
-       int read = m_buffer->read(spec->dataF, cnt);
+       int read = m_buffer->read(m_spec->dataF, cnt);
 
        if (read > 0) {
                process(read);
@@ -448,7 +446,7 @@
 {
        Q_UNUSED(seek);
 
-       spec->dataF = framebuffer;
+       m_spec->dataF = framebuffer;
        int readSpace = m_buffer->read_space();
 
        if (! m_isRecording ) {

Index: core/WriteSource.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/WriteSource.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- core/WriteSource.h  3 May 2007 10:38:29 -0000       1.12
+++ core/WriteSource.h  11 May 2007 13:09:23 -0000      1.13
@@ -17,7 +17,7 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
 
-$Id: WriteSource.h,v 1.12 2007/05/03 10:38:29 r_sijrier Exp $
+$Id: WriteSource.h,v 1.13 2007/05/11 13:09:23 r_sijrier Exp $
 */
 
 #ifndef WRITESOURCE_H
@@ -52,16 +52,13 @@
 
        int process(nframes_t nframes);
 
-       int prepare_export(ExportSpecification* spec);
        int finish_export();
-
        void set_process_peaks(bool process);
        void set_recording(int rec);
        void prepare_buffer();
 
        size_t is_recording() const;
 
-       ExportSpecification*    spec;
        void set_diskio(DiskIO* io );
        Peak*           m_peak;
 
@@ -70,6 +67,7 @@
        SNDFILE*        sf;
        SF_INFO         sfinfo;
        DiskIO*         diskio;
+       ExportSpecification*    m_spec;
        
        GDither         dither;
        nframes_t       out_samples_max;
@@ -89,6 +87,7 @@
        int     m_buffersize;
        int     m_chunksize;
        
+       int prepare_export();
        
 
 signals:

Index: traverso/songcanvas/TrackView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/TrackView.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- traverso/songcanvas/TrackView.cpp   2 May 2007 05:58:20 -0000       1.32
+++ traverso/songcanvas/TrackView.cpp   11 May 2007 13:09:23 -0000      1.33
@@ -103,7 +103,6 @@
 void TrackView::add_new_audioclipview( AudioClip * clip )
 {
        PENTER;
-       printf("TrackView:: Adding new View for clip %lld\n", clip->get_id());
        AudioClipView* clipView = new AudioClipView(m_sv, this, clip);
        m_clipViews.append(clipView);
 }




reply via email to

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