[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso/src/core AudioClip.cpp ReadSource.cpp
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso/src/core AudioClip.cpp ReadSource.cpp |
Date: |
Sat, 01 Dec 2007 23:45:52 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/12/01 23:45:52
Modified files:
src/core : AudioClip.cpp ReadSource.cpp
Log message:
* fix mixing bug in AudioClip, add some comments
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.156&r2=1.157
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.cpp?cvsroot=traverso&r1=1.85&r2=1.86
Patches:
Index: AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -b -r1.156 -r1.157
--- AudioClip.cpp 29 Nov 2007 13:17:30 -0000 1.156
+++ AudioClip.cpp 1 Dec 2007 23:45:51 -0000 1.157
@@ -420,55 +420,57 @@
AudioBus* bus = m_song->get_clip_render_bus();
bus->silence_buffers(nframes);
- AudioBus* sendbus = m_song->get_render_bus();
TimeRef mix_pos;
int channelcount = get_channels();
audio_sample_t* mixdown[channelcount];
+ uint framesToProcess = nframes;
int outputRate = m_readSource->get_output_rate();
TimeRef transportLocation = m_song->get_transport_location();
- TimeRef upperRange = transportLocation + TimeRef(nframes, outputRate);
+ TimeRef upperRange = transportLocation + TimeRef(framesToProcess,
outputRate);
if ( (m_trackStartLocation < upperRange) && (m_trackEndLocation >
transportLocation) ) {
- // FIXME wrong calculation!
if (transportLocation < m_trackStartLocation) {
- uint offset = (m_trackStartLocation -
transportLocation).to_frame(outputRate);
+ // Using to_frame() for both the m_trackStartLocation
and transportLocation seems to round
+ // better then using (m_trackStartLocation -
transportLocation).to_frame()
+ // TODO : fine out why!
+ uint offset =
(m_trackStartLocation).to_frame(outputRate) -
transportLocation.to_frame(outputRate);
mix_pos = m_sourceStartLocation;
// printf("offset %d\n", offset);
for (int chan=0; chan<bus->get_channel_count(); ++chan)
{
- audio_sample_t* buf = bus->get_buffer(chan,
nframes);
+ audio_sample_t* buf = bus->get_buffer(chan,
framesToProcess);
mixdown[chan] = buf + offset;
}
- nframes = nframes - offset;
+ framesToProcess = framesToProcess - 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);
+ mixdown[chan] = bus->get_buffer(chan,
framesToProcess);
}
}
if (m_trackEndLocation < upperRange) {
- nframes -= (upperRange -
m_trackEndLocation).to_frame(outputRate);
-// printf("if (m_trackEndLocation < upperRange): nframes
%d\n", nframes);
+ // Using to_frame() for both the upperRange and
m_trackEndLocation seems to round
+ // better then using (upperRange -
m_trackEndLocation).to_frame()
+ // TODO : fine out why!
+ framesToProcess -= upperRange.to_frame(outputRate) -
m_trackEndLocation.to_frame(outputRate);
+// printf("if (m_trackEndLocation < upperRange):
framesToProcess %d\n", framesToProcess);
}
} else {
return 0;
}
-
-// printf("Setting mix pos to start location %d\n",
mix_pos.to_frame(outputRate));
- int read_frames = 0;
-
+ uint read_frames = 0;
if (m_song->realtime_path()) {
- read_frames = m_readSource->rb_read(mixdown, mix_pos, nframes);
+ read_frames = m_readSource->rb_read(mixdown, mix_pos,
framesToProcess);
} else {
- read_frames =
m_readSource->file_read(m_song->renderDecodeBuffer, mix_pos, nframes);
+ read_frames =
m_readSource->file_read(m_song->renderDecodeBuffer, mix_pos, framesToProcess);
if (read_frames > 0) {
for (int chan=0; chan<channelcount; ++chan) {
memcpy(mixdown[chan],
m_song->renderDecodeBuffer->destination[chan], read_frames *
sizeof(audio_sample_t));
@@ -481,8 +483,8 @@
return 0;
}
- if (read_frames != nframes) {
-// printf("read_frames, nframes %d, %d\n", read_frames, nframes);
+ if (read_frames != framesToProcess) {
+ printf("read_frames, framesToProcess %d, %d\n", read_frames,
framesToProcess);
}
@@ -493,6 +495,10 @@
TimeRef endlocation = mix_pos + TimeRef(read_frames, get_rate());
m_fader->process_gain(mixdown, mix_pos, endlocation, read_frames,
channelcount);
+ AudioBus* sendbus = m_song->get_render_bus();
+
+ // NEVER EVER FORGET that the mixing should be done on the WHOLE
buffer, not just part of it
+ // so use an unmodified nframes variable!!!!!!!!!!!!!!!!!!!!!!!!!!!1
if (channelcount == 1) {
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);
Index: ReadSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -b -r1.85 -r1.86
--- ReadSource.cpp 30 Nov 2007 07:25:22 -0000 1.85
+++ ReadSource.cpp 1 Dec 2007 23:45:51 -0000 1.86
@@ -369,9 +369,6 @@
int ReadSource::rb_read(audio_sample_t** dst, TimeRef& start, nframes_t count)
{
-// static int runcount;
-// runcount++;
-
if (m_channelCount == 0) {
return count;
}
@@ -382,9 +379,14 @@
}
TimeRef diff = m_rbRelativeFileReadPos - start;
- if (diff.universal_frame() > 0 && diff.to_frame(m_outputRate) == 0) {
+ // In universal frame positioning, it is possible (somehow) that the
start
+ // location and m_rbRelativeFileReadPos differ very very slighly, and
when
+ // converted to frames, the difference is much smaller then 1 frame.
+ // To catch these kind of I think 'rounding issues' we convert to
frames here
+ // and see if the diff in frames == 0, in which case it should be fine
to make
+ // our m_rbRelativeFileReadPos equal to start, and thus avoiding
unwanted resync actions!
+ if ( (diff.universal_frame() > 0) && (diff.to_frame(m_outputRate) == 0)
) {
m_rbRelativeFileReadPos = start;
-// printf("diff == %d\n", diff.to_frame(m_outputRate));
}
if (start != m_rbRelativeFileReadPos) {
@@ -404,8 +406,8 @@
}
m_rbRelativeFileReadPos += advance;
-// printf("rb_read:: advance %d\n",
advance.to_frame(m_outputRate));
-// printf("rb_read:: m_rbRelativeFileReadPos after advance
%d\n", m_rbRelativeFileReadPos.to_frame(m_outputRate));
+/* printf("rb_read:: advance %d\n",
advance.to_frame(m_outputRate));
+ printf("rb_read:: m_rbRelativeFileReadPos after advance
%d\n", m_rbRelativeFileReadPos.to_frame(m_outputRate));*/
} else {
TimeRef synclocation = start +
m_clip->get_track_start_location() + m_clip->get_source_start_location();
start_resync(synclocation);
@@ -420,14 +422,13 @@
readcount = m_buffers.at(chan)->read(dst[chan], count);
if (readcount != count) {
+ printf("readcount, count: %d, %d\n", readcount, count);
// Hmm, not sure what to do in this case....
}
}
m_rbRelativeFileReadPos.add_frames(readcount, m_outputRate);
-/* if (runcount < 20)
- printf("rb_read:: m_rbRelativeFileReadPos after add_frames
%lld\n", m_rbRelativeFileReadPos.universal_frame());*/
return readcount;
}
@@ -546,7 +547,7 @@
{
// printf("starting resync!\n");
if (m_needSync || m_syncInProgress) {
- printf("start_resync still in progress!\n");
+// printf("start_resync still in progress!\n");
return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Traverso-commit] traverso/src/core AudioClip.cpp ReadSource.cpp,
Remon Sijrier <=