diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -229,7 +229,7 @@ bool DLSFile::ReadDLSRegion(FILE *f, DWO break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -252,11 +252,11 @@ bool DLSFile::ReadDLSRegionList(FILE *f, if (list_type == FOURCC_RGN) { this->ReadDLSRegion(f, chunk.length - sizeof(list_type), instrument.regions); } else { - DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); fseek(f, chunk.length - sizeof(list_type), SEEK_CUR); } } else { - DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); } } @@ -299,7 +299,7 @@ bool DLSFile::ReadDLSInstrument(FILE *f, break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -320,15 +320,15 @@ bool DLSFile::ReadDLSInstrumentList(FILE if (fread(&list_type, sizeof(list_type), 1, f) != 1) return false; if (list_type == FOURCC_INS) { - DEBUG(driver, 6, "DLS: Reading instrument %d", (int)instruments.size()); + Debug(driver, 6, "DLS: Reading instrument {}", (int)instruments.size()); if (!this->ReadDLSInstrument(f, chunk.length - sizeof(list_type))) return false; } else { - DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); fseek(f, chunk.length - sizeof(list_type), SEEK_CUR); } } else { - DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); } } @@ -387,7 +387,7 @@ bool DLSFile::ReadDLSWave(FILE *f, DWORD break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -412,15 +412,15 @@ bool DLSFile::ReadDLSWaveList(FILE *f, D if (fread(&list_type, sizeof(list_type), 1, f) != 1) return false; if (list_type == FOURCC_wave) { - DEBUG(driver, 6, "DLS: Reading wave %d", (int)waves.size()); + Debug(driver, 6, "DLS: Reading wave {}", waves.size()); if (!this->ReadDLSWave(f, chunk.length - sizeof(list_type), chunk_offset - base_offset)) return false; } else { - DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF)); fseek(f, chunk.length - sizeof(list_type), SEEK_CUR); } } else { - DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); } } @@ -430,7 +430,7 @@ bool DLSFile::ReadDLSWaveList(FILE *f, D bool DLSFile::LoadFile(const wchar_t *file) { - DEBUG(driver, 2, "DMusic: Try to load DLS file %s", FS2OTTD(file).c_str()); + Debug(driver, 2, "DMusic: Try to load DLS file {}", FS2OTTD(file)); FILE *f = _wfopen(file, L"rb"); if (f == nullptr) return false; @@ -446,7 +446,7 @@ bool DLSFile::LoadFile(const wchar_t *fi hdr.length -= sizeof(FOURCC); - DEBUG(driver, 2, "DMusic: Parsing DLS file"); + Debug(driver, 2, "DMusic: Parsing DLS file"); DLSHEADER header; MemSetT(&header, 0); @@ -495,7 +495,7 @@ bool DLSFile::LoadFile(const wchar_t *fi break; default: - DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); + Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF)); fseek(f, chunk.length, SEEK_CUR); break; } @@ -585,7 +585,7 @@ static void TransmitNotesOff(IDirectMusi static void MidiThreadProc() { - DEBUG(driver, 2, "DMusic: Entering playback thread"); + Debug(driver, 2, "DMusic: Entering playback thread"); REFERENCE_TIME last_volume_time = 0; // timestamp of the last volume change REFERENCE_TIME block_time = 0; // timestamp of the last block sent to the port @@ -617,7 +617,7 @@ static void MidiThreadProc() } if (_playback.do_stop) { - DEBUG(driver, 2, "DMusic thread: Stopping playback"); + Debug(driver, 2, "DMusic thread: Stopping playback"); /* Turn all notes off and wait a bit to allow the messages to be handled. */ clock->GetTime(&cur_time); @@ -632,7 +632,7 @@ static void MidiThreadProc() if (wfso == WAIT_OBJECT_0) { if (_playback.do_start) { - DEBUG(driver, 2, "DMusic thread: Starting playback"); + Debug(driver, 2, "DMusic thread: Starting playback"); { /* New scope to limit the time the mutex is locked. */ std::lock_guard lock(_thread_mutex); @@ -669,14 +669,14 @@ static void MidiThreadProc() preload_bytes += block.data.size(); if (block.ticktime >= current_segment.start) { if (current_segment.loop) { - DEBUG(driver, 2, "DMusic: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes); + Debug(driver, 2, "DMusic: timer: loop from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes); current_segment.start_block = bl; break; } else { /* Skip the transmission delay compensation performed in the Win32 MIDI driver. * The DMusic driver will most likely be used with the MS softsynth, which is not subject to transmission delays. */ - DEBUG(driver, 2, "DMusic: timer: start from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes); + Debug(driver, 2, "DMusic: timer: start from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes); playback_start_time -= block.realtime * MIDITIME_TO_REFTIME; break; } @@ -691,7 +691,7 @@ static void MidiThreadProc() /* Check for volume change. */ if (current_volume != _playback.new_volume) { if (current_time - last_volume_time > 10 * MS_TO_REFTIME) { - DEBUG(driver, 2, "DMusic thread: volume change"); + Debug(driver, 2, "DMusic thread: volume change"); current_volume = _playback.new_volume; last_volume_time = current_time; for (int ch = 0; ch < 16; ch++) { @@ -709,7 +709,7 @@ static void MidiThreadProc() /* check that block isn't at end-of-song override */ if (current_segment.end > 0 && block.ticktime >= current_segment.end) { if (current_segment.loop) { - DEBUG(driver, 2, "DMusic thread: Looping song"); + Debug(driver, 2, "DMusic thread: Looping song"); current_block = current_segment.start_block; playback_start_time = current_time - current_file.blocks[current_block].realtime * MIDITIME_TO_REFTIME; } else { @@ -723,13 +723,13 @@ static void MidiThreadProc() if (block.realtime * MIDITIME_TO_REFTIME > playback_time + 3 *_playback.preload_time * MS_TO_REFTIME) { /* Stop the thread loop until we are at the preload time of the next block. */ next_timeout = Clamp(((int64)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000); - DEBUG(driver, 9, "DMusic thread: Next event in %lu ms (music %u, ref " OTTD_PRINTF64 ")", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time); + Debug(driver, 9, "DMusic thread: Next event in {} ms (music {}, ref {})", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time); break; } /* Timestamp of the current block. */ block_time = playback_start_time + block.realtime * MIDITIME_TO_REFTIME; - DEBUG(driver, 9, "DMusic thread: Streaming block " PRINTF_SIZE " (cur=" OTTD_PRINTF64 ", block=" OTTD_PRINTF64 ")", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME)); + Debug(driver, 9, "DMusic thread: Streaming block {} (cur={}, block={})", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME)); const byte *data = block.data.data(); size_t remaining = block.data.size(); @@ -822,7 +822,7 @@ static void MidiThreadProc() } } - DEBUG(driver, 2, "DMusic: Exiting playback thread"); + Debug(driver, 2, "DMusic: Exiting playback thread"); /* Turn all notes off and wait a bit to allow the messages to be handled by real hardware. */ clock->GetTime(&cur_time); @@ -867,7 +867,7 @@ static const char *LoadDefaultDLSFile(co if (SUCCEEDED(RegQueryValueEx(hkDM, L"GMFilePath", nullptr, nullptr, (LPBYTE)dls_path, &buf_size))) { wchar_t expand_path[MAX_PATH * 2]; ExpandEnvironmentStrings(dls_path, expand_path, lengthof(expand_path)); - if (!dls_file.LoadFile(expand_path)) DEBUG(driver, 1, "Failed to load default GM DLS file from registry"); + if (!dls_file.LoadFile(expand_path)) Debug(driver, 1, "Failed to load default GM DLS file from registry"); } RegCloseKey(hkDM); } @@ -1100,10 +1100,10 @@ const char *MusicDriver_DMusic::Start(co MemSetT(&caps, 0); caps.dwSize = sizeof(DMUS_PORTCAPS); - DEBUG(driver, 1, "Detected DirectMusic ports:"); + Debug(driver, 1, "Detected DirectMusic ports:"); for (int i = 0; _music->EnumPort(i, &caps) == S_OK; i++) { if (caps.dwClass == DMUS_PC_OUTPUTCLASS) { - DEBUG(driver, 1, " %d: %s%s", i, convert_from_fs(caps.wszDescription, desc, lengthof(desc)), i == pIdx ? " (selected)" : ""); + Debug(driver, 1, " {}: {}{}", i, convert_from_fs(caps.wszDescription, desc, lengthof(desc)), i == pIdx ? " (selected)" : ""); } } }