[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/core AudioClip.cpp AudioClip.h Aud...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/core AudioClip.cpp AudioClip.h Aud... |
Date: |
Mon, 10 Sep 2007 18:42:49 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/09/10 18:42:49
Modified files:
src/core : AudioClip.cpp AudioClip.h AudioClipManager.cpp
AudioClipManager.h Curve.cpp Export.h
FadeCurve.cpp Peak.cpp Project.cpp
ReadSource.cpp SnapList.cpp SnapList.h Song.cpp
Song.h TimeLine.cpp TimeLine.h Track.cpp
Track.h Utils.cpp Utils.h
Log message:
Conversion work from nframes_t to TimeRef
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.130&r2=1.131
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.h?cvsroot=traverso&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClipManager.cpp?cvsroot=traverso&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClipManager.h?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Curve.cpp?cvsroot=traverso&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Export.h?cvsroot=traverso&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/FadeCurve.cpp?cvsroot=traverso&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Peak.cpp?cvsroot=traverso&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.cpp?cvsroot=traverso&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.cpp?cvsroot=traverso&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/SnapList.cpp?cvsroot=traverso&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/SnapList.h?cvsroot=traverso&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.134&r2=1.135
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.h?cvsroot=traverso&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/TimeLine.cpp?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/TimeLine.h?cvsroot=traverso&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Track.cpp?cvsroot=traverso&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Track.h?cvsroot=traverso&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Utils.cpp?cvsroot=traverso&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Utils.h?cvsroot=traverso&r1=1.11&r2=1.12
Patches:
Index: AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -b -r1.130 -r1.131
--- AudioClip.cpp 31 Aug 2007 09:19:51 -0000 1.130
+++ AudioClip.cpp 10 Sep 2007 18:42:47 -0000 1.131
@@ -95,7 +95,7 @@
m_sourceStartLocation = TimeRef(e.attribute( "sourcestart", ""
).toLongLong(&ok));
m_sourceEndLocation = m_sourceStartLocation + m_length;
- set_track_start_frame( e.attribute( "trackstart", "" ).toUInt());
+ set_track_start_location( e.attribute( "trackstart", ""
).toLongLong(&ok));
m_domNode = node.cloneNode();
init();
}
@@ -152,9 +152,8 @@
bool ok;
m_sourceStartLocation = TimeRef(e.attribute( "sourcestart", ""
).toLongLong(&ok));
m_length = TimeRef(e.attribute( "length", "0" ).toLongLong(&ok));
-
m_sourceEndLocation = m_sourceStartLocation + m_length;
- set_track_start_frame(e.attribute( "trackstart", "" ).toLongLong(&ok));
+ set_track_start_location(e.attribute( "trackstart", ""
).toLongLong(&ok));
emit stateChanged();
@@ -343,12 +342,10 @@
m_length = m_sourceEndLocation - m_sourceStartLocation;
}
-void AudioClip::set_track_start_frame(nframes_t newTrackStartFrame)
+void AudioClip::set_track_start_location(const TimeRef& location)
{
- m_trackStartLocation = TimeRef(newTrackStartFrame, get_rate());
-
+ m_trackStartLocation = location;
set_track_end_location(m_trackStartLocation + m_length);
-
emit positionChanged(this);
}
@@ -832,14 +829,14 @@
return audiodevice().get_sample_rate();
}
-nframes_t AudioClip::get_source_length( ) const
+TimeRef& AudioClip::get_source_length( ) const
{
- return m_sourceLength.to_frame(get_rate());
+ return m_sourceLength;
}
-nframes_t AudioClip::get_length() const
+TimeRef& AudioClip::get_length() const
{
- return m_length.to_frame(get_rate());
+ return m_length;
}
int AudioClip::recording_state( ) const
@@ -847,27 +844,6 @@
return m_recordingStatus;
}
-nframes_t AudioClip::get_source_end_frame( ) const
-{
- return m_sourceEndLocation.to_frame(get_rate());
-}
-
-nframes_t AudioClip::get_source_start_frame( ) const
-{
- return m_sourceStartLocation.to_frame(get_rate());
-}
-
-nframes_t AudioClip::get_track_end_frame( ) const
-{
- return m_trackEndLocation.to_frame(get_rate());
-}
-
-nframes_t AudioClip::get_track_start_frame( ) const
-{
- return m_trackStartLocation.to_frame(get_rate());
-}
-
-
Command * AudioClip::clip_fade_in( )
{
if (!fadeIn) {
Index: AudioClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- AudioClip.h 31 Aug 2007 09:19:51 -0000 1.61
+++ AudioClip.h 10 Sep 2007 18:42:48 -0000 1.62
@@ -71,7 +71,7 @@
int init_recording(QByteArray bus);
int process(nframes_t nframes);
- void set_track_start_frame(nframes_t newTrackFirstFrame);
+ void set_track_start_location(const TimeRef& location);
void set_name(const QString& name);
void set_fade_in(nframes_t b);
void set_fade_out(nframes_t b);
@@ -90,13 +90,8 @@
FadeCurve* get_fade_out() const;
PluginChain* get_plugin_chain() const {return m_pluginChain;}
- nframes_t get_length() const;
- nframes_t get_track_start_frame() const;
- nframes_t get_track_end_frame() const;
- nframes_t get_source_start_frame() const;
- nframes_t get_source_end_frame() const;
- nframes_t get_source_length() const;
-
+ TimeRef& get_length() const;
+ TimeRef& get_source_length() const;
TimeRef& get_track_start_location() const {return m_trackStartLocation;}
TimeRef& get_track_end_location() const {return m_trackEndLocation;}
TimeRef& get_source_start_location() const {return
m_sourceStartLocation;}
@@ -122,11 +117,11 @@
static bool smaller(const AudioClip* left, const AudioClip* right )
{
- return left->get_track_start_frame() <
right->get_track_start_frame();
+ return left->get_track_start_location() <
right->get_track_start_location();
}
static bool greater(const AudioClip* left, const AudioClip* right )
{
- return left->get_track_start_frame() >
right->get_track_start_frame();
+ return left->get_track_start_location() >
right->get_track_start_location();
}
private:
Index: AudioClipManager.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClipManager.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- AudioClipManager.cpp 17 Aug 2007 00:18:29 -0000 1.16
+++ AudioClipManager.cpp 10 Sep 2007 18:42:48 -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: AudioClipManager.cpp,v 1.16 2007/08/17 00:18:29 r_sijrier Exp $
+ $Id: AudioClipManager.cpp,v 1.17 2007/09/10 18:42:48 r_sijrier Exp $
*/
#include "AudioClipManager.h"
@@ -38,7 +38,7 @@
PENTERCONS;
m_song = song;
set_history_stack( m_song->get_history_stack() );
- lastFrame = 0;
+ lastLocation = 0;
}
AudioClipManager::~ AudioClipManager( )
@@ -83,31 +83,19 @@
{
PENTER;
- lastFrame = 0;
+ lastLocation = TimeRef(0);
foreach(AudioClip* clip, m_clips) {
- if (clip->get_track_end_frame() >= lastFrame)
- lastFrame = clip->get_track_end_frame();
+ if (clip->get_track_end_location() >= lastLocation)
+ lastLocation = clip->get_track_end_location();
}
emit m_song->lastFramePositionChanged();
}
-nframes_t AudioClipManager::get_last_frame( )
+const TimeRef& AudioClipManager::get_last_location() const
{
- return lastFrame;
-}
-
-nframes_t AudioClipManager::get_start_frame( )
-{
- nframes_t startframe = UINT_MAX;
-
- foreach(AudioClip* clip, m_clips) {
- if (clip->get_track_start_frame() < startframe)
- startframe = clip->get_track_start_frame();
- }
-
- return startframe;
+ return lastLocation;
}
void AudioClipManager::get_selected_clips_state( QList< AudioClip * > & list )
Index: AudioClipManager.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClipManager.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- AudioClipManager.h 16 Mar 2007 00:14:43 -0000 1.6
+++ AudioClipManager.h 10 Sep 2007 18:42:48 -0000 1.7
@@ -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: AudioClipManager.h,v 1.6 2007/03/16 00:14:43 r_sijrier Exp $
+$Id: AudioClipManager.h,v 1.7 2007/09/10 18:42:48 r_sijrier Exp $
*/
#ifndef AUDIOCLIPMANAGER_H
@@ -48,15 +48,14 @@
QList<AudioClip* >* get_clip_list();
- nframes_t get_last_frame();
- nframes_t get_start_frame();
+ const TimeRef& get_last_location() const;
private:
QList<AudioClip* > m_clips;
QList<AudioClip* > clipselection;
Song* m_song;
- nframes_t lastFrame;
+ TimeRef lastLocation;
public slots:
void add_clip(AudioClip* clip);
Index: Curve.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Curve.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- Curve.cpp 11 Aug 2007 22:54:57 -0000 1.42
+++ Curve.cpp 10 Sep 2007 18:42:48 -0000 1.43
@@ -295,7 +295,7 @@
double slope_before = ((x[i+1] - x[i]) /
(y[i+1] - y[i]));
double slope_after = (xdelta / ydelta);
- if (slope_after * slope_before < 0.0) {
+ if ((slope_after * slope_before) < 0.0) {
/* slope m_changed sign */
fpi = 0.0;
} else {
@@ -305,12 +305,9 @@
}
/* compute second derivative for either side of control
point `i' */
-
- fppL = (((-2 * (fpi + (2 * fplast))) / (xdelta))) +
- ((6 * ydelta) / xdelta2);
-
- fppR = (2 * ((2 * fpi) + fplast) / xdelta) -
- ((6 * ydelta) / xdelta2);
+ double fractal = ((6 * ydelta) / xdelta2); // anyone
knows a better name for it?
+ fppL = (((-2 * (fpi + (2 * fplast))) / (xdelta))) +
fractal;
+ fppR = (2 * ((2 * fpi) + fplast) / xdelta) - fractal;
/* compute polynomial coefficients */
Index: Export.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Export.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- Export.h 13 Aug 2007 00:01:52 -0000 1.13
+++ Export.h 10 Sep 2007 18:42:48 -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: Export.h,v 1.13 2007/08/13 00:01:52 benjie Exp $
+$Id: Export.h,v 1.14 2007/09/10 18:42:48 r_sijrier Exp $
*/
#ifndef EXPORT_H
@@ -85,7 +85,7 @@
float peakvalue;
float normvalue;
bool resumeTransport;
- nframes_t resumeTransportFrame;
+ TimeRef resumeTransportLocation;
bool renderfinished;
bool isCdExport;
};
Index: FadeCurve.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/FadeCurve.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- FadeCurve.cpp 11 Aug 2007 22:54:57 -0000 1.25
+++ FadeCurve.cpp 10 Sep 2007 18:42:48 -0000 1.26
@@ -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: FadeCurve.cpp,v 1.25 2007/08/11 22:54:57 benjie Exp $
+$Id: FadeCurve.cpp,v 1.26 2007/09/10 18:42:48 r_sijrier Exp $
*/
#include "FadeCurve.h"
@@ -30,6 +30,7 @@
#include "Command.h"
#include "CommandGroup.h"
#include <AddRemove.h>
+#include "AudioDevice.h"
// Always put me below _all_ includes, this is needed
// in case we run with memory leak detection enabled!
@@ -174,17 +175,17 @@
int fadepos = 0;
if (m_type == FadeIn) {
- if( !( m_song->get_transport_frame() <
(m_clip->get_track_start_frame() + get_range()) ) ) {
+ if( !( m_song->get_transport_location() <
(m_clip->get_track_start_location() + get_range()) ) ) {
return;
}
- fadepos = m_song->get_transport_frame() -
m_clip->get_track_start_frame();
+ fadepos = (m_song->get_transport_location() -
m_clip->get_track_start_location()).to_frame(audiodevice().get_sample_rate());
} else {
- if( !(m_song->get_transport_frame() >
(m_clip->get_track_end_frame() - get_range())) ) {
+ if( !(m_song->get_transport_location() >
(m_clip->get_track_end_location() - get_range())) ) {
return;
}
- fadepos = m_song->get_transport_frame() -
(m_clip->get_track_end_frame() - (nframes_t)get_range());
+ fadepos = (m_song->get_transport_location() -
(m_clip->get_track_end_location() - TimeRef(get_range(),
audiodevice().get_sample_rate()))).to_frame(audiodevice().get_sample_rate());
}
// printf("mix_pos is %d, len is %d\n", mix_pos, fadeIn->get_range());
Index: Peak.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Peak.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- Peak.cpp 28 Aug 2007 19:51:52 -0000 1.44
+++ Peak.cpp 10 Sep 2007 18:42:48 -0000 1.45
@@ -23,7 +23,7 @@
#include "Peak.h"
-#include "AbstractAudioReader.h"
+#include "PeakDataReader.h"
#include "ResampleAudioReader.h"
#include "ReadSource.h"
#include "ResourcesManager.h"
@@ -146,8 +146,7 @@
fread(&m_data.normValuesDataOffset,
sizeof(m_data.normValuesDataOffset), 1, m_file);
fread(&m_data.peakDataOffset, sizeof(m_data.peakDataOffset), 1, m_file);
- m_peakreader = new ResampleAudioReader(m_fileName, 4, "peak");
- ((ResampleAudioReader*)m_peakreader)->set_output_rate(32000);
+ m_peakreader = new PeakDataReader(m_fileName);
m_peakdataDecodeBuffer = new DecodeBuffer;
peaksAvailable = true;
@@ -247,13 +246,8 @@
pixelcount = m_data.peakDataSizeForLevel[zoomLevel -
SAVING_ZOOM_FACTOR] - offset;
}
-/* // Seek to the correct position in the buffer on hard disk
- fseek(m_file, m_data.peakDataLevelOffsets[zoomLevel -
SAVING_ZOOM_FACTOR] + offset, SEEK_SET);
-
- // Read in the pixelcount of peakdata
- int read = fread(buffer, sizeof(peak_data_t), pixelcount,
m_file);*/
-
- int read = m_peakreader->read_from(m_peakdataDecodeBuffer,
(nframes_t)(m_data.peakDataLevelOffsets[zoomLevel - SAVING_ZOOM_FACTOR] +
offset)*sizeof(peak_data_t), (nframes_t)pixelcount);
+ nframes_t readposition = m_data.peakDataLevelOffsets[zoomLevel
- SAVING_ZOOM_FACTOR] + offset;
+ int read = m_peakreader->read_from(m_peakdataDecodeBuffer,
readposition, pixelcount);
if (read != pixelcount) {
PERROR("Could not read in all peak data, pixelcount is
%d, read count is %d", pixelcount, read);
Index: Project.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- Project.cpp 19 Jul 2007 12:28:42 -0000 1.54
+++ Project.cpp 10 Sep 2007 18:42:48 -0000 1.55
@@ -557,7 +557,7 @@
PMESG("Starting export for song %lld", song->get_id());
emit exportStartedForSong(song);
spec->resumeTransport = false;
- spec->resumeTransportFrame = song->get_transport_frame();
+ spec->resumeTransportLocation = song->get_transport_location();
song->readbuffer = readbuffer;
if (spec->normalize) {
@@ -593,7 +593,7 @@
while(song->render(spec) > 0) {}
-// song->set_transport_pos(spec->resumeTransportFrame);
+ song->set_transport_pos(spec->resumeTransportLocation);
if (spec->resumeTransport) {
if (!QMetaObject::invokeMethod(song, "start_transport",
Qt::QueuedConnection)) {
printf("Invoking Song::start_transport()
failed\n");
Index: ReadSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- ReadSource.cpp 29 Aug 2007 17:01:30 -0000 1.53
+++ ReadSource.cpp 10 Sep 2007 18:42:48 -0000 1.54
@@ -150,7 +150,7 @@
node.setAttribute("name", m_name);
node.setAttribute("origbitdepth", m_origBitDepth);
node.setAttribute("wasrecording", m_wasRecording);
- node.setAttribute("length", m_length.to_frame(m_rate));
+ node.setAttribute("length", m_length.universal_frame());
node.setAttribute("rate", m_rate);
node.setAttribute("decoder", m_decodertype);
@@ -168,7 +168,8 @@
set_dir( e.attribute("dir", "" ));
m_id = e.attribute("id", "").toLongLong();
m_rate = e.attribute("rate", "0").toUInt();
- m_length = TimeRef(e.attribute("length", "0").toUInt(), m_rate);
+ bool ok;
+ m_length = TimeRef(e.attribute("length", "0").toLongLong(&ok));
m_origBitDepth = e.attribute("origbitdepth", "0").toInt();
m_wasRecording = e.attribute("wasrecording", "0").toInt();
m_decodertype = e.attribute("decoder", "");
@@ -198,7 +199,7 @@
m_rate = project->get_rate();
if (m_silent) {
- m_length = TimeRef(UINT_MAX);
+ m_length = TimeRef(LONG_LONG_MAX);
m_channelCount = 0;
m_origBitDepth = project->get_bitdepth();
return 1;
@@ -422,14 +423,14 @@
// if not, fill the buffer from the earliest point this clip
// will come into play.
if (fileposition < 0) {
-// printf("not seeking to %ld, but too %d\n\n",
fileposition,m_clip->get_source_start_frame());
+// printf("not seeking to %ld, but too %d\n\n",
fileposition,m_clip->get_source_start_location());
// Song's start from 0, this makes a period start from
// 0 - 1023 for example, the nframes is 1024!
// Setting a songs new position is on 1024, and NOT
// 1023.. Hmm, something isn't correct here, but at least
substract 1
// to make this thing work!
// TODO check if this is still needed!
- fileposition = TimeRef(m_clip->get_source_start_frame() - 1,
audiodevice().get_sample_rate());
+ fileposition = m_clip->get_source_start_location() - TimeRef(1,
audiodevice().get_sample_rate());
}
// printf("rb_seek_to_file_position:: seeking to relative pos: %d\n",
fileposition);
@@ -556,7 +557,7 @@
m_buffers.append(new RingBufferNPT<float>(m_bufferSize));
}
- TimeRef synclocation = m_clip->get_song()->get_working_location();
+ TimeRef synclocation = m_clip->get_song()->get_work_location();
start_resync(synclocation);
}
@@ -599,6 +600,6 @@
int ReadSource::file_read(DecodeBuffer * buffer, nframes_t start, nframes_t
cnt)
{
- TimeRef startlocation(start, get_rate() );
+ TimeRef startlocation(start, get_rate());
return file_read(buffer, startlocation, cnt);
}
Index: SnapList.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/SnapList.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- SnapList.cpp 31 Aug 2007 09:19:51 -0000 1.17
+++ SnapList.cpp 10 Sep 2007 18:42:48 -0000 1.18
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2006 Nicola Doebelin
+Copyright (C) 2006-2007 Nicola Doebelin, Remon Sijrier
This file is part of Traverso
@@ -17,7 +17,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: SnapList.cpp,v 1.17 2007/08/31 09:19:51 r_sijrier Exp $
*/
#include "SnapList.h"
@@ -62,9 +61,9 @@
void SnapList::update_snaplist()
{
- xposList.clear();
- xposLut.clear();
- xposBool.clear();
+ m_xposList.clear();
+ m_xposLut.clear();
+ m_xposBool.clear();
// collects all clip boundaries and adds them to the snap list
QList<AudioClip* >* acList =
m_song->get_audioclip_manager()->get_clip_list();
@@ -73,7 +72,7 @@
// Be able to snap to trackstart
if (m_rangeStart == 0) {
- xposList.append(0);
+ m_xposList.append(0);
}
for( int i = 0; i < acList->size(); i++ ) {
@@ -83,18 +82,18 @@
continue;
}
- nframes_t startframe = clip->get_track_start_frame();
- nframes_t endframe = clip->get_track_end_frame();
+ TimeRef startlocation = clip->get_track_start_location();
+ TimeRef endlocation = clip->get_track_end_location();
- if (startframe > endframe) {
+ if (startlocation > endlocation) {
PERROR("clip xstart > xend, this must be a programming
error!");
continue; // something wrong, ignore this clip
}
- if (startframe >= m_rangeStart && startframe <= m_rangeEnd) {
- xposList.append(startframe);
+ if (startlocation >= m_rangeStart && startlocation <=
m_rangeEnd) {
+ m_xposList.append(startlocation);
}
- if (endframe >= m_rangeStart && endframe <= m_rangeEnd) {
- xposList.append(endframe);
+ if (endlocation >= m_rangeStart && endlocation <= m_rangeEnd) {
+ m_xposList.append(endlocation);
}
}
@@ -102,34 +101,34 @@
QList<Marker*> markerList = m_song->get_timeline()->get_markers();
for (int i = 0; i < markerList.size(); ++i) {
if (markerList.at(i)->is_snappable() &&
markerList.at(i)->get_when() >= m_rangeStart && markerList.at(i)->get_when() <=
m_rangeEnd) {
- xposList.append(markerList.at(i)->get_when());
+ m_xposList.append(markerList.at(i)->get_when());
}
}
// add the working cursor's position
- nframes_t workingframe = m_song->get_working_frame();
- //printf("workingframe xpos is %d\n", workingframe / m_scalefactor);
- if (m_song->get_work_snap()->is_snappable() && workingframe >=
m_rangeStart && workingframe <= m_rangeEnd) {
- xposList.append(m_song->get_working_frame());
+ TimeRef worklocation = m_song->get_work_location();
+ //printf("worklocation xpos is %d\n", worklocation / m_scalefactor);
+ if (m_song->get_work_snap()->is_snappable() && worklocation >=
m_rangeStart && worklocation <= m_rangeEnd) {
+ m_xposList.append(m_song->get_work_location());
}
// sort the list
- qSort(xposList);
+ qSort(m_xposList);
- int range = (m_rangeEnd - m_rangeStart) / m_scalefactor;
+ int range = (int)((m_rangeEnd - m_rangeStart) / m_scalefactor);
// create a linear lookup table
for (int i = 0; i <= range; ++i) {
- xposLut.push_back(0);
- xposBool.push_back(false);
+ m_xposLut.push_back(0);
+ m_xposBool.push_back(false);
}
- nframes_t lastVal = 0;
+ TimeRef lastVal = 0;
long lastIndex = -1;
// now modify the regions around snap points in the lookup table
- for (int i = 0; i < xposList.size(); i++) {
- if (lastIndex > -1 && xposList.at(i) == lastVal) {
+ for (int i = 0; i < m_xposList.size(); i++) {
+ if (lastIndex > -1 && m_xposList.at(i) == lastVal) {
continue; // check for duplicates and skip them
}
@@ -138,27 +137,27 @@
int ls = -SNAP_WIDTH;
if (lastIndex > -1) {
- if ( (nframes_t)(xposList.at(i) - lastVal) <
(nframes_t)(2 * SNAP_WIDTH * m_scalefactor) ) {
- ls = - (int) ((xposList.at(i) / m_scalefactor -
lastVal / m_scalefactor) / 2);
+ if ( (m_xposList.at(i) - lastVal) < (2 * SNAP_WIDTH *
m_scalefactor) ) {
+ ls = - (int) ((m_xposList.at(i) / m_scalefactor
- lastVal / m_scalefactor) / 2);
}
}
for (int j = ls; j <= SNAP_WIDTH; j++) {
- int pos = (xposList.at(i) - m_rangeStart) /
m_scalefactor + j; // index in the LUT
+ int pos = (int)((m_xposList.at(i) - m_rangeStart) /
m_scalefactor + j); // index in the LUT
if (pos < 0) {
continue;
}
- if (pos >= xposLut.size()) {
+ if (pos >= m_xposLut.size()) {
break;
}
- xposLut[pos] = xposList.at(i);
- xposBool[pos] = true;
+ m_xposLut[pos] = m_xposList.at(i);
+ m_xposBool[pos] = true;
}
- lastVal = xposList.at(i);
+ lastVal = m_xposList.at(i);
lastIndex = i;
}
@@ -168,13 +167,13 @@
// public function that checks if there is a snap position
// within +-SNAP_WIDTH of the supplied value i
-int SnapList::get_snap_value(nframes_t pos)
+TimeRef SnapList::get_snap_value(const TimeRef& pos)
{
if (m_isDirty) {
update_snaplist();
}
- int i = (pos - m_rangeStart) / m_scalefactor;
+ int i = (int)((pos - m_rangeStart) / m_scalefactor);
SLPRINT("get_snap_value:: i is %d\n", i);
// catch dangerous values:
@@ -183,19 +182,19 @@
return pos;
}
- if (xposLut.isEmpty()) {
+ if (m_xposLut.isEmpty()) {
SLPRINT("get_snap_value:: empty lut\n");
return pos;
}
- if (i >= xposLut.size()) {
- SLPRINT("get_snap_value:: i > xposLut.size()\n");
+ if (i >= m_xposLut.size()) {
+ SLPRINT("get_snap_value:: i > m_xposLut.size()\n");
return pos;
}
if (is_snap_value(pos)) {
- SLPRINT("get_snap_value returns: %d (was %d)\n", xposLut.at(i),
pos);
- return xposLut.at(i);
+ SLPRINT("get_snap_value returns: %d (was %d)\n",
m_xposLut.at(i), pos);
+ return m_xposLut.at(i);
}
@@ -204,13 +203,13 @@
}
// returns true if i is inside a snap area, else returns false
-bool SnapList::is_snap_value(nframes_t pos)
+bool SnapList::is_snap_value(const TimeRef& pos)
{
if (m_isDirty) {
update_snaplist();
}
- int i = (pos - m_rangeStart) / m_scalefactor;
+ int i = (int)((pos - m_rangeStart) / m_scalefactor);
SLPRINT("is_snap_value:: i is %d\n", i);
// need to catch values outside the LUT. Return false in that case
@@ -218,23 +217,23 @@
return false;
}
- if (i >= xposBool.size()) {
+ if (i >= m_xposBool.size()) {
return false;
}
- SLPRINT("is_snap_value returns: %d\n", xposBool.at(i));
- return xposBool.at(i);
+ SLPRINT("is_snap_value returns: %d\n", m_xposBool.at(i));
+ return m_xposBool.at(i);
}
// returns the difference between the unsnapped and snapped location.
// The return value is negative if the supplied value is < snapped value
-int SnapList::get_snap_diff(nframes_t pos)
+qint64 SnapList::get_snap_diff(const TimeRef& pos)
{
if (m_isDirty) {
update_snaplist();
}
- int i = (pos - m_rangeStart) / m_scalefactor;
+ int i = (int)((pos - m_rangeStart) / m_scalefactor);
SLPRINT("get_snap_diff:: i is %d\n", i);
// need to catch values outside the LUT. Return 0 in that case
@@ -242,15 +241,15 @@
return 0;
}
- if (i >= xposLut.size()) {
+ if (i >= m_xposLut.size()) {
return 0;
}
- SLPRINT("get_snap_diff returns: %d\n", xposLut.at(i));
- return pos - xposLut.at(i);
+ SLPRINT("get_snap_diff returns: %d\n", m_xposLut.at(i));
+ return (pos - m_xposLut.at(i)).universal_frame();
}
-void SnapList::set_range(nframes_t start, nframes_t end, int scalefactor)
+void SnapList::set_range(const TimeRef& start, const TimeRef& end, int
scalefactor)
{
SLPRINT("setting xstart %d, xend %d scalefactor %d\n", start, end,
scalefactor);
@@ -264,22 +263,22 @@
m_isDirty = true;
};
-nframes_t SnapList::next_snap_pos(nframes_t pos)
+TimeRef SnapList::next_snap_pos(const TimeRef& pos)
{
if (m_isDirty) {
update_snaplist();
}
- int index = pos / m_scalefactor;
+ int index = (int)(pos / m_scalefactor);
- nframes_t newpos = pos;
+ TimeRef newpos = pos;
- if (index > xposLut.size()) {
- index = xposLut.size() - 1;
+ if (index > m_xposLut.size()) {
+ index = m_xposLut.size() - 1;
}
- for (; index<xposLut.size(); ++index) {
- nframes_t snap = xposLut.at(index);
+ for (; index<m_xposLut.size(); ++index) {
+ TimeRef snap = m_xposLut.at(index);
if (snap > pos) {
newpos = snap;
break;
@@ -289,25 +288,25 @@
return newpos;
}
-nframes_t SnapList::prev_snap_pos(nframes_t pos)
+TimeRef SnapList::prev_snap_pos(const TimeRef& pos)
{
if (m_isDirty) {
update_snaplist();
}
- if (! xposLut.size()) {
+ if (! m_xposLut.size()) {
return pos;
}
- nframes_t newpos = pos;
+ TimeRef newpos = pos;
- int index = pos / m_scalefactor;
- if (index > xposLut.size()) {
- index = xposLut.size() - 1;
+ int index = (int)(pos / m_scalefactor);
+ if (index > m_xposLut.size()) {
+ index = m_xposLut.size() - 1;
}
do {
- nframes_t snap = xposLut.at(index);
+ TimeRef snap = m_xposLut.at(index);
if (snap < pos && snap != 0) {
newpos = snap;
break;
@@ -326,11 +325,3 @@
return newpos;
}
-TimeRef SnapList::get_snap_value(TimeRef& location)
-{
- if (location < 0) {
- location = 0;
- }
- TimeRef snap(get_snap_value(location.to_frame(44100)), 44100);
- return snap;
-}
Index: SnapList.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/SnapList.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- SnapList.h 31 Aug 2007 09:19:51 -0000 1.11
+++ SnapList.h 10 Sep 2007 18:42:48 -0000 1.12
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2006 Nicola Doebelin
+Copyright (C) 2006-2007 Nicola Doebelin, Remon Sijrier
This file is part of Traverso
@@ -17,7 +17,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: SnapList.h,v 1.11 2007/08/31 09:19:51 r_sijrier Exp $
*/
#ifndef SNAPLIST_H
@@ -40,24 +39,23 @@
SnapList(Song* song);
~SnapList() {};
- int get_snap_value(nframes_t);
- TimeRef get_snap_value(TimeRef& location);
- bool is_snap_value(nframes_t);
- int get_snap_diff(nframes_t);
- nframes_t next_snap_pos(nframes_t pos);
- nframes_t prev_snap_pos(nframes_t pos);
+ TimeRef get_snap_value(const TimeRef& location);
+ bool is_snap_value(const TimeRef& location);
+ qint64 get_snap_diff(const TimeRef& location);
+ TimeRef next_snap_pos(const TimeRef& location);
+ TimeRef prev_snap_pos(const TimeRef& location);
- void set_range(nframes_t start, nframes_t end, int scalefactor);
+ void set_range(const TimeRef& start, const TimeRef& end, int
scalefactor);
private:
Song* m_song;
- QList<nframes_t> xposList;
- QList<int> xposLut;
- QList<bool> xposBool;
+ QList<TimeRef> m_xposList;
+ QList<TimeRef> m_xposLut;
+ QList<bool> m_xposBool;
bool m_isDirty;
- nframes_t m_rangeStart;
- nframes_t m_rangeEnd;
- int m_scalefactor;
+ TimeRef m_rangeStart;
+ TimeRef m_rangeEnd;
+ qint64 m_scalefactor;
void update_snaplist();
Index: Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -b -r1.134 -r1.135
--- Song.cpp 30 Aug 2007 20:42:43 -0000 1.134
+++ Song.cpp 10 Sep 2007 18:42:48 -0000 1.135
@@ -159,7 +159,8 @@
m_scheduledForDeletion = false;
m_isSnapOn=true;
changed = m_rendering = m_recording = m_prepareRecording = false;
- firstVisibleFrame=workingFrame=0;
+ firstVisibleFrame=0;
+ m_workLocation=0;
m_seeking = m_startSeek = 0;
// TODO seek to old position on project exit ?
// m_transportFrame = 0;
@@ -196,9 +197,9 @@
m_sbx = e.attribute("sbx", "0").toInt();
m_sby = e.attribute("sby", "0").toInt();
set_first_visible_frame(e.attribute( "firstVisibleFrame", "0"
).toUInt());
- set_work_at(e.attribute( "workingFrame", "0").toUInt());
bool ok;
+ set_work_at(e.attribute( "m_workLocation", "0").toLongLong(&ok));
m_transportLocation = TimeRef(e.attribute( "transportlocation",
"0").toLongLong(&ok));
// Start seeking to the 'old' transport pos
@@ -237,7 +238,7 @@
properties.setAttribute("title", title);
properties.setAttribute("artists", artists);
properties.setAttribute("firstVisibleFrame", firstVisibleFrame);
- properties.setAttribute("workingFrame", (uint)workingFrame);
+ properties.setAttribute("m_workLocation",
m_workLocation.universal_frame());
properties.setAttribute("transportlocation",
m_transportLocation.universal_frame());
properties.setAttribute("hzoom", m_hzoom);
properties.setAttribute("sbx", m_sbx);
@@ -349,23 +350,24 @@
spec->start_frame = INT_MAX;
spec->end_frame = 0;
- nframes_t endframe, startframe;
+ TimeRef endlocation, startlocation;
+ int devicerate = audiodevice().get_sample_rate();
foreach (Track* track, m_tracks) {
- track->get_render_range(startframe, endframe);
+ track->get_render_range(startlocation, endlocation);
if (track->is_solo()) {
- spec->end_frame = endframe;
- spec->start_frame = startframe;
+ spec->end_frame = endlocation.to_frame(devicerate);
+ spec->start_frame = startlocation.to_frame(devicerate);
break;
}
- if (endframe > spec->end_frame) {
- spec->end_frame = endframe;
+ if (endlocation.to_frame(devicerate) > spec->end_frame) {
+ spec->end_frame = endlocation.to_frame(devicerate);
}
- if (startframe < (uint)spec->start_frame) {
- spec->start_frame = startframe;
+ if (startlocation.to_frame(devicerate) <
(uint)spec->start_frame) {
+ spec->start_frame = startlocation.to_frame(devicerate);
}
}
@@ -373,18 +375,18 @@
if (spec->isCdExport) {
QList<Marker*> markers = m_timeline->get_markers();
if (markers.size() >= 2) {
- startframe = markers.at(0)->get_when();
- PMESG2(" Start marker found at %d", startframe);
+ startlocation = TimeRef(markers.at(0)->get_when(),
devicerate);
+ PMESG2(" Start marker found at %d",
startlocation.to_frame(devicerate));
// round down to the start of the CD frome (75th of a
sec)
- startframe = cd_to_frame(frame_to_cd(startframe,
m_project->get_rate()), m_project->get_rate());
- spec->start_frame = startframe;
+ startlocation =
TimeRef(cd_to_frame(frame_to_cd(startlocation.to_frame(devicerate),
m_project->get_rate()), m_project->get_rate()), devicerate);
+ spec->start_frame = startlocation.to_frame(devicerate);
} else {
PMESG2(" No start marker found");
}
- if (m_timeline->get_end_position(endframe)) {
- PMESG2(" End marker found at %d", endframe);
- spec->end_frame = endframe;
+ if (m_timeline->get_end_position(endlocation)) {
+ PMESG2(" End marker found at %d",
endlocation.to_frame(devicerate));
+ spec->end_frame = endlocation.to_frame(devicerate);
} else {
PMESG2(" No end marker found");
}
@@ -570,16 +572,13 @@
emit firstVisibleFrameChanged();
}
-void Song::set_work_at(nframes_t pos)
+void Song::set_work_at(const TimeRef& location)
{
- PENTER;
-
- workingFrame = pos;
+ m_workLocation = location;
snaplist->mark_dirty(workSnap);
emit workingPosChanged();
}
-
Command* Song::toggle_snap()
{
set_snapping( ! m_isSnapOn );
@@ -673,35 +672,35 @@
Command* Song::work_next_edge()
{
- nframes_t w = m_acmanager->get_last_frame();
+/* nframes_t w = m_acmanager->get_last_frame();
foreach(Track* track, m_tracks) {
- AudioClip* c=track->get_clip_after(workingFrame);
+ AudioClip* c=track->get_clip_after(m_workLocation);
- if ((c) && (c->get_track_start_frame() < w &&
c->get_track_start_frame() > workingFrame))
- w = c->get_track_start_frame();
+ if ((c) && (c->get_track_start_location() < w &&
c->get_track_start_location() > m_workLocation))
+ w = c->get_track_start_location();
}
set_work_at(w);
emit setCursorAtEdge();
-
+*/
return (Command*) 0;
}
Command* Song::work_previous_edge()
{
- nframes_t w = 0;
+/* TimeRef w(0);
foreach(Track* track, m_tracks) {
- AudioClip* c = track->get_clip_before(workingFrame);
- if ((c) && (c->get_track_end_frame() >= w &&
c->get_track_end_frame() < workingFrame) )
- w=c->get_track_end_frame();
+ AudioClip* c = track->get_clip_before(m_workLocation);
+ if ((c) && (c->get_track_end_location() >= w &&
c->get_track_end_location() < m_workLocation) )
+ w=c->get_track_end_location();
}
set_work_at(w);
emit setCursorAtEdge();
-
+*/
return (Command*) 0;
}
@@ -1013,9 +1012,9 @@
m_playBackBus = audiodevice().get_playback_bus("Playback 1");
}
-nframes_t Song::get_last_frame( ) const
+const TimeRef& Song::get_last_location() const
{
- return m_acmanager->get_last_frame();
+ return m_acmanager->get_last_location();
}
void Song::private_add_track(Track* track)
@@ -1038,17 +1037,17 @@
return 0;
}
-void Song::move_clip(Track * from, Track * too, AudioClip * clip, nframes_t
pos)
+void Song::move_clip(Track * from, Track * too, AudioClip * clip, TimeRef
location)
{
if (from == too) {
- clip->set_track_start_frame(pos);
+ clip->set_track_start_location(location);
return;
}
Command::process_command(from->remove_clip(clip, false, true));
Command::process_command(too->add_clip(clip, false, true));
- clip->set_track_start_frame(pos);
+ clip->set_track_start_location(location);
}
Command* Song::set_editing_mode( )
@@ -1268,12 +1267,6 @@
m_readyToRecord = true;
}
-void Song::set_transport_pos(nframes_t frames)
-{
- TimeRef location(frames, audiodevice().get_sample_rate());
- set_transport_pos(location);
-}
-
void Song::set_transport_pos(TimeRef location)
{
#if defined (THREAD_CHECK)
@@ -1327,16 +1320,4 @@
}
-nframes_t Song::get_transport_frame()
-{
- return m_transportLocation.to_frame(audiodevice().get_sample_rate());
-}
-
// eof
-
-TimeRef Song::get_working_location() const
-{
- TimeRef location(workingFrame, audiodevice().get_sample_rate());
- return location;
-}
-
Index: Song.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- Song.h 28 Aug 2007 19:51:52 -0000 1.66
+++ Song.h 10 Sep 2007 18:42:48 -0000 1.67
@@ -83,12 +83,10 @@
int is_transport_rolling() const {return m_transport;}
void get_scrollbar_xy(int& x, int& y) {x = m_sbx; y = m_sby;}
- nframes_t get_transport_frame();
- nframes_t get_working_frame() const {return workingFrame;}
+ const TimeRef& get_work_location() const {return m_workLocation;}
nframes_t get_first_visible_frame() const;
- nframes_t get_last_frame() const;
+ const TimeRef& get_last_location() const;
const TimeRef& get_transport_location() const {return
m_transportLocation;}
- TimeRef get_working_location() const;
const TimeRef& get_new_transport_location() const {return
m_newTransportLocation;}
@@ -111,9 +109,8 @@
void set_artists(const QString& pArtistis);
void set_first_visible_frame(nframes_t pos);
void set_title(const QString& sTitle);
- void set_work_at(nframes_t pos);
+ void set_work_at(const TimeRef& location);
void set_transport_pos(TimeRef location);
- void set_transport_pos(nframes_t frames);
void set_hzoom(int hzoom);
void set_snapping(bool snap);
void set_scrollbar_xy(int x, int y) {m_sbx = x; m_sby = y;}
@@ -130,7 +127,7 @@
void solo_track(Track* track);
void create(int tracksToCreate);
- void move_clip(Track* from, Track* too, AudioClip* clip, nframes_t pos);
+ void move_clip(Track* from, Track* too, AudioClip* clip, TimeRef
location);
Command* add_track(Track* track, bool historable=true);
Command* remove_track(Track* track, bool historable=true);
@@ -172,13 +169,13 @@
// would suffice, or should we use t_atomic_int_set/get() to make
// it 100% portable and working on all platforms...?
volatile size_t m_transportFrame;
- volatile size_t workingFrame;
volatile size_t m_newTransportFramePos;
volatile size_t m_transport;
volatile size_t m_seeking;
volatile size_t m_startSeek;
TimeRef m_transportLocation;
+ TimeRef m_workLocation;
TimeRef m_newTransportLocation;
Index: TimeLine.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/TimeLine.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- TimeLine.cpp 9 May 2007 20:11:47 -0000 1.6
+++ TimeLine.cpp 10 Sep 2007 18:42:49 -0000 1.7
@@ -24,6 +24,7 @@
#include "Song.h"
#include "Marker.h"
#include <AddRemove.h>
+#include "AudioDevice.h"
TimeLine::TimeLine(Song * song)
@@ -124,11 +125,11 @@
return 0;
}
-bool TimeLine::get_end_position(nframes_t & pos)
+bool TimeLine::get_end_position(TimeRef& pos)
{
foreach(Marker* marker, m_markers) {
if (marker->get_type() == Marker::ENDMARKER) {
- pos = marker->get_when();
+ pos = TimeRef(marker->get_when(),
audiodevice().get_sample_rate());
return true;
}
}
Index: TimeLine.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/TimeLine.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- TimeLine.h 9 May 2007 20:11:47 -0000 1.6
+++ TimeLine.h 10 Sep 2007 18:42:49 -0000 1.7
@@ -44,7 +44,7 @@
Song *get_song() const {return m_song;}
Marker* get_marker(qint64 id);
- bool get_end_position(nframes_t &pos);
+ bool get_end_position(TimeRef& pos);
bool has_end_marker();
Command* add_marker(Marker* marker, bool historable=true);
Index: Track.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Track.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- Track.cpp 11 Aug 2007 22:54:57 -0000 1.64
+++ Track.cpp 10 Sep 2007 18:42:49 -0000 1.65
@@ -187,24 +187,24 @@
}
-AudioClip* Track::get_clip_after(nframes_t framePos)
+AudioClip* Track::get_clip_after(const TimeRef& pos)
{
AudioClip* clip;
for (int i=0; i < audioClipList.size(); ++i) {
clip = audioClipList.at(i);
- if (clip->get_track_start_frame() > framePos)
+ if (clip->get_track_start_location() > pos)
return clip;
}
return (AudioClip*) 0;
}
-AudioClip* Track::get_clip_before(nframes_t framePos)
+AudioClip* Track::get_clip_before(const TimeRef& pos)
{
AudioClip* clip;
for (int i=0; i < audioClipList.size(); ++i) {
clip = audioClipList.at(i);
- if (clip->get_track_start_frame() < framePos)
+ if (clip->get_track_start_location() < pos)
return clip;
}
return (AudioClip*) 0;
@@ -318,7 +318,7 @@
AudioClip* clip = resources_manager()->new_audio_clip(name);
clip->set_song(m_song);
clip->set_track(this);
- clip->set_track_start_frame(m_song->get_transport_frame());
+ clip->set_track_start_location(m_song->get_transport_location());
if (clip->init_recording(busIn) < 0) {
PERROR("Could not create AudioClip to record to!");
@@ -498,13 +498,13 @@
emit stateChanged();
}
-void Track::get_render_range(nframes_t& startframe, nframes_t& endframe )
+void Track::get_render_range(TimeRef& startlocation, TimeRef& endlocation )
{
if (audioClipList.size() == 0)
return;
- endframe = 0;
- startframe = INT_MAX;
+ endlocation = 0;
+ startlocation = LONG_LONG_MAX;
AudioClip* clip;
@@ -512,12 +512,12 @@
clip = audioClipList.at( i );
if (! clip->is_muted() ) {
- if (clip->get_track_end_frame() > endframe) {
- endframe = clip->get_track_end_frame();
+ if (clip->get_track_end_location() > endlocation) {
+ endlocation = clip->get_track_end_location();
}
- if (clip->get_track_start_frame() < startframe) {
- startframe = clip->get_track_start_frame();
+ if (clip->get_track_start_location() < startlocation) {
+ startlocation =
clip->get_track_start_location();
}
}
}
Index: Track.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Track.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- Track.h 30 May 2007 13:57:36 -0000 1.30
+++ Track.h 10 Sep 2007 18:42:49 -0000 1.31
@@ -66,9 +66,9 @@
int disarm();
// Get functions:
- AudioClip* get_clip_after(nframes_t framePos);
- AudioClip* get_clip_before(nframes_t framePos);
- void get_render_range(nframes_t& startframe, nframes_t& endframe);
+ AudioClip* get_clip_after(const TimeRef& pos);
+ AudioClip* get_clip_before(const TimeRef& pos);
+ void get_render_range(TimeRef& startlocation, TimeRef& endlocation);
QString get_bus_in() const {return busIn;}
QString get_bus_out() const{return busOut;}
int get_height() const {return m_height;}
Index: Utils.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Utils.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- Utils.cpp 11 Aug 2007 22:54:57 -0000 1.12
+++ Utils.cpp 10 Sep 2007 18:42:49 -0000 1.13
@@ -146,14 +146,14 @@
return out;
}
-nframes_t msms_to_frame( QString str, int rate )
+TimeRef msms_to_timeref(QString str)
{
- nframes_t out = 0;
+ TimeRef out = 0;
QStringList lst = str.simplified().split(QRegExp("[;,.:]"),
QString::SkipEmptyParts);
- if (lst.size() >= 1) out += lst.at(0).toInt() * 60 * rate;
- if (lst.size() >= 2) out += lst.at(1).toInt() * rate;
- if (lst.size() >= 3) out += lst.at(2).toInt() * rate / 1000;
+ if (lst.size() >= 1) out += lst.at(0).toInt() * 60 *
UNIVERSAL_SAMPLE_RATE;
+ if (lst.size() >= 2) out += lst.at(1).toInt() * UNIVERSAL_SAMPLE_RATE;
+ if (lst.size() >= 3) out += lst.at(2).toInt() * UNIVERSAL_SAMPLE_RATE /
1000;
return out;
}
@@ -218,5 +218,63 @@
return pixmap;
}
+QString timeref_to_ms(const TimeRef& ref)
+{
+ long unsigned int remainder;
+ int mins, secs;
+
+ qint64 universalframe = ref.universal_frame();
+
+ mins = (int) (universalframe / ( 60 * UNIVERSAL_SAMPLE_RATE ));
+ remainder = (long unsigned int) (universalframe - (mins * 60 *
UNIVERSAL_SAMPLE_RATE));
+ secs = (int) (remainder / UNIVERSAL_SAMPLE_RATE);
+ return QString().sprintf("%02d:%02d", mins, secs);
+}
+
+// TimeRef to MM:SS.99 (hundredths)
+QString timeref_to_ms_2 (const TimeRef& ref)
+{
+ QString spos;
+ long unsigned int remainder;
+ int mins, secs, frames;
+
+ qint64 universalframe = ref.universal_frame();
+
+ mins = universalframe / ( 60 * UNIVERSAL_SAMPLE_RATE );
+ remainder = universalframe - ( mins * 60 * UNIVERSAL_SAMPLE_RATE );
+ secs = remainder / UNIVERSAL_SAMPLE_RATE;
+ remainder -= secs * UNIVERSAL_SAMPLE_RATE;
+ frames = remainder * 100 / UNIVERSAL_SAMPLE_RATE;
+ spos.sprintf ( " %02d:%02d%c%02d", mins, secs,
QLocale::system().decimalPoint().toAscii(), frames );
-//eof
+ return spos;
+}
+
+// TimeRef to MM:SS.999 (ms)
+QString timeref_to_ms_3(const TimeRef& ref)
+{
+ QString spos;
+ long unsigned int remainder;
+ int mins, secs, frames;
+
+ qint64 universalframe = ref.universal_frame();
+
+ mins = universalframe / ( 60 * UNIVERSAL_SAMPLE_RATE );
+ remainder = universalframe - ( mins * 60 * UNIVERSAL_SAMPLE_RATE );
+ secs = remainder / UNIVERSAL_SAMPLE_RATE;
+ remainder -= secs * UNIVERSAL_SAMPLE_RATE;
+ frames = remainder * 1000 / UNIVERSAL_SAMPLE_RATE;
+ spos.sprintf ( " %02d:%02d%c%03d", mins, secs,
QLocale::system().decimalPoint().toAscii(), frames );
+
+ return spos;
+}
+
+
+QString timeref_to_text(const TimeRef & ref, int scalefactor)
+{
+ if (scalefactor >= 512*882) {
+ return timeref_to_ms_2(ref);
+ } else {
+ return timeref_to_ms_3(ref);
+ }
+}
Index: Utils.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Utils.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- Utils.h 8 May 2007 22:13:40 -0000 1.11
+++ Utils.h 10 Sep 2007 18:42:49 -0000 1.12
@@ -37,8 +37,14 @@
QString frame_to_cd(nframes_t nframes, int rate);
QString frame_to_hms(double nframes, int rate);
QString frame_to_ms(double nframes, int rate);
+
+QString timeref_to_ms(const TimeRef& ref);
+QString timeref_to_ms_2 (const TimeRef& ref);
+QString timeref_to_ms_3 (const TimeRef& ref);
+QString timeref_to_text(const TimeRef& ref, int scalefactor);
+
nframes_t smpte_to_frame(QString str, int rate);
-nframes_t msms_to_frame(QString str, int rate);
+TimeRef msms_to_timeref(QString str);
nframes_t cd_to_frame(QString str, int rate);
QString coefficient_to_dbstring(float coeff);
QDateTime extract_date_time(qint64 id);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src/core AudioClip.cpp AudioClip.h Aud...,
Remon Sijrier <=