Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
newdigate committed Dec 16, 2023
2 parents 64f1638 + 6616113 commit cbe3100
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/ResamplingReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,35 @@ class ResamplingReader {
return playRaw(array, true);
}

bool playWav(TArray *array) {
bool result = false;

do
{
wav_header hdr;
unsigned infoTagsSize;
wav_data_header wav_data_hdr;
WaveHeaderParser parser;

if (!parser.readWaveHeaderFromBuffer((char*) array, hdr))
break;

// make unwarranted assumptions about the header format
// by using a magic number...
if (!parser.readInfoTags((unsigned char*) array, 36, infoTagsSize))
break;

if (!parser.readDataHeader((unsigned char*) array, 36 + infoTagsSize, wav_data_hdr))
break;

result = playRaw((TArray*)((char*) array + (36 + infoTagsSize + sizeof wav_data_hdr)),
wav_data_hdr.data_bytes / 2,
hdr.num_channels);
} while (0);

return result;
}

bool play(const char *filename, bool isWave, uint16_t numChannelsIfRaw = 0)
{
close();
Expand Down
6 changes: 6 additions & 0 deletions src/playresmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class AudioPlayResmp : public AudioStream
return playWav((int16_t *) data, fileSize);
}

bool playWav(int16_t *data)
{
stop();
return reader->playWav(data);
}

void setPlaybackRate(float f) {
reader->setPlaybackRate(f);
}
Expand Down

0 comments on commit cbe3100

Please sign in to comment.