File tree 2 files changed +35
-0
lines changed 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,35 @@ class ResamplingReader {
61
61
return playRaw (array, true );
62
62
}
63
63
64
+ bool playWav (TArray *array) {
65
+ bool result = false ;
66
+
67
+ do
68
+ {
69
+ wav_header hdr;
70
+ unsigned infoTagsSize;
71
+ wav_data_header wav_data_hdr;
72
+ WaveHeaderParser parser;
73
+
74
+ if (!parser.readWaveHeaderFromBuffer ((char *) array, hdr))
75
+ break ;
76
+
77
+ // make unwarranted assumptions about the header format
78
+ // by using a magic number...
79
+ if (!parser.readInfoTags ((unsigned char *) array, 36 , infoTagsSize))
80
+ break ;
81
+
82
+ if (!parser.readDataHeader ((unsigned char *) array, 36 + infoTagsSize, wav_data_hdr))
83
+ break ;
84
+
85
+ result = playRaw ((TArray*)((char *) array + (36 + infoTagsSize + sizeof wav_data_hdr)),
86
+ wav_data_hdr.data_bytes / 2 ,
87
+ hdr.num_channels );
88
+ } while (0 );
89
+
90
+ return result;
91
+ }
92
+
64
93
bool play (const char *filename, bool isWave, uint16_t numChannelsIfRaw = 0 )
65
94
{
66
95
close ();
Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ class AudioPlayResmp : public AudioStream
54
54
return playWav ((int16_t *) data, fileSize);
55
55
}
56
56
57
+ bool playWav (int16_t *data)
58
+ {
59
+ stop ();
60
+ return reader->playWav (data);
61
+ }
62
+
57
63
void setPlaybackRate (float f) {
58
64
reader->setPlaybackRate (f);
59
65
}
You can’t perform that action at this time.
0 commit comments