diff options
Diffstat (limited to 'src/mame/audio/tx1.cpp')
-rw-r--r-- | src/mame/audio/tx1.cpp | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/src/mame/audio/tx1.cpp b/src/mame/audio/tx1.cpp index a6dd9d2aeb6..22f3e23ec5b 100644 --- a/src/mame/audio/tx1.cpp +++ b/src/mame/audio/tx1.cpp @@ -111,7 +111,7 @@ void tx1_sound_device::device_start() /* Allocate the stream */ - m_stream = stream_alloc_legacy(0, 2, machine().sample_rate()); + m_stream = stream_alloc(0, 2, machine().sample_rate()); m_freq_to_step = (double)(1 << TX1_FRAC) / (double)machine().sample_rate(); /* Compute the engine resistor weights */ @@ -356,20 +356,16 @@ static inline void update_engine(int eng[4]) //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void tx1_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void tx1_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { uint32_t step_0, step_1, step_2; double /*gain_0, gain_1,*/ gain_2, gain_3; - stream_sample_t *fl = &outputs[0][0]; - stream_sample_t *fr = &outputs[1][0]; - - /* Clear the buffers */ - memset(outputs[0], 0, samples * sizeof(*outputs[0])); - memset(outputs[1], 0, samples * sizeof(*outputs[1])); + auto &fl = outputs[0]; + auto &fr = outputs[1]; /* 8253 outputs for the player/opponent engine sounds. */ step_0 = m_pit8253.counts[0].val ? (TX1_PIT_CLOCK / m_pit8253.counts[0].val * m_freq_to_step) : 0; @@ -381,7 +377,7 @@ void tx1_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_s gain_2 = tx1_engine_gains[m_ay_outputb & 0xf]; gain_3 = BIT(m_ay_outputb, 5) ? 1.0f : 1.5f; - while (samples--) + for (int sampindex = 0; sampindex < fl.samples(); sampindex++) { if (m_step0 & ((1 << TX1_FRAC))) { @@ -404,8 +400,8 @@ void tx1_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_s m_step2 &= ((1 << TX1_FRAC) - 1); } - *fl++ = (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2; - *fr++ = (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2; + fl.put_int(sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768); + fr.put_int(sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768); m_step0 += step_0; m_step1 += step_1; @@ -662,7 +658,7 @@ void buggyboy_sound_device::device_start() m_eng_voltages[i] = combine_weights(aweights, BIT(tmp[i], 0), BIT(tmp[i], 1), BIT(tmp[i], 2), BIT(tmp[i], 3)); /* Allocate the stream */ - m_stream = stream_alloc_legacy(0, 2, machine().sample_rate()); + m_stream = stream_alloc(0, 2, machine().sample_rate()); m_freq_to_step = (double)(1 << 24) / (double)machine().sample_rate(); } @@ -763,10 +759,10 @@ void buggyboy_sound_device::ym2_b_w(uint8_t data) //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { /* This is admittedly a bit of a hack job... */ @@ -774,12 +770,8 @@ void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, str int n1_en, n2_en; double gain0, gain1_l, gain1_r; - stream_sample_t *fl = &outputs[0][0]; - stream_sample_t *fr = &outputs[1][0]; - - /* Clear the buffers */ - memset(outputs[0], 0, samples * sizeof(*outputs[0])); - memset(outputs[1], 0, samples * sizeof(*outputs[1])); + auto &fl = outputs[0]; + auto &fr = outputs[1]; /* 8253 outputs for the player/opponent buggy engine sounds. */ step_0 = m_pit8253.counts[0].val ? (BUGGYBOY_PIT_CLOCK / m_pit8253.counts[0].val * m_freq_to_step) : 0; @@ -796,10 +788,10 @@ void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, str gain1_l = bb_engine_gains[m_ym2_outputa >> 4] * 5; gain1_r = bb_engine_gains[m_ym2_outputa & 0xf] * 5; - while (samples--) + for (int sampindex = 0; sampindex < fl.samples(); sampindex++) { int i; - stream_sample_t pit0, pit1, n1, n2; + s32 pit0, pit1, n1, n2; pit0 = m_eng_voltages[(m_step0 >> 24) & 0xf]; pit1 = m_eng_voltages[(m_step1 >> 24) & 0xf]; @@ -839,8 +831,8 @@ void buggyboy_sound_device::sound_stream_update_legacy(sound_stream &stream, str else n2 = 8192; - *fl++ = n1 + n2 + (pit0 * gain0) + (pit1 * gain1_l); - *fr++ = n1 + n2 + (pit0 * gain0) + (pit1 * gain1_r); + fl.put_int(sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_l), 32768); + fr.put_int(sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_r), 32768); m_step0 += step_0; m_step1 += step_1; |