20 void Print(
const char* fmt, ...);
27 static MCIERROR mci_err;
28 static MMRESULT wav_err;
31 static int mci_send_string(
const char* cmd_str)
33 mci_err = mciSendString(cmd_str, ret_str,
sizeof(ret_str),
hwndApp);
35 if (mciGetErrorString(mci_err, err_str,
sizeof(err_str)))
36 Print(
"Error (%s): '%s'\n", cmd_str, err_str);
38 Print(
"Error (%s): %d - UNKNOWN\n", cmd_str, mci_err);
47 static void print_wav_error()
58 MMCKINFO mmckinfoParent;
59 MMCKINFO mmckinfoSubchunk;
67 hmmio = mmioOpen((LPSTR) fname, NULL, MMIO_READ | MMIO_ALLOCBUF);
70 Print(
"load_wave_file(): '%s' - Failed to open file.\n", fname);
78 mmckinfoParent.fccType = mmioFOURCC(
'W',
'A',
'V',
'E');
79 if (mmioDescend(hmmio, (LPMMCKINFO) &mmckinfoParent, NULL, MMIO_FINDRIFF)) {
80 Print(
"load_wave_file(): '%s' - This is not a WAVE file.\n", fname);
89 mmckinfoSubchunk.ckid = mmioFOURCC(
'f',
'm',
't',
' ');
90 if (mmioDescend(hmmio, &mmckinfoSubchunk, &mmckinfoParent, MMIO_FINDCHUNK)) {
91 Print(
"load_wave_file(): '%s' - WAVE file has no \"fmt\" chunk\n", fname);
99 dwFmtSize = mmckinfoSubchunk.cksize;
102 if (mmioRead(hmmio, (HPSTR) format, dwFmtSize) != (LRESULT)dwFmtSize) {
103 Print(
"load_wave_file(): '%s' - Failed to read format chunk.\n", fname);
109 mmioAscend(hmmio, &mmckinfoSubchunk, 0);
115 mmckinfoSubchunk.ckid = mmioFOURCC(
'd',
'a',
't',
'a');
116 if (mmioDescend(hmmio, &mmckinfoSubchunk, &mmckinfoParent, MMIO_FINDCHUNK)) {
117 Print(
"load_wave_file(): '%s' - WAVE file has no data chunk.\n", fname);
123 dwDataSize = mmckinfoSubchunk.cksize;
124 if (dwDataSize == 0L) {
125 Print(
"load_wave_file(): '%s' - The data chunk contains no data.\n", fname);
131 hdr->lpData = (LPSTR)
new(__FILE__,__LINE__) BYTE[dwDataSize];
132 hdr->dwBufferLength = dwDataSize;
135 if (mmioRead(hmmio, (HPSTR) hdr->lpData, dwDataSize) != (LRESULT)dwDataSize) {
136 Print(
"load_wave_file(): '%s' - Failed to read data chunk.\n", fname);