diff options
Diffstat (limited to 'src/devices/sound/okim6295.cpp')
-rw-r--r-- | src/devices/sound/okim6295.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/devices/sound/okim6295.cpp b/src/devices/sound/okim6295.cpp index d4006fea1da..1101cbdfa2f 100644 --- a/src/devices/sound/okim6295.cpp +++ b/src/devices/sound/okim6295.cpp @@ -56,24 +56,24 @@ DEFINE_DEVICE_TYPE(OKIM6295, okim6295_device, "okim6295", "OKI MSM6295 ADPCM") // volume lookup table. The manual lists only 9 steps, ~3dB per step. Given the dB values, // that seems to map to a 5-bit volume control. Any volume parameter beyond the 9th index // results in silent playback. -const stream_buffer::sample_t okim6295_device::s_volume_table[16] = +const sound_stream::sample_t okim6295_device::s_volume_table[16] = { - stream_buffer::sample_t(0x20) / stream_buffer::sample_t(0x20), // 0 dB - stream_buffer::sample_t(0x16) / stream_buffer::sample_t(0x20), // -3.2 dB - stream_buffer::sample_t(0x10) / stream_buffer::sample_t(0x20), // -6.0 dB - stream_buffer::sample_t(0x0b) / stream_buffer::sample_t(0x20), // -9.2 dB - stream_buffer::sample_t(0x08) / stream_buffer::sample_t(0x20), // -12.0 dB - stream_buffer::sample_t(0x06) / stream_buffer::sample_t(0x20), // -14.5 dB - stream_buffer::sample_t(0x04) / stream_buffer::sample_t(0x20), // -18.0 dB - stream_buffer::sample_t(0x03) / stream_buffer::sample_t(0x20), // -20.5 dB - stream_buffer::sample_t(0x02) / stream_buffer::sample_t(0x20), // -24.0 dB - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), + sound_stream::sample_t(0x20) / sound_stream::sample_t(0x20), // 0 dB + sound_stream::sample_t(0x16) / sound_stream::sample_t(0x20), // -3.2 dB + sound_stream::sample_t(0x10) / sound_stream::sample_t(0x20), // -6.0 dB + sound_stream::sample_t(0x0b) / sound_stream::sample_t(0x20), // -9.2 dB + sound_stream::sample_t(0x08) / sound_stream::sample_t(0x20), // -12.0 dB + sound_stream::sample_t(0x06) / sound_stream::sample_t(0x20), // -14.5 dB + sound_stream::sample_t(0x04) / sound_stream::sample_t(0x20), // -18.0 dB + sound_stream::sample_t(0x03) / sound_stream::sample_t(0x20), // -20.5 dB + sound_stream::sample_t(0x02) / sound_stream::sample_t(0x20), // -24.0 dB + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), }; @@ -175,17 +175,11 @@ void okim6295_device::device_clock_changed() // our sound stream //------------------------------------------------- -void okim6295_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6295_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - // iterate over voices and accumulate sample data for (auto & elem : m_voice) - elem.generate_adpcm(*this, outputs[0]); - - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, std::clamp(outputs[0].getraw(i), -1.0f, 1.0f)); + elem.generate_adpcm(*this, stream); } @@ -341,21 +335,21 @@ okim6295_device::okim_voice::okim_voice() : // add them to an output stream //------------------------------------------------- -void okim6295_device::okim_voice::generate_adpcm(device_rom_interface &rom, write_stream_view &buffer) +void okim6295_device::okim_voice::generate_adpcm(device_rom_interface &rom, sound_stream &stream) { // skip if not active if (!m_playing) return; // loop while we still have samples to generate - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // fetch the next sample byte int nibble = rom.read_byte(m_base_offset + m_sample / 2) >> (((m_sample & 1) << 2) ^ 4); // output to the buffer, scaling by the volume // signal in range -2048..2047 - buffer.add_int(sampindex, m_adpcm.clock(nibble) * m_volume, 2048); + stream.add_int(0, sampindex, m_adpcm.clock(nibble) * m_volume, 2048); // next! if (++m_sample >= m_count) |