diff options
Diffstat (limited to 'src/devices/sound/multipcm.cpp')
-rw-r--r-- | src/devices/sound/multipcm.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/devices/sound/multipcm.cpp b/src/devices/sound/multipcm.cpp index 2d3315c2c4b..285b6ade701 100644 --- a/src/devices/sound/multipcm.cpp +++ b/src/devices/sound/multipcm.cpp @@ -35,6 +35,7 @@ #include "emu.h" #include "multipcm.h" +#include "wavwrite.h" ALLOW_SAVE_TYPE(multipcm_device::state_t); // allow save_item on a non-fundamental type @@ -368,6 +369,10 @@ void multipcm_device::write_slot(slot_t &slot, int32_t reg, uint8_t data) envelope_generator_calc(slot); slot.m_envelope_gen.m_state = state_t::ATTACK; slot.m_envelope_gen.m_volume = 0; + +#if MULTIPCM_LOG_SAMPLES + dump_sample(slot); +#endif } else { @@ -639,6 +644,38 @@ int16_t multipcm_device::clamp_to_int16(int32_t value) return (int16_t)value; } +#if MULTIPCM_LOG_SAMPLES +void multipcm_device::dump_sample(slot_t &slot) +{ + if (m_logged_map[slot.m_base]) + return; + + m_logged_map[slot.m_base] = true; + + char filebuf[256]; + snprintf(filebuf, 256, "multipcm%08x.wav", slot.m_base); + wav_file *file = wav_open(filebuf, m_stream->sample_rate(), 1); + if (file == nullptr) + return; + + uint32_t offset = slot.m_offset; + bool done = false; + while (!done) + { + int16_t sample = (int16_t) (read_byte(slot.m_base + (offset >> TL_SHIFT)) << 8); + wav_add_data_16(file, &sample, 1); + + offset += 1 << TL_SHIFT; + if (offset >= (slot.m_sample.m_end << TL_SHIFT)) + { + done = true; + } + } + + wav_close(file); +} +#endif + //------------------------------------------------- // sound_stream_update - handle a stream update //------------------------------------------------- |