diff options
author | 2020-09-16 14:33:59 -0700 | |
---|---|---|
committer | 2020-09-16 14:33:59 -0700 | |
commit | 566c63ea799cfc8a6335310fe2466d5accabeecd (patch) | |
tree | bc656711ba7b2d4b43e7b6066df94bf73ec239c0 /src/devices/sound | |
parent | 69e021ed3c88252bee30caec13b5f9f524fb9416 (diff) |
cdp1863/cdp1864/cpd1869: update to new stream callbacks
Diffstat (limited to 'src/devices/sound')
-rw-r--r-- | src/devices/sound/cdp1864.cpp | 27 | ||||
-rw-r--r-- | src/devices/sound/cdp1864.h | 4 | ||||
-rw-r--r-- | src/devices/sound/cdp1869.cpp | 25 | ||||
-rw-r--r-- | src/devices/sound/cdp1869.h | 4 |
4 files changed, 28 insertions, 32 deletions
diff --git a/src/devices/sound/cdp1864.cpp b/src/devices/sound/cdp1864.cpp index 12b138ac469..e8168004811 100644 --- a/src/devices/sound/cdp1864.cpp +++ b/src/devices/sound/cdp1864.cpp @@ -119,7 +119,7 @@ void cdp1864_device::device_start() initialize_palette(); // create sound stream - m_stream = stream_alloc_legacy(0, 1, machine().sample_rate()); + m_stream = stream_alloc(0, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE); // allocate timers m_int_timer = timer_alloc(TIMER_INT); @@ -253,40 +253,35 @@ void cdp1864_device::device_timer(emu_timer &timer, device_timer_id id, int para //------------------------------------------------- -// sound_stream_update_legacy - handle update requests for +// sound_stream_update - handle update requests for // our sound stream //------------------------------------------------- -void cdp1864_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { - // reset the output stream - memset(outputs[0], 0, samples * sizeof(*outputs[0])); - - int16_t signal = m_signal; - stream_sample_t *buffer = outputs[0]; - - memset( buffer, 0, samples * sizeof(*buffer) ); + stream_buffer::sample_t signal = m_signal; + auto &buffer = outputs[0]; if (m_aoe) { double frequency = unscaled_clock() / 8 / 4 / (m_latch + 1) / 2; - int rate = machine().sample_rate() / 2; + int rate = buffer.sample_rate() / 2; /* get progress through wave */ int incr = m_incr; if (signal < 0) { - signal = -0x7fff; + signal = -1.0; } else { - signal = 0x7fff; + signal = 1.0; } - while( samples-- > 0 ) + for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) { - *buffer++ = signal; + buffer.put(sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -299,6 +294,8 @@ void cdp1864_device::sound_stream_update_legacy(sound_stream &stream, stream_sam m_incr = incr; m_signal = signal; } + else + buffer.fill(0); } diff --git a/src/devices/sound/cdp1864.h b/src/devices/sound/cdp1864.h index 1b9a843954b..6c589128ef7 100644 --- a/src/devices/sound/cdp1864.h +++ b/src/devices/sound/cdp1864.h @@ -115,7 +115,7 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // internal callbacks - virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override; + virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; private: enum @@ -157,7 +157,7 @@ private: // sound state int m_aoe; // audio on int m_latch; // sound latch - int16_t m_signal; // current signal + stream_buffer::sample_t m_signal; // current signal int m_incr; // initial wave state // timers diff --git a/src/devices/sound/cdp1869.cpp b/src/devices/sound/cdp1869.cpp index 8d89b42ba48..98580d7ae54 100644 --- a/src/devices/sound/cdp1869.cpp +++ b/src/devices/sound/cdp1869.cpp @@ -400,7 +400,7 @@ void cdp1869_device::device_start() m_bkg = 0; // create sound stream - m_stream = stream_alloc_legacy(0, 1, machine().sample_rate()); + m_stream = stream_alloc(0, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE); // initialize other m_tonediv = 0; @@ -506,40 +506,37 @@ void cdp1869_device::cdp1869_palette(palette_device &palette) const //------------------------------------------------- -// sound_stream_update_legacy - handle update requests for +// sound_stream_update - handle update requests for // our sound stream //------------------------------------------------- -void cdp1869_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void cdp1869_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { - // reset the output stream - memset(outputs[0], 0, samples * sizeof(*outputs[0])); - - int16_t signal = m_signal; - stream_sample_t *buffer = outputs[0]; + stream_buffer::sample_t signal = m_signal; + auto &buffer = outputs[0]; if (!m_toneoff && m_toneamp) { double frequency = (clock() / 2) / (512 >> m_tonefreq) / (m_tonediv + 1); // double amplitude = m_toneamp * ((0.78*5) / 15); - int rate = machine().sample_rate() / 2; + int rate = buffer.sample_rate() / 2; /* get progress through wave */ int incr = m_incr; if (signal < 0) { - signal = -(m_toneamp * (0x07fff / 15)); + signal = -(stream_buffer::sample_t(m_toneamp) / 15.0); } else { - signal = m_toneamp * (0x07fff / 15); + signal = stream_buffer::sample_t(m_toneamp) / 15.0; } - while( samples-- > 0 ) + for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) { - *buffer++ = signal; + buffer.put(sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -552,6 +549,8 @@ void cdp1869_device::sound_stream_update_legacy(sound_stream &stream, stream_sam m_incr = incr; m_signal = signal; } + else + buffer.fill(0); /* if (!m_wnoff) { diff --git a/src/devices/sound/cdp1869.h b/src/devices/sound/cdp1869.h index 50b32492233..dc9c1501ea0 100644 --- a/src/devices/sound/cdp1869.h +++ b/src/devices/sound/cdp1869.h @@ -216,7 +216,7 @@ protected: virtual space_config_vector memory_space_config() const override; // device_sound_interface callbacks - virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override; + virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; inline bool is_ntsc(); inline uint8_t read_page_ram_byte(offs_t address); @@ -264,7 +264,7 @@ private: uint16_t m_hma; // home memory address // sound state - int16_t m_signal; // current signal + stream_buffer::sample_t m_signal; // current signal int m_incr; // initial wave state int m_toneoff; // tone off int m_wnoff; // white noise off |