20 #include "vorbis/codec.h"
21 #include "vorbis/vorbisfile.h"
32 if (!filename || !filename[0] || !
creator)
35 int namelen = strlen(filename);
40 if ((filename[namelen-3] ==
'o' || filename[namelen-3] ==
'O') &&
41 (filename[namelen-2] ==
'g' || filename[namelen-2] ==
'G') &&
42 (filename[namelen-1] ==
'g' || filename[namelen-1] ==
'G')) {
53 ZeroMemory(&head,
sizeof(head));
54 ZeroMemory(&fmt,
sizeof(fmt));
55 ZeroMemory(&fact,
sizeof(fact));
56 ZeroMemory(&data,
sizeof(data));
63 ::fopen_s(&f, filename,
"rb");
66 fseek(f, 0, SEEK_END);
68 fseek(f, 0, SEEK_SET);
74 buf =
new(__FILE__,__LINE__) BYTE[len];
77 fread(buf, len, 1, f);
83 if (len >
sizeof(head)) {
84 CopyMemory(&head, buf,
sizeof(head));
86 if (head.
RIFF == MAKEFOURCC(
'R',
'I',
'F',
'F') &&
87 head.
WAVE == MAKEFOURCC(
'W',
'A',
'V',
'E')) {
92 DWORD chunk_id = *((LPDWORD) p);
95 case MAKEFOURCC(
'f',
'm',
't',
' '):
96 CopyMemory(&fmt, p,
sizeof(fmt));
100 case MAKEFOURCC(
'f',
'a',
'c',
't'):
101 CopyMemory(&fact, p,
sizeof(fact));
105 case MAKEFOURCC(
's',
'm',
'p',
'l'):
106 CopyMemory(&fact, p,
sizeof(fact));
110 case MAKEFOURCC(
'd',
'a',
't',
'a'):
111 CopyMemory(&data, p,
sizeof(data));
150 if (!filename || !filename[0] || !
creator)
153 int namelen = strlen(filename);
159 ZeroMemory(&wfex,
sizeof(wfex));
162 ::fopen_s(&f, filename,
"rb");
165 OggVorbis_File* povf =
new(__FILE__,__LINE__) OggVorbis_File;
168 Print(
"Sound::CreateOggStream(%s) - out of memory!\n", filename);
172 ZeroMemory(povf,
sizeof(OggVorbis_File));
174 if (ov_open(f, povf, NULL, 0) < 0) {
175 Print(
"Sound::CreateOggStream(%s) - not an Ogg bitstream\n", filename);
180 Print(
"\nOpened Ogg Bitstream '%s'\n", filename);
181 char **ptr=ov_comment(povf,-1)->user_comments;
182 vorbis_info *vi=ov_info(povf,-1);
188 Print(
"Bitstream is %d channel, %ldHz\n", vi->channels, vi->rate);
189 Print(
"Decoded length: %ld samples\n",
190 (
long)ov_pcm_total(povf,-1));
191 Print(
"Encoded by: %s\n\n", ov_comment(povf,-1)->vendor);
193 wfex.wFormatTag = WAVE_FORMAT_PCM;
194 wfex.nChannels = vi->channels;
195 wfex.nSamplesPerSec = vi->rate;
196 wfex.nAvgBytesPerSec = vi->channels * vi->rate * 2;
197 wfex.nBlockAlign = vi->channels * 2;
198 wfex.wBitsPerSample = 16;
203 sizeof(OggVorbis_File),
238 : status(UNINITIALIZED), volume(0), flags(0), looped(0),
239 velocity(0,0,0), location(0,0,0), sound_check(0)