diff options
Diffstat (limited to 'src/devices/sound/okim6376.cpp')
-rw-r--r-- | src/devices/sound/okim6376.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/devices/sound/okim6376.cpp b/src/devices/sound/okim6376.cpp index 3cb3e6fc17b..d7cd143e003 100644 --- a/src/devices/sound/okim6376.cpp +++ b/src/devices/sound/okim6376.cpp @@ -169,7 +169,7 @@ void okim6376_device::device_start() m_ch2_update = 0; m_st_pulses = 0; /* generate the name and create the stream */ - m_stream = stream_alloc_legacy(0, 1, get_sample_rate()); + m_stream = stream_alloc(0, 1, get_sample_rate()); /* initialize the voices */ for (voice = 0; voice < OKIM6376_VOICES; voice++) @@ -578,21 +578,18 @@ void okim6376_device::write(uint8_t data) } //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void okim6376_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void okim6376_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { - int i; - - memset(outputs[0], 0, samples * sizeof(*outputs[0])); + outputs[0].fill(0); - for (i = 0; i < OKIM6376_VOICES; i++) + for (int i = 0; i < OKIM6376_VOICES; i++) { struct ADPCMVoice *voice = &m_voice[i]; - stream_sample_t *buffer = outputs[0]; + auto &buffer = outputs[0]; int16_t sample_data[MAX_SAMPLE_CHUNK]; - int remaining = samples; if (i == 0) //channel 1 is the only channel to affect NAR { if (m_nartimer > 0) @@ -606,16 +603,16 @@ void okim6376_device::sound_stream_update_legacy(sound_stream &stream, stream_sa } /* loop while we have samples remaining */ - while (remaining) + for (int sampindex = 0; sampindex < buffer.samples(); ) { + int remaining = buffer.samples() - sampindex; int samples = (remaining > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : remaining; - int samp; generate_adpcm(voice, sample_data, samples,i); - for (samp = 0; samp < samples; samp++) - *buffer++ += sample_data[samp]; + for (int samp = 0; samp < samples; samp++) + buffer.add_int(sampindex + samp, sample_data[samp], 32768); - remaining -= samples; + sampindex += samples; } } } |