[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src core/Project.cpp core/Song.cpp cor...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src core/Project.cpp core/Song.cpp cor... |
Date: |
Thu, 19 Jul 2007 12:28:43 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/07/19 12:28:43
Modified files:
src/core : Project.cpp Song.cpp Song.h
src/engine : AudioDevice.cpp AudioDevice.h defines.h
JackDriver.cpp
src/traverso : Traverso.cpp
Log message:
* First start to move to universal sample rate
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Project.cpp?cvsroot=traverso&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.cpp?cvsroot=traverso&r1=1.124&r2=1.125
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/Song.h?cvsroot=traverso&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/AudioDevice.cpp?cvsroot=traverso&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/AudioDevice.h?cvsroot=traverso&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/defines.h?cvsroot=traverso&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/traverso/src/engine/JackDriver.cpp?cvsroot=traverso&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/Traverso.cpp?cvsroot=traverso&r1=1.45&r2=1.46
Patches:
Index: core/Project.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Project.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- core/Project.cpp 15 Jul 2007 05:09:46 -0000 1.53
+++ core/Project.cpp 19 Jul 2007 12:28:42 -0000 1.54
@@ -593,7 +593,7 @@
while(song->render(spec) > 0) {}
- song->set_transport_pos(spec->resumeTransportFrame);
+// song->set_transport_pos(spec->resumeTransportFrame);
if (spec->resumeTransport) {
if (!QMetaObject::invokeMethod(song, "start_transport",
Qt::QueuedConnection)) {
printf("Invoking Song::start_transport()
failed\n");
Index: core/Song.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.cpp,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -b -r1.124 -r1.125
--- core/Song.cpp 18 Jul 2007 18:15:22 -0000 1.124
+++ core/Song.cpp 19 Jul 2007 12:28:42 -0000 1.125
@@ -162,7 +162,8 @@
firstVisibleFrame=workingFrame=0;
m_seeking = m_startSeek = 0;
// TODO seek to old position on project exit ?
- m_transportFrame = 0;
+// m_transportFrame = 0;
+ m_transportLocation.set_position(0, audiodevice().get_sample_rate());
m_mode = EDIT;
m_sbx = m_sby = 0;
@@ -195,9 +196,10 @@
m_sby = e.attribute("sby", "0").toInt();
set_first_visible_frame(e.attribute( "firstVisibleFrame", "0"
).toUInt());
set_work_at(e.attribute( "workingFrame", "0").toUInt());
- m_transportFrame = e.attribute( "transportFrame", "0").toUInt();
+// m_transportFrame = e.attribute( "transportFrame", "0").toUInt();
+ m_transportLocation.set_position(e.attribute( "transportFrame",
"0").toUInt(), audiodevice().get_sample_rate());
// Start seeking to the 'old' transport pos
- set_transport_pos(m_transportFrame);
+ set_transport_pos(m_transportLocation);
set_snapping(e.attribute("snapping", "0").toInt());
m_mode = e.attribute("mode", "0").toInt();
@@ -233,7 +235,7 @@
properties.setAttribute("artists", artists);
properties.setAttribute("firstVisibleFrame", firstVisibleFrame);
properties.setAttribute("workingFrame", (uint)workingFrame);
- properties.setAttribute("transportFrame", (uint)m_transportFrame);
+ properties.setAttribute("transportFrame",
(uint)m_transportLocation.to_frame(audiodevice().get_sample_rate()));
properties.setAttribute("hzoom", m_hzoom);
properties.setAttribute("sbx", m_sbx);
properties.setAttribute("sby", m_sby);
@@ -413,7 +415,8 @@
m_exportSource = new WriteSource(spec);
}
- m_transportFrame = spec->start_frame;
+// m_transportFrame = spec->start_frame;
+ m_transportLocation.set_position(spec->start_frame, spec->sample_rate);
resize_buffer(false, spec->blocksize);
@@ -744,7 +747,8 @@
}
// update the m_transportFrame
- m_transportFrame += nframes;
+// m_transportFrame += nframes;
+ m_transportLocation.add_frames(nframes,
audiodevice().get_sample_rate());
if (!processResult) {
return 0;
@@ -925,7 +929,9 @@
// with the correct resampled audio data!
// We need to seek to a different position then the current one,
// else the seek won't happen at all :)
- set_transport_pos(m_transportFrame + audiodevice().get_buffer_size());
+ TimeRef location = m_transportLocation;
+ location.add_frames(audiodevice().get_buffer_size(),
audiodevice().get_sample_rate());
+ set_transport_pos(location);
}
int Song::get_bitdepth( )
@@ -1131,9 +1137,9 @@
return true;
case TransportStarting:
- if (state.frame != m_transportFrame) {
+ if (state.location != m_transportLocation) {
if ( ! m_seeking ) {
- m_newTransportFramePos = state.frame;
+ m_newTransportLocation = state.location;
m_startSeek = 1;
m_seeking = 1;
@@ -1251,13 +1257,18 @@
m_readyToRecord = true;
}
-void Song::set_transport_pos(nframes_t position)
+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)
Q_ASSERT(QThread::currentThreadId() == threadId);
#endif
- printf("set_transport_pos(%lu)\n", position);
- audiodevice().transport_seek_to(m_audiodeviceClient, position);
+ audiodevice().transport_seek_to(m_audiodeviceClient, location);
}
@@ -1283,7 +1294,7 @@
m_diskio->prepare_for_seek();
// 'Tell' the diskio it should start a seek action.
- RT_THREAD_EMIT(this, (void*)m_newTransportFramePos, seekStart(uint));
+ RT_THREAD_EMIT(this,
(void*)m_newTransportLocation.to_frame(audiodevice().get_sample_rate()),
seekStart(uint));
}
void Song::seek_finished()
@@ -1292,7 +1303,7 @@
Q_ASSERT_X(threadId == QThread::currentThreadId (),
"Song::seek_finished", "Called from other Thread!");
#endif
PMESG2("Song :: entering seek_finished");
- m_transportFrame = m_newTransportFramePos;
+ m_transportLocation = m_newTransportLocation;
m_seeking = 0;
if (m_resumeTransport) {
@@ -1304,5 +1315,11 @@
PMESG2("Song :: leaving seek_finished");
}
+
+nframes_t Song::get_transport_frame()
+{
+ return m_transportLocation.to_frame(audiodevice().get_sample_rate());
+}
+
// eof
Index: core/Song.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/Song.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- core/Song.h 25 Jun 2007 15:59:59 -0000 1.63
+++ core/Song.h 19 Jul 2007 12:28:42 -0000 1.64
@@ -83,7 +83,7 @@
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() const;
+ nframes_t get_transport_frame();
nframes_t get_working_frame() const {return workingFrame;}
nframes_t get_first_visible_frame() const;
nframes_t get_last_frame() const;
@@ -108,7 +108,8 @@
void set_first_visible_frame(nframes_t pos);
void set_title(const QString& sTitle);
void set_work_at(nframes_t pos);
- void set_transport_pos(nframes_t pos);
+ 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;}
@@ -173,6 +174,9 @@
volatile size_t m_seeking;
volatile size_t m_startSeek;
+ TimeRef m_transportLocation;
+ TimeRef m_newTransportLocation;
+
nframes_t firstVisibleFrame;
QString artists;
@@ -259,11 +263,6 @@
void prepare_recording();
};
-inline nframes_t Song::get_transport_frame() const
-{
- return m_transportFrame;
-}
-
inline float Song::get_gain() const
{
return m_fader->get_gain();
Index: engine/AudioDevice.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/engine/AudioDevice.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- engine/AudioDevice.cpp 25 Jun 2007 13:32:28 -0000 1.36
+++ engine/AudioDevice.cpp 19 Jul 2007 12:28:42 -0000 1.37
@@ -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: AudioDevice.cpp,v 1.36 2007/06/25 13:32:28 r_sijrier Exp $
+$Id: AudioDevice.cpp,v 1.37 2007/07/19 12:28:42 r_sijrier Exp $
*/
#include "AudioDevice.h"
@@ -790,7 +790,7 @@
state.tranport = TransportRolling;
state.isSlave = false;
state.realtime = false;
- state.frame = 0; // get from client!!
+ state.location.set_position(0, get_sample_rate()); // get from client!!
client->transport_control(state);
}
@@ -810,19 +810,20 @@
state.tranport = TransportStopped;
state.isSlave = false;
state.realtime = false;
- state.frame = 0; // get from client!!
+ state.location.set_position(0, get_sample_rate()); // get from client!!
client->transport_control(state);
}
// return 0 if valid request, non-zero otherwise.
-int AudioDevice::transport_seek_to(Client* client, nframes_t frame)
+int AudioDevice::transport_seek_to(Client* client, TimeRef location)
{
#if defined (JACK_SUPPORT)
JackDriver* jackdriver = slaved_jack_driver();
if (jackdriver) {
PMESG("using jack_transport_locate");
- return jack_transport_locate(jackdriver->get_client(), frame);
+ nframes_t frames = location.to_frame(get_sample_rate());
+ return jack_transport_locate(jackdriver->get_client(), frames);
}
#endif
@@ -830,7 +831,7 @@
state.tranport = TransportStarting;
state.isSlave = false;
state.realtime = false;
- state.frame = frame;
+ state.location = location;
client->transport_control(state);
Index: engine/AudioDevice.h
===================================================================
RCS file: /sources/traverso/traverso/src/engine/AudioDevice.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- engine/AudioDevice.h 21 Jun 2007 14:31:10 -0000 1.19
+++ engine/AudioDevice.h 19 Jul 2007 12:28:42 -0000 1.20
@@ -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: AudioDevice.h,v 1.19 2007/06/21 14:31:10 r_sijrier Exp $
+$Id: AudioDevice.h,v 1.20 2007/07/19 12:28:42 r_sijrier Exp $
*/
#ifndef AUDIODEVICE_H
@@ -59,7 +59,7 @@
void transport_start(Client* client);
void transport_stop(Client* client);
- int transport_seek_to(Client* client, nframes_t frame);
+ int transport_seek_to(Client* client, TimeRef location);
/**
* Get the Playback AudioBus instance with name \a name.
Index: engine/defines.h
===================================================================
RCS file: /sources/traverso/traverso/src/engine/defines.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- engine/defines.h 3 Jul 2007 14:40:26 -0000 1.12
+++ engine/defines.h 19 Jul 2007 12:28:42 -0000 1.13
@@ -2,6 +2,7 @@
#define TRAVERSO_TYPES_H
#include <inttypes.h>
+#include <QtGlobal>
#include "FastDelegate.h"
// Implementation for atomic int get/set from glibc's atomic.h/c
@@ -47,11 +48,44 @@
TransportStarting = 3
};
+// Unviversal samplerate for the frequences 22050, 32000, 44100, 88200, 96000
and 192000 Hz
+static const quint64 UNIVERSAL_SAMPLE_RATE = 28224000;
+
+struct TimeRef {
+
+ TimeRef(){}
+ TimeRef(long position) : m_position(position) {}
+
+ TimeRef(nframes_t frame, int rate) {
+ m_position = (UNIVERSAL_SAMPLE_RATE / rate) * frame;
+ }
+
+ void set_position(nframes_t frame, int rate) {
+ m_position = (UNIVERSAL_SAMPLE_RATE / rate) * frame;
+ }
+
+ void add_frames(nframes_t frames, int rate) {
+ m_position += ((UNIVERSAL_SAMPLE_RATE / rate) * frames);
+ }
+
+ nframes_t to_frame(int rate) {
+ return nframes_t(m_position / (UNIVERSAL_SAMPLE_RATE / rate));
+ }
+
+ friend int operator!=(const TimeRef& left, const TimeRef& right) {
+ return left.m_position != right.m_position;
+ }
+
+private:
+ quint64 m_position;
+};
+
+
typedef struct {
int tranport;
- nframes_t frame;
bool isSlave;
bool realtime;
+ TimeRef location;
} transport_state_t;
/**
@@ -70,7 +104,6 @@
typedef FastDelegate1<transport_state_t, int> TransportControlCallback;
-
/**
* Used for the type argument of jack_port_register() for default
* audio ports.
Index: engine/JackDriver.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/engine/JackDriver.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- engine/JackDriver.cpp 25 Jun 2007 13:32:28 -0000 1.18
+++ engine/JackDriver.cpp 19 Jul 2007 12:28:42 -0000 1.19
@@ -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: JackDriver.cpp,v 1.18 2007/06/25 13:32:28 r_sijrier Exp $
+ $Id: JackDriver.cpp,v 1.19 2007/07/19 12:28:42 r_sijrier Exp $
*/
#include "JackDriver.h"
@@ -242,7 +242,7 @@
transport_state_t tranportstate;
tranportstate.tranport = state;
- tranportstate.frame = pos.frame;
+ tranportstate.location = TimeRef(pos.frame,
audiodevice().get_sample_rate());
tranportstate.realtime = true;
device->transport_control(tranportstate);
@@ -255,7 +255,7 @@
{
transport_state_t tranportstate;
tranportstate.tranport = state;
- tranportstate.frame = pos->frame;
+ tranportstate.location = TimeRef(pos->frame,
audiodevice().get_sample_rate());
tranportstate.isSlave = true;
tranportstate.realtime = true;
Index: traverso/Traverso.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/Traverso.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- traverso/Traverso.cpp 4 Jun 2007 18:39:36 -0000 1.45
+++ traverso/Traverso.cpp 19 Jul 2007 12:28:42 -0000 1.46
@@ -89,6 +89,7 @@
QCoreApplication::setOrganizationDomain("traverso-daw.org");
qRegisterMetaType<InfoStruct>("InfoStruct");
+ qRegisterMetaType<TimeRef>("TimeRef");
config().check_and_load_configuration();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src core/Project.cpp core/Song.cpp cor...,
Remon Sijrier <=