Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv2882
Modified Files:
AudioIO.h AudioIO.cpp
Log Message:
One more foray into variable speed playback...
Cursor positioning is now maintained using either the transcription bar "play
at speed" function and the time track "envelopes".
Seeking only works at normal speed for now.
Index: AudioIO.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.cpp,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- AudioIO.cpp 25 Apr 2007 03:46:00 -0000 1.156
+++ AudioIO.cpp 23 May 2007 06:37:56 -0000 1.157
@@ -63,7 +63,7 @@
#include "Resample.h"
#include "RingBuffer.h"
#include "Prefs.h"
-#include "TimeTrack.h"
+#include "Project.h"
#include "widgets/Meter.h"
@@ -874,6 +874,7 @@
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &mSoftwarePlaythrough, false);
+ mTimeTrack = timeTrack;
mListener = listener;
mInputMeter = NULL;
mOutputMeter = NULL;
@@ -890,14 +891,17 @@
mCutPreviewGapStart = cutPreviewGapStart;
mCutPreviewGapLen = cutPreviewGapLen;
- mPlaySpeed = 1.0;
- if (timeTrack) {
- mPlaySpeed = timeTrack->GetEnvelope()->GetValue(t0);
- mPlaySpeed = 1 / ((timeTrack->GetRangeLower() * (1 - mPlaySpeed) +
- mPlaySpeed * timeTrack->GetRangeUpper())/100.0);
+ double factor = 1.0;
+ if (mTimeTrack) {
+ factor = mTimeTrack->GetEnvelope()->Average(0, mT1);
+ factor = (mTimeTrack->GetRangeLower() *
+ (1 - factor) +
+ factor *
+ mTimeTrack->GetRangeUpper()) /
+ 100.0;
}
- mWarpedT1 = mT0 + ((mT1 - mT0) * mPlaySpeed);
-
+ mWarpedT1 = mT0 + ((mT1 - mT0) / factor);
+
//
// The RingBuffer sizes, and the max amount of the buffer to
// fill at a time, both grow linearly with the number of
@@ -971,7 +975,7 @@
mPlaybackBuffers[i] = new RingBuffer(floatSample, playbackBufferSize);
mPlaybackMixers[i] = new Mixer(1, &mPlaybackTracks[i],
- timeTrack, mT0, mWarpedT1, 1,
+ mTimeTrack, mT0, mWarpedT1, 1,
playbackMixBufferSize, false,
mRate, floatSample, false);
mPlaybackMixers[i]->ApplyTrackGains(false);
@@ -1654,7 +1658,7 @@
unsigned int i;
gAudioIO->mAudioThreadFillBuffersLoopActive = true;
-
+
if( mPlaybackTracks.GetCount() > 0 )
{
// Though extremely unlikely, it is possible that some buffers
@@ -1897,7 +1901,7 @@
numCaptureChannels,
(float *)outputBuffer, (int)framesPerBuffer,
gain);
}
-
+
if (gAudioIO->mSeek)
{
// Pause audio thread and wait for it to finish
@@ -1911,17 +1915,17 @@
gAudioIO->mTime += gAudioIO->mSeek;
if (gAudioIO->mTime < gAudioIO->mT0)
gAudioIO->mTime = gAudioIO->mT0;
- else if (gAudioIO->mTime > gAudioIO->mT1)
- gAudioIO->mTime = gAudioIO->mT1;
+ else if (gAudioIO->mTime > gAudioIO->mWarpedT1)
+ gAudioIO->mTime = gAudioIO->mWarpedT1;
gAudioIO->mSeek = 0.0;
// Reset mixer positions and flush buffers for all tracks
+ gAudioIO->mT = gAudioIO->mT0 + ((gAudioIO->mTime - gAudioIO->mT0));
for (i = 0; i < (unsigned int)numPlaybackTracks; i++)
{
- gAudioIO->mPlaybackMixers[i]->Reposition( gAudioIO->mTime );
- gAudioIO->mPlaybackBuffers[i]->Discard(
gAudioIO->mPlaybackBuffers[i]->AvailForGet() );
+ gAudioIO->mPlaybackMixers[i]->Reposition(gAudioIO->mT);
+
gAudioIO->mPlaybackBuffers[i]->Discard(gAudioIO->mPlaybackBuffers[i]->AvailForGet());
}
- gAudioIO->mT = gAudioIO->mTime;
// Reload the ring buffers
gAudioIO->mAudioThreadShouldCallFillBuffersOnce = true;
@@ -2099,9 +2103,19 @@
}
}
}
-
+
// Update the current time position
- gAudioIO->mTime += ((framesPerBuffer / gAudioIO->mRate) /
gAudioIO->mPlaySpeed);
+ double factor = 1.0;
+ if (gAudioIO->mTimeTrack) {
+ factor =
gAudioIO->mTimeTrack->GetEnvelope()->GetValue(gAudioIO->mTime);
+ factor = (gAudioIO->mTimeTrack->GetRangeLower() *
+ (1 - factor) +
+ factor *
+ gAudioIO->mTimeTrack->GetRangeUpper()) /
+ 100.0;
+ }
+ gAudioIO->mTime += ((framesPerBuffer / gAudioIO->mRate) * factor);
+
// Record the reported latency from PortAudio.
// TODO: Don't recalculate this with every callback?
Index: AudioIO.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- AudioIO.h 25 Apr 2007 03:46:00 -0000 1.48
+++ AudioIO.h 23 May 2007 06:37:56 -0000 1.49
@@ -34,6 +34,7 @@
class TimeTrack;
class AudioThread;
class Meter;
+class TimeTrack;
extern AudioIO *gAudioIO;
@@ -217,7 +218,6 @@
double mTime;
double mWarpedT1;
double mSeek;
- double mPlaySpeed;
double mPlaybackRingBufferSecs;
double mCaptureRingBufferSecs;
double mMaxPlaybackSecsToCopy;
@@ -267,6 +267,8 @@
friend void InitAudioIO();
friend void DeinitAudioIO();
+ TimeTrack *mTimeTrack;
+
#if USE_PORTAUDIO_V19
friend int audacityAudioCallback(
const void *inputBuffer, void *outputBuffer,
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs