diff --git a/src/Sound.cpp b/src/Sound.cpp index c7f91b41..05e2f579 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -88,6 +88,7 @@ BOOL InitSoundObject(const char *resname, int no) unsigned short format = resource_pointer[5] | (resource_pointer[6] << 8); unsigned short channels = resource_pointer[7] | (resource_pointer[8] << 8); unsigned long sample_rate = resource_pointer[9] | (resource_pointer[0xA] << 8) | (resource_pointer[0xB] << 16) | (resource_pointer[0xC] << 24); + unsigned short bits_per_sample = resource_pointer[0x13] | (resource_pointer[0x14] << 8); if (format != 1) // 1 is WAVE_FORMAT_PCM return FALSE; @@ -95,6 +96,9 @@ BOOL InitSoundObject(const char *resname, int no) if (channels != 1) // The mixer only supports mono right now return FALSE; + if (bits_per_sample != 8) // The mixer only supports 8-bit samples (unsigned ones, at that) + return FALSE; + // 二次バッファの生成 (Create secondary buffer) lpSECONDARYBUFFER[no] = AudioBackend_CreateSound(sample_rate, resource_pointer + 0x3A, buffer_size); @@ -156,6 +160,7 @@ BOOL LoadSoundObject(const char *file_name, int no) unsigned short format = wp[5] | (wp[6] << 8); unsigned short channels = wp[7] | (wp[8] << 8); unsigned long sample_rate = wp[9] | (wp[0xA] << 8) | (wp[0xB] << 16) | (wp[0xC] << 24); + unsigned short bits_per_sample = wp[0x13] | (wp[0x14] << 8); if (format != 1) // 1 is WAVE_FORMAT_PCM { @@ -169,6 +174,12 @@ BOOL LoadSoundObject(const char *file_name, int no) return FALSE; } + if (bits_per_sample != 8) // The mixer only supports 8-bit samples (unsigned ones, at that) + { + free(wp); + return FALSE; + } + // セカンダリバッファの生成 (Create secondary buffer) lpSECONDARYBUFFER[no] = AudioBackend_CreateSound(sample_rate, wp + 0x3A, buffer_size);