1
0
mirror of https://github.com/RPCS3/soundtouch.git synced 2024-11-08 20:12:27 +01:00

Added function to get duration ratio between the original input and processed output tracks.

This commit is contained in:
oparviai 2016-10-15 19:34:59 +00:00
parent ac03757ec8
commit 753848865d
4 changed files with 32 additions and 2 deletions

View File

@ -259,6 +259,24 @@ public:
/// Sets sample rate.
void setSampleRate(uint srate);
/// Get ratio between input and output audio durations, useful for calculating
/// processed output duration: if you'll process a stream of N samples, then
/// you can expect to get out N * getInputOutputSampleRatio() samples.
///
/// This ratio will give accurate target duration ratio for a full audio track,
/// given that the the whole track is processed with same processing parameters.
///
/// If this ratio is applied to calculate intermediate offsets inside a processing
/// stream, then this ratio is approximate and can deviate +- some tens of milliseconds
/// from ideal offset, yet by end of the audio stream the duration ratio will become
/// exact.
///
/// Example: if processing with parameters "-tempo=15 -pitch=-3", the function
/// will return value 0.8695652... Now, if processing an audio stream whose duration
/// is exactly one million audio samples, then you can expect the processed
/// output duration be 0.869565 * 1000000 = 869565 samples.
double getInputOutputSampleRatio();
/// Flushes the last samples from the processing pipeline to the output.
/// Clears also the internal processing buffers.
//

View File

@ -211,7 +211,7 @@ int RateTransposer::isEmpty() const
/// Return approximate initial input-output latency
int RateTransposer::getLatency() const
{
return (bUseAAFilter) ? pAAFilter->getLength() : 0;
return (bUseAAFilter) ? pAAFilter->getLength() : 0;
}

View File

@ -172,6 +172,9 @@ public:
/// Returns nonzero if there aren't any samples available for outputting.
int isEmpty() const;
/// Return approximate initial input-output latency
int getLatency() const;
};
}

View File

@ -475,7 +475,6 @@ int SoundTouch::getSetting(int settingId) const
return size;
}
case SETTING_NOMINAL_OUTPUT_SEQUENCE :
{
int size = pTDStretch->getOutputBatchSize();
@ -514,6 +513,7 @@ int SoundTouch::getSetting(int settingId) const
}
// Clears all the samples in the object's output and internal processing
// buffers.
void SoundTouch::clear()
@ -567,3 +567,12 @@ uint SoundTouch::receiveSamples(uint maxSamples)
samplesOutput += (long)ret;
return ret;
}
/// Get ratio between input and output audio durations, useful for calculating
/// processed output duration: if you'll process a stream of N samples, then
/// you can expect to get out N * getInputOutputSampleRatio() samples.
double SoundTouch::getInputOutputSampleRatio()
{
return 1.0 / (tempo * rate);
}