mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
-multipcm: Added optional compile-time sample logging. [Ryan Holtz]
This commit is contained in:
parent
8637500ca5
commit
04956ee677
@ -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
|
||||
//-------------------------------------------------
|
||||
|
@ -5,6 +5,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define MULTIPCM_LOG_SAMPLES 0
|
||||
|
||||
#if MULTIPCM_LOG_SAMPLES
|
||||
#include <map>
|
||||
#endif
|
||||
|
||||
class multipcm_device : public device_t,
|
||||
public device_sound_interface,
|
||||
public device_rom_interface
|
||||
@ -130,6 +136,11 @@ private:
|
||||
|
||||
int16_t clamp_to_int16(int32_t value);
|
||||
|
||||
#if MULTIPCM_LOG_SAMPLES
|
||||
void dump_sample(slot_t &slot);
|
||||
std::map<uint32_t, bool> m_logged_map;
|
||||
#endif
|
||||
|
||||
static constexpr uint32_t TL_SHIFT = 12;
|
||||
|
||||
static const int32_t VALUE_TO_CHANNEL[32];
|
||||
|
Loading…
Reference in New Issue
Block a user