printf("playing sample1\n");
sleep(1);
- SGSoundSample *sample2 = new SGSoundSample("jet.wav", srcDir);
+ SGSoundSample *sample2 = new SGSoundSample("jet_ulaw.wav", srcDir);
sample2->set_volume(0.5);
sample2->set_pitch(0.4);
sample2->play_looped();
}
};
- unsigned int formatConstruct(ALint numChannels, ALint bitsPerSample)
+ unsigned int formatConstruct(ALint numChannels, ALint bitsPerSample, bool compressed)
{
unsigned int rv = 0;
- if (numChannels == 1 && bitsPerSample == 8) rv = SG_SAMPLE_MONO8;
- if (numChannels == 1 && bitsPerSample == 16) rv = SG_SAMPLE_MONO16;
+ if (!compressed) {
+ if (numChannels == 1 && bitsPerSample == 16) rv = SG_SAMPLE_MONO16;
+ else if (numChannels == 1 && bitsPerSample == 8) rv = SG_SAMPLE_MONO8;
+ } else {
+ if (numChannels == 1 && bitsPerSample == 4) rv = SG_SAMPLE_ADPCM;
+ else if (numChannels == 1 && bitsPerSample == 8) rv = SG_SAMPLE_MULAW;
+ }
return rv;
}
assert(b->data == NULL);
bool found_header = false;
+ bool compressed = false;
uint32_t chunkLength;
int32_t magic;
uint16_t audioFormat;
codec = (bitsPerSample == 8 || sgIsLittleEndian()) ? codecLinear : codecPCM16BE;
break;
case 7: /* uLaw */
- bitsPerSample *= 2; /* uLaw is 16-bit packed into 8 bits */
- codec = codecULaw;
+ if (alIsExtensionPresent((ALchar *)"AL_EXT_mulaw")) {
+ compressed = true;
+ codec = codecLinear;
+ } else {
+ bitsPerSample *= 2; /* uLaw is 16-bit packed into 8 bits */
+ codec = codecULaw;
+ }
break;
default:
throw sg_io_exception("unsupported WAV encoding", b->path);
}
b->frequency = samplesPerSecond;
- b->format = formatConstruct(numChannels, bitsPerSample);
+ b->format = formatConstruct(numChannels, bitsPerSample, compressed);
} else if (magic == WAV_DATA_4CC) {
if (!found_header) {
/* ToDo: A bit wrong to check here, fmt chunk could come later... */
#define MAX_SOURCES 128
-
#ifndef ALC_ALL_DEVICES_SPECIFIER
# define ALC_ALL_DEVICES_SPECIFIER 0x1013
#endif
+#ifndef AL_FORMAT_MONO_MULAW_EXT
+# define AL_FORMAT_MONO_MULAW_EXT 0x10014
+#endif
+#ifndef AL_FORMAT_MONO_IMA4
+# define AL_FORMAT_MONO_IMA4 0x1300
+#endif
class SGSoundMgr::SoundManagerPrivate
{
ALenum format = AL_NONE;
unsigned int fmt = sample->get_format();
- if (fmt == SG_SAMPLE_MONO8) format = AL_FORMAT_MONO8;
if (fmt == SG_SAMPLE_MONO16) format = AL_FORMAT_MONO16;
+ else if (fmt == SG_SAMPLE_MONO8) format = AL_FORMAT_MONO8;
+ else if (fmt == SG_SAMPLE_MULAW) format = AL_FORMAT_MONO_MULAW_EXT;
ALsizei size = sample->get_size();
ALsizei freq = sample->get_frequency();