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

Added utility function to get elapsed duration i.e. how much so far has been read from the WAV file

This commit is contained in:
oparviai 2012-08-30 16:30:13 +00:00
parent 6fc0dd1867
commit b4e22218e6
2 changed files with 17 additions and 1 deletions

View File

@ -651,6 +651,14 @@ uint WavInFile::getLengthMS() const
}
/// Returns how many milliseconds of audio have so far been read from the file
uint WavInFile::getElapsedMS() const
{
return (uint)(1000.0 * (double)dataRead / (double)header.format.byte_rate);
}
//////////////////////////////////////////////////////////////////////////////
//
// Class WavOutFile

View File

@ -116,8 +116,11 @@ private:
/// File pointer.
FILE *fptr;
/// Position within the audio stream
long position;
/// Counter of how many bytes of sample data have been read from the file.
uint dataRead;
long dataRead;
/// WAV header information
WavHeader header;
@ -175,6 +178,11 @@ public:
/// Get the audio file length in milliseconds
uint getLengthMS() const;
/// Returns how many milliseconds of audio have so far been read from the file
///
/// \return elapsed duration in milliseconds
uint getElapsedMS() const;
/// Reads audio samples from the WAV file. This routine works only for 8 bit samples.
/// Reads given number of elements from the file or if end-of-file reached, as many
/// elements as are left in the file.