diff options
Diffstat (limited to 'src/devices')
368 files changed, 1701 insertions, 1880 deletions
diff --git a/src/devices/bus/a2bus/a2mcms.cpp b/src/devices/bus/a2bus/a2mcms.cpp index 3455fa3d8fc..7ccf96376fa 100644 --- a/src/devices/bus/a2bus/a2mcms.cpp +++ b/src/devices/bus/a2bus/a2mcms.cpp @@ -249,19 +249,16 @@ TIMER_CALLBACK_MEMBER(mcms_device::clr_irq_tick) m_write_irq(CLEAR_LINE); } -void mcms_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mcms_device::sound_stream_update(sound_stream &stream) { int i, v; uint16_t wptr; int8_t sample; int32_t mixL, mixR; - auto &outL = outputs[1]; - auto &outR = outputs[0]; - if (m_enabled) { - for (i = 0; i < outL.samples(); i++) + for (i = 0; i < stream.samples(); i++) { mixL = mixR = 0; @@ -282,15 +279,10 @@ void mcms_device::sound_stream_update(sound_stream &stream, std::vector<read_str } } - outL.put_int(i, mixL * m_mastervol, 32768 << 9); - outR.put_int(i, mixR * m_mastervol, 32768 << 9); + stream.put_int(0, i, mixL * m_mastervol, 32768 << 9); + stream.put_int(1, i, mixR * m_mastervol, 32768 << 9); } } - else - { - outL.fill(0); - outR.fill(0); - } } void mcms_device::voiceregs_w(offs_t offset, uint8_t data) diff --git a/src/devices/bus/a2bus/a2mcms.h b/src/devices/bus/a2bus/a2mcms.h index e05ad64f18e..0f8cd2e72fb 100644 --- a/src/devices/bus/a2bus/a2mcms.h +++ b/src/devices/bus/a2bus/a2mcms.h @@ -41,7 +41,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(set_irq_tick); TIMER_CALLBACK_MEMBER(clr_irq_tick); diff --git a/src/devices/bus/a2bus/a2mockingboard.cpp b/src/devices/bus/a2bus/a2mockingboard.cpp index f002e129136..635ceb980f0 100644 --- a/src/devices/bus/a2bus/a2mockingboard.cpp +++ b/src/devices/bus/a2bus/a2mockingboard.cpp @@ -154,14 +154,13 @@ void a2bus_ayboard_device::single_via_devices(machine_config &config) m_via1->writepb_handler().set(FUNC(a2bus_ayboard_device::via1_out_b)); m_via1->irq_handler().set(FUNC(a2bus_ayboard_device::via1_irq_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AY8913(config, m_ay1, 1022727); - m_ay1->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_ay1->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); AY8913(config, m_ay2, 1022727); - m_ay2->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_ay2->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } void a2bus_ayboard_device::device_add_mconfig(machine_config &config) @@ -184,8 +183,8 @@ void a2bus_mockingboard_device::device_add_mconfig(machine_config &config) VOTRAX_SC01A(config, m_sc01, 1022727); m_sc01->ar_callback().set(m_via1, FUNC(via6522_device::write_cb1)); - m_sc01->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_sc01->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_sc01->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_sc01->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void a2bus_phasor_device::device_add_mconfig(machine_config &config) @@ -195,16 +194,15 @@ void a2bus_phasor_device::device_add_mconfig(machine_config &config) m_via1->writepb_handler().set(FUNC(a2bus_phasor_device::via1_out_b)); m_via2->writepb_handler().set(FUNC(a2bus_phasor_device::via2_out_b)); - SPEAKER(config, "lspeaker2").front_left(); - SPEAKER(config, "rspeaker2").front_right(); + SPEAKER(config, "speaker2").front(); - m_ay2->reset_routes().add_route(ALL_OUTPUTS, "lspeaker2", 0.5); + m_ay2->reset_routes().add_route(ALL_OUTPUTS, "speaker2", 0.5, 0); AY8913(config, m_ay3, 1022727); - m_ay3->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_ay3->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); AY8913(config, m_ay4, 1022727); - m_ay4->add_route(ALL_OUTPUTS, "rspeaker2", 0.5); + m_ay4->add_route(ALL_OUTPUTS, "speaker2", 0.5, 1); } void a2bus_echoplus_device::device_add_mconfig(machine_config &config) diff --git a/src/devices/bus/a2bus/a2scsi.cpp b/src/devices/bus/a2bus/a2scsi.cpp index cebfbd31565..53aff96effa 100644 --- a/src/devices/bus/a2bus/a2scsi.cpp +++ b/src/devices/bus/a2bus/a2scsi.cpp @@ -68,16 +68,15 @@ void a2bus_scsi_device::device_add_mconfig(machine_config &config) { // These machines were strictly external CD-ROMs so sound didn't route back into them; the AppleCD SC had // RCA jacks for connection to speakers/a stereo. - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); NSCSI_BUS(config, m_scsibus); NSCSI_CONNECTOR(config, "scsibus:0", default_scsi_devices, nullptr, false); NSCSI_CONNECTOR(config, "scsibus:1").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsibus:2", default_scsi_devices, nullptr, false); NSCSI_CONNECTOR(config, "scsibus:3", default_scsi_devices, nullptr, false); diff --git a/src/devices/bus/amiga/cpuslot/a570.cpp b/src/devices/bus/amiga/cpuslot/a570.cpp index 4e134004580..abd42370380 100644 --- a/src/devices/bus/amiga/cpuslot/a570.cpp +++ b/src/devices/bus/amiga/cpuslot/a570.cpp @@ -120,8 +120,8 @@ void a570_device::device_add_mconfig(machine_config &config) m_tpi->out_pb_cb().set(FUNC(a570_device::tpi_portb_w)); CR511B(config, m_drive, 0); - m_drive->add_route(0, "lspeaker", 1.0); - m_drive->add_route(1, "rspeaker", 1.0); + m_drive->add_route(0, "speaker", 1.0, 0); + m_drive->add_route(1, "speaker", 1.0, 1); m_drive->scor_cb().set(m_tpi, FUNC(tpi6525_device::i1_w)).invert(); m_drive->stch_cb().set(m_tpi, FUNC(tpi6525_device::i2_w)).invert(); m_drive->sten_cb().set(m_tpi, FUNC(tpi6525_device::i3_w)); @@ -129,8 +129,7 @@ void a570_device::device_add_mconfig(machine_config &config) m_drive->drq_cb().set(m_tpi, FUNC(tpi6525_device::i4_w)); m_drive->drq_cb().append(FUNC(a570_device::drq_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: Add stereo input for Amiga sound } diff --git a/src/devices/bus/bbc/1mhzbus/m5000.cpp b/src/devices/bus/bbc/1mhzbus/m5000.cpp index ae3fd948969..758e3311491 100644 --- a/src/devices/bus/bbc/1mhzbus/m5000.cpp +++ b/src/devices/bus/bbc/1mhzbus/m5000.cpp @@ -63,12 +63,11 @@ DEFINE_DEVICE_TYPE(BBC_M87, bbc_m87_device, "bbc_m87", "Peartree Music 87 void bbc_m500_device::add_common_devices(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); HTMUSIC(config, m_hybrid, 12_MHz_XTAL / 2); - m_hybrid->add_route(0, "lspeaker", 1.0); - m_hybrid->add_route(1, "rspeaker", 1.0); + m_hybrid->add_route(0, "speaker", 1.0, 0); + m_hybrid->add_route(1, "speaker", 1.0, 1); BBC_1MHZBUS_SLOT(config, m_1mhzbus, DERIVED_CLOCK(1, 1), bbc_1mhzbus_devices, nullptr); m_1mhzbus->irq_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_1mhzbus_slot_device::irq_w)); @@ -417,19 +416,15 @@ TIMER_CALLBACK_MEMBER(htmusic_device::dsp_tick) // sound_stream_update - handle a stream update //------------------------------------------------- -void htmusic_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void htmusic_device::sound_stream_update(sound_stream &stream) { - // reset the output streams - outputs[0].fill(0); - outputs[1].fill(0); - // iterate over channels and accumulate sample data for (int channel = 0; channel < 16; channel++) { - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - outputs[0].add_int(sampindex, m_sam_l[channel], 8031 * 16); - outputs[1].add_int(sampindex, m_sam_r[channel], 8031 * 16); + stream.add_int(0, sampindex, m_sam_l[channel], 8031 * 16); + stream.add_int(1, sampindex, m_sam_r[channel], 8031 * 16); } } } diff --git a/src/devices/bus/bbc/1mhzbus/m5000.h b/src/devices/bus/bbc/1mhzbus/m5000.h index 02b99fd12e3..44704a2b492 100644 --- a/src/devices/bus/bbc/1mhzbus/m5000.h +++ b/src/devices/bus/bbc/1mhzbus/m5000.h @@ -47,7 +47,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(dsp_tick); diff --git a/src/devices/bus/cbus/pc9801_118.cpp b/src/devices/bus/cbus/pc9801_118.cpp index c1326270ffc..7cd2477b0fe 100644 --- a/src/devices/bus/cbus/pc9801_118.cpp +++ b/src/devices/bus/cbus/pc9801_118.cpp @@ -52,8 +52,7 @@ void pc9801_118_device::device_add_mconfig(machine_config &config) // TODO: "ANCHOR" & "MAZE" custom NEC chips // sourced by 5D clock - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // actually YMF297-F (YMF288 + OPL3 compatible FM sources), unknown clock / divider // 5B is near both CS-4232 and this @@ -63,8 +62,8 @@ void pc9801_118_device::device_add_mconfig(machine_config &config) //m_opn3->port_b_read_callback().set(FUNC(pc8801_state::opn_portb_r)); //m_opn3->port_a_write_callback().set(FUNC(pc8801_state::opn_porta_w)); m_opn3->port_b_write_callback().set(FUNC(pc9801_118_device::opn_portb_w)); - m_opn3->add_route(ALL_OUTPUTS, "lspeaker", 1.00); - m_opn3->add_route(ALL_OUTPUTS, "rspeaker", 1.00); + m_opn3->add_route(ALL_OUTPUTS, "speaker", 1.00, 0); + m_opn3->add_route(ALL_OUTPUTS, "speaker", 1.00, 1); } diff --git a/src/devices/bus/cbus/pc9801_86.cpp b/src/devices/bus/cbus/pc9801_86.cpp index ffb595cba4b..eef4f353fa2 100644 --- a/src/devices/bus/cbus/pc9801_86.cpp +++ b/src/devices/bus/cbus/pc9801_86.cpp @@ -70,8 +70,7 @@ void pc9801_86_device::pc9801_86_config(machine_config &config) INPUT_MERGER_ANY_HIGH(config, m_irqs).output_handler().set([this](int state) { m_bus->int_w<5>(state); }); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2608(config, m_opna, 7.987_MHz_XTAL); // actually YM2608B // shouldn't have one // m_opna->set_addrmap(0, &pc9801_86_device::opna_map); @@ -80,13 +79,13 @@ void pc9801_86_device::pc9801_86_config(machine_config &config) //m_opna->port_b_read_callback().set(FUNC(pc8801_state::opn_portb_r)); //m_opna->port_a_write_callback().set(FUNC(pc8801_state::opn_porta_w)); m_opna->port_b_write_callback().set(FUNC(pc9801_86_device::opn_portb_w)); - m_opna->add_route(0, "lspeaker", 1.00); - m_opna->add_route(0, "rspeaker", 1.00); - m_opna->add_route(1, "lspeaker", 1.00); - m_opna->add_route(2, "rspeaker", 1.00); + m_opna->add_route(0, "speaker", 1.00, 0); + m_opna->add_route(0, "speaker", 1.00, 1); + m_opna->add_route(1, "speaker", 1.00, 0); + m_opna->add_route(2, "speaker", 1.00, 1); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // burr brown pcm61p - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // burr brown pcm61p + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // burr brown pcm61p + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // burr brown pcm61p } void pc9801_86_device::device_add_mconfig(machine_config &config) @@ -98,10 +97,10 @@ void pc9801_86_device::device_add_mconfig(machine_config &config) void pc9801_86_device::opna_reset_routes_config(machine_config &config) { m_opna->reset_routes(); - m_opna->add_route(0, "lspeaker", 0.50); - m_opna->add_route(0, "rspeaker", 0.50); - m_opna->add_route(1, "lspeaker", 0.50); - m_opna->add_route(2, "rspeaker", 0.50); + m_opna->add_route(0, "speaker", 0.50, 0); + m_opna->add_route(0, "speaker", 0.50, 1); + m_opna->add_route(1, "speaker", 0.50, 0); + m_opna->add_route(2, "speaker", 0.50, 1); } // to load a different bios for slots: @@ -527,10 +526,10 @@ void pc9801_speakboard_device::device_add_mconfig(machine_config &config) YM2608(config, m_opna_slave, 7.987_MHz_XTAL); m_opna_slave->set_addrmap(0, &pc9801_speakboard_device::opna_map); - m_opna_slave->add_route(0, "lspeaker", 0.50); - m_opna_slave->add_route(0, "rspeaker", 0.50); - m_opna_slave->add_route(1, "lspeaker", 0.50); - m_opna_slave->add_route(2, "rspeaker", 0.50); + m_opna_slave->add_route(0, "speaker", 0.50, 0); + m_opna_slave->add_route(0, "speaker", 0.50, 1); + m_opna_slave->add_route(1, "speaker", 0.50, 0); + m_opna_slave->add_route(2, "speaker", 0.50, 1); } void pc9801_speakboard_device::device_start() @@ -598,8 +597,8 @@ void otomichan_kai_device::device_add_mconfig(machine_config &config) m_opna->set_addrmap(0, &otomichan_kai_device::opna_map); YM3438(config, m_opn2c, 7.987_MHz_XTAL); - m_opn2c->add_route(0, "lspeaker", 0.50); - m_opn2c->add_route(1, "rspeaker", 0.50); + m_opn2c->add_route(0, "speaker", 0.50, 0); + m_opn2c->add_route(1, "speaker", 0.50, 1); } u8 otomichan_kai_device::id_r() diff --git a/src/devices/bus/cbus/sb16_ct2720.cpp b/src/devices/bus/cbus/sb16_ct2720.cpp index 3f77a83698c..cbe417c9960 100644 --- a/src/devices/bus/cbus/sb16_ct2720.cpp +++ b/src/devices/bus/cbus/sb16_ct2720.cpp @@ -39,15 +39,14 @@ sb16_ct2720_device::sb16_ct2720_device(const machine_config &mconfig, const char void sb16_ct2720_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); CT1745(config, m_mixer); m_mixer->set_fm_tag(m_opl3); m_mixer->set_ldac_tag(m_ldac); m_mixer->set_rdac_tag(m_rdac); - m_mixer->add_route(0, "lspeaker", 1.0); - m_mixer->add_route(1, "rspeaker", 1.0); + m_mixer->add_route(0, "speaker", 1.0, 0); + m_mixer->add_route(1, "speaker", 1.0, 1); m_mixer->irq_status_cb().set([this] () { (void)this; return 0; @@ -59,14 +58,14 @@ void sb16_ct2720_device::device_add_mconfig(machine_config &config) // MIDI_PORT(config, "mdin", midiin_slot, "midiin").rxd_handler().set(FUNC(sb_device::midi_rx_w)); // MIDI_PORT(config, "mdout", midiout_slot, "midiout"); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); // unknown DAC + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 1); // unknown DAC YMF262(config, m_opl3, XTAL(14'318'181)); - m_opl3->add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_opl3->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_opl3->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_opl3->add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_opl3->add_route(0, m_mixer, 1.00, 0); + m_opl3->add_route(1, m_mixer, 1.00, 1); + m_opl3->add_route(2, m_mixer, 1.00, 0); + m_opl3->add_route(3, m_mixer, 1.00, 1); } void sb16_ct2720_device::device_start() diff --git a/src/devices/bus/centronics/covox.cpp b/src/devices/bus/centronics/covox.cpp index 4b3521b5955..9989308f593 100644 --- a/src/devices/bus/centronics/covox.cpp +++ b/src/devices/bus/centronics/covox.cpp @@ -92,10 +92,9 @@ centronics_covox_stereo_device::centronics_covox_stereo_device(const machine_con void centronics_covox_stereo_device::device_add_mconfig(machine_config &config) { /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } void centronics_covox_stereo_device::device_start() diff --git a/src/devices/bus/centronics/samdac.cpp b/src/devices/bus/centronics/samdac.cpp index 46a7682f4ba..90afc8e8a7c 100644 --- a/src/devices/bus/centronics/samdac.cpp +++ b/src/devices/bus/centronics/samdac.cpp @@ -23,11 +23,10 @@ DEFINE_DEVICE_TYPE(CENTRONICS_SAMDAC, centronics_samdac_device, "centronics_samd void centronics_samdac_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_8BIT_R2R(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); - DAC_8BIT_R2R(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); + DAC_8BIT_R2R(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + DAC_8BIT_R2R(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } diff --git a/src/devices/bus/coco/coco_orch90.cpp b/src/devices/bus/coco/coco_orch90.cpp index 83595798916..33151fb5d73 100644 --- a/src/devices/bus/coco/coco_orch90.cpp +++ b/src/devices/bus/coco/coco_orch90.cpp @@ -116,10 +116,9 @@ namespace void coco_orch90_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // ls374.ic5 + r7 (8x20k) + r9 (8x10k) - DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // ls374.ic4 + r6 (8x20k) + r8 (8x10k) + SPEAKER(config, "speaker", 2).front(); + DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // ls374.ic5 + r7 (8x20k) + r9 (8x10k) + DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // ls374.ic4 + r6 (8x20k) + r8 (8x10k) } //------------------------------------------------- diff --git a/src/devices/bus/coco/coco_ssc.cpp b/src/devices/bus/coco/coco_ssc.cpp index 6f5ff8443a6..d6a0140d293 100644 --- a/src/devices/bus/coco/coco_ssc.cpp +++ b/src/devices/bus/coco/coco_ssc.cpp @@ -135,7 +135,7 @@ namespace virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // Power of 2 static constexpr int BUFFER_SIZE = 4; @@ -499,21 +499,18 @@ void cocossc_sac_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void cocossc_sac_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cocossc_sac_device::sound_stream_update(sound_stream &stream) { - auto &src = inputs[0]; - auto &dst = outputs[0]; - - int count = dst.samples(); + int count = stream.samples(); m_rms[m_index] = 0; if( count > 0 ) { for( int sampindex = 0; sampindex < count; sampindex++ ) { - auto source_sample = src.get(sampindex); + auto source_sample = stream.get(0, sampindex); m_rms[m_index] += source_sample * source_sample; - dst.put(sampindex, source_sample); + stream.put(0, sampindex, source_sample); } m_rms[m_index] = m_rms[m_index] / count; diff --git a/src/devices/bus/coco/coco_stecomp.cpp b/src/devices/bus/coco/coco_stecomp.cpp index 83477fd41fb..93b4b63908b 100644 --- a/src/devices/bus/coco/coco_stecomp.cpp +++ b/src/devices/bus/coco/coco_stecomp.cpp @@ -68,10 +68,9 @@ namespace void coco_stereo_composer_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "sc_lspeaker").front_left(); - SPEAKER(config, "sc_rspeaker").front_right(); - DAC_8BIT_R2R(config, m_ldac).add_route(ALL_OUTPUTS, "sc_lspeaker", 0.5); - DAC_8BIT_R2R(config, m_rdac).add_route(ALL_OUTPUTS, "sc_rspeaker", 0.5); + SPEAKER(config, "sc_speaker").front(); + DAC_8BIT_R2R(config, m_ldac).add_route(ALL_OUTPUTS, "sc_speaker", 0.5, 0); + DAC_8BIT_R2R(config, m_rdac).add_route(ALL_OUTPUTS, "sc_speaker", 0.5, 1); pia6821_device &pia(PIA6821(config, "sc_pia")); pia.writepa_handler().set("sc_ldac", FUNC(dac_byte_interface::data_w)); diff --git a/src/devices/bus/cpc/playcity.cpp b/src/devices/bus/cpc/playcity.cpp index c6abaeed14e..a2429242f43 100644 --- a/src/devices/bus/cpc/playcity.cpp +++ b/src/devices/bus/cpc/playcity.cpp @@ -31,12 +31,11 @@ void cpc_playcity_device::device_add_mconfig(machine_config &config) m_ctc->zc_callback<2>().set(m_ctc, FUNC(z80ctc_device::trg3)); m_ctc->intr_callback().set(FUNC(cpc_playcity_device::ctc_intr_cb)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ294(config, m_ymz1, DERIVED_CLOCK(1, 1)); // when timer is not set, operates at 4MHz (interally divided by 2, so equivalent to the ST) - m_ymz1->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_ymz1->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); YMZ294(config, m_ymz2, DERIVED_CLOCK(1, 1)); - m_ymz2->add_route(ALL_OUTPUTS, "lspeaker", 0.30); + m_ymz2->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); // pass-through cpc_expansion_slot_device &exp(CPC_EXPANSION_SLOT(config, "exp", DERIVED_CLOCK(1, 1), cpc_exp_cards, nullptr)); diff --git a/src/devices/bus/isa/gblaster.cpp b/src/devices/bus/isa/gblaster.cpp index 1cbd9458c04..3b6d66adb14 100644 --- a/src/devices/bus/isa/gblaster.cpp +++ b/src/devices/bus/isa/gblaster.cpp @@ -70,14 +70,13 @@ DEFINE_DEVICE_TYPE(ISA8_GAME_BLASTER, isa8_gblaster_device, "isa_gblaster", "Gam void isa8_gblaster_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SAA1099(config, m_saa1099_1, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_1->add_route(0, "lspeaker", 0.50); - m_saa1099_1->add_route(1, "rspeaker", 0.50); + m_saa1099_1->add_route(0, "speaker", 0.50, 0); + m_saa1099_1->add_route(1, "speaker", 0.50, 1); SAA1099(config, m_saa1099_2, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_2->add_route(0, "lspeaker", 0.50); - m_saa1099_2->add_route(1, "rspeaker", 0.50); + m_saa1099_2->add_route(0, "speaker", 0.50, 0); + m_saa1099_2->add_route(1, "speaker", 0.50, 1); } //************************************************************************** diff --git a/src/devices/bus/isa/gus.cpp b/src/devices/bus/isa/gus.cpp index 2017482fc96..3d9fd1c073f 100644 --- a/src/devices/bus/isa/gus.cpp +++ b/src/devices/bus/isa/gus.cpp @@ -242,26 +242,19 @@ TIMER_CALLBACK_MEMBER(gf1_device::dma_tick) m_drq1_handler(1); } -void gf1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gf1_device::sound_stream_update(sound_stream &stream) { int x; - //uint32_t count; - - auto &outputl = outputs[0]; - auto &outputr = outputs[1]; - - outputl.fill(0); - outputr.fill(0); for(x=0;x<32;x++) // for each voice { uint16_t vol = (m_volume_table[(m_voice[x].current_vol & 0xfff0) >> 4]); - for (int sampindex = 0; sampindex < outputl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { uint32_t current = m_voice[x].current_addr >> 9; // TODO: implement proper panning - outputl.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192); - outputr.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192); + stream.add_int(0, sampindex, m_voice[x].sample * vol, 32768 * 8192); + stream.add_int(1, sampindex, m_voice[x].sample * vol, 32768 * 8192); if((!(m_voice[x].voice_ctrl & 0x40)) && (m_voice[x].current_addr >= m_voice[x].end_addr) && !m_voice[x].rollover && !(m_voice[x].voice_ctrl & 0x01)) { if(m_voice[x].vol_ramp_ctrl & 0x04) @@ -1238,11 +1231,10 @@ INPUT_PORTS_END void isa16_gus_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GGF1(config, m_gf1, GF1_CLOCK); - m_gf1->add_route(0, "lspeaker", 0.50); - m_gf1->add_route(1, "rspeaker", 0.50); + m_gf1->add_route(0, "speaker", 0.50, 0); + m_gf1->add_route(1, "speaker", 0.50, 1); m_gf1->txd_handler().set("mdout", FUNC(midi_port_device::write_txd)); m_gf1->txirq_handler().set(FUNC(isa16_gus_device::midi_txirq)); diff --git a/src/devices/bus/isa/gus.h b/src/devices/bus/isa/gus.h index cc86b2f088c..e58fea6c9fa 100644 --- a/src/devices/bus/isa/gus.h +++ b/src/devices/bus/isa/gus.h @@ -122,7 +122,7 @@ public: void eop_w(int state); // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; protected: // device-level overrides diff --git a/src/devices/bus/isa/sb16.cpp b/src/devices/bus/isa/sb16.cpp index 30d0a6f8950..b260edca7b9 100644 --- a/src/devices/bus/isa/sb16.cpp +++ b/src/devices/bus/isa/sb16.cpp @@ -434,27 +434,26 @@ void sb16_lle_device::device_add_mconfig(machine_config &config) m_cpu->port_in_cb<2>().set(FUNC(sb16_lle_device::p2_r)); m_cpu->port_out_cb<2>().set(FUNC(sb16_lle_device::p2_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); CT1745(config, m_mixer); m_mixer->set_fm_tag("ymf262"); m_mixer->set_ldac_tag(m_ldac); m_mixer->set_rdac_tag(m_rdac); - m_mixer->add_route(0, "lspeaker", 1.0); - m_mixer->add_route(1, "rspeaker", 1.0); + m_mixer->add_route(0, "speaker", 1.0, 0); + m_mixer->add_route(1, "speaker", 1.0, 1); m_mixer->irq_status_cb().set([this] () { return (m_irq8 << 0) | (m_irq16 << 1) | (m_irq_midi << 2) | (0x8 << 4); }); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); // unknown DAC + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 1); // unknown DAC ymf262_device &ymf262(YMF262(config, "ymf262", XTAL(14'318'181))); - ymf262.add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - ymf262.add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - ymf262.add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - ymf262.add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + ymf262.add_route(0, m_mixer, 1.00, 0); + ymf262.add_route(1, m_mixer, 1.00, 1); + ymf262.add_route(2, m_mixer, 1.00, 0); + ymf262.add_route(3, m_mixer, 1.00, 1); PC_JOY(config, m_joy); } diff --git a/src/devices/bus/isa/sblaster.cpp b/src/devices/bus/isa/sblaster.cpp index 0f73dc7ec9f..a17d808cebd 100644 --- a/src/devices/bus/isa/sblaster.cpp +++ b/src/devices/bus/isa/sblaster.cpp @@ -1152,11 +1152,10 @@ DEFINE_DEVICE_TYPE(ISA16_SOUND_BLASTER_16, isa16_sblaster16_device, "isa_sblaste void sb_device::common(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC PC_JOY(config, m_joy); @@ -1169,16 +1168,16 @@ void isa8_sblaster1_0_device::device_add_mconfig(machine_config &config) common(config); YM3812(config, m_ym3812, ym3812_StdClock); - m_ym3812->add_route(ALL_OUTPUTS, "lspeaker", 3.0); - m_ym3812->add_route(ALL_OUTPUTS, "rspeaker", 3.0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 3.0, 0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 3.0, 1); SAA1099(config, m_saa1099_1, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_1->add_route(0, "lspeaker", 0.5); - m_saa1099_1->add_route(1, "rspeaker", 0.5); + m_saa1099_1->add_route(0, "speaker", 0.5, 0); + m_saa1099_1->add_route(1, "speaker", 0.5, 1); SAA1099(config, m_saa1099_2, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_2->add_route(0, "lspeaker", 0.5); - m_saa1099_2->add_route(1, "rspeaker", 0.5); + m_saa1099_2->add_route(0, "speaker", 0.5, 0); + m_saa1099_2->add_route(1, "speaker", 0.5, 1); } void isa8_sblaster1_5_device::device_add_mconfig(machine_config &config) @@ -1186,8 +1185,8 @@ void isa8_sblaster1_5_device::device_add_mconfig(machine_config &config) common(config); YM3812(config, m_ym3812, ym3812_StdClock); - m_ym3812->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_ym3812->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); /* no CM/S support (empty sockets) */ } @@ -1196,10 +1195,10 @@ void isa16_sblaster16_device::device_add_mconfig(machine_config &config) common(config); ymf262_device &ymf262(YMF262(config, "ymf262", ymf262_StdClock)); - ymf262.add_route(0, "lspeaker", 1.0); - ymf262.add_route(1, "rspeaker", 1.0); - ymf262.add_route(2, "lspeaker", 1.0); - ymf262.add_route(3, "rspeaker", 1.0); + ymf262.add_route(0, "speaker", 1.0, 0); + ymf262.add_route(1, "speaker", 1.0, 1); + ymf262.add_route(2, "speaker", 1.0, 0); + ymf262.add_route(3, "speaker", 1.0, 1); } //************************************************************************** diff --git a/src/devices/bus/isa/stereo_fx.cpp b/src/devices/bus/isa/stereo_fx.cpp index 70f3c5160c7..bfd6eb6cfe5 100644 --- a/src/devices/bus/isa/stereo_fx.cpp +++ b/src/devices/bus/isa/stereo_fx.cpp @@ -124,15 +124,14 @@ void stereo_fx_device::device_add_mconfig(machine_config &config) m_cpu->port_in_cb<3>().set(FUNC(stereo_fx_device::p3_r)); m_cpu->port_out_cb<3>().set(FUNC(stereo_fx_device::p3_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym3812_device &ym3812(YM3812(config, "ym3812", XTAL(3'579'545))); - ym3812.add_route(ALL_OUTPUTS, "lspeaker", 1.00); - ym3812.add_route(ALL_OUTPUTS, "rspeaker", 1.00); + ym3812.add_route(ALL_OUTPUTS, "speaker", 1.00, 0); + ym3812.add_route(ALL_OUTPUTS, "speaker", 1.00, 1); /* no CM/S support (empty sockets) */ - DAC_8BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC_8BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_8BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC PC_JOY(config, m_joy); } diff --git a/src/devices/bus/msx/cart/moonsound.cpp b/src/devices/bus/msx/cart/moonsound.cpp index 2251e0ac788..ba03a17d4d3 100644 --- a/src/devices/bus/msx/cart/moonsound.cpp +++ b/src/devices/bus/msx/cart/moonsound.cpp @@ -57,18 +57,17 @@ void msx_cart_moonsound_device::ymf278b_map(address_map &map) void msx_cart_moonsound_device::device_add_mconfig(machine_config &config) { // The moonsound cartridge has a separate stereo output. - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMF278B(config, m_ymf278b, 33.8688_MHz_XTAL); m_ymf278b->set_addrmap(0, &msx_cart_moonsound_device::ymf278b_map); m_ymf278b->irq_handler().set(FUNC(msx_cart_moonsound_device::irq_w)); - m_ymf278b->add_route(0, "lspeaker", 0.50); - m_ymf278b->add_route(1, "rspeaker", 0.50); - m_ymf278b->add_route(2, "lspeaker", 0.40); - m_ymf278b->add_route(3, "rspeaker", 0.40); - m_ymf278b->add_route(4, "lspeaker", 0.50); - m_ymf278b->add_route(5, "rspeaker", 0.50); + m_ymf278b->add_route(0, "speaker", 0.50, 0); + m_ymf278b->add_route(1, "speaker", 0.50, 1); + m_ymf278b->add_route(2, "speaker", 0.40, 0); + m_ymf278b->add_route(3, "speaker", 0.40, 1); + m_ymf278b->add_route(4, "speaker", 0.50, 0); + m_ymf278b->add_route(5, "speaker", 0.50, 1); } ROM_START(msx_cart_moonsound) diff --git a/src/devices/bus/msx/module/sfg.cpp b/src/devices/bus/msx/module/sfg.cpp index 34657e59738..a9ba98068a5 100644 --- a/src/devices/bus/msx/module/sfg.cpp +++ b/src/devices/bus/msx/module/sfg.cpp @@ -63,12 +63,11 @@ void msx_cart_sfg_device::device_add_mconfig(machine_config &config) // YM3012 (DAC) // YM2148 (MKS) - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ym2151(YM2151(config, m_ym2151, DERIVED_CLOCK(1, 1))); // The SFG01 uses a YM2151, the SFG05 uses a YM2164, input clock comes from the main cpu frequency ym2151.irq_handler().set(FUNC(msx_cart_sfg_device::ym2151_irq_w)); - ym2151.add_route(0, "lspeaker", 0.80); - ym2151.add_route(1, "rspeaker", 0.80); + ym2151.add_route(0, "speaker", 0.80, 0); + ym2151.add_route(1, "speaker", 0.80, 1); YM2148(config, m_ym2148, XTAL(4'000'000)); m_ym2148->txd_handler().set("mdout", FUNC(midi_port_device::write_txd)); @@ -186,8 +185,8 @@ void msx_cart_sfg05_device::device_add_mconfig(machine_config &config) ym2164_device &ym2164(YM2164(config.replace(), m_ym2151, DERIVED_CLOCK(1, 1))); ym2164.irq_handler().set(FUNC(msx_cart_sfg05_device::ym2151_irq_w)); - ym2164.add_route(0, "lspeaker", 0.80); - ym2164.add_route(1, "rspeaker", 0.80); + ym2164.add_route(0, "speaker", 0.80, 0); + ym2164.add_route(1, "speaker", 0.80, 1); } ROM_START(msx_sfg05) diff --git a/src/devices/bus/pc8801/gsx8800.cpp b/src/devices/bus/pc8801/gsx8800.cpp index 2e28c298136..df630cf83bf 100644 --- a/src/devices/bus/pc8801/gsx8800.cpp +++ b/src/devices/bus/pc8801/gsx8800.cpp @@ -44,10 +44,10 @@ void gsx8800_device::device_add_mconfig(machine_config &config) // it's just known that one goes to the left and the other to the right // cfr. http://mydocuments.g2.xrea.com/html/p8/soundinfo.html YM2149(config, m_psg[0], psg_x1_clock); - m_psg[0]->add_route(ALL_OUTPUTS, "^^lspeaker", 0.50); + m_psg[0]->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 0); YM2149(config, m_psg[1], psg_x1_clock); - m_psg[1]->add_route(ALL_OUTPUTS, "^^rspeaker", 0.50); + m_psg[1]->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 1); // ...->irq_handler().set(FUNC(gsx8800_device::int3_w)); diff --git a/src/devices/bus/pc8801/hmb20.cpp b/src/devices/bus/pc8801/hmb20.cpp index 82fd4081f48..6da14585d6e 100644 --- a/src/devices/bus/pc8801/hmb20.cpp +++ b/src/devices/bus/pc8801/hmb20.cpp @@ -37,6 +37,6 @@ void hmb20_device::device_add_mconfig(machine_config &config) // TODO: OPM mixing YM2151(config, m_opm, hmb20_x1_clock); // m_opm->irq_handler().set(FUNC(hmb20_device::int4_w)); - m_opm->add_route(ALL_OUTPUTS, "^^lspeaker", 0.50); - m_opm->add_route(ALL_OUTPUTS, "^^rspeaker", 0.50); + m_opm->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 0); + m_opm->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 1); } diff --git a/src/devices/bus/pc8801/jmbx1.cpp b/src/devices/bus/pc8801/jmbx1.cpp index c868a7e2c7b..a5beb667a31 100644 --- a/src/devices/bus/pc8801/jmbx1.cpp +++ b/src/devices/bus/pc8801/jmbx1.cpp @@ -44,15 +44,15 @@ void jmbx1_device::device_add_mconfig(machine_config &config) // doesn't seem to have irq mask YM2151(config, m_opm1, jmb_x1_clock / 2); m_opm1->irq_handler().set(FUNC(jmbx1_device::int4_w)); - m_opm1->add_route(ALL_OUTPUTS, "^^lspeaker", 0.25); - m_opm1->add_route(ALL_OUTPUTS, "^^rspeaker", 0.25); + m_opm1->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 0); + m_opm1->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 1); YM2151(config, m_opm2, jmb_x1_clock / 2); - m_opm2->add_route(ALL_OUTPUTS, "^^lspeaker", 0.25); - m_opm2->add_route(ALL_OUTPUTS, "^^rspeaker", 0.25); + m_opm2->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 0); + m_opm2->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 1); YM2149(config, m_ssg, jmb_x1_clock / 4); // TODO: adds a non-negligible DC offset, likely needs high pass filter - m_ssg->add_route(ALL_OUTPUTS, "^^lspeaker", 0.20); - m_ssg->add_route(ALL_OUTPUTS, "^^rspeaker", 0.20); + m_ssg->add_route(ALL_OUTPUTS, "^^speaker", 0.20, 0); + m_ssg->add_route(ALL_OUTPUTS, "^^speaker", 0.20, 1); } diff --git a/src/devices/bus/pc8801/pc8801_23.cpp b/src/devices/bus/pc8801/pc8801_23.cpp index 507f4e49c7b..74cfdc9881d 100644 --- a/src/devices/bus/pc8801/pc8801_23.cpp +++ b/src/devices/bus/pc8801/pc8801_23.cpp @@ -50,10 +50,10 @@ void pc8801_23_device::device_add_mconfig(machine_config &config) // m_opna->port_a_read_callback().set(FUNC(pc8801_23_device::opn_porta_r)); // m_opna->port_b_read_callback().set_ioport("OPN_PB"); // TODO: per-channel mixing is unconfirmed - m_opna->add_route(0, "^^lspeaker", 0.25); - m_opna->add_route(0, "^^rspeaker", 0.25); - m_opna->add_route(1, "^^lspeaker", 0.75); - m_opna->add_route(2, "^^rspeaker", 0.75); + m_opna->add_route(0, "^^speaker", 0.25, 0); + m_opna->add_route(0, "^^speaker", 0.25, 1); + m_opna->add_route(1, "^^speaker", 0.75, 0); + m_opna->add_route(2, "^^speaker", 0.75, 1); } void pc8801_23_device::device_start() diff --git a/src/devices/bus/pc8801/pcg8100.cpp b/src/devices/bus/pc8801/pcg8100.cpp index c2bf07c7f73..f97c6a36d9f 100644 --- a/src/devices/bus/pc8801/pcg8100.cpp +++ b/src/devices/bus/pc8801/pcg8100.cpp @@ -46,8 +46,8 @@ void pcg8100_device::device_add_mconfig(machine_config &config) for (auto &dac1bit : m_dac1bit) { SPEAKER_SOUND(config, dac1bit); - dac1bit->add_route(ALL_OUTPUTS, "^^lspeaker", 0.25); - dac1bit->add_route(ALL_OUTPUTS, "^^rspeaker", 0.25); + dac1bit->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 0); + dac1bit->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 1); } } diff --git a/src/devices/bus/pci/sonicvibes.cpp b/src/devices/bus/pci/sonicvibes.cpp index 6b1f0398824..e17a6abe582 100644 --- a/src/devices/bus/pci/sonicvibes.cpp +++ b/src/devices/bus/pci/sonicvibes.cpp @@ -62,18 +62,17 @@ sonicvibes_device::sonicvibes_device(const machine_config &mconfig, const char * void sonicvibes_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: (barely visible) only 24'576 xtal on a Turtle Beach PCB, is it really 12-ish MHz? YMF262(config, m_opl3, XTAL(14'318'181)); - m_opl3->add_route(0, "lspeaker", 1.0); - m_opl3->add_route(1, "rspeaker", 1.0); - m_opl3->add_route(2, "lspeaker", 1.0); - m_opl3->add_route(3, "rspeaker", 1.0); + m_opl3->add_route(0, "speaker", 1.0, 0); + m_opl3->add_route(1, "speaker", 1.0, 1); + m_opl3->add_route(2, "speaker", 1.0, 0); + m_opl3->add_route(3, "speaker", 1.0, 1); -// DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC -// DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC +// DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5); // unknown DAC +// DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5); // unknown DAC PC_JOY(config, m_joy); diff --git a/src/devices/bus/pci/sw1000xg.cpp b/src/devices/bus/pci/sw1000xg.cpp index 99255915915..6b91069db92 100644 --- a/src/devices/bus/pci/sw1000xg.cpp +++ b/src/devices/bus/pci/sw1000xg.cpp @@ -83,12 +83,11 @@ void sw1000xg_device::device_add_mconfig(machine_config &config) H83002(config, m_maincpu, 16_MHz_XTAL); m_maincpu->set_addrmap(AS_PROGRAM, &sw1000xg_device::h8_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP30(config, m_swp30); m_swp30->set_addrmap(AS_DATA, &sw1000xg_device::swp30_map); - m_swp30->add_route(0, "lspeaker", 1.0); - m_swp30->add_route(1, "rspeaker", 1.0); + m_swp30->add_route(0, "speaker", 1.0, 0); + m_swp30->add_route(1, "speaker", 1.0, 1); } diff --git a/src/devices/bus/plg1x0/plg100-vl.cpp b/src/devices/bus/plg1x0/plg100-vl.cpp index ae6f326c2bd..ee8a5050c14 100644 --- a/src/devices/bus/plg1x0/plg100-vl.cpp +++ b/src/devices/bus/plg1x0/plg100-vl.cpp @@ -67,8 +67,8 @@ void plg100_vl_device::device_add_mconfig(machine_config &config) m_cpu->write_sci_tx<1>().set([this] (int state) { m_connector->do_midi_tx(state); }); DSPV(config, m_dspv, 22.5792_MHz_XTAL); - m_dspv->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_dspv->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_dspv->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_dspv->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); } ROM_START( plg100_vl ) diff --git a/src/devices/bus/plg1x0/plg1x0.cpp b/src/devices/bus/plg1x0/plg1x0.cpp index 6abd5100209..939b4265e5d 100644 --- a/src/devices/bus/plg1x0/plg1x0.cpp +++ b/src/devices/bus/plg1x0/plg1x0.cpp @@ -12,7 +12,7 @@ DEFINE_DEVICE_TYPE(PLG1X0_CONNECTOR, plg1x0_connector, "plg1x0_connector", "PLG1 plg1x0_connector::plg1x0_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, PLG1X0_CONNECTOR, tag, owner, clock), device_single_card_slot_interface<device_plg1x0_interface>(mconfig, *this), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_midi_tx(*this) { } diff --git a/src/devices/bus/rc2014/sound.cpp b/src/devices/bus/rc2014/sound.cpp index acdb36e5442..3dafc5a7fb8 100644 --- a/src/devices/bus/rc2014/sound.cpp +++ b/src/devices/bus/rc2014/sound.cpp @@ -158,14 +158,13 @@ void rc2014_ym2149_device::device_reset() void rc2014_ym2149_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2149(config, m_psg, 0); - m_psg->add_route(0, "rspeaker", 0.25); - m_psg->add_route(2, "rspeaker", 0.25); - m_psg->add_route(1, "lspeaker", 0.25); - m_psg->add_route(2, "lspeaker", 0.25); + m_psg->add_route(0, "speaker", 0.25, 1); + m_psg->add_route(2, "speaker", 0.25, 1); + m_psg->add_route(1, "speaker", 0.25, 0); + m_psg->add_route(2, "speaker", 0.25, 0); } //************************************************************************** @@ -190,14 +189,13 @@ rc2014_ay8190_device::rc2014_ay8190_device(const machine_config &mconfig, const void rc2014_ay8190_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AY8910(config, m_psg, 0); - m_psg->add_route(0, "rspeaker", 0.25); - m_psg->add_route(2, "rspeaker", 0.25); - m_psg->add_route(1, "lspeaker", 0.25); - m_psg->add_route(2, "lspeaker", 0.25); + m_psg->add_route(0, "speaker", 0.25, 1); + m_psg->add_route(2, "speaker", 0.25, 1); + m_psg->add_route(1, "speaker", 0.25, 0); + m_psg->add_route(2, "speaker", 0.25, 0); } } diff --git a/src/devices/bus/rs232/mboardd.cpp b/src/devices/bus/rs232/mboardd.cpp index 002f868c40a..1ec2bdc8c9b 100644 --- a/src/devices/bus/rs232/mboardd.cpp +++ b/src/devices/bus/rs232/mboardd.cpp @@ -78,12 +78,11 @@ void mockingboard_d_device::device_add_mconfig(machine_config &config) m_cpu->out_p1_cb().set(FUNC(mockingboard_d_device::p1_w)); m_cpu->out_ser_tx_cb().set(FUNC(mockingboard_d_device::ser_tx_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AY8913(config, m_ay1, 1022727); - m_ay1->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_ay1->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); AY8913(config, m_ay2, 1022727); - m_ay2->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_ay2->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); } const tiny_rom_entry *mockingboard_d_device::device_rom_region() const diff --git a/src/devices/bus/segaai/soundbox.cpp b/src/devices/bus/segaai/soundbox.cpp index 3496f1ac479..230275da343 100644 --- a/src/devices/bus/segaai/soundbox.cpp +++ b/src/devices/bus/segaai/soundbox.cpp @@ -142,12 +142,11 @@ void segaai_soundbox_device::device_add_mconfig(machine_config &config) m_tmp8255->out_pb_callback().set(FUNC(segaai_soundbox_device::tmp8255_portb_w)); m_tmp8255->out_pc_callback().set(FUNC(segaai_soundbox_device::tmp8255_portc_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, DERIVED_CLOCK(1,1)); // ~3.58MHz m_ym2151->irq_handler().set(FUNC(segaai_soundbox_device::ym2151_irq_w)); - m_ym2151->add_route(0, "lspeaker", 1.00); - m_ym2151->add_route(1, "rspeaker", 1.00); + m_ym2151->add_route(0, "speaker", 1.00, 0); + m_ym2151->add_route(1, "speaker", 1.00, 1); } ROM_START(soundbox) diff --git a/src/devices/bus/spectrum/neogs.cpp b/src/devices/bus/spectrum/neogs.cpp index 156c2e2895c..2848523a328 100644 --- a/src/devices/bus/spectrum/neogs.cpp +++ b/src/devices/bus/spectrum/neogs.cpp @@ -426,11 +426,10 @@ void neogs_device::device_add_mconfig(machine_config &config) m_sdcard->set_prefer_sdhc(); m_sdcard->spi_miso_callback().set([this](int state) { m_spi_data_in_latch <<= 1; m_spi_data_in_latch |= state; }); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.75); // TDA1543 - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.75); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 0); // TDA1543 + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } const tiny_rom_entry *neogs_device::device_rom_region() const diff --git a/src/devices/bus/st/replay.cpp b/src/devices/bus/st/replay.cpp new file mode 100644 index 00000000000..f7df23a2dcc --- /dev/null +++ b/src/devices/bus/st/replay.cpp @@ -0,0 +1,108 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// Microdeal ST Replay + +// A 8-bit mono DAC and a 8-bit mono ADC on a cartridge, with a vague +// lowpass filter. + +// A peculiarity of the ST cartridge port is that it's readonly. So +// writing to the DAC is done by reading at an appropriate address. + +#include "emu.h" +#include "replay.h" + +#include "sound/adc.h" +#include "sound/dac.h" +#include "speaker.h" + +namespace { + +class st_replay_device : public device_t, public device_stcart_interface +{ +public: + st_replay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + virtual ~st_replay_device(); + + virtual void map(address_space_installer &space) override; + +protected: + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; + +private: + required_device<zn449_device> m_adc; + required_device<zn429e_device> m_dac; + required_device<microphone_device> m_mic; + required_device<speaker_device> m_speaker; + + void cartmap(address_map &map) ATTR_COLD; + + u16 dac_w(offs_t data); + u8 adc_r(); +}; + +st_replay_device::st_replay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ST_REPLAY, tag, owner, clock), + device_stcart_interface(mconfig, *this), + m_adc(*this, "adc"), + m_dac(*this, "dac"), + m_mic(*this, "mic"), + m_speaker(*this, "speaker") +{ +} + +st_replay_device::~st_replay_device() +{ +} + +u16 st_replay_device::dac_w(offs_t data) +{ + m_dac->write(data); + return 0xffff; +} + +u8 st_replay_device::adc_r() +{ + double tm = machine().time().as_double(); + s8 level = 127 * sin(tm*440*2*M_PI); + return level + 0x80; +} + +void st_replay_device::map(address_space_installer &space) +{ + space.install_device(0xfa0000, 0xfbffff, *this, &st_replay_device::cartmap); +} + +void st_replay_device::cartmap(address_map &map) +{ + map(0x00000, 0x001ff).r(FUNC(st_replay_device::dac_w)).mirror(0xfe00); + map(0x10001, 0x10001).r(m_adc, FUNC(zn449_device::read)).mirror(0xfffe); +} + +void st_replay_device::device_add_mconfig(machine_config &config) +{ + MICROPHONE(config, m_mic, 1).front_center(); + m_mic->add_route(0, m_adc, 1.0, 0); + + ZN449(config, m_adc); + + // ZN429D the schematics say, not sure if any significant difference + ZN429E(config, m_dac); + m_dac->add_route(0, m_speaker, 1.0, 0); + + SPEAKER(config, m_speaker, 1).front_center(); +} + +void st_replay_device::device_start() +{ +} + +void st_replay_device::device_reset() +{ +} + +} // anonymous namespace + +DEFINE_DEVICE_TYPE_PRIVATE(ST_REPLAY, device_stcart_interface, st_replay_device, "st_replay", "Microdeal ST Replay") diff --git a/src/devices/bus/st/replay.h b/src/devices/bus/st/replay.h new file mode 100644 index 00000000000..b6e2c73a062 --- /dev/null +++ b/src/devices/bus/st/replay.h @@ -0,0 +1,15 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#ifndef MAME_BUS_ST_REPLAY_H +#define MAME_BUS_ST_REPLAY_H + +// Microdeal ST Replay + +#pragma once + +#include "stcart.h" + +DECLARE_DEVICE_TYPE(ST_REPLAY, device_stcart_interface) + +#endif // MAME_BUS_ST_REPLAY_H diff --git a/src/devices/bus/st/stcart.cpp b/src/devices/bus/st/stcart.cpp new file mode 100644 index 00000000000..0e53093bf92 --- /dev/null +++ b/src/devices/bus/st/stcart.cpp @@ -0,0 +1,40 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "stcart.h" + +#include "replay.h" + +DEFINE_DEVICE_TYPE(STCART_CONNECTOR, stcart_connector, "stcart_connector", "Atari ST cartridge connector") + +stcart_connector::stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, STCART_CONNECTOR, tag, owner, clock), + device_single_card_slot_interface<device_stcart_interface>(mconfig, *this) +{ +} + +void stcart_connector::device_start() +{ +} + +void stcart_connector::map(address_space_installer &space) +{ + auto card = get_card_device(); + if(card) + card->map(space); +} + +void stcart_intf(device_slot_interface &device) +{ + device.option_add("replay", ST_REPLAY); +} + +device_stcart_interface::device_stcart_interface(const machine_config &mconfig, device_t &device) : + device_interface(device, "stcart") +{ +} + +device_stcart_interface::~device_stcart_interface() +{ +} diff --git a/src/devices/bus/st/stcart.h b/src/devices/bus/st/stcart.h new file mode 100644 index 00000000000..49ccb78a2e6 --- /dev/null +++ b/src/devices/bus/st/stcart.h @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +// Atari ST cartridges + +#ifndef MAME_BUS_ST_STCART_H +#define MAME_BUS_ST_STCART_H + +#pragma once + +class device_stcart_interface; + +class stcart_connector: public device_t, public device_single_card_slot_interface<device_stcart_interface> +{ +public: + template <typename T> + stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt) + : stcart_connector(mconfig, tag, owner, (uint32_t)0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + + stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void map(address_space_installer &space); + +protected: + virtual void device_start() override ATTR_COLD; +}; + +class device_stcart_interface: public device_interface +{ +public: + device_stcart_interface(const machine_config &mconfig, device_t &device); + virtual ~device_stcart_interface(); + + virtual void map(address_space_installer &space) = 0; + +protected: + +}; + +DECLARE_DEVICE_TYPE(STCART_CONNECTOR, stcart_connector) + +void stcart_intf(device_slot_interface &device); + +#endif // MAME_BUS_ST_STCART_H diff --git a/src/devices/bus/waveblaster/db50xg.cpp b/src/devices/bus/waveblaster/db50xg.cpp index 6d3c0f067d5..c105227dce5 100644 --- a/src/devices/bus/waveblaster/db50xg.cpp +++ b/src/devices/bus/waveblaster/db50xg.cpp @@ -71,8 +71,8 @@ void db50xg_device::device_add_mconfig(machine_config &config) m_cpu->write_sci_tx<0>().set([this] (int state) { m_connector->do_midi_tx(state); }); SWP00(config, m_swp00); - m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); } ROM_START( db50xg ) diff --git a/src/devices/bus/waveblaster/db60xg.cpp b/src/devices/bus/waveblaster/db60xg.cpp index 4f8ede66612..c194d5d0e6e 100644 --- a/src/devices/bus/waveblaster/db60xg.cpp +++ b/src/devices/bus/waveblaster/db60xg.cpp @@ -69,8 +69,8 @@ void db60xg_device::device_add_mconfig(machine_config &config) m_cpu->write_sci_tx<0>().set([this] (int state) { m_connector->do_midi_tx(state); }); SWP00(config, m_swp00); - m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); } ROM_START( db60xg ) diff --git a/src/devices/bus/waveblaster/omniwave.cpp b/src/devices/bus/waveblaster/omniwave.cpp index 54d5731029f..a83399c28f9 100644 --- a/src/devices/bus/waveblaster/omniwave.cpp +++ b/src/devices/bus/waveblaster/omniwave.cpp @@ -47,8 +47,8 @@ void omniwave_device::midi_rx(int state) void omniwave_device::device_add_mconfig(machine_config &config) { KS0164(config, m_ks0164, 16.9344_MHz_XTAL); - m_ks0164->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_ks0164->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_ks0164->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_ks0164->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); m_ks0164->midi_tx().set([this] (int state) { m_connector->do_midi_tx(state); }); } diff --git a/src/devices/bus/waveblaster/waveblaster.cpp b/src/devices/bus/waveblaster/waveblaster.cpp index c280a2fd083..fc019ff62e1 100644 --- a/src/devices/bus/waveblaster/waveblaster.cpp +++ b/src/devices/bus/waveblaster/waveblaster.cpp @@ -15,7 +15,7 @@ DEFINE_DEVICE_TYPE(WAVEBLASTER_CONNECTOR, waveblaster_connector, "waveblaster_co waveblaster_connector::waveblaster_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, WAVEBLASTER_CONNECTOR, tag, owner, clock), device_single_card_slot_interface<device_waveblaster_interface>(mconfig, *this), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_midi_tx(*this) { } diff --git a/src/devices/bus/waveblaster/wg130.cpp b/src/devices/bus/waveblaster/wg130.cpp index 32aeae3c8a3..8c44347c2b7 100644 --- a/src/devices/bus/waveblaster/wg130.cpp +++ b/src/devices/bus/waveblaster/wg130.cpp @@ -77,8 +77,8 @@ void wg130_device::device_add_mconfig(machine_config &config) { GT913(config, m_gt913, 30_MHz_XTAL / 2); m_gt913->set_addrmap(AS_DATA, &wg130_device::map); - m_gt913->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_gt913->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_gt913->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_gt913->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); m_gt913->read_port1().set_constant(0xff); m_gt913->write_port1().set_nop(); m_gt913->read_port2().set_constant(0xff); diff --git a/src/devices/cpu/h6280/h6280.cpp b/src/devices/cpu/h6280/h6280.cpp index f725e6065a5..1261de78a78 100644 --- a/src/devices/cpu/h6280/h6280.cpp +++ b/src/devices/cpu/h6280/h6280.cpp @@ -169,7 +169,7 @@ DEFINE_DEVICE_TYPE(H6280, h6280_device, "h6280", "Hudson Soft HuC6280") h6280_device::h6280_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : cpu_device(mconfig, H6280, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_program_config("program", ENDIANNESS_LITTLE, 8, 21, 0, 16, 0, address_map_constructor(FUNC(h6280_device::internal_map), this)) , m_io_config("io", ENDIANNESS_LITTLE, 8, 2) , m_port_in_cb(*this, 0) @@ -232,8 +232,8 @@ const h6280_device::ophandler h6280_device::s_opcodetable[256] = void h6280_device::device_add_mconfig(machine_config &config) { C6280(config, m_psg, DERIVED_CLOCK(1,2)); - m_psg->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_psg->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_psg->add_route(0, *this, 1.0, 0); + m_psg->add_route(1, *this, 1.0, 1); } void h6280_device::device_start() diff --git a/src/devices/cpu/h8/gt913.cpp b/src/devices/cpu/h8/gt913.cpp index 8201ac9d66d..620f82173a4 100644 --- a/src/devices/cpu/h8/gt913.cpp +++ b/src/devices/cpu/h8/gt913.cpp @@ -28,7 +28,7 @@ DEFINE_DEVICE_TYPE(GT913, gt913_device, "gt913", "Casio GT913F") gt913_device::gt913_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : h8_device(mconfig, GT913, tag, owner, clock, address_map_constructor(FUNC(gt913_device::map), this)), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_rom(*this, DEVICE_SELF), m_data_config("data", ENDIANNESS_BIG, 16, 22, 0), m_write_ple(*this), @@ -102,8 +102,8 @@ void gt913_device::device_add_mconfig(machine_config &config) GT913_SOUND(config, m_sound, DERIVED_CLOCK(1, 1)); m_sound->set_device_rom_tag(m_rom); - m_sound->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_sound->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_sound->add_route(0, *this, 1.0, 0); + m_sound->add_route(1, *this, 1.0, 1); GT913_KBD_HLE(config, m_kbd, 0); m_kbd->irq_cb().set([this] (int val) { diff --git a/src/devices/cpu/h8/swx00.cpp b/src/devices/cpu/h8/swx00.cpp index 12ff74e9bbf..f626a8303ae 100644 --- a/src/devices/cpu/h8/swx00.cpp +++ b/src/devices/cpu/h8/swx00.cpp @@ -7,7 +7,7 @@ DEFINE_DEVICE_TYPE(SWX00, swx00_device, "swx00", "Yamaha SWX00") swx00_device::swx00_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, u8 mode) : h8s2000_device(mconfig, SWX00, tag, owner, clock, address_map_constructor(FUNC(swx00_device::map), this)), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_intc(*this, "intc"), m_adc(*this, "adc"), m_dma(*this, "dma"), @@ -316,8 +316,8 @@ void swx00_device::device_add_mconfig(machine_config &config) SWX00_SOUND(config, m_swx00); m_swx00->set_space(DEVICE_SELF, AS_S); - m_swx00->add_route(0, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 0); - m_swx00->add_route(1, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 1); + m_swx00->add_route(0, DEVICE_SELF, 1.0, 0); + m_swx00->add_route(1, DEVICE_SELF, 1.0, 1); } device_memory_interface::space_config_vector swx00_device::memory_space_config() const diff --git a/src/devices/cpu/m6502/gew12.cpp b/src/devices/cpu/m6502/gew12.cpp index 2459bb13517..4d77abc7771 100644 --- a/src/devices/cpu/m6502/gew12.cpp +++ b/src/devices/cpu/m6502/gew12.cpp @@ -20,7 +20,7 @@ DEFINE_DEVICE_TYPE(GEW12, gew12_device, "gew12", "Yamaha YMW728-F (GEW12)") gew12_device::gew12_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : m6502_mcu_device_base<w65c02_device>(mconfig, GEW12, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_in_cb(*this, 0xff), m_out_cb(*this) , m_rom(*this, DEVICE_SELF) , m_bank(*this, "bank%u", 0U) diff --git a/src/devices/cpu/m6502/gew7.cpp b/src/devices/cpu/m6502/gew7.cpp index 2594a2166ef..76e1378d9e8 100644 --- a/src/devices/cpu/m6502/gew7.cpp +++ b/src/devices/cpu/m6502/gew7.cpp @@ -20,7 +20,7 @@ DEFINE_DEVICE_TYPE(GEW7, gew7_device, "gew7", "Yamaha YMW270-F (GEW7)") gew7_device::gew7_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : m6502_mcu_device_base<w65c02_device>(mconfig, GEW7, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_in_cb(*this, 0xff), m_out_cb(*this) , m_rom(*this, DEVICE_SELF) , m_bank(*this, "bank%u", 0U) @@ -37,8 +37,8 @@ void gew7_device::device_add_mconfig(machine_config &config) { GEW7_PCM(config, m_pcm, DERIVED_CLOCK(1, 1)); m_pcm->set_device_rom_tag(m_rom); - m_pcm->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_pcm->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_pcm->add_route(0, *this, 1.0, 0); + m_pcm->add_route(1, *this, 1.0, 1); } void gew7_device::device_start() diff --git a/src/devices/cpu/m6502/rp2a03.cpp b/src/devices/cpu/m6502/rp2a03.cpp index 0d9153b42f7..4132e780d5a 100644 --- a/src/devices/cpu/m6502/rp2a03.cpp +++ b/src/devices/cpu/m6502/rp2a03.cpp @@ -45,7 +45,7 @@ rp2a03_core_device::rp2a03_core_device(const machine_config &mconfig, const char rp2a03_device::rp2a03_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : rp2a03_core_device(mconfig, type, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 1) + , device_mixer_interface(mconfig, *this) , m_apu(*this, "nesapu") { program_config.m_internal_map = address_map_constructor(FUNC(rp2a03_device::rp2a03_map), this); @@ -84,7 +84,7 @@ void rp2a03_device::device_add_mconfig(machine_config &config) APU_2A03(config, m_apu, DERIVED_CLOCK(1,1)); m_apu->irq().set(FUNC(rp2a03_device::apu_irq)); m_apu->mem_read().set(FUNC(rp2a03_device::apu_read_mem)); - m_apu->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + m_apu->add_route(ALL_OUTPUTS, *this, 1.0, 0); } void rp2a03g_device::device_add_mconfig(machine_config &config) @@ -92,7 +92,7 @@ void rp2a03g_device::device_add_mconfig(machine_config &config) NES_APU(config, m_apu, DERIVED_CLOCK(1,1)); m_apu->irq().set(FUNC(rp2a03g_device::apu_irq)); m_apu->mem_read().set(FUNC(rp2a03g_device::apu_read_mem)); - m_apu->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + m_apu->add_route(ALL_OUTPUTS, *this, 1.0, 0); } diff --git a/src/devices/cpu/m6502/st2205u.cpp b/src/devices/cpu/m6502/st2205u.cpp index 8e63a20fab4..cf7639b9aca 100644 --- a/src/devices/cpu/m6502/st2205u.cpp +++ b/src/devices/cpu/m6502/st2205u.cpp @@ -101,25 +101,19 @@ st2302u_device::st2302u_device(const machine_config &mconfig, const char *tag, d { } -void st2205u_base_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void st2205u_base_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - outputs[1].fill(0); - outputs[2].fill(0); - outputs[3].fill(0); - - int samples = outputs[0].samples(); + int samples = stream.samples(); int outpos = 0; while (samples-- != 0) { for (int channel = 0; channel < 4; channel++) { s16 adpcm_contribution = m_adpcm_level[channel]; - outputs[channel].add_int(outpos, adpcm_contribution * 0x10, 32768); + stream.add_int(channel, outpos, adpcm_contribution * 0x10, 32768); auto psg_contribution = std::sin((double)m_psg_freqcntr[channel]/4096.0f); - outputs[channel].add_int(outpos, psg_contribution * m_psg_amplitude[channel]*0x80,32768); + stream.add_int(channel, outpos, psg_contribution * m_psg_amplitude[channel]*0x80,32768); } outpos++; diff --git a/src/devices/cpu/m6502/st2205u.h b/src/devices/cpu/m6502/st2205u.h index 17cc7f18740..cad10f08b3b 100644 --- a/src/devices/cpu/m6502/st2205u.h +++ b/src/devices/cpu/m6502/st2205u.h @@ -64,7 +64,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual unsigned st2xxx_bt_divider(int n) const override; virtual u8 st2xxx_prs_mask() const override { return 0xc0; } diff --git a/src/devices/cpu/tms57002/tms57002.cpp b/src/devices/cpu/tms57002/tms57002.cpp index 593a74e3263..3485ba25695 100644 --- a/src/devices/cpu/tms57002/tms57002.cpp +++ b/src/devices/cpu/tms57002/tms57002.cpp @@ -920,21 +920,20 @@ void tms57002_device::execute_run() icount = 0; } -void tms57002_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms57002_device::sound_stream_update(sound_stream &stream) { - assert(inputs[0].samples() == 1); - assert(outputs[0].samples() == 1); - - stream_buffer::sample_t in_scale = 32767.0 * ((st0 & ST0_SIM) ? 256.0 : 1.0); - si[0] = s32(inputs[0].get(0) * in_scale) & 0xffffff; - si[1] = s32(inputs[1].get(0) * in_scale) & 0xffffff; - si[2] = s32(inputs[2].get(0) * in_scale) & 0xffffff; - si[3] = s32(inputs[3].get(0) * in_scale) & 0xffffff; - - outputs[0].put_int(0, s32(so[0] << 8) >> 1, 32768 * 32768); - outputs[1].put_int(0, s32(so[1] << 8) >> 1, 32768 * 32768); - outputs[2].put_int(0, s32(so[2] << 8) >> 1, 32768 * 32768); - outputs[3].put_int(0, s32(so[3] << 8) >> 1, 32768 * 32768); + assert(stream.samples() == 1); + + sound_stream::sample_t in_scale = 32768.0 * ((st0 & ST0_SIM) ? 256.0 : 1.0); + si[0] = s32(stream.get(0, 0) * in_scale) & 0xffffff; + si[1] = s32(stream.get(1, 0) * in_scale) & 0xffffff; + si[2] = s32(stream.get(2, 0) * in_scale) & 0xffffff; + si[3] = s32(stream.get(3, 0) * in_scale) & 0xffffff; + + stream.put(0, 0, s32(so[0] << 8) / 2147483648.0); + stream.put(1, 0, s32(so[1] << 8) / 2147483648.0); + stream.put(2, 0, s32(so[2] << 8) / 2147483648.0); + stream.put(3, 0, s32(so[3] << 8) / 2147483648.0); sync_w(1); } diff --git a/src/devices/cpu/tms57002/tms57002.h b/src/devices/cpu/tms57002/tms57002.h index 7a6dce18416..547afff6d08 100644 --- a/src/devices/cpu/tms57002/tms57002.h +++ b/src/devices/cpu/tms57002/tms57002.h @@ -36,7 +36,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual space_config_vector memory_space_config() const override; virtual u32 execute_min_cycles() const noexcept override; virtual u32 execute_max_cycles() const noexcept override; diff --git a/src/devices/cpu/upd177x/upd177x.cpp b/src/devices/cpu/upd177x/upd177x.cpp index b5cd302312f..f8e9590f873 100644 --- a/src/devices/cpu/upd177x/upd177x.cpp +++ b/src/devices/cpu/upd177x/upd177x.cpp @@ -782,13 +782,11 @@ void upd177x_cpu_device::execute_run() } -void upd177x_cpu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd177x_cpu_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - const int smpl = m_dac_sign ? -m_dac : m_dac; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put_int(sampindex, smpl, 256); + stream.put_int(0, sampindex, smpl, 256); } } diff --git a/src/devices/cpu/upd177x/upd177x.h b/src/devices/cpu/upd177x/upd177x.h index 70a186acc55..0dcb245a446 100644 --- a/src/devices/cpu/upd177x/upd177x.h +++ b/src/devices/cpu/upd177x/upd177x.h @@ -57,7 +57,7 @@ protected: virtual std::unique_ptr<util::disasm_interface> create_disassembler() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void program_map(address_map &map) ATTR_COLD; diff --git a/src/devices/imagedev/cassette.cpp b/src/devices/imagedev/cassette.cpp index 21cb7e8bd10..5c5d1ea560c 100644 --- a/src/devices/imagedev/cassette.cpp +++ b/src/devices/imagedev/cassette.cpp @@ -448,33 +448,29 @@ std::string cassette_image_device::call_display() // Cassette sound //------------------------------------------------- -void cassette_image_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cassette_image_device::sound_stream_update(sound_stream &stream) { cassette_state state = get_state() & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER); if (exists() && (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))) { + int samples = stream.samples(); cassette_image *cassette = get_image(); double time_index = get_position(); - double duration = ((double) outputs[0].samples()) / outputs[0].sample_rate(); + double duration = ((double) samples) / stream.sample_rate(); - if (m_samples.size() < outputs[0].samples()) - m_samples.resize(outputs[0].samples()); + if (m_samples.size() < samples) + m_samples.resize(samples); const cassette_image::Info info = cassette->get_info(); - for (int ch = 0; ch < outputs.size(); ch++) + for (int ch = 0; ch < stream.output_count(); ch++) { if (ch < info.channels) - cassette->get_samples(ch, time_index, duration, outputs[0].samples(), 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); + cassette->get_samples(ch, time_index, duration, samples, 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); else - cassette->get_samples(0, time_index, duration, outputs[0].samples(), 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); - for (int sampindex = 0; sampindex < outputs[ch].samples(); sampindex++) - outputs[ch].put_int(sampindex, m_samples[sampindex], 32768); + cassette->get_samples(0, time_index, duration, samples, 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); + for (int sampindex = 0; sampindex < samples; sampindex++) + stream.put_int(ch, sampindex, m_samples[sampindex], 32768); } } - else - { - for (int ch = 0; ch < outputs.size(); ch++) - outputs[ch].fill(0); - } } diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h index 60bd0357324..d73e248590e 100644 --- a/src/devices/imagedev/cassette.h +++ b/src/devices/imagedev/cassette.h @@ -103,7 +103,7 @@ public: void seek(double time, int origin); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; device_sound_interface& set_stereo() { m_stereo = true; return *this; } protected: diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 8dd70d5fd62..b6f3e2b69b5 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -1595,18 +1595,17 @@ void floppy_sound_device::step(int zone) // sound_stream_update - update the sound stream //------------------------------------------------- -void floppy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void floppy_sound_device::sound_stream_update(sound_stream &stream) { // We are using only one stream, unlike the parent class // Also, there is no need for interpolation, as we only expect // one sample rate of 44100 for all samples int16_t out; - auto &samplebuffer = outputs[0]; int m_idx = 0; int sampleend = 0; - for (int sampindex = 0; sampindex < samplebuffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { out = 0; @@ -1700,7 +1699,7 @@ void floppy_sound_device::sound_stream_update(sound_stream &stream, std::vector< } // Write to the stream buffer - samplebuffer.put_int(sampindex, out, 32768); + stream.put_int(0, sampindex, out, 32768); } } diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index 8e03f9438a7..2e7b0de3b50 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -413,7 +413,7 @@ protected: private: // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; sound_stream* m_sound; int m_step_base; diff --git a/src/devices/machine/acorn_vidc.cpp b/src/devices/machine/acorn_vidc.cpp index cd428e3fc01..daeb50d8ea3 100644 --- a/src/devices/machine/acorn_vidc.cpp +++ b/src/devices/machine/acorn_vidc.cpp @@ -65,8 +65,7 @@ acorn_vidc10_device::acorn_vidc10_device(const machine_config &mconfig, device_t , m_sound_mode(false) , m_dac(*this, "dac%u", 0) , m_dac_type(dac_type) - , m_lspeaker(*this, "lspeaker") - , m_rspeaker(*this, "rspeaker") + , m_speaker(*this, "speaker") , m_vblank_cb(*this) , m_sound_drq_cb(*this) , m_pixel_clock(0) @@ -110,12 +109,11 @@ device_memory_interface::space_config_vector acorn_vidc10_device::memory_space_c void acorn_vidc10_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker).front(); for (int i = 0; i < m_sound_max_channels; i++) { // custom DAC - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[i], 0).add_route(0, m_lspeaker, m_sound_input_gain).add_route(0, m_rspeaker, m_sound_input_gain); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[i], 0).add_route(0, m_speaker, m_sound_input_gain, 0).add_route(0, m_speaker, m_sound_input_gain, 1); } } @@ -405,9 +403,8 @@ inline void acorn_vidc10_device::refresh_stereo_image(u8 channel) const float left_gain[8] = { 1.0f, 2.0f, 1.66f, 1.34f, 1.0f, 0.66f, 0.34f, 0.0f }; const float right_gain[8] = { 1.0f, 0.0f, 0.34f, 0.66f, 1.0f, 1.34f, 1.66f, 2.0f }; - m_lspeaker->set_input_gain(channel, left_gain[m_stereo_image[channel]] * m_sound_input_gain); - m_rspeaker->set_input_gain(channel, right_gain[m_stereo_image[channel]] * m_sound_input_gain); - //printf("%d %f %f\n",channel,m_lspeaker->input(channel).gain(),m_rspeaker->input(channel).gain()); + m_speaker->set_input_gain(0, left_gain[m_stereo_image[channel]] * m_sound_input_gain); + m_speaker->set_input_gain(1, right_gain[m_stereo_image[channel]] * m_sound_input_gain); } @@ -582,14 +579,14 @@ void arm_vidc20_device::device_add_mconfig(machine_config &config) for (int i = 0; i < m_sound_max_channels; i++) { m_dac[i]->reset_routes(); - m_dac[i]->add_route(0, m_lspeaker, 0.0); - m_dac[i]->add_route(0, m_rspeaker, 0.0); + m_dac[i]->add_route(0, m_speaker, 0.0, 0); + m_dac[i]->add_route(0, m_speaker, 0.0, 1); } // For simplicity we separate DACs for 32-bit mode // TODO: how stereo image copes with this if at all? - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[0], 0).add_route(ALL_OUTPUTS, m_lspeaker, 0.25); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[1], 0).add_route(ALL_OUTPUTS, m_rspeaker, 0.25); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[0], 0).add_route(ALL_OUTPUTS, m_speaker, 0.25, 0); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[1], 0).add_route(ALL_OUTPUTS, m_speaker, 0.25, 1); } void arm_vidc20_device::device_config_complete() diff --git a/src/devices/machine/acorn_vidc.h b/src/devices/machine/acorn_vidc.h index 23f8564f94a..49b5c0dca54 100644 --- a/src/devices/machine/acorn_vidc.h +++ b/src/devices/machine/acorn_vidc.h @@ -90,8 +90,7 @@ protected: required_device_array<dac_16bit_r2r_twos_complement_device, 8> m_dac; int m_dac_type; - required_device<speaker_device> m_lspeaker; - required_device<speaker_device> m_rspeaker; + required_device<speaker_device> m_speaker; virtual void refresh_stereo_image(u8 channel); const int m_sound_max_channels = 8; diff --git a/src/devices/machine/cr511b.cpp b/src/devices/machine/cr511b.cpp index dc3fa967ba5..7f52ced1e20 100644 --- a/src/devices/machine/cr511b.cpp +++ b/src/devices/machine/cr511b.cpp @@ -45,7 +45,7 @@ DEFINE_DEVICE_TYPE(CR511B, cr511b_device, "cr511b", "CR-511-B CD-ROM drive") cr511b_device::cr511b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : cdrom_image_device(mconfig, CR511B, tag, owner, clock), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_cdda(*this, "cdda"), m_stch_cb(*this), m_sten_cb(*this), @@ -72,8 +72,8 @@ cr511b_device::cr511b_device(const machine_config &mconfig, const char *tag, dev void cr511b_device::device_add_mconfig(machine_config &config) { CDDA(config, m_cdda); - m_cdda->add_route(0, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 0); - m_cdda->add_route(1, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 1); + m_cdda->add_route(0, DEVICE_SELF, 1.0, 0); + m_cdda->add_route(1, DEVICE_SELF, 1.0, 1); m_cdda->set_cdrom_tag(*this); m_cdda->audio_end_cb().set(FUNC(cr511b_device::audio_end_cb)); } diff --git a/src/devices/machine/generalplus_gpl16250soc.cpp b/src/devices/machine/generalplus_gpl16250soc.cpp index dc4505ce9ff..ec915385d99 100644 --- a/src/devices/machine/generalplus_gpl16250soc.cpp +++ b/src/devices/machine/generalplus_gpl16250soc.cpp @@ -27,7 +27,7 @@ DEFINE_DEVICE_TYPE(GCM394, sunplus_gcm394_device, "gcm394", "GeneralPlus GPL1625 sunplus_gcm394_base_device::sunplus_gcm394_base_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock, address_map_constructor internal) : unsp_20_device(mconfig, type, tag, owner, clock, internal), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_screen(*this, finder_base::DUMMY_TAG), m_spg_video(*this, "spgvideo"), m_spg_audio(*this, "spgaudio"), @@ -1845,8 +1845,8 @@ void sunplus_gcm394_base_device::device_add_mconfig(machine_config &config) m_spg_audio->write_irq_callback().set(FUNC(sunplus_gcm394_base_device::audioirq_w)); m_spg_audio->space_read_callback().set(FUNC(sunplus_gcm394_base_device::read_space)); - m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_spg_audio->add_route(0, *this, 1.0, 0); + m_spg_audio->add_route(1, *this, 1.0, 1); GCM394_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); m_spg_video->write_video_irq_callback().set(FUNC(sunplus_gcm394_base_device::videoirq_w)); diff --git a/src/devices/machine/gt913_snd.cpp b/src/devices/machine/gt913_snd.cpp index 803e6443278..1965b798432 100644 --- a/src/devices/machine/gt913_snd.cpp +++ b/src/devices/machine/gt913_snd.cpp @@ -102,9 +102,9 @@ void gt913_sound_device::device_reset() std::memset(m_voices, 0, sizeof(m_voices)); } -void gt913_sound_device::sound_stream_update(sound_stream& stream, std::vector<read_stream_view> const& inputs, std::vector<write_stream_view>& outputs) +void gt913_sound_device::sound_stream_update(sound_stream& stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s64 left = 0, right = 0; @@ -115,8 +115,8 @@ void gt913_sound_device::sound_stream_update(sound_stream& stream, std::vector<r mix_sample(voice, left, right); } - outputs[0].put_int_clamp(i, (left * m_gain) >> 27, 32678); - outputs[1].put_int_clamp(i, (right * m_gain) >> 27, 32768); + stream.put_int_clamp(0, i, (left * m_gain) >> 27, 32678); + stream.put_int_clamp(1, i, (right * m_gain) >> 27, 32768); } } diff --git a/src/devices/machine/gt913_snd.h b/src/devices/machine/gt913_snd.h index 790eca81196..ba05cabe470 100644 --- a/src/devices/machine/gt913_snd.h +++ b/src/devices/machine/gt913_snd.h @@ -38,7 +38,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/machine/k054321.cpp b/src/devices/machine/k054321.cpp index 6a362f655b2..d53fd8d346f 100644 --- a/src/devices/machine/k054321.cpp +++ b/src/devices/machine/k054321.cpp @@ -59,8 +59,7 @@ void k054321_device::sound_map(address_map &map) k054321_device::k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, K054321, tag, owner, clock), - m_left(*this, finder_base::DUMMY_TAG), - m_right(*this, finder_base::DUMMY_TAG), + m_speaker(*this, finder_base::DUMMY_TAG), m_soundlatch(*this, "soundlatch%u", 0) { } @@ -68,17 +67,12 @@ k054321_device::k054321_device(const machine_config &mconfig, const char *tag, d void k054321_device::device_start() { // make sure that device_sound_interface is configured - if (!m_left->inputs() && !m_right->inputs()) + if (!m_speaker->inputs()) throw device_missing_dependencies(); // remember initial input gains - m_left_gains = std::make_unique<float[]>(m_left->inputs()); - m_right_gains = std::make_unique<float[]>(m_right->inputs()); - - for (int i = 0; i < m_left->inputs(); i++) - m_left_gains[i] = m_left->input_gain(i); - for (int i = 0; i < m_right->inputs(); i++) - m_right_gains[i] = m_right->input_gain(i); + m_left_gain = m_speaker->input_gain(0); + m_right_gain = m_speaker->input_gain(1); // register for savestates save_item(NAME(m_volume)); @@ -133,8 +127,6 @@ void k054321_device::propagate_volume() { double vol = pow(2, (m_volume - 40)/10.0); - for (int i = 0; i < m_left->inputs(); i++) - m_left->set_input_gain(i, m_active & 2 ? vol * m_left_gains[i] : 0.0); - for (int i = 0; i < m_right->inputs(); i++) - m_right->set_input_gain(i, m_active & 1 ? vol * m_right_gains[i] : 0.0); + m_speaker->set_input_gain(0, m_active & 2 ? vol * m_left_gain : 0.0); + m_speaker->set_input_gain(1, m_active & 1 ? vol * m_right_gain : 0.0); } diff --git a/src/devices/machine/k054321.h b/src/devices/machine/k054321.h index 9fba2f93c18..3d4739bf1a1 100644 --- a/src/devices/machine/k054321.h +++ b/src/devices/machine/k054321.h @@ -11,16 +11,15 @@ class k054321_device : public device_t { public: - template<typename T, typename U> - k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&left, U &&right) : - k054321_device(mconfig, tag, owner, 0) + k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + template<typename T> + k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&speaker) : + k054321_device(mconfig, tag, owner) { - m_left.set_tag(std::forward<T>(left)); - m_right.set_tag(std::forward<U>(right)); + m_speaker.set_tag(std::forward<T>(speaker)); } - k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void main_map(address_map &map) ATTR_COLD; void sound_map(address_map &map) ATTR_COLD; @@ -30,12 +29,10 @@ protected: virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; private: - required_device<device_sound_interface> m_left; - required_device<device_sound_interface> m_right; + required_device<device_sound_interface> m_speaker; required_device_array<generic_latch_8_device, 3> m_soundlatch; - std::unique_ptr<float[]> m_left_gains; - std::unique_ptr<float[]> m_right_gains; + float m_left_gain, m_right_gain; u8 m_volume; u8 m_active; diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp index e1033518cb5..dc9fd2f5064 100644 --- a/src/devices/machine/laserdsc.cpp +++ b/src/devices/machine/laserdsc.cpp @@ -392,7 +392,7 @@ TIMER_CALLBACK_MEMBER(laserdisc_device::fetch_vbi_data) // laserdiscs //------------------------------------------------- -void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void laserdisc_device::sound_stream_update(sound_stream &stream) { // compute AND values based on the squelch int16_t leftand = (m_audiosquelch & 1) ? 0x0000 : 0xffff; @@ -403,17 +403,7 @@ void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<rea if (samples_avail < 0) samples_avail += m_audiobufsize; - // if no attached ld, just clear the buffers - auto &dst0 = outputs[0]; - auto &dst1 = outputs[1]; - if (samples_avail < outputs[0].samples()) - { - dst0.fill(0); - dst1.fill(0); - } - - // otherwise, stream from our buffer - else + if (samples_avail >= stream.samples()) { int16_t *buffer0 = &m_audiobuffer[0][0]; int16_t *buffer1 = &m_audiobuffer[1][0]; @@ -421,10 +411,10 @@ void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<rea // copy samples, clearing behind us as we go int sampindex; - for (sampindex = 0; sampout != m_audiobufin && sampindex < outputs[0].samples(); sampindex++) + for (sampindex = 0; sampout != m_audiobufin && sampindex < stream.samples(); sampindex++) { - dst0.put_int(sampindex, buffer0[sampout] & leftand, 32768); - dst1.put_int(sampindex, buffer1[sampout] & rightand, 32768); + stream.put_int(0, sampindex, buffer0[sampout] & leftand, 32768); + stream.put_int(1, sampindex, buffer1[sampout] & rightand, 32768); buffer0[sampout] = 0; buffer1[sampout] = 0; sampout++; @@ -434,16 +424,16 @@ void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<rea m_audiobufout = sampout; // clear out the rest of the buffer - if (sampindex < outputs[0].samples()) + if (sampindex < stream.samples()) { sampout = (m_audiobufout == 0) ? m_audiobufsize - 1 : m_audiobufout - 1; s32 fill0 = buffer0[sampout] & leftand; s32 fill1 = buffer1[sampout] & rightand; - for ( ; sampindex < outputs[0].samples(); sampindex++) + for ( ; sampindex < stream.samples(); sampindex++) { - dst0.put_int(sampindex, fill0, 32768); - dst1.put_int(sampindex, fill1, 32768); + stream.put_int(0, sampindex, fill0, 32768); + stream.put_int(1, sampindex, fill1, 32768); } } } diff --git a/src/devices/machine/laserdsc.h b/src/devices/machine/laserdsc.h index 04e980ae64e..f84cd47a06a 100644 --- a/src/devices/machine/laserdsc.h +++ b/src/devices/machine/laserdsc.h @@ -213,7 +213,7 @@ protected: virtual void device_validity_check(validity_checker &valid) const override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual TIMER_CALLBACK_MEMBER(fetch_vbi_data); diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index bba035194f3..c9d91704cce 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -813,16 +813,16 @@ void netlist_mame_stream_output_device::device_reset() LOGDEVCALLS("reset %s\n", name()); } -void netlist_mame_stream_output_device::sound_update_fill(write_stream_view &target) +void netlist_mame_stream_output_device::sound_update_fill(sound_stream &stream, int output) { - if (target.samples() < m_buffer.size()) - osd_printf_warning("sound %s: samples %d less bufsize %d\n", name(), target.samples(), m_buffer.size()); + if (stream.samples() < m_buffer.size()) + osd_printf_warning("sound %s: samples %d less bufsize %d\n", name(), stream.samples(), m_buffer.size()); int sampindex; for (sampindex = 0; sampindex < m_buffer.size(); sampindex++) - target.put(sampindex, m_buffer[sampindex]); - if (sampindex < target.samples()) - target.fill(m_cur, sampindex); + stream.put(output, sampindex, m_buffer[sampindex]); + if (sampindex < stream.samples()) + stream.fill(output, m_cur, sampindex); } @@ -860,7 +860,7 @@ void netlist_mame_stream_output_device::process(netlist::netlist_time_ext tim, n // throw emu_fatalerror("sound %s: pos %d exceeded bufsize %d\n", name().c_str(), pos, m_bufsize); while (m_buffer.size() < pos ) { - m_buffer.push_back(static_cast<stream_buffer::sample_t>(m_cur)); + m_buffer.push_back(static_cast<sound_stream::sample_t>(m_cur)); } m_cur = val; @@ -1396,7 +1396,7 @@ void netlist_mame_sound_device::device_start() m_inbuffer.resize(m_in.size()); /* initialize the stream(s) */ - m_stream = stream_alloc(m_in.size(), m_out.size(), m_sound_clock, STREAM_DISABLE_INPUT_RESAMPLING); + m_stream = stream_alloc(m_in.size(), m_out.size(), m_sound_clock); LOGDEVCALLS("sound device_start exit\n"); } @@ -1439,23 +1439,23 @@ void netlist_mame_sound_device::update_to_current_time() LOGTIMING("%s : %f us before machine time\n", this->name(), (cur - mtime).as_double() * 1000000.0); } -void netlist_mame_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void netlist_mame_sound_device::sound_stream_update(sound_stream &stream) { for (auto &e : m_in) { - auto clock_period = inputs[e.first].sample_period(); + auto clock_period = stream.sample_period(); auto sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(clock_period).as_raw())); - m_inbuffer[e.first] = netlist_mame_sound_input_buffer(inputs[e.first]); - e.second->buffer_reset(sample_time, m_inbuffer[e.first].samples(), &m_inbuffer[e.first]); + m_inbuffer[e.first] = netlist_mame_sound_input_buffer(stream, e.first); + e.second->buffer_reset(sample_time, stream.samples(), &m_inbuffer[e.first]); } - int samples = outputs[0].samples(); + int samples = stream.samples(); LOGDEBUG("samples %d\n", samples); // end_time() is the time at the END of the last sample we're generating // however, the sample value is the value at the START of that last sample, // so subtract one sample period so that we only process up to the minimum - auto nl_target_time = nltime_from_attotime(outputs[0].end_time() - outputs[0].sample_period()); + auto nl_target_time = nltime_from_attotime(stream.end_time() - stream.sample_period()); auto nltime(netlist().exec().time()); if (nltime < nl_target_time) @@ -1465,7 +1465,7 @@ void netlist_mame_sound_device::sound_stream_update(sound_stream &stream, std::v for (auto &e : m_out) { - e.second->sound_update_fill(outputs[e.first]); + e.second->sound_update_fill(stream, e.first); e.second->buffer_reset(nl_target_time); } diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index 51f5bdeb09f..67b6b7d143c 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -249,19 +249,20 @@ private: // ---------------------------------------------------------------------------------------- // netlist_mame_sound_input_buffer // -// This is a wrapper device to provide operator[] on read_stream_view. +// This is a wrapper device to provide operator[] on an input stream. // ---------------------------------------------------------------------------------------- -class netlist_mame_sound_input_buffer : public read_stream_view +class netlist_mame_sound_input_buffer { public: - netlist_mame_sound_input_buffer() : - read_stream_view() { } + sound_stream *m_stream = nullptr; + int m_stream_input = 0; - netlist_mame_sound_input_buffer(read_stream_view const &src) : - read_stream_view(src) { } + netlist_mame_sound_input_buffer() {} - stream_buffer::sample_t operator[](std::size_t index) { return get(index); } + netlist_mame_sound_input_buffer(sound_stream &stream, int input) : m_stream(&stream), m_stream_input(input) { } + + sound_stream::sample_t operator[](std::size_t index) { return m_stream->get(m_stream_input, index); } }; // ---------------------------------------------------------------------------------------- @@ -302,7 +303,7 @@ protected: // device_t overrides virtual void device_start() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void device_validity_check(validity_checker &valid) const override; //virtual void device_reset() override ATTR_COLD; @@ -634,7 +635,7 @@ public: m_buffer.clear(); } - void sound_update_fill(write_stream_view &target); + void sound_update_fill(sound_stream &stream, int output); void set_sample_time(netlist::netlist_time t) { m_sample_time = t; } @@ -649,7 +650,7 @@ private: uint32_t m_channel; const char * m_out_name; - std::vector<stream_buffer::sample_t> m_buffer; + std::vector<sound_stream::sample_t> m_buffer; double m_cur; netlist::netlist_time m_sample_time; diff --git a/src/devices/machine/pxa255.cpp b/src/devices/machine/pxa255.cpp index f11043af4e0..2c06dd618a7 100644 --- a/src/devices/machine/pxa255.cpp +++ b/src/devices/machine/pxa255.cpp @@ -265,11 +265,10 @@ void pxa255_periphs_device::device_add_mconfig(machine_config &config) PALETTE(config, m_palette).set_entries(256); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "lspeaker", 1.0); - DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } /* diff --git a/src/devices/machine/s2636.cpp b/src/devices/machine/s2636.cpp index 10a5a2e2be8..d2576b07f1f 100644 --- a/src/devices/machine/s2636.cpp +++ b/src/devices/machine/s2636.cpp @@ -441,10 +441,9 @@ void s2636_device::write_intack(int state) // sound_stream_update - generate audio output //------------------------------------------------- -void s2636_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void s2636_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { if (!m_sample_cnt) { @@ -460,7 +459,7 @@ void s2636_device::sound_stream_update(sound_stream &stream, std::vector<read_st } } - buffer.put(sampindex, m_sound_lvl ? 1.0 : 0.0); + stream.put(0, sampindex, m_sound_lvl ? 1.0 : 0.0); m_sample_cnt--; } } diff --git a/src/devices/machine/s2636.h b/src/devices/machine/s2636.h index 25c3d89f761..4be53bc73b1 100644 --- a/src/devices/machine/s2636.h +++ b/src/devices/machine/s2636.h @@ -60,7 +60,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum diff --git a/src/devices/machine/spg110.cpp b/src/devices/machine/spg110.cpp index 6afa6e8a4d3..1d3ac8260a0 100644 --- a/src/devices/machine/spg110.cpp +++ b/src/devices/machine/spg110.cpp @@ -18,7 +18,7 @@ DEFINE_DEVICE_TYPE(SPG110, spg110_device, "spg110", "SPG110 System-on-a-Chip") spg110_device::spg110_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal) : unsp_device(mconfig, type, tag, owner, clock, internal), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_screen(*this, finder_base::DUMMY_TAG), m_spg_io(*this, "spg_io"), m_spg_video(*this, "spg_video"), @@ -132,8 +132,8 @@ void spg110_device::device_add_mconfig(machine_config &config) m_spg_audio->write_irq_callback().set(FUNC(spg110_device::audioirq_w)); m_spg_audio->space_read_callback().set(FUNC(spg110_device::space_r)); - m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_spg_audio->add_route(0, *this, 1.0, 0); + m_spg_audio->add_route(1, *this, 1.0, 1); } void spg110_device::internal_map(address_map &map) diff --git a/src/devices/machine/spg2xx.cpp b/src/devices/machine/spg2xx.cpp index 09e0e0c6f39..cf5988f995f 100644 --- a/src/devices/machine/spg2xx.cpp +++ b/src/devices/machine/spg2xx.cpp @@ -21,7 +21,7 @@ DEFINE_DEVICE_TYPE(SPG28X, spg28x_device, "spg28x", "SPG280-series Syste spg2xx_device::spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint16_t sprite_limit, address_map_constructor internal) : unsp_device(mconfig, type, tag, owner, clock, internal), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_spg_audio(*this, "spgaudio"), m_spg_io(*this, "spgio"), m_spg_sysdma(*this, "spgsysdma"), @@ -193,8 +193,8 @@ void spg24x_device::device_add_mconfig(machine_config &config) m_spg_audio->channel_irq_callback().set(FUNC(spg24x_device::audiochirq_w)); m_spg_audio->space_read_callback().set(FUNC(spg24x_device::space_r)); - m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_spg_audio->add_route(0, *this, 1.0, 0); + m_spg_audio->add_route(1, *this, 1.0, 1); SPG24X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); diff --git a/src/devices/machine/spg2xx_audio.cpp b/src/devices/machine/spg2xx_audio.cpp index c81aee592a6..05fea0b4724 100644 --- a/src/devices/machine/spg2xx_audio.cpp +++ b/src/devices/machine/spg2xx_audio.cpp @@ -871,12 +871,9 @@ void spg2xx_audio_device::audio_w(offs_t offset, uint16_t data) } } -void spg2xx_audio_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void spg2xx_audio_device::sound_stream_update(sound_stream &stream) { - auto &out_l = outputs[0]; - auto &out_r = outputs[1]; - - for (int i = 0; i < out_l.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int32_t left_total = 0; int32_t right_total = 0; @@ -976,8 +973,8 @@ void spg2xx_audio_device::sound_stream_update(sound_stream &stream, std::vector< int32_t left_final = (int16_t)((left_total * (int16_t)m_audio_ctrl_regs[AUDIO_MAIN_VOLUME]) >> 7); int32_t right_final = (int16_t)((right_total * (int16_t)m_audio_ctrl_regs[AUDIO_MAIN_VOLUME]) >> 7); - out_l.put_int(i, int16_t(left_final), 32768); - out_r.put_int(i, int16_t(right_final), 32768); + stream.put_int(0, i, int16_t(left_final), 32768); + stream.put_int(1, i, int16_t(right_final), 32768); } } diff --git a/src/devices/machine/spg2xx_audio.h b/src/devices/machine/spg2xx_audio.h index 4834d9b965d..955ebf45975 100644 --- a/src/devices/machine/spg2xx_audio.h +++ b/src/devices/machine/spg2xx_audio.h @@ -33,7 +33,7 @@ public: protected: // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(irq_tick); TIMER_CALLBACK_MEMBER(audio_beat_tick); diff --git a/src/devices/machine/vrender0.cpp b/src/devices/machine/vrender0.cpp index 81ffdea1af0..2fe339a083a 100644 --- a/src/devices/machine/vrender0.cpp +++ b/src/devices/machine/vrender0.cpp @@ -42,8 +42,7 @@ vrender0soc_device::vrender0soc_device(const machine_config &mconfig, const char m_palette(*this, "palette"), m_vr0vid(*this, "vr0vid"), m_vr0snd(*this, "vr0snd"), - m_lspeaker(*this, "lspeaker"), - m_rspeaker(*this, "rspeaker"), + m_speaker(*this, "speaker"), m_uart(*this, "uart%u", 0), m_crtcregs(*this, "crtcregs"), write_tx(*this) @@ -135,15 +134,14 @@ void vrender0soc_device::device_add_mconfig(machine_config &config) PALETTE(config, m_palette, palette_device::RGB_565); - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker).front(); SOUND_VRENDER0(config, m_vr0snd, DERIVED_CLOCK(1,1)); // Correct? m_vr0snd->set_addrmap(vr0sound_device::AS_TEXTURE, &vrender0soc_device::texture_map); m_vr0snd->set_addrmap(vr0sound_device::AS_FRAME, &vrender0soc_device::frame_map); m_vr0snd->irq_callback().set(FUNC(vrender0soc_device::soundirq_cb)); - m_vr0snd->add_route(0, m_lspeaker, 1.0); - m_vr0snd->add_route(1, m_rspeaker, 1.0); + m_vr0snd->add_route(0, m_speaker, 1.0, 0); + m_vr0snd->add_route(1, m_speaker, 1.0, 1); } diff --git a/src/devices/machine/vrender0.h b/src/devices/machine/vrender0.h index 604966f2547..ca418101959 100644 --- a/src/devices/machine/vrender0.h +++ b/src/devices/machine/vrender0.h @@ -110,8 +110,7 @@ private: required_device <palette_device> m_palette; required_device <vr0video_device> m_vr0vid; required_device <vr0sound_device> m_vr0snd; - required_device <speaker_device> m_lspeaker; - required_device <speaker_device> m_rspeaker; + required_device <speaker_device> m_speaker; required_device_array <vr0uart_device, 2> m_uart; required_shared_ptr <uint32_t> m_crtcregs; std::unique_ptr<uint16_t []> m_textureram; diff --git a/src/devices/sound/ad1848.cpp b/src/devices/sound/ad1848.cpp index ac37b4cd05f..b9395d23360 100644 --- a/src/devices/sound/ad1848.cpp +++ b/src/devices/sound/ad1848.cpp @@ -23,10 +23,9 @@ ad1848_device::ad1848_device(const machine_config &mconfig, const char *tag, dev void ad1848_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } diff --git a/src/devices/sound/adc.cpp b/src/devices/sound/adc.cpp new file mode 100644 index 00000000000..3f2ee0b3175 --- /dev/null +++ b/src/devices/sound/adc.cpp @@ -0,0 +1,66 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// ADCs, unsigned or signed two-complement + +#include "emu.h" +#include "adc.h" + + +zn449_device::zn449_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ZN449, tag, owner, clock), + device_sound_interface(mconfig, *this), + m_stream(nullptr), + m_current_value(0) +{ +} + +u8 zn449_device::read() +{ + m_stream->update(); + return m_current_value; +} + +void zn449_device::device_start() +{ + save_item(NAME(m_current_value)); + m_stream = stream_alloc(1, 0, SAMPLE_RATE_INPUT_ADAPTIVE); +} + +void zn449_device::sound_stream_update(sound_stream &stream) +{ + sound_stream::sample_t last_sample = stream.get(0, stream.samples()-1); + m_current_value = 128 * last_sample + 128; +} + +DEFINE_DEVICE_TYPE(ZN449, zn449_device, "zn449", "ZN449 ADC") + + + +adc10_device::adc10_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ADC10, tag, owner, clock), + device_sound_interface(mconfig, *this), + m_stream(nullptr), + m_current_value(0) +{ +} + +u16 adc10_device::read() +{ + m_stream->update(); + return m_current_value; +} + +void adc10_device::device_start() +{ + save_item(NAME(m_current_value)); + m_stream = stream_alloc(1, 0, SAMPLE_RATE_INPUT_ADAPTIVE); +} + +void adc10_device::sound_stream_update(sound_stream &stream) +{ + sound_stream::sample_t last_sample = stream.get(0, stream.samples()-1); + m_current_value = std::clamp(int(512 * last_sample), -512, 511); +} + +DEFINE_DEVICE_TYPE(ADC10, adc10_device, "adc10", "10-bits signed ADC") diff --git a/src/devices/sound/adc.h b/src/devices/sound/adc.h new file mode 100644 index 00000000000..43903a930de --- /dev/null +++ b/src/devices/sound/adc.h @@ -0,0 +1,42 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// ADCs, unsigned or signed two-complement + +#ifndef MAME_SOUND_ADC_H +#define MAME_SOUND_ADC_H + +#pragma once + +class zn449_device : public device_t, public device_sound_interface +{ +public: + zn449_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + u8 read(); + +protected: + sound_stream *m_stream; + u8 m_current_value; + + virtual void device_start() override ATTR_COLD; + virtual void sound_stream_update(sound_stream &stream) override; +}; + +class adc10_device : public device_t, public device_sound_interface +{ +public: + adc10_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + u16 read(); + +protected: + sound_stream *m_stream; + u16 m_current_value; + + virtual void device_start() override ATTR_COLD; + virtual void sound_stream_update(sound_stream &stream) override; +}; + +DECLARE_DEVICE_TYPE(ZN449, zn449_device); +DECLARE_DEVICE_TYPE(ADC10, adc10_device); + +#endif // MAME_SOUND_ADC_H diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp index f7cf5875e93..1e3eaac954e 100644 --- a/src/devices/sound/aica.cpp +++ b/src/devices/sound/aica.cpp @@ -1234,11 +1234,11 @@ s32 aica_device::UpdateSlot(AICA_SLOT *slot) return sample; } -void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, write_stream_view &bufl, write_stream_view &bufr) +void aica_device::DoMasterSamples(sound_stream &stream) { int i; - for (int s = 0; s < bufl.samples(); ++s) + for (int s = 0; s < stream.samples(); ++s) { s32 smpl = 0, smpr = 0; @@ -1279,7 +1279,7 @@ void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, w { if (EFSDL(i + 16)) // 16,17 for EXTS { - m_DSP.EXTS[i] = s16(inputs[i].get(s) * 32767.0); + m_DSP.EXTS[i] = s16(stream.get(i, s) * 32767.0); u32 Enc = ((EFPAN(i + 16)) << 0x8) | ((EFSDL(i + 16)) << 0xd); smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT; smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT; @@ -1297,9 +1297,9 @@ void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, w smpr = clip16(smpr >> 3); } - bufl.put_int(s, smpl * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); + stream.put_int(0, s, smpl * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); // TODO: diverges with SCSP, also wut? - bufr.put_int(s, smpr * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); + stream.put_int(1, s, smpr * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); } } @@ -1385,9 +1385,9 @@ void aica_device::exec_dma() // sound_stream_update - handle a stream update //------------------------------------------------- -void aica_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void aica_device::sound_stream_update(sound_stream &stream) { - DoMasterSamples(inputs, outputs[0], outputs[1]); + DoMasterSamples(stream); } //------------------------------------------------- diff --git a/src/devices/sound/aica.h b/src/devices/sound/aica.h index 6e99346cd4f..afca6b17387 100644 --- a/src/devices/sound/aica.h +++ b/src/devices/sound/aica.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; @@ -126,7 +126,7 @@ private: u16 r16(u32 addr); [[maybe_unused]] void TimersAddTicks(int ticks); s32 UpdateSlot(AICA_SLOT *slot); - void DoMasterSamples(std::vector<read_stream_view> const &inputs, write_stream_view &bufl, write_stream_view &bufr); + void DoMasterSamples(sound_stream &stream); void exec_dma(); diff --git a/src/devices/sound/ap2010pcm.cpp b/src/devices/sound/ap2010pcm.cpp index 234264f52f9..7a7d9442be1 100644 --- a/src/devices/sound/ap2010pcm.cpp +++ b/src/devices/sound/ap2010pcm.cpp @@ -59,16 +59,13 @@ void ap2010pcm_device::device_start() save_item(NAME(m_fifo_fast_tail)); } -void ap2010pcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ap2010pcm_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - buffer.fill(0); - int16_t sample = 0; uint16_t sample_empty_count = 0; uint16_t fifo_size = m_fifo_size; uint16_t fifo_fast_size = m_fifo_fast_size; - for (size_t i = 0; i < buffer.samples(); i++) { + for (size_t i = 0; i < stream.samples(); i++) { if (m_fifo_fast_size) { sample = fifo_fast_pop(); } else if (m_fifo_size) { @@ -78,10 +75,10 @@ void ap2010pcm_device::sound_stream_update(sound_stream &stream, std::vector<rea sample_empty_count++; } - buffer.put_int(i, sample * m_volume, 32768); + stream.put_int(0, i, sample * m_volume, 32768); } if (fifo_size && sample_empty_count) { - LOG("pcm 0s = %d (had %d + fast %d, needed %d)\n", sample_empty_count, fifo_size, fifo_fast_size, buffer.samples()); + LOG("pcm 0s = %d (had %d + fast %d, needed %d)\n", sample_empty_count, fifo_size, fifo_fast_size, stream.samples()); } } diff --git a/src/devices/sound/ap2010pcm.h b/src/devices/sound/ap2010pcm.h index bea50bc4424..c5be63bbddd 100644 --- a/src/devices/sound/ap2010pcm.h +++ b/src/devices/sound/ap2010pcm.h @@ -30,7 +30,7 @@ protected: virtual void device_start() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // FIXME: Games check this against 0x1ff, but samples are lost with that limit diff --git a/src/devices/sound/asc.cpp b/src/devices/sound/asc.cpp index 231e6b2357f..347f9104649 100644 --- a/src/devices/sound/asc.cpp +++ b/src/devices/sound/asc.cpp @@ -123,20 +123,14 @@ TIMER_CALLBACK_MEMBER(asc_device::delayed_stream_update) // our sound stream //------------------------------------------------- -void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void asc_device::sound_stream_update(sound_stream &stream) { int i, ch; static uint32_t wtoffs[2] = { 0, 0x200 }; - auto &outL = outputs[0]; - auto &outR = outputs[1]; - switch (m_regs[R_MODE-0x800] & 3) { case 0: // chip off - outL.fill(0); - outR.fill(0); - // IIvx/IIvi bootrom indicates VASP updates this flag even when the chip is off if (m_chip_type == asc_type::VASP) { @@ -154,7 +148,7 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre case 1: // FIFO mode { - for (i = 0; i < outL.samples(); i++) + for (i = 0; i < stream.samples(); i++) { int8_t smpll, smplr; @@ -257,15 +251,15 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre break; } - outL.put_int(i, smpll, 32768 / 64); - outR.put_int(i, smplr, 32768 / 64); + stream.put_int(0, i, smpll, 32768 / 64); + stream.put_int(1, i, smplr, 32768 / 64); } break; } case 2: // wavetable mode { - for (i = 0; i < outL.samples(); i++) + for (i = 0; i < stream.samples(); i++) { int32_t mixL, mixR; int8_t smpl; @@ -291,8 +285,8 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre mixR += smpl*256; } - outL.put_int(i, mixL, 32768 * 4); - outR.put_int(i, mixR, 32768 * 4); + stream.put_int(0, i, mixL, 32768 * 4); + stream.put_int(1, i, mixR, 32768 * 4); } break; } diff --git a/src/devices/sound/asc.h b/src/devices/sound/asc.h index 2f32b841c03..952f6bff8aa 100644 --- a/src/devices/sound/asc.h +++ b/src/devices/sound/asc.h @@ -77,7 +77,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update); diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp index e29b6f31617..be7b8a7946b 100644 --- a/src/devices/sound/astrocde.cpp +++ b/src/devices/sound/astrocde.cpp @@ -115,9 +115,8 @@ void astrocade_io_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void astrocade_io_device::sound_stream_update(sound_stream &stream) { - auto &dest = outputs[0]; uint16_t noise_state; uint8_t master_count; uint8_t noise_clock; @@ -129,14 +128,14 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector< /* loop over samples */ int samples_this_time; - constexpr stream_buffer::sample_t sample_scale = 1.0f / 60.0f; - for (int sampindex = 0; sampindex < dest.samples(); sampindex += samples_this_time) + constexpr sound_stream::sample_t sample_scale = 1.0f / 60.0f; + for (int sampindex = 0; sampindex < stream.samples(); sampindex += samples_this_time) { s32 cursample = 0; /* compute the number of cycles until the next master oscillator reset */ /* or until the next noise boundary */ - samples_this_time = std::min<int>(dest.samples() - sampindex, 256 - master_count); + samples_this_time = std::min<int>(stream.samples() - sampindex, 256 - master_count); samples_this_time = std::min(samples_this_time, 64 - noise_clock); /* sum the output of the tone generators */ @@ -152,7 +151,7 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector< cursample += m_reg[7] >> 4; /* scale to max and output */ - dest.fill(stream_buffer::sample_t(cursample) * sample_scale, sampindex, samples_this_time); + stream.fill(0, sound_stream::sample_t(cursample) * sample_scale, sampindex, samples_this_time); /* clock the noise; a 2-bit counter clocks a 4-bit counter which clocks the LFSR */ noise_clock += samples_this_time; diff --git a/src/devices/sound/astrocde.h b/src/devices/sound/astrocde.h index 7c623e0f1f2..1fbe7504e8e 100644 --- a/src/devices/sound/astrocde.h +++ b/src/devices/sound/astrocde.h @@ -57,7 +57,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: void write(offs_t offset, uint8_t data); diff --git a/src/devices/sound/awacs.cpp b/src/devices/sound/awacs.cpp index 236852c854b..3ddb10e7007 100644 --- a/src/devices/sound/awacs.cpp +++ b/src/devices/sound/awacs.cpp @@ -103,7 +103,7 @@ void awacs_device::device_reset() // our sound stream //------------------------------------------------- -void awacs_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void awacs_device::sound_stream_update(sound_stream &stream) { m_last_sample = machine().time(); @@ -119,14 +119,14 @@ void awacs_device::sound_stream_update(sound_stream &stream, std::vector<read_st u32 data = m_output_cb(m_phase | (m_output_buffer ? 0x10000 : 0)); s16 left = data >> 16; s16 right = data; - outputs[0].put_int(0, left, 32768); - outputs[1].put_int(0, right, 32768); + stream.put_int(0, 0, left, 32768); + stream.put_int(1, 0, right, 32768); } else { m_output_buffer = false; - outputs[0].put_int(0, 0, 32768); - outputs[1].put_int(0, 0, 32768); + stream.put_int(0, 0, 0, 32768); + stream.put_int(1, 0, 0, 32768); } if(m_active & ACTIVE_IN) diff --git a/src/devices/sound/awacs.h b/src/devices/sound/awacs.h index d46f3fcec29..89bb254eb3a 100644 --- a/src/devices/sound/awacs.h +++ b/src/devices/sound/awacs.h @@ -49,7 +49,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; devcb_write_line m_irq_out_cb, m_irq_in_cb; devcb_read32 m_output_cb; diff --git a/src/devices/sound/ay8910.cpp b/src/devices/sound/ay8910.cpp index b4ad9a01043..f93d0027a85 100644 --- a/src/devices/sound/ay8910.cpp +++ b/src/devices/sound/ay8910.cpp @@ -593,7 +593,7 @@ be induced by cutoff currents from the 15 FETs. #define ENABLE_REGISTER_TEST (0) // Enable preprogrammed registers -static constexpr stream_buffer::sample_t MAX_OUTPUT = 1.0; +static constexpr sound_stream::sample_t MAX_OUTPUT = 1.0; /************************************* @@ -758,7 +758,7 @@ static const ay8910_device::mosfet_param ay8910_mosfet_param = * *************************************/ -static inline void build_3D_table(double rl, const ay8910_device::ay_ym_param *par, const ay8910_device::ay_ym_param *par_env, int normalize, double factor, int zero_is_off, stream_buffer::sample_t *tab) +static inline void build_3D_table(double rl, const ay8910_device::ay_ym_param *par, const ay8910_device::ay_ym_param *par_env, int normalize, double factor, int zero_is_off, sound_stream::sample_t *tab) { double min = 10.0, max = 0.0; @@ -817,7 +817,7 @@ static inline void build_3D_table(double rl, const ay8910_device::ay_ym_param *p // for (e = 0;e<16;e++) printf("%d %d\n",e << 10, tab[e << 10]); } -static inline void build_single_table(double rl, const ay8910_device::ay_ym_param *par, int normalize, stream_buffer::sample_t *tab, int zero_is_off) +static inline void build_single_table(double rl, const ay8910_device::ay_ym_param *par, int normalize, sound_stream::sample_t *tab, int zero_is_off) { double rt; double rw; @@ -855,7 +855,7 @@ static inline void build_single_table(double rl, const ay8910_device::ay_ym_para } -static inline void build_mosfet_resistor_table(const ay8910_device::mosfet_param &par, const double rd, stream_buffer::sample_t *tab) +static inline void build_mosfet_resistor_table(const ay8910_device::mosfet_param &par, const double rd, sound_stream::sample_t *tab) { for (int j = 0; j < par.m_count; j++) { @@ -873,7 +873,7 @@ static inline void build_mosfet_resistor_table(const ay8910_device::mosfet_param } -stream_buffer::sample_t ay8910_device::mix_3D() +sound_stream::sample_t ay8910_device::mix_3D() { int indx = 0; @@ -1055,20 +1055,11 @@ void ay8910_device::ay8910_write_reg(int r, int v) // sound_stream_update - handle a stream update //------------------------------------------------- -void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ay8910_device::sound_stream_update(sound_stream &stream) { tone_t *tone; envelope_t *envelope; - int samples = outputs[0].samples(); - - // hack to prevent us from hanging when starting filtered outputs - if (!m_ready) - { - for (int chan = 0; chan < m_streams; chan++) - outputs[chan].fill(0); - } - // The 8910 has three outputs, each output is the mix of one of the three // tone generators and of the (single) noise generator. The two are mixed // BEFORE going into the DAC. The formula to mix each channel is: @@ -1077,7 +1068,7 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s // is 1, not 0, and can be modulated changing the volume. // buffering loop - for (int sampindex = 0; sampindex < samples; sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { for (int chan = 0; chan < NUM_CHANNELS; chan++) { @@ -1172,38 +1163,38 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s { env_volume >>= 1; if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field - outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); + stream.put(chan, sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); else - outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume : 0]); + stream.put(chan, sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume : 0]); } else { if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); else - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); } } else { if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); else - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); } } else { if (is_expanded_mode()) - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); else - outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); + stream.put(chan, sampindex, m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); } } } else { - outputs[0].put(sampindex, mix_3D()); + stream.put(0, sampindex, mix_3D()); } } } @@ -1298,7 +1289,7 @@ void ay8910_device::device_start() m_streams = 1; } - m_vol3d_table = make_unique_clear<stream_buffer::sample_t[]>(8*32*32*32); + m_vol3d_table = make_unique_clear<sound_stream::sample_t[]>(8*32*32*32); build_mixer_table(); diff --git a/src/devices/sound/ay8910.h b/src/devices/sound/ay8910.h index ca763dc754c..44ec39649c2 100644 --- a/src/devices/sound/ay8910.h +++ b/src/devices/sound/ay8910.h @@ -140,7 +140,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void ay8910_write_ym(int addr, u8 data); u8 ay8910_read_ym(); @@ -294,7 +294,7 @@ private: // internal helpers void set_type(psg_type_t psg_type); - inline stream_buffer::sample_t mix_3D(); + inline sound_stream::sample_t mix_3D(); void ay8910_write_reg(int r, int v); void build_mixer_table(); void ay8910_statesave(); @@ -324,9 +324,9 @@ private: u8 m_vol_enabled[NUM_CHANNELS]; const ay_ym_param *m_par; const ay_ym_param *m_par_env; - stream_buffer::sample_t m_vol_table[NUM_CHANNELS][16]; - stream_buffer::sample_t m_env_table[NUM_CHANNELS][32]; - std::unique_ptr<stream_buffer::sample_t[]> m_vol3d_table; + sound_stream::sample_t m_vol_table[NUM_CHANNELS][16]; + sound_stream::sample_t m_env_table[NUM_CHANNELS][32]; + std::unique_ptr<sound_stream::sample_t[]> m_vol3d_table; int m_flags; // Flags int m_feature; // Chip specific features int m_res_load[3]; // Load on channel in ohms diff --git a/src/devices/sound/bbd.cpp b/src/devices/sound/bbd.cpp index 5b694b6970c..f09a0e5ad3a 100644 --- a/src/devices/sound/bbd.cpp +++ b/src/devices/sound/bbd.cpp @@ -12,105 +12,48 @@ // bbd_device_base - constructor //------------------------------------------------- -template<int Entries, int Outputs> -bbd_device_base<Entries, Outputs>::bbd_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type) : +bbd_device_base::bbd_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type) : device_t(mconfig, type, tag, owner, clock), - device_sound_interface(mconfig, *this), - m_stream(nullptr), - m_curpos(0), - m_cv_handler(*this), - m_next_bbdtime(attotime::zero) + device_sound_interface(mconfig, *this) { - std::fill_n(&m_buffer[0], Entries, 0); } - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -template<int Entries, int Outputs> -void bbd_device_base<Entries, Outputs>::device_start() +void bbd_device_base::set_bucket_count(int buckets) { - m_cv_handler.resolve(); - - if (m_cv_handler.isnull()) - m_stream = stream_alloc(1, Outputs, sample_rate()); - else - m_stream = stream_alloc(1, Outputs, SAMPLE_RATE_OUTPUT_ADAPTIVE, STREAM_DISABLE_INPUT_RESAMPLING); + m_buffer.resize(buckets); +} +void bbd_device_base::device_start() +{ + m_stream = stream_alloc(1, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE, STREAM_SYNCHRONOUS); save_item(NAME(m_buffer)); save_item(NAME(m_curpos)); - save_item(NAME(m_next_bbdtime)); -} -//------------------------------------------------- -// device_clock_changed - handle a clock change -//------------------------------------------------- +} -template<int Entries, int Outputs> -void bbd_device_base<Entries, Outputs>::device_clock_changed() +void bbd_device_base::device_reset() { - if (m_cv_handler.isnull()) - m_stream->set_sample_rate(sample_rate()); + std::fill(m_buffer.begin(), m_buffer.end(), 0); + m_curpos = 0; } +void bbd_device_base::tick() +{ + u32 nextpos = m_curpos + 1; + if(nextpos == m_buffer.size()) + nextpos = 0; + m_buffer[nextpos] = m_buffer[m_curpos]; + m_curpos = nextpos; +} -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -template<int Entries, int Outputs> -void bbd_device_base<Entries, Outputs>::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void bbd_device_base::sound_stream_update(sound_stream &stream) { - // BBDs that I've seen so far typically have 2 outputs, with the first outputting - // sample n-1 and the second outputting sampe n; if chips with more outputs - // or other taps turn up, this logic will need to be made more flexible - if (m_cv_handler.isnull()) - { - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - { - for (int outnum = 0; outnum < Outputs; outnum++) - outputs[outnum].put(sampindex, m_buffer[(m_curpos + (Outputs - 1) - outnum) % Entries]); - m_buffer[m_curpos] = inputs[0].get(sampindex); - m_curpos = (m_curpos + 1) % Entries; - } - } - else - { - read_stream_view in(inputs[0], m_next_bbdtime); - attotime intime = in.start_time(); - attotime outtime = outputs[0].start_time(); - int inpos = 0; - - // loop until all outputs generated - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - { - // we need to process some more BBD input - while (outtime >= m_next_bbdtime) - { - // find the input sample that overlaps our start time - while (intime + in.sample_period() < m_next_bbdtime) - { - inpos++; - intime += in.sample_period(); - } - - // copy that to the buffer - m_buffer[m_curpos] = in.get(inpos); - m_curpos = (m_curpos + 1) % std::size(m_buffer); - - // advance the end time of this BBD sample - m_next_bbdtime += attotime(0, m_cv_handler(m_next_bbdtime)); - } - - // copy the most recently-generated BBD data - for (int outnum = 0; outnum < Outputs; outnum++) - outputs[outnum].put(sampindex, outputval(outnum - (Outputs - 1))); - outtime += outputs[0].sample_period(); - } - } + u32 nextpos = m_curpos + 1; + if(nextpos == m_buffer.size()) + nextpos = 0; + stream.put(0, 0, m_buffer[nextpos]); + m_buffer[m_curpos] = stream.get(0, 0); } @@ -124,6 +67,7 @@ DEFINE_DEVICE_TYPE(MN3004, mn3004_device, "mn3004", "MN3004 BBD") mn3004_device::mn3004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3004) { + set_bucket_count(512); } @@ -137,6 +81,7 @@ DEFINE_DEVICE_TYPE(MN3005, mn3005_device, "mn3005", "MN3005 BBD") mn3005_device::mn3005_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3005) { + set_bucket_count(4096); } @@ -150,6 +95,7 @@ DEFINE_DEVICE_TYPE(MN3006, mn3006_device, "mn3006", "MN3006 BBD") mn3006_device::mn3006_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3006) { + set_bucket_count(128); } @@ -163,6 +109,7 @@ DEFINE_DEVICE_TYPE(MN3204P, mn3204p_device, "mn3204p", "MN3204P BBD") mn3204p_device::mn3204p_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3204P) { + set_bucket_count(512); } @@ -176,4 +123,5 @@ DEFINE_DEVICE_TYPE(MN3207, mn3207_device, "mn3207", "MN3207 BBD") mn3207_device::mn3207_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3207) { + set_bucket_count(1024); } diff --git a/src/devices/sound/bbd.h b/src/devices/sound/bbd.h index 64394a90620..4b761a64904 100644 --- a/src/devices/sound/bbd.h +++ b/src/devices/sound/bbd.h @@ -11,45 +11,38 @@ // ======================> bbd_device_base -template<int Entries, int Outputs> class bbd_device_base : public device_t, public device_sound_interface { public: - // configuration - template <typename... T> void set_cv_handler(T &&... args) - { - m_cv_handler.set(std::forward<T>(args)...); - } + void tick(); protected: - using cv_delegate = device_delegate<attoseconds_t (attotime const &)>; - // internal constructor bbd_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type); + void set_bucket_count(int buckets); + // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void device_clock_changed() override; + virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; protected: // override to convert clock to sample rate - stream_buffer::sample_t outputval(s32 index) const { return m_buffer[(m_curpos - index) % std::size(m_buffer)]; } + sound_stream::sample_t outputval(s32 index) const { return m_buffer[(m_curpos - index) % std::size(m_buffer)]; } virtual u32 sample_rate() const { return clock(); } sound_stream * m_stream; u32 m_curpos; - cv_delegate m_cv_handler; - attotime m_next_bbdtime; - stream_buffer::sample_t m_buffer[Entries + 1]; + std::vector<sound_stream::sample_t> m_buffer; }; // ======================> mn3004_device -class mn3004_device : public bbd_device_base<512, 2> +class mn3004_device : public bbd_device_base { public: mn3004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -60,7 +53,7 @@ DECLARE_DEVICE_TYPE(MN3004, mn3004_device) // ======================> mn3005_device -class mn3005_device : public bbd_device_base<4096, 2> +class mn3005_device : public bbd_device_base { public: mn3005_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -71,7 +64,7 @@ DECLARE_DEVICE_TYPE(MN3005, mn3005_device) // ======================> mn3006_device -class mn3006_device : public bbd_device_base<128, 2> +class mn3006_device : public bbd_device_base { public: mn3006_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -82,7 +75,7 @@ DECLARE_DEVICE_TYPE(MN3006, mn3006_device) // ======================> mn3204p_device -class mn3204p_device : public bbd_device_base<512, 2> +class mn3204p_device : public bbd_device_base { public: mn3204p_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -93,7 +86,7 @@ DECLARE_DEVICE_TYPE(MN3204P, mn3204p_device) // ======================> mn3207_device -class mn3207_device : public bbd_device_base<1024, 2> +class mn3207_device : public bbd_device_base { public: mn3207_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); diff --git a/src/devices/sound/beep.cpp b/src/devices/sound/beep.cpp index fd4096c72eb..9a341a7a2d3 100644 --- a/src/devices/sound/beep.cpp +++ b/src/devices/sound/beep.cpp @@ -52,19 +52,14 @@ void beep_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void beep_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void beep_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - // if we're not enabled, just fill with 0 + // if we're not enabled, just leave cleared if (!m_enable || m_frequency == 0) - { - buffer.fill(0); return; - } // fill in the sample - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { m_incr -= m_frequency; while (m_incr < 0) @@ -73,7 +68,7 @@ void beep_device::sound_stream_update(sound_stream &stream, std::vector<read_str m_signal = -m_signal; } - buffer.put(sampindex, m_signal); + stream.put(0, sampindex, m_signal); } } diff --git a/src/devices/sound/beep.h b/src/devices/sound/beep.h index a33ab803020..651ad143985 100644 --- a/src/devices/sound/beep.h +++ b/src/devices/sound/beep.h @@ -28,14 +28,14 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; // stream number bool m_enable; // enable beep uint32_t m_frequency; // set frequency - this can be changed using the appropriate function int32_t m_incr; // initial wave state - stream_buffer::sample_t m_signal; // current signal + sound_stream::sample_t m_signal; // current signal }; DECLARE_DEVICE_TYPE(BEEP, beep_device) diff --git a/src/devices/sound/bsmt2000.cpp b/src/devices/sound/bsmt2000.cpp index 428009b1fc2..44f35c09ba5 100644 --- a/src/devices/sound/bsmt2000.cpp +++ b/src/devices/sound/bsmt2000.cpp @@ -186,12 +186,12 @@ TIMER_CALLBACK_MEMBER(bsmt2000_device::deferred_data_write) // for our sound stream //------------------------------------------------- -void bsmt2000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void bsmt2000_device::sound_stream_update(sound_stream &stream) { // just fill with current left/right values - constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - outputs[0].fill(stream_buffer::sample_t(m_left_data) * sample_scale); - outputs[1].fill(stream_buffer::sample_t(m_right_data) * sample_scale); + constexpr sound_stream::sample_t sample_scale = 1.0 / 32768.0; + stream.fill(0, sound_stream::sample_t(m_left_data) * sample_scale); + stream.fill(1, sound_stream::sample_t(m_right_data) * sample_scale); } diff --git a/src/devices/sound/bsmt2000.h b/src/devices/sound/bsmt2000.h index dc9fc5751c2..e0c9fbabaec 100644 --- a/src/devices/sound/bsmt2000.h +++ b/src/devices/sound/bsmt2000.h @@ -52,7 +52,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/c140.cpp b/src/devices/sound/c140.cpp index 688ebec6459..9c83dac32db 100644 --- a/src/devices/sound/c140.cpp +++ b/src/devices/sound/c140.cpp @@ -215,12 +215,12 @@ void c140_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void c140_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c140_device::sound_stream_update(sound_stream &stream) { float pbase = (float)m_baserate * 2.0f / (float)m_sample_rate; s16 *lmix, *rmix; - int samples = outputs[0].samples(); + int samples = stream.samples(); if (samples > m_sample_rate) samples = m_sample_rate; /* zap the contents of the mixer buffer */ @@ -317,22 +317,20 @@ void c140_device::sound_stream_update(sound_stream &stream, std::vector<read_str lmix = m_mixer_buffer_left.get(); rmix = m_mixer_buffer_right.get(); { - auto &dest1 = outputs[0]; - auto &dest2 = outputs[1]; for (int i = 0; i < samples; i++) { - dest1.put_int_clamp(i, *lmix++, 32768 / 8); - dest2.put_int_clamp(i, *rmix++, 32768 / 8); + stream.put_int_clamp(0, i, *lmix++, 32768 / 8); + stream.put_int_clamp(1, i, *rmix++, 32768 / 8); } } } -void c219_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c219_device::sound_stream_update(sound_stream &stream) { float pbase = (float)m_baserate * 2.0f / (float)m_sample_rate; s16 *lmix, *rmix; - int samples = outputs[0].samples(); + int samples = stream.samples(); if (samples > m_sample_rate) samples = m_sample_rate; /* zap the contents of the mixer buffer */ @@ -448,12 +446,10 @@ void c219_device::sound_stream_update(sound_stream &stream, std::vector<read_str lmix = m_mixer_buffer_left.get(); rmix = m_mixer_buffer_right.get(); { - auto &dest1 = outputs[0]; - auto &dest2 = outputs[1]; for (int i = 0; i < samples; i++) { - dest1.put_int_clamp(i, *lmix++, 32768 / 8); - dest2.put_int_clamp(i, *rmix++, 32768 / 8); + stream.put_int_clamp(0, i, *lmix++, 32768 / 8); + stream.put_int_clamp(1, i, *rmix++, 32768 / 8); } } } diff --git a/src/devices/sound/c140.h b/src/devices/sound/c140.h index 2fda0526a82..9fd23b3b0a6 100644 --- a/src/devices/sound/c140.h +++ b/src/devices/sound/c140.h @@ -44,7 +44,7 @@ protected: virtual void rom_bank_pre_change() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual int find_sample(int adrs, int bank, int voice); @@ -118,7 +118,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual int find_sample(int adrs, int bank, int voice) override; diff --git a/src/devices/sound/c352.cpp b/src/devices/sound/c352.cpp index dcbd58f3eb3..f4b21be2663 100644 --- a/src/devices/sound/c352.cpp +++ b/src/devices/sound/c352.cpp @@ -123,14 +123,9 @@ void c352_device::ramp_volume(c352_voice_t &v, int ch, u8 val) v.curr_vol[ch] += (vol_delta > 0) ? -1 : 1; } -void c352_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c352_device::sound_stream_update(sound_stream &stream) { - auto &buffer_fl = outputs[0]; - auto &buffer_fr = outputs[1]; - auto &buffer_rl = outputs[2]; - auto &buffer_rr = outputs[3]; - - for (int i = 0; i < buffer_fl.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int out[4] = { 0, 0, 0, 0 }; @@ -174,10 +169,10 @@ void c352_device::sound_stream_update(sound_stream &stream, std::vector<read_str out[3] += (((v.flags & C352_FLG_PHASEFR) ? -s : s) * v.curr_vol[3]) >> 8; } - buffer_fl.put_int(i, s16(out[0] >> 3), 32768); - buffer_fr.put_int(i, s16(out[1] >> 3), 32768); - buffer_rl.put_int(i, s16(out[2] >> 3), 32768); - buffer_rr.put_int(i, s16(out[3] >> 3), 32768); + stream.put_int(0, i, s16(out[0] >> 3), 32768); + stream.put_int(1, i, s16(out[1] >> 3), 32768); + stream.put_int(2, i, s16(out[2] >> 3), 32768); + stream.put_int(3, i, s16(out[3] >> 3), 32768); } } diff --git a/src/devices/sound/c352.h b/src/devices/sound/c352.h index 321d5144879..b404952745a 100644 --- a/src/devices/sound/c352.h +++ b/src/devices/sound/c352.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/c6280.cpp b/src/devices/sound/c6280.cpp index c6f3e92a4fd..df857d1f172 100644 --- a/src/devices/sound/c6280.cpp +++ b/src/devices/sound/c6280.cpp @@ -42,7 +42,7 @@ #include <algorithm> -void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c6280_device::sound_stream_update(sound_stream &stream) { static const u8 scale_tab[16] = { @@ -53,11 +53,7 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st const u8 lmal = scale_tab[(m_balance >> 4) & 0x0f]; const u8 rmal = scale_tab[(m_balance >> 0) & 0x0f]; - /* Clear buffer */ - outputs[0].fill(0); - outputs[1].fill(0); - - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 lout = 0, rout = 0; for (int ch = 0; ch < 6; ch++) @@ -164,8 +160,8 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st } } } - outputs[0].put_int(i, lout, 32768); - outputs[1].put_int(i, rout, 32768); + stream.put_int(0, i, lout, 32768); + stream.put_int(1, i, rout, 32768); } } diff --git a/src/devices/sound/c6280.h b/src/devices/sound/c6280.h index 407f5abaad0..85c94566ee7 100644 --- a/src/devices/sound/c6280.h +++ b/src/devices/sound/c6280.h @@ -22,7 +22,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct channel { diff --git a/src/devices/sound/cdda.cpp b/src/devices/sound/cdda.cpp index 5c39bbfe84e..281a625c0bf 100644 --- a/src/devices/sound/cdda.cpp +++ b/src/devices/sound/cdda.cpp @@ -15,9 +15,9 @@ static constexpr int MAX_SCAN_SECTORS = 2; // sound_stream_update - handle a stream update //------------------------------------------------- -void cdda_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdda_device::sound_stream_update(sound_stream &stream) { - get_audio_data(outputs[0], outputs[1]); + get_audio_data(stream); } //------------------------------------------------- @@ -199,12 +199,11 @@ int cdda_device::audio_ended() converts it to 2 16-bit 44.1 kHz streams -------------------------------------------------*/ -void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &bufR) +void cdda_device::get_audio_data(sound_stream &stream) { - int i; int16_t *audio_cache = (int16_t *) m_audio_cache.get(); - for (int sampindex = 0; sampindex < bufL.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { /* if no file, audio not playing, audio paused, or out of disc data, just zero fill */ @@ -219,25 +218,23 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf m_sequence_counter = m_disc->sequence_counter(); m_audio_data[0] = m_audio_data[1] = 0; - bufL.fill(0, sampindex); - bufR.fill(0, sampindex); return; } - int samples = bufL.samples() - sampindex; + int samples = stream.samples() - sampindex; if (samples > m_audio_samples) { samples = m_audio_samples; } - for (i = 0; i < samples; i++) + for (int i = 0; i < samples; i++) { /* CD-DA data on the disc is big-endian */ m_audio_data[0] = s16(big_endianize_int16( audio_cache[ m_audio_bptr ] )); - bufL.put_int(sampindex + i, m_audio_data[0], 32768); + stream.put_int(0, sampindex + i, m_audio_data[0], 32768); m_audio_bptr++; m_audio_data[1] = s16(big_endianize_int16( audio_cache[ m_audio_bptr ] )); - bufR.put_int(sampindex + i, m_audio_data[1], 32768); + stream.put_int(1, sampindex + i, m_audio_data[1], 32768); m_audio_bptr++; } @@ -252,7 +249,7 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf sectors = MAX_SECTORS; } - for (i = 0; i < sectors; i++) + for (int i = 0; i < sectors; i++) { const auto adr_control = m_disc->get_adr_control(m_disc->get_track(m_audio_lba)); diff --git a/src/devices/sound/cdda.h b/src/devices/sound/cdda.h index dcdea3cc5bf..5eadd5e315f 100644 --- a/src/devices/sound/cdda.h +++ b/src/devices/sound/cdda.h @@ -37,10 +37,10 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: - void get_audio_data(write_stream_view &bufL, write_stream_view &bufR); + void get_audio_data(sound_stream &stream); required_device<cdrom_image_device> m_disc; diff --git a/src/devices/sound/cdp1863.cpp b/src/devices/sound/cdp1863.cpp index da9194b9a7e..31d135b5c78 100644 --- a/src/devices/sound/cdp1863.cpp +++ b/src/devices/sound/cdp1863.cpp @@ -85,15 +85,14 @@ void cdp1863_device::device_start() // our sound stream //------------------------------------------------- -void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdp1863_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t signal = m_signal; - auto &buffer = outputs[0]; + sound_stream::sample_t signal = m_signal; if (m_oe) { double frequency; - int rate = buffer.sample_rate() / 2; + int rate = stream.sample_rate() / 2; // get progress through wave int incr = m_incr; @@ -118,9 +117,9 @@ void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_ signal = 1.0; } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, signal); + stream.put(0, sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -133,8 +132,6 @@ void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_incr = incr; m_signal = signal; } - else - buffer.fill(0); } diff --git a/src/devices/sound/cdp1863.h b/src/devices/sound/cdp1863.h index 4d6f4f295b3..15c9054f13f 100644 --- a/src/devices/sound/cdp1863.h +++ b/src/devices/sound/cdp1863.h @@ -54,7 +54,7 @@ protected: virtual void device_start() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; @@ -65,7 +65,7 @@ private: // sound state int m_oe; // output enable int m_latch; // sound latch - stream_buffer::sample_t m_signal;// current signal + sound_stream::sample_t m_signal;// current signal int m_incr; // initial wave state }; diff --git a/src/devices/sound/cdp1864.cpp b/src/devices/sound/cdp1864.cpp index 2d8acb64358..c211dc451f4 100644 --- a/src/devices/sound/cdp1864.cpp +++ b/src/devices/sound/cdp1864.cpp @@ -243,15 +243,14 @@ TIMER_CALLBACK_MEMBER(cdp1864_device::dma_tick) // our sound stream //------------------------------------------------- -void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdp1864_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t signal = m_signal; - auto &buffer = outputs[0]; + sound_stream::sample_t signal = m_signal; if (m_aoe) { double frequency = unscaled_clock() / 8 / 4 / (m_latch + 1) / 2; - int rate = buffer.sample_rate() / 2; + int rate = stream.sample_rate() / 2; /* get progress through wave */ int incr = m_incr; @@ -265,9 +264,9 @@ void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_ signal = 1.0; } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, signal); + stream.put(0, sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -280,8 +279,6 @@ void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_ 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 c1bb7b36797..09ab0f78730 100644 --- a/src/devices/sound/cdp1864.h +++ b/src/devices/sound/cdp1864.h @@ -114,7 +114,7 @@ protected: virtual void device_reset() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(int_tick); TIMER_CALLBACK_MEMBER(efx_tick); @@ -152,7 +152,7 @@ private: // sound state int m_aoe; // audio on int m_latch; // sound latch - stream_buffer::sample_t m_signal; // current signal + sound_stream::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 c0a54adaf99..531a95a065b 100644 --- a/src/devices/sound/cdp1869.cpp +++ b/src/devices/sound/cdp1869.cpp @@ -493,33 +493,32 @@ void cdp1869_device::cdp1869_palette(palette_device &palette) const // our sound stream //------------------------------------------------- -void cdp1869_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdp1869_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t signal = m_signal; - auto &buffer = outputs[0]; + sound_stream::sample_t signal = m_signal; 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 = buffer.sample_rate() / 2; + int rate = stream.sample_rate() / 2; /* get progress through wave */ int incr = m_incr; if (signal < 0) { - signal = -(stream_buffer::sample_t(m_toneamp) / 15.0); + signal = -(sound_stream::sample_t(m_toneamp) / 15.0); } else { - signal = stream_buffer::sample_t(m_toneamp) / 15.0; + signal = sound_stream::sample_t(m_toneamp) / 15.0; } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, signal); + stream.put(0, sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -532,8 +531,6 @@ void cdp1869_device::sound_stream_update(sound_stream &stream, std::vector<read_ 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 eb458ee3bd9..537e8814133 100644 --- a/src/devices/sound/cdp1869.h +++ b/src/devices/sound/cdp1869.h @@ -215,7 +215,7 @@ protected: virtual space_config_vector memory_space_config() const override; // device_sound_interface callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(prd_update); @@ -266,7 +266,7 @@ private: uint16_t m_hma; // home memory address // sound state - stream_buffer::sample_t m_signal; // current signal + sound_stream::sample_t m_signal; // current signal int m_incr; // initial wave state int m_toneoff; // tone off int m_wnoff; // white noise off diff --git a/src/devices/sound/cem3394.cpp b/src/devices/sound/cem3394.cpp index b047092e00b..d2920a333c6 100644 --- a/src/devices/sound/cem3394.cpp +++ b/src/devices/sound/cem3394.cpp @@ -296,16 +296,13 @@ double cem3394_device::filter(double input, double cutoff) // buffer in mono //------------------------------------------------- -void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cem3394_device::sound_stream_update(sound_stream &stream) { - auto &external = inputs[0]; - auto &buffer = outputs[0]; - if (m_wave_select == 0 && m_mixer_external == 0) LOGMASKED(LOG_VALUES, "%f V didn't cut it\n", m_values[WAVE_SELECT]); // loop over samples - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // get the current VCO position and step it forward double vco_position = m_vco_position; @@ -336,7 +333,7 @@ void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_ // compute extension input (for Bally/Sente this is the noise) if (ENABLE_EXTERNAL) - result += EXTERNAL_VOLUME * m_mixer_external * external.get(sampindex); + result += EXTERNAL_VOLUME * m_mixer_external * stream.get(0, sampindex); // compute the modulated filter frequency and apply the filter // modulation tracks the VCO triangle @@ -344,7 +341,7 @@ void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_ result = filter(result, filter_freq); // write the sample - buffer.put(sampindex, result * m_volume); + stream.put(0, sampindex, result * m_volume); } } @@ -407,7 +404,7 @@ double cem3394_device::compute_db(double voltage) } -stream_buffer::sample_t cem3394_device::compute_db_volume(double voltage) +sound_stream::sample_t cem3394_device::compute_db_volume(double voltage) { double temp; diff --git a/src/devices/sound/cem3394.h b/src/devices/sound/cem3394.h index e086ad7bf4b..bb109dbc2a2 100644 --- a/src/devices/sound/cem3394.h +++ b/src/devices/sound/cem3394.h @@ -32,7 +32,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: // Set the voltage going to a particular parameter @@ -51,7 +51,7 @@ public: private: double compute_db(double voltage); - stream_buffer::sample_t compute_db_volume(double voltage); + sound_stream::sample_t compute_db_volume(double voltage); private: double filter(double input, double cutoff); diff --git a/src/devices/sound/cf61909.cpp b/src/devices/sound/cf61909.cpp index 77b8af0b5de..136633079b2 100644 --- a/src/devices/sound/cf61909.cpp +++ b/src/devices/sound/cf61909.cpp @@ -132,9 +132,9 @@ void cf61909_device::write(offs_t offset, u8 data) } /**************************************************************************/ -void cf61909_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cf61909_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sample = 0; @@ -156,6 +156,6 @@ void cf61909_device::sound_stream_update(sound_stream &stream, std::vector<read_ } // Jaminator patent shows 10-bit sampling, assume that's actually true - outputs[0].put_int_clamp(i, sample >> 9, 1 << 9); + stream.put_int_clamp(0, i, sample >> 9, 1 << 9); } } diff --git a/src/devices/sound/cf61909.h b/src/devices/sound/cf61909.h index 0ccc6264c0b..c1aa58d889b 100644 --- a/src/devices/sound/cf61909.h +++ b/src/devices/sound/cf61909.h @@ -29,7 +29,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void rom_bank_pre_change() override; private: diff --git a/src/devices/sound/ct1745.cpp b/src/devices/sound/ct1745.cpp index 520274dd709..1ca962d1b49 100644 --- a/src/devices/sound/ct1745.cpp +++ b/src/devices/sound/ct1745.cpp @@ -29,7 +29,7 @@ DEFINE_DEVICE_TYPE(CT1745, ct1745_mixer_device, "ct1745", "Creative Labs CT1745 ct1745_mixer_device::ct1745_mixer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CT1745, tag, owner, clock) , device_memory_interface(mconfig, *this) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_irq_status_cb(*this, 0) , m_fm(*this, finder_base::DUMMY_TAG) , m_ldac(*this, finder_base::DUMMY_TAG) diff --git a/src/devices/sound/dac.cpp b/src/devices/sound/dac.cpp index c831ab24ac4..26d70d308f3 100644 --- a/src/devices/sound/dac.cpp +++ b/src/devices/sound/dac.cpp @@ -25,11 +25,11 @@ DEFINE_DEVICE_TYPE(_dac_type, _dac_class, _dac_shortname, _dac_description) // the given number of bits to a sample value //------------------------------------------------- -stream_buffer::sample_t dac_mapper_unsigned(u32 input, u8 bits) +sound_stream::sample_t dac_mapper_unsigned(u32 input, u8 bits) { - stream_buffer::sample_t scale = 1.0 / stream_buffer::sample_t((bits > 1) ? (1 << bits) : 1); + sound_stream::sample_t scale = 1.0 / sound_stream::sample_t((bits > 1) ? (1 << bits) : 1); input &= (1 << bits) - 1; - return stream_buffer::sample_t(input) * scale; + return sound_stream::sample_t(input) * scale; } @@ -38,7 +38,7 @@ stream_buffer::sample_t dac_mapper_unsigned(u32 input, u8 bits) // value of the given number of bits to a sample value //------------------------------------------------- -stream_buffer::sample_t dac_mapper_signed(u32 input, u8 bits) +sound_stream::sample_t dac_mapper_signed(u32 input, u8 bits) { return dac_mapper_unsigned(input ^ (1 << (bits - 1)), bits); } @@ -50,7 +50,7 @@ stream_buffer::sample_t dac_mapper_signed(u32 input, u8 bits) // treated as a negative 1s complement //------------------------------------------------- -stream_buffer::sample_t dac_mapper_ones_complement(u32 input, u8 bits) +sound_stream::sample_t dac_mapper_ones_complement(u32 input, u8 bits) { // this mapping assumes symmetric reference voltages, // which is true for all existing cases @@ -65,7 +65,7 @@ stream_buffer::sample_t dac_mapper_ones_complement(u32 input, u8 bits) // dac_device_base - constructor //------------------------------------------------- -dac_device_base::dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : +dac_device_base::dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : device_t(mconfig, type, tag, owner, clock), device_sound_interface(mconfig, *this), m_stream(nullptr), @@ -91,7 +91,7 @@ void dac_device_base::device_start() m_value_map[code] = m_mapper(code, m_bits) * m_gain; // determine the number of inputs - int inputs = (m_specified_inputs_mask == 0) ? 0 : 2; + int inputs = (get_sound_requested_inputs_mask() == 0) ? 0 : 2; // large stream buffer to favour emu/sound.cpp resample quality m_stream = stream_alloc(inputs, 1, 48000 * 32); @@ -105,38 +105,33 @@ void dac_device_base::device_start() // sound_stream_update - stream updates //------------------------------------------------- -void dac_device_base::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dac_device_base::sound_stream_update(sound_stream &stream) { - auto &out = outputs[0]; - // rails are constant - if (inputs.size() == 0) + if (stream.input_count() == 0) { - out.fill(m_range_min + m_curval * (m_range_max - m_range_min)); + stream.fill(0, m_range_min + m_curval * (m_range_max - m_range_min)); return; } - auto &hi = inputs[DAC_INPUT_RANGE_HI]; - auto &lo = inputs[DAC_INPUT_RANGE_LO]; - // constant lo, streaming hi - if (!BIT(m_specified_inputs_mask, DAC_INPUT_RANGE_LO)) + if (!BIT(get_sound_requested_inputs_mask(), DAC_INPUT_RANGE_LO)) { - for (int sampindex = 0; sampindex < out.samples(); sampindex++) - out.put(sampindex, m_range_min + m_curval * (hi.get(sampindex) - m_range_min)); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, m_range_min + m_curval * (stream.get(DAC_INPUT_RANGE_HI, sampindex) - m_range_min)); } // constant hi, streaming lo - else if (!BIT(m_specified_inputs_mask, DAC_INPUT_RANGE_HI)) + else if (!BIT(get_sound_requested_inputs_mask(), DAC_INPUT_RANGE_HI)) { - for (int sampindex = 0; sampindex < out.samples(); sampindex++) - out.put(sampindex, lo.get(sampindex) + m_curval * (m_range_max - lo.get(sampindex))); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, stream.get(DAC_INPUT_RANGE_LO, sampindex) + m_curval * (m_range_max - stream.get(DAC_INPUT_RANGE_LO, sampindex))); } // both streams provided else { - for (int sampindex = 0; sampindex < out.samples(); sampindex++) - out.put(sampindex, lo.get(sampindex) + m_curval * (hi.get(sampindex) - lo.get(sampindex))); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, stream.get(DAC_INPUT_RANGE_LO, sampindex) + m_curval * (stream.get(DAC_INPUT_RANGE_HI, sampindex) - stream.get(DAC_INPUT_RANGE_LO, sampindex))); } } diff --git a/src/devices/sound/dac.h b/src/devices/sound/dac.h index 58fa5cd7864..1465ee94a2e 100644 --- a/src/devices/sound/dac.h +++ b/src/devices/sound/dac.h @@ -33,17 +33,17 @@ // TYPE DEFINITIONS //************************************************************************** -constexpr stream_buffer::sample_t dac_gain_r2r = 1.0; -constexpr stream_buffer::sample_t dac_gain_bw = 2.0; +constexpr sound_stream::sample_t dac_gain_r2r = 1.0; +constexpr sound_stream::sample_t dac_gain_bw = 2.0; // ======================> dac_mapper_callback -using dac_mapper_callback = stream_buffer::sample_t (*)(u32 input, u8 bits); +using dac_mapper_callback = sound_stream::sample_t (*)(u32 input, u8 bits); -stream_buffer::sample_t dac_mapper_unsigned(u32 input, u8 bits); -stream_buffer::sample_t dac_mapper_signed(u32 input, u8 bits); -stream_buffer::sample_t dac_mapper_ones_complement(u32 input, u8 bits); +sound_stream::sample_t dac_mapper_unsigned(u32 input, u8 bits); +sound_stream::sample_t dac_mapper_signed(u32 input, u8 bits); +sound_stream::sample_t dac_mapper_ones_complement(u32 input, u8 bits); // ======================> dac_bit_interface @@ -82,13 +82,13 @@ class dac_device_base : public device_t, public device_sound_interface { protected: // constructor - dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain); + dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain); // device startup virtual void device_start() override ATTR_COLD; // stream generation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // set the current value void set_value(u32 value) @@ -100,26 +100,26 @@ protected: public: // configuration: default output range is -1..1 for all cases except // for 1-bit DACs, which default to 0..1 - dac_device_base &set_output_range(stream_buffer::sample_t range_min, stream_buffer::sample_t range_max) + dac_device_base &set_output_range(sound_stream::sample_t range_min, sound_stream::sample_t range_max) { m_range_min = range_min; m_range_max = range_max; return *this; } - dac_device_base &set_output_range(stream_buffer::sample_t vref) { return set_output_range(-vref, vref); } + dac_device_base &set_output_range(sound_stream::sample_t vref) { return set_output_range(-vref, vref); } private: // internal state sound_stream *m_stream; - stream_buffer::sample_t m_curval; - std::vector<stream_buffer::sample_t> m_value_map; + sound_stream::sample_t m_curval; + std::vector<sound_stream::sample_t> m_value_map; // configuration state u8 const m_bits; dac_mapper_callback const m_mapper; - stream_buffer::sample_t const m_gain; - stream_buffer::sample_t m_range_min; - stream_buffer::sample_t m_range_max; + sound_stream::sample_t const m_gain; + sound_stream::sample_t m_range_min; + sound_stream::sample_t m_range_max; }; @@ -128,7 +128,7 @@ private: class dac_bit_device_base : public dac_device_base, public dac_bit_interface { protected: - dac_bit_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : + dac_bit_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : dac_device_base(mconfig, type, tag, owner, clock, bits, mapper, gain) { } @@ -144,7 +144,7 @@ public: class dac_byte_device_base : public dac_device_base, public dac_byte_interface { protected: - dac_byte_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : + dac_byte_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : dac_device_base(mconfig, type, tag, owner, clock, bits, mapper, gain) { } @@ -160,7 +160,7 @@ public: class dac_word_device_base : public dac_device_base, public dac_word_interface { protected: - dac_word_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : + dac_word_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : dac_device_base(mconfig, type, tag, owner, clock, bits, mapper, gain) { } diff --git a/src/devices/sound/dac3350a.cpp b/src/devices/sound/dac3350a.cpp index 77e91650a64..91e0593c358 100644 --- a/src/devices/sound/dac3350a.cpp +++ b/src/devices/sound/dac3350a.cpp @@ -320,13 +320,13 @@ float dac3350a_device::calculate_volume(int val) return powf(10.0, db / 20.0); } -void dac3350a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dac3350a_device::sound_stream_update(sound_stream &stream) { - const stream_buffer::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; + const sound_stream::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; - for (int channel = 0; channel < 2 && channel < outputs.size(); channel++) + for (int channel = 0; channel < 2 && channel < stream.output_count(); channel++) { - for (int sampindex = 0; sampindex < outputs[channel].samples(); sampindex++) - outputs[channel].put(sampindex, inputs[channel].get(sampindex) * enable_scale * m_volume[channel]); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(channel, sampindex, stream.get(channel, sampindex) * enable_scale * m_volume[channel]); } } diff --git a/src/devices/sound/dac3350a.h b/src/devices/sound/dac3350a.h index f1a284e1cec..920c5e73f92 100644 --- a/src/devices/sound/dac3350a.h +++ b/src/devices/sound/dac3350a.h @@ -17,7 +17,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void i2c_device_handle_write(); diff --git a/src/devices/sound/dac76.cpp b/src/devices/sound/dac76.cpp index 6e2065dd2cc..d5f6939edd5 100644 --- a/src/devices/sound/dac76.cpp +++ b/src/devices/sound/dac76.cpp @@ -103,7 +103,7 @@ void dac76_device::device_reset() // our sound stream //------------------------------------------------- -void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dac76_device::sound_stream_update(sound_stream &stream) { // get current output level int step_size = (2 << m_chord); @@ -113,7 +113,7 @@ void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_st vout *= (m_sb ? +1 : -1); // range is 0-8031, normalize to 0-1 range - stream_buffer::sample_t y = stream_buffer::sample_t(vout) * (1.0 / 8031.0); + sound_stream::sample_t y = sound_stream::sample_t(vout) * (1.0 / 8031.0); if (m_voltage_output) { @@ -121,16 +121,14 @@ void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_st y *= ((y >= 0) ? m_r_pos : m_r_neg) * FULL_SCALE_MULT; } - write_stream_view &out = outputs[0]; if (m_streaming_iref) { - const read_stream_view &iref = inputs[0]; - const int n = out.samples(); + const int n = stream.samples(); for (int i = 0; i < n; ++i) - out.put(i, iref.get(i) * y); + stream.put(0, i, stream.get(0, i) * y); } else { - out.fill(m_fixed_iref * y); + stream.fill(0, m_fixed_iref * y); } } diff --git a/src/devices/sound/dac76.h b/src/devices/sound/dac76.h index 462355b0b8f..5f4edbd29f5 100644 --- a/src/devices/sound/dac76.h +++ b/src/devices/sound/dac76.h @@ -92,7 +92,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr int m_level[8] = { 0, 33, 99, 231, 495, 1023, 2079, 4191 }; diff --git a/src/devices/sound/digitalk.cpp b/src/devices/sound/digitalk.cpp index d41c267e798..ebe7fbb14da 100644 --- a/src/devices/sound/digitalk.cpp +++ b/src/devices/sound/digitalk.cpp @@ -544,28 +544,27 @@ void digitalker_device::digitalker_step() // sound_stream_update - handle a stream update //------------------------------------------------- -void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void digitalker_device::sound_stream_update(sound_stream &stream) { - auto &sout = outputs[0]; int cpos = 0; - while(cpos != sout.samples()) { + while(cpos != stream.samples()) { if(m_zero_count == 0 && m_dac_index == 128) digitalker_step(); if(m_zero_count) { - int n = sout.samples() - cpos; + int n = stream.samples() - cpos; if(n > m_zero_count) n = m_zero_count; - sout.fill(0, cpos, n); + stream.fill(0, 0, cpos, n); cpos += n; m_zero_count -= n; } else if(m_dac_index != 128) { - while(cpos != sout.samples() && m_dac_index != 128) { + while(cpos != stream.samples() && m_dac_index != 128) { s32 v = m_dac[m_dac_index]; int pp = m_pitch_pos; - while(cpos != sout.samples() && pp != m_pitch) { - sout.put_int(cpos++, v, 32768); + while(cpos != stream.samples() && pp != m_pitch) { + stream.put_int(0, cpos++, v, 32768); pp++; } if(pp == m_pitch) { @@ -575,9 +574,6 @@ void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<re m_pitch_pos = pp; } - } else { - sout.fill(0, cpos); - break; } } } diff --git a/src/devices/sound/digitalk.h b/src/devices/sound/digitalk.h index 053c9a60018..a169a9bebe8 100644 --- a/src/devices/sound/digitalk.h +++ b/src/devices/sound/digitalk.h @@ -29,7 +29,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void digitalker_write(uint8_t *adr, uint8_t vol, int8_t dac); diff --git a/src/devices/sound/disc_cls.h b/src/devices/sound/disc_cls.h index 6bd94631bde..2e301099b04 100644 --- a/src/devices/sound/disc_cls.h +++ b/src/devices/sound/disc_cls.h @@ -120,13 +120,14 @@ public: /* Add gain to the output and put into the buffers */ /* Clipping will be handled by the main sound system */ double val = DISCRETE_INPUT(0) * DISCRETE_INPUT(1); - m_outview->put(m_outview_sample++, val * (1.0 / 32768.0)); + m_stream->put(m_stream_output, m_outview_sample++, val * (1.0 / 32768.0)); } virtual int max_output() override { return 0; } - virtual void set_output_ptr(write_stream_view &view) override { m_outview = &view; m_outview_sample = 0; } + virtual void set_output_ptr(sound_stream &stream, int output) override { m_stream = &stream; m_stream_output = output; m_outview_sample = 0; } private: - write_stream_view *m_outview = nullptr; - u32 m_outview_sample = 0U; + sound_stream *m_stream = nullptr; + int m_stream_output = 0; + u32 m_outview_sample = 0U; }; DISCRETE_CLASS(dso_csvlog, 0, @@ -233,10 +234,9 @@ public: //protected: uint32_t m_stream_in_number = 0; - read_stream_view const *m_inview = nullptr; /* current in ptr for stream */ uint32_t m_inview_sample = 0; private: - void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs); + void stream_generate(sound_stream &stream); double m_gain = 0.0; /* node gain */ double m_offset = 0.0; /* node offset */ diff --git a/src/devices/sound/disc_inp.hxx b/src/devices/sound/disc_inp.hxx index 1c6c9a6dba5..51519169767 100644 --- a/src/devices/sound/disc_inp.hxx +++ b/src/devices/sound/disc_inp.hxx @@ -242,16 +242,16 @@ void DISCRETE_CLASS_FUNC(dss_input_pulse, input_write)(int sub_node, uint8_t dat #define DSS_INPUT_STREAM__GAIN DISCRETE_INPUT(1) #define DSS_INPUT_STREAM__OFFSET DISCRETE_INPUT(2) -void discrete_dss_input_stream_node::stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void discrete_dss_input_stream_node::stream_generate(sound_stream &stream) { - outputs[0].fill(m_data * (1.0 / 32768.0)); + stream.fill(0, m_data * (1.0 / 32768.0)); } DISCRETE_STEP(dss_input_stream) { /* the context pointer is set to point to the current input stream data in discrete_stream_update */ - if (EXPECTED(m_inview)) + if (EXPECTED(m_buffer_stream)) { - set_output(0, m_inview->get(m_inview_sample) * 32768.0 * m_gain + m_offset); + set_output(0, m_buffer_stream->get(m_stream_in_number, m_inview_sample) * 32768.0 * m_gain + m_offset); m_inview_sample++; } else @@ -260,7 +260,6 @@ DISCRETE_STEP(dss_input_stream) DISCRETE_RESET(dss_input_stream) { - m_inview = nullptr; m_data = 0; } @@ -300,7 +299,6 @@ DISCRETE_START(dss_input_stream) m_stream_in_number = DSS_INPUT_STREAM__STREAM; m_gain = DSS_INPUT_STREAM__GAIN; m_offset = DSS_INPUT_STREAM__OFFSET; - m_inview = nullptr; m_is_buffered = is_buffered(); m_buffer_stream = nullptr; @@ -316,6 +314,7 @@ void DISCRETE_CLASS_NAME(dss_input_stream)::stream_start(void) m_buffer_stream = m_device->machine().sound().stream_alloc(*snd_device, 0, 1, this->sample_rate(), stream_update_delegate(&discrete_dss_input_stream_node::stream_generate,this), STREAM_DEFAULT_FLAGS); - snd_device->get_stream()->set_input(m_stream_in_number, m_buffer_stream); + // WTF? + // snd_device->get_stream()->set_input(m_stream_in_number, m_buffer_stream); } } diff --git a/src/devices/sound/discrete.cpp b/src/devices/sound/discrete.cpp index ad5b89c8bd9..1a8b16602ac 100644 --- a/src/devices/sound/discrete.cpp +++ b/src/devices/sound/discrete.cpp @@ -1050,26 +1050,25 @@ void discrete_device::process(int samples) // our sound stream //------------------------------------------------- -void discrete_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void discrete_sound_device::sound_stream_update(sound_stream &stream) { int outputnum = 0; /* Setup any output streams */ for (discrete_sound_output_interface *node : m_output_list) { - node->set_output_ptr(outputs[outputnum]); + node->set_output_ptr(stream, outputnum); outputnum++; } /* Setup any input streams */ for (discrete_dss_input_stream_node *node : m_input_stream_list) { - node->m_inview = &inputs[node->m_stream_in_number]; node->m_inview_sample = 0; } /* just process it */ - process(outputs[0].samples()); + process(stream.samples()); } //------------------------------------------------- diff --git a/src/devices/sound/discrete.h b/src/devices/sound/discrete.h index 5a850ffc340..aa90b83b3f9 100644 --- a/src/devices/sound/discrete.h +++ b/src/devices/sound/discrete.h @@ -4164,7 +4164,7 @@ class discrete_sound_output_interface public: virtual ~discrete_sound_output_interface() { } - virtual void set_output_ptr(write_stream_view &view) = 0; + virtual void set_output_ptr(sound_stream &stream, int output) = 0; }; //************************************************************************** @@ -4305,7 +4305,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: typedef std::vector<discrete_dss_input_stream_node *> istream_node_list_t; diff --git a/src/devices/sound/dmadac.cpp b/src/devices/sound/dmadac.cpp index ae2ebce61ad..e1e937069b6 100644 --- a/src/devices/sound/dmadac.cpp +++ b/src/devices/sound/dmadac.cpp @@ -158,7 +158,7 @@ void dmadac_set_volume(dmadac_sound_device **devlist, uint8_t num_channels, uint void dmadac_sound_device::set_volume(uint16_t volume) { m_channel->update(); - m_volume = stream_buffer::sample_t(volume) * (1.0 / 256.0); + m_volume = sound_stream::sample_t(volume) * (1.0 / 256.0); } DEFINE_DEVICE_TYPE(DMADAC, dmadac_sound_device, "dmadac", "DMA-driven DAC") @@ -178,23 +178,19 @@ dmadac_sound_device::dmadac_sound_device(const machine_config &mconfig, const ch // sound_stream_update - handle a stream update //------------------------------------------------- -void dmadac_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dmadac_sound_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; uint32_t curout = m_bufout; uint32_t curin = m_bufin; - /* feed as much as we can */ + /* feed as much as we can, leave the rest as silence */ int sampindex; - for (sampindex = 0; curout != curin && sampindex < output.samples(); sampindex++) + for (sampindex = 0; curout != curin && sampindex < stream.samples(); sampindex++) { - output.put(sampindex, stream_buffer::sample_t(m_buffer[curout]) * m_volume); + stream.put(0, sampindex, sound_stream::sample_t(m_buffer[curout]) * m_volume); curout = (curout + 1) % BUFFER_SIZE; } - /* fill the rest with silence */ - output.fill(0, sampindex); - /* save the new output pointer */ m_bufout = curout; } diff --git a/src/devices/sound/dmadac.h b/src/devices/sound/dmadac.h index d221a7575e4..c05e967b59a 100644 --- a/src/devices/sound/dmadac.h +++ b/src/devices/sound/dmadac.h @@ -24,7 +24,7 @@ public: template <typename T> void transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, T* data) { int j; - constexpr stream_buffer::sample_t sample_scale = 1.0 / double(std::numeric_limits<T>::max()); + constexpr sound_stream::sample_t sample_scale = 1.0 / double(std::numeric_limits<T>::max()); if (m_enabled) { @@ -35,7 +35,7 @@ public: /* copy the data */ for (j = 0; j < total_frames && curin != maxin; j++) { - m_buffer[curin] = stream_buffer::sample_t(*src) * sample_scale; + m_buffer[curin] = sound_stream::sample_t(*src) * sample_scale; curin = (curin + 1) % BUFFER_SIZE; src += frame_spacing; } @@ -56,18 +56,18 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state /* sound stream and buffers */ sound_stream * m_channel; - std::vector<stream_buffer::sample_t> m_buffer; + std::vector<sound_stream::sample_t> m_buffer; uint32_t m_bufin; uint32_t m_bufout; /* per-channel parameters */ - stream_buffer::sample_t m_volume; + sound_stream::sample_t m_volume; uint8_t m_enabled; static constexpr int BUFFER_SIZE = 32768; diff --git a/src/devices/sound/dspv.cpp b/src/devices/sound/dspv.cpp index 9877cee3fb1..9ced7ba9ceb 100644 --- a/src/devices/sound/dspv.cpp +++ b/src/devices/sound/dspv.cpp @@ -113,9 +113,8 @@ void dspv_device::snd_w(offs_t offset, u16 data) logerror("w %02x, %04x %s\n", offset, data, machine().describe_context()); } -void dspv_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dspv_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } void dspv_device::device_start() diff --git a/src/devices/sound/dspv.h b/src/devices/sound/dspv.h index defc5343b32..ec6dab50c46 100644 --- a/src/devices/sound/dspv.h +++ b/src/devices/sound/dspv.h @@ -28,7 +28,7 @@ protected: virtual void state_export(const device_state_entry &entry) override; virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; virtual std::unique_ptr<util::disasm_interface> create_disassembler() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: address_space_config m_prg1_config, m_prg2_config, m_data_config; diff --git a/src/devices/sound/es1373.cpp b/src/devices/sound/es1373.cpp index 5ce753da4a7..c3b88ecac49 100644 --- a/src/devices/sound/es1373.cpp +++ b/src/devices/sound/es1373.cpp @@ -80,8 +80,7 @@ void es1373_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } DEFINE_DEVICE_TYPE(ES1373, es1373_device, "es1373", "Creative Labs Ensoniq AudioPCI97 ES1373") @@ -211,24 +210,21 @@ TIMER_CALLBACK_MEMBER(es1373_device::delayed_stream_update) // sound_stream_update - handle update requests for // our sound stream //------------------------------------------------- -void es1373_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void es1373_device::sound_stream_update(sound_stream &stream) { if (m_dac1.enable) { LOGMASKED(LOG_UNIMPL, "%s: sound_stream_update DAC1 not implemented yet\n", tag()); } if (m_dac2.enable) { - send_audio_out(m_dac2, ICSTATUS_DAC2_INT_MASK, outputs[0], outputs[1]); - } else { - outputs[0].fill(0); - outputs[1].fill(0); + send_audio_out(m_dac2, ICSTATUS_DAC2_INT_MASK, stream); } if (m_adc.enable) { if (m_adc.format!=SCTRL_16BIT_MONO) { LOGMASKED(LOG_UNIMPL, "%s: sound_stream_update Only SCTRL_16BIT_MONO recorded supported\n", tag()); } else { - for (int i=0; i<outputs[0].samples(); i++) { + for (int i=0; i<stream.samples(); i++) { if (m_adc.buf_count<=m_adc.buf_size) { LOGMASKED(LOG_OTHER, "%s: ADC buf_count: %i buf_size: %i buf_rptr: %i buf_wptr: %i\n", machine().describe_context(), m_adc.buf_count, m_adc.buf_size, m_adc.buf_rptr, m_adc.buf_wptr); @@ -270,7 +266,7 @@ void es1373_device::sound_stream_update(sound_stream &stream, std::vector<read_s //------------------------------------------------- // send_audio_out - Sends channel audio output data //------------------------------------------------- -void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_stream_view &outL, write_stream_view &outR) +void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, sound_stream &stream) { // Only transfer PCI data if bus mastering is enabled // Fill initial half buffer @@ -281,7 +277,7 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_st //uint32_t sample_size = calc_size(chan.format); // Send data to sound stream bool buf_row_done; - for (int i=0; i<outL.samples(); i++) { + for (int i=0; i<stream.samples(); i++) { buf_row_done = false; int16_t lsamp = 0, rsamp = 0; if (chan.buf_count<=chan.buf_size) { @@ -293,7 +289,7 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_st } if (i == 0) LOGMASKED(LOG_OTHER, "%s: chan: %X samples: %i buf_count: %X buf_size: %X buf_rptr: %X buf_wptr: %X\n", - machine().describe_context(), chan.number, outL.samples(), chan.buf_count, chan.buf_size, chan.buf_rptr, chan.buf_wptr); + machine().describe_context(), chan.number, stream.samples(), chan.buf_count, chan.buf_size, chan.buf_rptr, chan.buf_wptr); // Buffer is 4 bytes per location, need to switch on sample mode switch (chan.format) { case SCTRL_8BIT_MONO: @@ -340,8 +336,8 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_st chan.buf_rptr -= 0x10; } } - outL.put_int(i, lsamp, 32768); - outR.put_int(i, rsamp, 32768); + stream.put_int(0, i, lsamp, 32768); + stream.put_int(1, i, rsamp, 32768); } } diff --git a/src/devices/sound/es1373.h b/src/devices/sound/es1373.h index 054a62901a3..b1c7739dde7 100644 --- a/src/devices/sound/es1373.h +++ b/src/devices/sound/es1373.h @@ -26,7 +26,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual void device_post_load() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update); @@ -52,7 +52,7 @@ private: void transfer_pci_audio(chan_info& chan, int type); uint32_t calc_size(const uint8_t &format); - void send_audio_out(chan_info& chan, uint32_t intr_mask, write_stream_view &outL, write_stream_view &outR); + void send_audio_out(chan_info& chan, uint32_t intr_mask, sound_stream &stream); emu_timer *m_timer; address_space *m_memory_space; diff --git a/src/devices/sound/es5503.cpp b/src/devices/sound/es5503.cpp index fc23656d36b..d4d05545852 100644 --- a/src/devices/sound/es5503.cpp +++ b/src/devices/sound/es5503.cpp @@ -152,12 +152,12 @@ void es5503_device::halt_osc(int onum, int type, uint32_t *accumulator, int ress m_irq_func(1); } } -void es5503_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void es5503_device::sound_stream_update(sound_stream &stream) { int32_t *mixp; int osc, snum, i; uint32_t ramptr; - int samples = outputs[0].samples(); + int samples = stream.samples(); assert(samples < (44100/50)); std::fill_n(&m_mix_buffer[0], samples*output_channels, 0); @@ -257,9 +257,9 @@ void es5503_device::sound_stream_update(sound_stream &stream, std::vector<read_s mixp = &m_mix_buffer[0]; for (int chan = 0; chan < output_channels; chan++) { - for (i = 0; i < outputs[chan].samples(); i++) + for (i = 0; i < stream.samples(); i++) { - outputs[chan].put_int(i, *mixp++, 32768*8); + stream.put_int(chan, i, *mixp++, 32768*8); } } } diff --git a/src/devices/sound/es5503.h b/src/devices/sound/es5503.h index ef22d476b42..e04d5018409 100644 --- a/src/devices/sound/es5503.h +++ b/src/devices/sound/es5503.h @@ -35,7 +35,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/es5506.cpp b/src/devices/sound/es5506.cpp index bc7412619f2..455c991b94b 100644 --- a/src/devices/sound/es5506.cpp +++ b/src/devices/sound/es5506.cpp @@ -1009,10 +1009,10 @@ inline void es550x_device::generate_irq(es550x_voice *voice, int v) ***********************************************************************************************/ -void es5506_device::generate_samples(std::vector<write_stream_view> &outputs) +void es5506_device::generate_samples(sound_stream &stream) { // loop while we still have samples to generate - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // loop over voices s32 cursample[12] = { 0 }; @@ -1038,15 +1038,15 @@ void es5506_device::generate_samples(std::vector<write_stream_view> &outputs) generate_irq(voice, v); } - for (int c = 0; c < outputs.size(); c++) - outputs[c].put_int(sampindex, cursample[c], 32768); + for (int c = 0; c < stream.output_count(); c++) + stream.put_int(c, sampindex, cursample[c], 32768); } } -void es5505_device::generate_samples(std::vector<write_stream_view> &outputs) +void es5505_device::generate_samples(sound_stream &stream) { // loop while we still have samples to generate - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // loop over voices s32 cursample[12] = { 0 }; @@ -1076,8 +1076,8 @@ void es5505_device::generate_samples(std::vector<write_stream_view> &outputs) generate_irq(voice, v); } - for (int c = 0; c < outputs.size(); c++) - outputs[c].put_int(sampindex, cursample[c], 32768); + for (int c = 0; c < stream.output_count(); c++) + stream.put_int(c, sampindex, cursample[c], 32768); } } @@ -2091,7 +2091,7 @@ u16 es5505_device::read(offs_t offset) // sound_stream_update - handle a stream update //------------------------------------------------- -void es550x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void es550x_device::sound_stream_update(sound_stream &stream) { #if ES5506_MAKE_WAVS // start the logging once we have a sample rate @@ -2103,7 +2103,7 @@ void es550x_device::sound_stream_update(sound_stream &stream, std::vector<read_s #endif // loop until all samples are output - generate_samples(outputs); + generate_samples(stream); #if ES5506_MAKE_WAVS // log the raw data diff --git a/src/devices/sound/es5506.h b/src/devices/sound/es5506.h index cb4279165af..372849f0ddb 100644 --- a/src/devices/sound/es5506.h +++ b/src/devices/sound/es5506.h @@ -84,7 +84,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void update_irq_state(); void update_internal_irq_state(); @@ -114,7 +114,7 @@ protected: void generate_ulaw(es550x_voice *voice, s32 *dest); void generate_pcm(es550x_voice *voice, s32 *dest); inline void generate_irq(es550x_voice *voice, int v); - virtual void generate_samples(std::vector<write_stream_view> &outputs) {} + virtual void generate_samples(sound_stream &stream) {} inline void update_index(es550x_voice *voice) { m_voice_index = voice->index; } virtual inline u16 read_sample(es550x_voice *voice, offs_t addr) { return 0; } @@ -189,7 +189,7 @@ protected: virtual void update_envelopes(es550x_voice *voice) override; virtual void check_for_end_forward(es550x_voice *voice, u64 &accum) override; virtual void check_for_end_reverse(es550x_voice *voice, u64 &accum) override; - virtual void generate_samples(std::vector<write_stream_view> &outputs) override; + virtual void generate_samples(sound_stream &stream) override; virtual inline u16 read_sample(es550x_voice *voice, offs_t addr) override { update_index(voice); return m_cache[get_bank(voice->control)].read_word(addr); } @@ -243,7 +243,7 @@ protected: virtual void update_envelopes(es550x_voice *voice) override; virtual void check_for_end_forward(es550x_voice *voice, u64 &accum) override; virtual void check_for_end_reverse(es550x_voice *voice, u64 &accum) override; - virtual void generate_samples(std::vector<write_stream_view> &outputs) override; + virtual void generate_samples(sound_stream &stream) override; virtual inline u16 read_sample(es550x_voice *voice, offs_t addr) override { update_index(voice); return m_cache[get_bank(voice->control)].read_word(addr); } diff --git a/src/devices/sound/esqpump.cpp b/src/devices/sound/esqpump.cpp index af1a59db799..cda48b68eb0 100644 --- a/src/devices/sound/esqpump.cpp +++ b/src/devices/sound/esqpump.cpp @@ -53,26 +53,22 @@ void esq_5505_5510_pump_device::device_clock_changed() m_stream->set_sample_rate(clock()); } -void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream) { - sound_assert(outputs[0].samples() == 1); - - auto &left = outputs[0]; - auto &right = outputs[1]; #define SAMPLE_SHIFT 4 - constexpr stream_buffer::sample_t input_scale = 32768.0 / (1 << SAMPLE_SHIFT); + constexpr sound_stream::sample_t input_scale = 32768.0 / (1 << SAMPLE_SHIFT); // anything for the 'aux' output? - stream_buffer::sample_t l = inputs[0].get(0) * (1.0 / (1 << SAMPLE_SHIFT)); - stream_buffer::sample_t r = inputs[1].get(0) * (1.0 / (1 << SAMPLE_SHIFT)); + sound_stream::sample_t l = stream.get(0, 0) * (1.0 / (1 << SAMPLE_SHIFT)); + sound_stream::sample_t r = stream.get(1, 0) * (1.0 / (1 << SAMPLE_SHIFT)); // push the samples into the ESP - m_esp->ser_w(0, s32(inputs[2].get(0) * input_scale)); - m_esp->ser_w(1, s32(inputs[3].get(0) * input_scale)); - m_esp->ser_w(2, s32(inputs[4].get(0) * input_scale)); - m_esp->ser_w(3, s32(inputs[5].get(0) * input_scale)); - m_esp->ser_w(4, s32(inputs[6].get(0) * input_scale)); - m_esp->ser_w(5, s32(inputs[7].get(0) * input_scale)); + m_esp->ser_w(0, s32(stream.get(2, 0) * input_scale)); + m_esp->ser_w(1, s32(stream.get(3, 0) * input_scale)); + m_esp->ser_w(2, s32(stream.get(4, 0) * input_scale)); + m_esp->ser_w(3, s32(stream.get(5, 0) * input_scale)); + m_esp->ser_w(4, s32(stream.get(6, 0) * input_scale)); + m_esp->ser_w(5, s32(stream.get(7, 0) * input_scale)); #if PUMP_FAKE_ESP_PROCESSING m_esp->ser_w(6, m_esp->ser_r(0) + m_esp->ser_r(2) + m_esp->ser_r(4)); @@ -88,16 +84,16 @@ void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream, std::v #endif // read the processed result from the ESP and add to the saved AUX data - stream_buffer::sample_t ll = stream_buffer::sample_t(m_esp->ser_r(6)) * (1.0 / 32768.0); - stream_buffer::sample_t rr = stream_buffer::sample_t(m_esp->ser_r(7)) * (1.0 / 32768.0); + sound_stream::sample_t ll = sound_stream::sample_t(m_esp->ser_r(6)) * (1.0 / 32768.0); + sound_stream::sample_t rr = sound_stream::sample_t(m_esp->ser_r(7)) * (1.0 / 32768.0); l += ll; r += rr; #if !PUMP_FAKE_ESP_PROCESSING && PUMP_REPLACE_ESP_PROGRAM // if we're processing the fake program through the ESP, the result should just be that of adding the inputs - stream_buffer::sample_t el = (inputs[2].get(0)) + (inputs[4].get(0)) + (inputs[6].get(0)); - stream_buffer::sample_t er = (inputs[3].get(0)) + (inputs[5].get(0)) + (inputs[7].get(0)); - stream_buffer::sample_t e_next = el + er; + sound_stream::sample_t el = (stream.get(2, 0)) + (stream.get(4, 0)) + (stream.get(6, 0)); + sound_stream::sample_t er = (stream.get(3, 0)) + (stream.get(5, 0)) + (stream.get(7, 0)); + sound_stream::sample_t e_next = el + er; e[(ei + 0x1d0f) % 0x4000] = e_next; if (fabs(l - e[ei]) > 1e-5) { @@ -107,8 +103,8 @@ void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream, std::v #endif // write the combined data to the output - left.put(0, l); - right.put(0, r); + stream.put(0, 0, l); + stream.put(1, 0, r); #if PUMP_DETECT_SILENCE if (left.get(0) == 0 && right.get(0) == 0) { diff --git a/src/devices/sound/esqpump.h b/src/devices/sound/esqpump.h index dfbfe477770..e6257c1c977 100644 --- a/src/devices/sound/esqpump.h +++ b/src/devices/sound/esqpump.h @@ -73,7 +73,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state: @@ -103,7 +103,7 @@ private: #endif #if !PUMP_FAKE_ESP_PROCESSING && PUMP_REPLACE_ESP_PROGRAM - std::vector<stream_buffer::sample_t> e; + std::vector<sound_stream::sample_t> e; int ei; #endif }; diff --git a/src/devices/sound/flt_biquad.cpp b/src/devices/sound/flt_biquad.cpp index de6bfe63462..6960f48c14b 100644 --- a/src/devices/sound/flt_biquad.cpp +++ b/src/devices/sound/flt_biquad.cpp @@ -474,22 +474,19 @@ void filter_biquad_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void filter_biquad_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void filter_biquad_device::sound_stream_update(sound_stream &stream) { - auto &src = inputs[0]; - auto &dst = outputs[0]; - - if (m_last_sample_rate != m_stream->sample_rate()) + if (m_last_sample_rate != stream.sample_rate()) { recalc(); - m_last_sample_rate = m_stream->sample_rate(); + m_last_sample_rate = stream.sample_rate(); } - for (int sampindex = 0; sampindex < dst.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - m_input = src.get(sampindex); + m_input = stream.get(0, sampindex); step(); - dst.put(sampindex, m_output); + stream.put(0, sampindex, m_output); } } diff --git a/src/devices/sound/flt_biquad.h b/src/devices/sound/flt_biquad.h index ad58a91de79..6f70a91280d 100644 --- a/src/devices/sound/flt_biquad.h +++ b/src/devices/sound/flt_biquad.h @@ -87,7 +87,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void recalc(); @@ -100,9 +100,9 @@ private: double m_q; double m_gain; - stream_buffer::sample_t m_input; + sound_stream::sample_t m_input; double m_w0, m_w1, m_w2; /* w[k], w[k-1], w[k-2], current and previous intermediate values */ - stream_buffer::sample_t m_output; + sound_stream::sample_t m_output; double m_a1, m_a2; /* digital filter coefficients, denominator */ double m_b0, m_b1, m_b2; /* digital filter coefficients, numerator */ }; diff --git a/src/devices/sound/flt_rc.cpp b/src/devices/sound/flt_rc.cpp index 489cb01fb07..2a14aaabbd3 100644 --- a/src/devices/sound/flt_rc.cpp +++ b/src/devices/sound/flt_rc.cpp @@ -55,34 +55,32 @@ void filter_rc_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void filter_rc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void filter_rc_device::sound_stream_update(sound_stream &stream) { - auto &src = inputs[0]; - auto &dst = outputs[0]; - stream_buffer::sample_t memory = m_memory; + sound_stream::sample_t memory = m_memory; - if (m_last_sample_rate != m_stream->sample_rate()) + if (m_last_sample_rate != stream.sample_rate()) { recalc(); - m_last_sample_rate = m_stream->sample_rate(); + m_last_sample_rate = stream.sample_rate(); } switch (m_type) { case LOWPASS_3R: case LOWPASS: - for (int sampindex = 0; sampindex < dst.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - memory += (src.get(sampindex) - memory) * m_k; - dst.put(sampindex, memory); + memory += (stream.get(0, sampindex) - memory) * m_k; + stream.put(0, sampindex, memory); } break; case HIGHPASS: case AC: - for (int sampindex = 0; sampindex < dst.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - dst.put(sampindex, src.get(sampindex) - memory); - memory += (src.get(sampindex) - memory) * m_k; + stream.put(0, sampindex, stream.get(0, sampindex) - memory); + memory += (stream.get(0, sampindex) - memory) * m_k; } break; } diff --git a/src/devices/sound/flt_rc.h b/src/devices/sound/flt_rc.h index 9230da69a49..daabe4c11c7 100644 --- a/src/devices/sound/flt_rc.h +++ b/src/devices/sound/flt_rc.h @@ -110,15 +110,15 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void recalc(); private: sound_stream* m_stream; - stream_buffer::sample_t m_k; - stream_buffer::sample_t m_memory; + sound_stream::sample_t m_k; + sound_stream::sample_t m_memory; int m_type; int m_last_sample_rate; double m_R1; diff --git a/src/devices/sound/flt_vol.cpp b/src/devices/sound/flt_vol.cpp index d5d92209cac..c3f8b5f0b2e 100644 --- a/src/devices/sound/flt_vol.cpp +++ b/src/devices/sound/flt_vol.cpp @@ -35,10 +35,10 @@ void filter_volume_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void filter_volume_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void filter_volume_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, inputs[0].get(i) * m_gain); + for (int i = 0; i < stream.samples(); i++) + stream.put(0, i, stream.get(0, i) * m_gain); } diff --git a/src/devices/sound/flt_vol.h b/src/devices/sound/flt_vol.h index 2e2d665f257..96bc61af200 100644 --- a/src/devices/sound/flt_vol.h +++ b/src/devices/sound/flt_vol.h @@ -25,7 +25,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream* m_stream; diff --git a/src/devices/sound/gaelco.cpp b/src/devices/sound/gaelco.cpp index 2c04678ff62..e40f35d1e7c 100644 --- a/src/devices/sound/gaelco.cpp +++ b/src/devices/sound/gaelco.cpp @@ -77,10 +77,10 @@ gaelco_gae1_device::gaelco_gae1_device(const machine_config &mconfig, device_typ Writes length bytes to the sound buffer ============================================================================*/ -void gaelco_gae1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gaelco_gae1_device::sound_stream_update(sound_stream &stream) { /* fill all data needed */ - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { int output_l = 0, output_r = 0; @@ -178,8 +178,8 @@ void gaelco_gae1_device::sound_stream_update(sound_stream &stream, std::vector<r #endif /* now that we have computed all channels, save current data to the output buffer */ - outputs[0].put_int(j, output_l, 32768); - outputs[1].put_int(j, output_r, 32768); + stream.put_int(0, j, output_l, 32768); + stream.put_int(1, j, output_r, 32768); } // if (wavraw) diff --git a/src/devices/sound/gaelco.h b/src/devices/sound/gaelco.h index 2fff2ca4bee..014472d73f9 100644 --- a/src/devices/sound/gaelco.h +++ b/src/devices/sound/gaelco.h @@ -43,7 +43,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/gb.cpp b/src/devices/sound/gb.cpp index 6a683a21313..e542f580fe6 100644 --- a/src/devices/sound/gb.cpp +++ b/src/devices/sound/gb.cpp @@ -1313,11 +1313,9 @@ void cgb04_apu_device::apu_power_off() // sound_stream_update - handle a stream update //------------------------------------------------- -void gameboy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gameboy_sound_device::sound_stream_update(sound_stream &stream) { - auto &outputl = outputs[0]; - auto &outputr = outputs[1]; - for (int sampindex = 0; sampindex < outputl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { s32 sample; s32 left = 0; @@ -1369,7 +1367,7 @@ void gameboy_sound_device::sound_stream_update(sound_stream &stream, std::vector right *= m_snd_control.vol_right; /* Update the buffers */ - outputl.put_int(sampindex, left, 32768 / 64); - outputr.put_int(sampindex, right, 32768 / 64); + stream.put_int(0, sampindex, left, 32768 / 64); + stream.put_int(1, sampindex, right, 32768 / 64); } } diff --git a/src/devices/sound/gb.h b/src/devices/sound/gb.h index be5f12fb324..ce1f1a75a88 100644 --- a/src/devices/sound/gb.h +++ b/src/devices/sound/gb.h @@ -27,7 +27,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; protected: enum diff --git a/src/devices/sound/gew.cpp b/src/devices/sound/gew.cpp index c9d3ea3e500..274acbc2494 100644 --- a/src/devices/sound/gew.cpp +++ b/src/devices/sound/gew.cpp @@ -543,9 +543,9 @@ void gew_pcm_device::dump_sample(slot_t &slot) // sound_stream_update - handle a stream update //------------------------------------------------- -void gew_pcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gew_pcm_device::sound_stream_update(sound_stream &stream) { - for (int32_t i = 0; i < outputs[0].samples(); ++i) + for (int32_t i = 0; i < stream.samples(); ++i) { int32_t smpl = 0; int32_t smpr = 0; @@ -624,8 +624,8 @@ void gew_pcm_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - outputs[0].put_int_clamp(i, smpl, 32768); - outputs[1].put_int_clamp(i, smpr, 32768); + stream.put_int_clamp(0, i, smpl, 32768); + stream.put_int_clamp(1, i, smpr, 32768); } } diff --git a/src/devices/sound/gew.h b/src/devices/sound/gew.h index ddee760d461..233a02227c5 100644 --- a/src/devices/sound/gew.h +++ b/src/devices/sound/gew.h @@ -29,7 +29,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/gt155.cpp b/src/devices/sound/gt155.cpp index 61faf1ac1e6..bdd71a074c5 100644 --- a/src/devices/sound/gt155.cpp +++ b/src/devices/sound/gt155.cpp @@ -93,9 +93,9 @@ void gt155_device::device_clock_changed() } /**************************************************************************/ -void gt155_device::sound_stream_update(sound_stream& stream, std::vector<read_stream_view> const& inputs, std::vector<write_stream_view>& outputs) +void gt155_device::sound_stream_update(sound_stream& stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s64 left = 0, right = 0; @@ -108,8 +108,8 @@ void gt155_device::sound_stream_update(sound_stream& stream, std::vector<read_st } } - outputs[0].put_int_clamp(i, left >> 11, 32678); - outputs[1].put_int_clamp(i, right >> 11, 32768); + stream.put_int_clamp(0, i, left >> 11, 32678); + stream.put_int_clamp(1, i, right >> 11, 32768); } } diff --git a/src/devices/sound/gt155.h b/src/devices/sound/gt155.h index 69dbe91121e..319ec1c2661 100644 --- a/src/devices/sound/gt155.h +++ b/src/devices/sound/gt155.h @@ -36,7 +36,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/hc55516.cpp b/src/devices/sound/hc55516.cpp index 885751c1a6a..0bd36ae381f 100644 --- a/src/devices/sound/hc55516.cpp +++ b/src/devices/sound/hc55516.cpp @@ -197,15 +197,12 @@ void cvsd_device_base::process_bit(bool bit, bool clock_state) // sound_stream_update - handle a stream update //------------------------------------------------- -void cvsd_device_base::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cvsd_device_base::sound_stream_update(sound_stream &stream) { // Stub, just return silence - auto &buffer = outputs[0]; - - m_samples_generated += buffer.samples(); + m_samples_generated += stream.samples(); if (m_samples_generated >= SAMPLE_RATE) m_samples_generated -= SAMPLE_RATE; - buffer.fill(0); } @@ -356,16 +353,14 @@ void hc55516_device::process_bit(bool bit, bool clock_state) // sound_stream_update_legacy - handle a stream update //------------------------------------------------- -void hc55516_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void hc55516_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (is_external_oscillator()) { // external oscillator - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - buffer.put_int(i, m_next_sample, 32768); + stream.put_int(0, i, m_next_sample, 32768); m_samples_generated++; @@ -384,8 +379,8 @@ void hc55516_device::sound_stream_update(sound_stream &stream, std::vector<read_ // software driven clock else { - for (int i = 0; i < buffer.samples(); i++) - buffer.put_int(i, m_next_sample, 32768); + for (int i = 0; i < stream.samples(); i++) + stream.put_int(0, i, m_next_sample, 32768); } } @@ -493,14 +488,12 @@ void mc3417_device::process_bit(bool bit, bool clock_state) } } -void mc3417_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mc3417_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (!is_external_oscillator()) { // track how many samples we've updated without a clock; if it's been more than 1/32 of a second, output silence - m_samples_generated += buffer.samples(); + m_samples_generated += stream.samples(); if (m_samples_generated > SAMPLE_RATE / 32) { m_samples_generated = SAMPLE_RATE; @@ -509,16 +502,16 @@ void mc3417_device::sound_stream_update(sound_stream &stream, std::vector<read_s } // compute the interpolation slope - stream_buffer::sample_t sample = m_curr_sample; - stream_buffer::sample_t slope = (m_next_sample - sample) / buffer.samples(); + sound_stream::sample_t sample = m_curr_sample; + sound_stream::sample_t slope = (m_next_sample - sample) / stream.samples(); m_curr_sample = m_next_sample; if (is_external_oscillator()) { // external oscillator - for (int i = 0; i < buffer.samples(); i++, sample += slope) + for (int i = 0; i < stream.samples(); i++, sample += slope) { - buffer.put(i, sample); + stream.put(0, i, sample); m_samples_generated++; @@ -537,8 +530,8 @@ void mc3417_device::sound_stream_update(sound_stream &stream, std::vector<read_s // software driven clock else { - for (int i = 0; i < buffer.samples(); i++, sample += slope) - buffer.put(i, sample); + for (int i = 0; i < stream.samples(); i++, sample += slope) + stream.put(0, i, sample); } } diff --git a/src/devices/sound/hc55516.h b/src/devices/sound/hc55516.h index 9862e489b3f..ac1a56bf739 100644 --- a/src/devices/sound/hc55516.h +++ b/src/devices/sound/hc55516.h @@ -52,7 +52,7 @@ public: // Audio In pin, an analog value of the audio waveform being pushed to the chip. // TODO: this is not hooked up or implemented yet, and this should really be handled as an // input stream from a separate DAC device, not a value push function at all. - //void audio_in_w(stream_buffer::sample_t data); + //void audio_in_w(sound_stream::sample_t data); // sets the buffered digit (0 or 1), common to all chips. TODO: replace all use of this with // digin_cb once implemented @@ -74,7 +74,7 @@ protected: //virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // callbacks devcb_write_line m_clock_state_push_cb; // TODO: get rid of this, if you use it you should feel bad @@ -129,7 +129,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // callbacks devcb_write_line m_agc_push_cb; @@ -179,7 +179,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // const coefficients defined by constructor; should these be adjustable by the user or externally defined, // as they are implemented using a set of two small lowpass filters outside the chip? @@ -190,8 +190,8 @@ protected: // internal state double m_sylfilter; double m_intfilter; - stream_buffer::sample_t m_curr_sample; - stream_buffer::sample_t m_next_sample; + sound_stream::sample_t m_curr_sample; + sound_stream::sample_t m_next_sample; // internal handlers virtual void process_bit(bool bit, bool clock_state) override; diff --git a/src/devices/sound/huc6230.cpp b/src/devices/sound/huc6230.cpp index ba969479cf2..33e59309f2b 100644 --- a/src/devices/sound/huc6230.cpp +++ b/src/devices/sound/huc6230.cpp @@ -19,16 +19,16 @@ #include "huc6230.h" -void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void huc6230_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { // TODO: this implies to read from the PSG inputs // doesn't seem right at all, eventually causes extreme DC offset on BIOS main menu, // possibly because adpcm_timer runs from a different thread, // needs to be rechecked once we have better examples ... - s32 samp0 = inputs[0].get(i) * 32768.0; - s32 samp1 = inputs[1].get(i) * 32768.0; + s32 samp0 = stream.get(0, i) * 32768.0; + s32 samp1 = stream.get(1, i) * 32768.0; for (int adpcm = 0; adpcm < 2; adpcm++) { @@ -42,8 +42,8 @@ void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_ samp1 = std::clamp(samp1 + ((channel->m_output * channel->m_rvol) >> 4), -32768, 32767); } - outputs[0].put_int(i, samp0, 32768); - outputs[1].put_int(i, samp1, 32768); + stream.put_int(0, i, samp0, 32768); + stream.put_int(1, i, samp1, 32768); } } diff --git a/src/devices/sound/huc6230.h b/src/devices/sound/huc6230.h index f71e746190c..4c0ba5dea0b 100644 --- a/src/devices/sound/huc6230.h +++ b/src/devices/sound/huc6230.h @@ -28,7 +28,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct adpcm_channel { diff --git a/src/devices/sound/i5000.cpp b/src/devices/sound/i5000.cpp index 3f194ef74c5..9c599651925 100644 --- a/src/devices/sound/i5000.cpp +++ b/src/devices/sound/i5000.cpp @@ -114,9 +114,9 @@ bool i5000snd_device::read_sample(int ch) } -void i5000snd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void i5000snd_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int32_t mix_l = 0; int32_t mix_r = 0; @@ -157,8 +157,8 @@ void i5000snd_device::sound_stream_update(sound_stream &stream, std::vector<read mix_l += m_channels[ch].output_l; } - outputs[0].put_int(i, mix_r, 32768 * 16); - outputs[1].put_int(i, mix_l, 32768 * 16); + stream.put_int(0, i, mix_r, 32768 * 16); + stream.put_int(1, i, mix_l, 32768 * 16); } } diff --git a/src/devices/sound/i5000.h b/src/devices/sound/i5000.h index 2769b58520c..7012e45cc5e 100644 --- a/src/devices/sound/i5000.h +++ b/src/devices/sound/i5000.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; sound_stream *m_stream; diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp index 2e93ab5b1da..521b1de28ff 100644 --- a/src/devices/sound/ics2115.cpp +++ b/src/devices/sound/ics2115.cpp @@ -422,13 +422,13 @@ void ics2115_device::ics2115_voice::update_ramp() } } -int ics2115_device::fill_output(ics2115_voice& voice, std::vector<write_stream_view> &outputs) +int ics2115_device::fill_output(ics2115_voice& voice, sound_stream &stream) { bool irq_invalid = false; const u16 fine = 1 << (3*(voice.vol.incr >> 6)); voice.vol.add = (voice.vol.incr & 0x3f)<< (10 - fine); - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { constexpr int RAMP_SHIFT = 6; const u32 volacc = (voice.vol.acc >> 14) & 0xfff; @@ -449,8 +449,8 @@ int ics2115_device::fill_output(ics2115_voice& voice, std::vector<write_stream_v //if (voice.playing()) if (!m_vmode || voice.playing()) { - outputs[0].add_int(i, (sample * vleft) >> (5 + volume_bits), 32768); - outputs[1].add_int(i, (sample * vright) >> (5 + volume_bits), 32768); + stream.add_int(0, i, (sample * vleft) >> (5 + volume_bits), 32768); + stream.add_int(1, i, (sample * vright) >> (5 + volume_bits), 32768); } voice.update_ramp(); @@ -465,11 +465,8 @@ int ics2115_device::fill_output(ics2115_voice& voice, std::vector<write_stream_v return irq_invalid; } -void ics2115_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ics2115_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - bool irq_invalid = false; for (int osc = 0; osc <= m_active_osc; osc++) { @@ -486,7 +483,7 @@ void ics2115_device::sound_stream_update(sound_stream &stream, std::vector<read_ logerror("[%06x=%04x]", curaddr, (s16)sample); #endif */ - if (fill_output(voice, outputs)) + if (fill_output(voice, stream)) irq_invalid = true; #ifdef ICS2115_DEBUG diff --git a/src/devices/sound/ics2115.h b/src/devices/sound/ics2115.h index a02a28075e3..8e99180ca53 100644 --- a/src/devices/sound/ics2115.h +++ b/src/devices/sound/ics2115.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; @@ -119,7 +119,7 @@ private: void recalc_irq(); // stream helper functions - int fill_output(ics2115_voice& voice, std::vector<write_stream_view> &outputs); + int fill_output(ics2115_voice& voice, sound_stream &stream); s32 get_sample(ics2115_voice& voice); u8 read_sample(ics2115_voice& voice, u32 addr) { return m_cache.read_byte((voice.osc.saddr << 20) | (addr & 0xfffff)); } diff --git a/src/devices/sound/iopspu.cpp b/src/devices/sound/iopspu.cpp index 55e6cd3b789..785d9a4f43b 100644 --- a/src/devices/sound/iopspu.cpp +++ b/src/devices/sound/iopspu.cpp @@ -89,10 +89,9 @@ void iop_spu_device::dma_done(int bank) core.m_status &= ~STATUS_DMA_ACTIVE; } -void iop_spu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void iop_spu_device::sound_stream_update(sound_stream &stream) { // TODO - outputs[0].fill(0); } TIMER_CALLBACK_MEMBER(iop_spu_device::autodma_done_timer_hack) diff --git a/src/devices/sound/iopspu.h b/src/devices/sound/iopspu.h index d52d3f2d4a4..94ac7614055 100644 --- a/src/devices/sound/iopspu.h +++ b/src/devices/sound/iopspu.h @@ -48,7 +48,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // HACK: This timer is currently used to trigger an interrupt after the auto-DMA-transferred buffer would have been // mixed and played back, as the PS2 BIOS pulls a null return address and crashes if we trigger the auto-DMA-complete diff --git a/src/devices/sound/iremga20.cpp b/src/devices/sound/iremga20.cpp index b87c9f26da0..99c7a823cf9 100644 --- a/src/devices/sound/iremga20.cpp +++ b/src/devices/sound/iremga20.cpp @@ -130,12 +130,9 @@ void iremga20_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void iremga20_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void iremga20_device::sound_stream_update(sound_stream &stream) { - auto &outL = outputs[0]; - auto &outR = outputs[1]; - - for (int i = 0; i < outL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sampleout = 0; @@ -159,8 +156,8 @@ void iremga20_device::sound_stream_update(sound_stream &stream, std::vector<read } } - outL.put_int(i, sampleout, 32768 * 4); - outR.put_int(i, sampleout, 32768 * 4); + stream.put_int(0, i, sampleout, 32768 * 4); + stream.put_int(1, i, sampleout, 32768 * 4); } } diff --git a/src/devices/sound/iremga20.h b/src/devices/sound/iremga20.h index 2f854d8c55a..c397327ca76 100644 --- a/src/devices/sound/iremga20.h +++ b/src/devices/sound/iremga20.h @@ -36,7 +36,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/k005289.cpp b/src/devices/sound/k005289.cpp index 4202ce8207c..5a766ddc8af 100644 --- a/src/devices/sound/k005289.cpp +++ b/src/devices/sound/k005289.cpp @@ -85,10 +85,9 @@ void k005289_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void k005289_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k005289_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - for (int sampid = 0; sampid < outputs[0].samples(); sampid++) + for (int sampid = 0; sampid < stream.samples(); sampid++) { for (int i = 0; i < 2; i++) { @@ -98,7 +97,7 @@ void k005289_device::sound_stream_update(sound_stream &stream, std::vector<read_ v.waveform = (v.waveform & ~0x1f) | ((v.waveform + 1) & 0x1f); v.counter = v.frequency; } - outputs[0].add_int(sampid, ((m_sound_prom[((i & 1) << 8) | v.waveform] & 0xf) - 8) * v.volume, 512); + stream.add_int(0, sampid, ((m_sound_prom[((i & 1) << 8) | v.waveform] & 0xf) - 8) * v.volume, 512); } } } diff --git a/src/devices/sound/k005289.h b/src/devices/sound/k005289.h index 1518202f13c..0cadc1182d5 100644 --- a/src/devices/sound/k005289.h +++ b/src/devices/sound/k005289.h @@ -26,7 +26,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: required_region_ptr<u8> m_sound_prom; diff --git a/src/devices/sound/k007232.cpp b/src/devices/sound/k007232.cpp index 125ebc1352e..137f3a0ca92 100644 --- a/src/devices/sound/k007232.cpp +++ b/src/devices/sound/k007232.cpp @@ -211,7 +211,7 @@ void k007232_device::set_bank(int chan_a_bank, int chan_b_bank) // sound_stream_update - handle a stream update //------------------------------------------------- -void k007232_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k007232_device::sound_stream_update(sound_stream &stream) { if (K007232_LOG_PCM) { @@ -237,7 +237,7 @@ void k007232_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { s32 lsum = 0, rsum = 0; for (int i = 0; i < KDAC_A_PCM_MAX; i++) @@ -282,7 +282,7 @@ void k007232_device::sound_stream_update(sound_stream &stream, std::vector<read_ rsum += out * vol_b; } } - outputs[0].put_int(j, lsum, 32768); - outputs[1].put_int(j, rsum, 32768); + stream.put_int(0, j, lsum, 32768); + stream.put_int(1, j, rsum, 32768); } } diff --git a/src/devices/sound/k007232.h b/src/devices/sound/k007232.h index 7082d412d56..3c95e71a51c 100644 --- a/src/devices/sound/k007232.h +++ b/src/devices/sound/k007232.h @@ -37,7 +37,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/k051649.cpp b/src/devices/sound/k051649.cpp index 3afa41849d8..c4dd31c1ba7 100644 --- a/src/devices/sound/k051649.cpp +++ b/src/devices/sound/k051649.cpp @@ -133,12 +133,9 @@ void k051649_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void k051649_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k051649_device::sound_stream_update(sound_stream &stream) { - // zap the contents of the mixer buffer - outputs[0].fill(0); - - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { for (sound_channel &voice : m_channel_list) { @@ -157,7 +154,7 @@ void k051649_device::sound_stream_update(sound_stream &stream, std::vector<read_ } // scale to 11 bit digital output on chip - outputs[0].add_int(i, voice.sample >> 4, 1024); + stream.add_int(0, i, voice.sample >> 4, 1024); } } } diff --git a/src/devices/sound/k051649.h b/src/devices/sound/k051649.h index 3e0b60dfc86..c71d7ed8fd7 100644 --- a/src/devices/sound/k051649.h +++ b/src/devices/sound/k051649.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // parameters for a channel diff --git a/src/devices/sound/k053260.cpp b/src/devices/sound/k053260.cpp index e08e385d8f8..d11ae99fcda 100644 --- a/src/devices/sound/k053260.cpp +++ b/src/devices/sound/k053260.cpp @@ -308,11 +308,11 @@ void k053260_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void k053260_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k053260_device::sound_stream_update(sound_stream &stream) { if (m_mode & 2) { - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { s32 buffer[2] = {0, 0}; @@ -322,15 +322,10 @@ void k053260_device::sound_stream_update(sound_stream &stream, std::vector<read_ voice.play(buffer); } - outputs[0].put_int_clamp(j, buffer[0], 32768); - outputs[1].put_int_clamp(j, buffer[1], 32768); + stream.put_int_clamp(0, j, buffer[0], 32768); + stream.put_int_clamp(1, j, buffer[1], 32768); } } - else - { - outputs[0].fill(0); - outputs[1].fill(0); - } } diff --git a/src/devices/sound/k053260.h b/src/devices/sound/k053260.h index 7f9e963ea26..a1da89af19e 100644 --- a/src/devices/sound/k053260.h +++ b/src/devices/sound/k053260.h @@ -41,7 +41,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/k054539.cpp b/src/devices/sound/k054539.cpp index b7108e925f8..3bcadb703b7 100644 --- a/src/devices/sound/k054539.cpp +++ b/src/devices/sound/k054539.cpp @@ -103,7 +103,7 @@ void k054539_device::keyoff(int channel) regs[0x22c] &= ~(1 << channel); } -void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k054539_device::sound_stream_update(sound_stream &stream) { static constexpr double VOL_CAP = 1.80; @@ -115,13 +115,9 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_ int16_t *rbase = (int16_t *)&ram[0]; if(!(regs[0x22f] & 1)) - { - outputs[0].fill(0); - outputs[1].fill(0); return; - } - for(int sample = 0; sample != outputs[0].samples(); sample++) { + for(int sample = 0; sample != stream.samples(); sample++) { double lval, rval; if(!(flags & DISABLE_REVERB)) lval = rval = rbase[reverb_pos]; @@ -299,8 +295,8 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } reverb_pos = (reverb_pos + 1) & 0x1fff; - outputs[0].put_int(sample, lval, 32768); - outputs[1].put_int(sample, rval, 32768); + stream.put_int(0, sample, lval, 32768); + stream.put_int(1, sample, rval, 32768); } } diff --git a/src/devices/sound/k054539.h b/src/devices/sound/k054539.h index 70df821dd2f..9e3ba6aa5f1 100644 --- a/src/devices/sound/k054539.h +++ b/src/devices/sound/k054539.h @@ -66,7 +66,7 @@ protected: virtual void device_post_load() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/ks0164.cpp b/src/devices/sound/ks0164.cpp index 78b24423b2e..bad6b32c4f3 100644 --- a/src/devices/sound/ks0164.cpp +++ b/src/devices/sound/ks0164.cpp @@ -474,9 +474,9 @@ void ks0164_device::cpu_map(address_map &map) map(0xe000, 0xffff).ram(); } -void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ks0164_device::sound_stream_update(sound_stream &stream) { - for(int sample = 0; sample != outputs[0].samples(); sample++) { + for(int sample = 0; sample != stream.samples(); sample++) { s32 suml = 0, sumr = 0; for(int voice = 0; voice < 0x20; voice++) { u16 *regs = m_sregs[voice]; @@ -537,7 +537,7 @@ void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_s } } } - outputs[0].put_int(sample, suml, 32768 * 32); - outputs[1].put_int(sample, sumr, 32768 * 32); + stream.put_int(0, sample, suml, 32768 * 32); + stream.put_int(1, sample, sumr, 32768 * 32); } } diff --git a/src/devices/sound/ks0164.h b/src/devices/sound/ks0164.h index cb7c0f5dff5..fde35585e93 100644 --- a/src/devices/sound/ks0164.h +++ b/src/devices/sound/ks0164.h @@ -27,7 +27,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/l7a1045_l6028_dsp_a.cpp b/src/devices/sound/l7a1045_l6028_dsp_a.cpp index aeb87e47968..cd65ec51f6e 100644 --- a/src/devices/sound/l7a1045_l6028_dsp_a.cpp +++ b/src/devices/sound/l7a1045_l6028_dsp_a.cpp @@ -151,12 +151,8 @@ void l7a1045_sound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void l7a1045_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void l7a1045_sound_device::sound_stream_update(sound_stream &stream) { - /* Clear the buffers */ - outputs[0].fill(0); - outputs[1].fill(0); - for (int i = 0; i < 32; i++) { if (m_key & (1 << i)) @@ -170,7 +166,7 @@ void l7a1045_sound_device::sound_stream_update(sound_stream &stream, std::vector uint32_t pos = vptr->pos; uint32_t frac = vptr->frac; - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { int32_t sample; uint8_t data; @@ -197,8 +193,8 @@ void l7a1045_sound_device::sound_stream_update(sound_stream &stream, std::vector sample = int8_t(data & 0xfc) << (3 - (data & 3)); frac += step; - outputs[0].add_int(j, sample * vptr->l_volume, 32768 * 512); - outputs[1].add_int(j, sample * vptr->r_volume, 32768 * 512); + stream.add_int(0, j, sample * vptr->l_volume, 32768 * 512); + stream.add_int(1, j, sample * vptr->r_volume, 32768 * 512); } vptr->pos = pos; diff --git a/src/devices/sound/l7a1045_l6028_dsp_a.h b/src/devices/sound/l7a1045_l6028_dsp_a.h index 3115e1826bb..20a5348a779 100644 --- a/src/devices/sound/l7a1045_l6028_dsp_a.h +++ b/src/devices/sound/l7a1045_l6028_dsp_a.h @@ -34,7 +34,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct l7a1045_voice diff --git a/src/devices/sound/lc78836m.cpp b/src/devices/sound/lc78836m.cpp index 7b611e59cf7..ecb007ad081 100644 --- a/src/devices/sound/lc78836m.cpp +++ b/src/devices/sound/lc78836m.cpp @@ -88,14 +88,12 @@ void lc78836m_device::device_clock_changed() update_clock(); } -void lc78836m_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lc78836m_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[0].put(0, m_sample_ch1 * m_att / 1024.0); + stream.put(0, 0, m_sample_ch1 * m_att / 1024.0); m_sample_ch1 = 0; - outputs[1].fill(0); - outputs[1].put(0, m_sample_ch2 * m_att / 1024.0); + stream.put(1, 0, m_sample_ch2 * m_att / 1024.0); m_sample_ch2 = 0; if (m_mute && m_att > 0) @@ -129,7 +127,7 @@ void lc78836m_device::bclk_w(int state) m_sample_bit++; if (m_sample_bit >= 16) { - stream_buffer::sample_t sample = m_sample / double(std::numeric_limits<int16_t>::max()); + sound_stream::sample_t sample = m_sample / double(std::numeric_limits<int16_t>::max()); if (m_lrck) m_sample_ch1 = sample; diff --git a/src/devices/sound/lc78836m.h b/src/devices/sound/lc78836m.h index e2622fa3500..a1dc2d04ef7 100644 --- a/src/devices/sound/lc78836m.h +++ b/src/devices/sound/lc78836m.h @@ -38,7 +38,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void update_clock(); @@ -56,7 +56,7 @@ private: uint8_t m_sample_bit; int16_t m_sample; - stream_buffer::sample_t m_sample_ch1, m_sample_ch2; + sound_stream::sample_t m_sample_ch1, m_sample_ch2; double m_att; }; diff --git a/src/devices/sound/lc82310.cpp b/src/devices/sound/lc82310.cpp index 3404a5c9629..87523d591d1 100644 --- a/src/devices/sound/lc82310.cpp +++ b/src/devices/sound/lc82310.cpp @@ -258,15 +258,15 @@ void lc82310_device::fill_buffer() stream->set_sample_rate(frame_sample_rate); } -void lc82310_device::append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount) +void lc82310_device::append_buffer(sound_stream &stream, int &pos, int scount) { int s1 = std::min(scount - pos, m_sample_count); int words_per_sample = std::min(m_frame_channels, 2); for (int i = 0; i < s1; i++) { - outputs[0].put_int(pos, samples[m_samples_idx * words_per_sample], 32768); - outputs[1].put_int(pos, samples[m_samples_idx * words_per_sample + (words_per_sample >> 1)], 32768); + stream.put_int(0, pos, samples[m_samples_idx * words_per_sample], 32768); + stream.put_int(1, pos, samples[m_samples_idx * words_per_sample + (words_per_sample >> 1)], 32768); m_samples_idx++; pos++; @@ -279,9 +279,9 @@ void lc82310_device::append_buffer(std::vector<write_stream_view> &outputs, int } } -void lc82310_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lc82310_device::sound_stream_update(sound_stream &stream) { - int csamples = outputs[0].samples(); + int csamples = stream.samples(); int pos = 0; while (pos < csamples) @@ -290,12 +290,8 @@ void lc82310_device::sound_stream_update(sound_stream &stream, std::vector<read_ fill_buffer(); if (m_sample_count <= 0) - { - outputs[0].fill(0, pos); - outputs[1].fill(0, pos); return; - } - append_buffer(outputs, pos, csamples); + append_buffer(stream, pos, csamples); } } diff --git a/src/devices/sound/lc82310.h b/src/devices/sound/lc82310.h index 802c7bbe2e9..64a4372c3d4 100644 --- a/src/devices/sound/lc82310.h +++ b/src/devices/sound/lc82310.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum : uint8_t @@ -63,7 +63,7 @@ private: void handle_command(uint8_t cmd, uint8_t param); void fill_buffer(); - void append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount); + void append_buffer(sound_stream &stream, int &pos, int scount); sound_stream *stream; std::unique_ptr<mp3_audio> mp3dec; diff --git a/src/devices/sound/lmc1992.cpp b/src/devices/sound/lmc1992.cpp index feaa0810226..313855ea6df 100644 --- a/src/devices/sound/lmc1992.cpp +++ b/src/devices/sound/lmc1992.cpp @@ -175,9 +175,8 @@ void lmc1992_device::device_start() // our sound stream //------------------------------------------------- -void lmc1992_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lmc1992_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } diff --git a/src/devices/sound/lmc1992.h b/src/devices/sound/lmc1992.h index dc9ea4d9806..371b241d2ff 100644 --- a/src/devices/sound/lmc1992.h +++ b/src/devices/sound/lmc1992.h @@ -71,7 +71,7 @@ protected: virtual void device_start() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: inline void execute_command(int addr, int data); diff --git a/src/devices/sound/lynx.cpp b/src/devices/sound/lynx.cpp index 1a1f20d0bda..8520804d07b 100644 --- a/src/devices/sound/lynx.cpp +++ b/src/devices/sound/lynx.cpp @@ -477,11 +477,9 @@ void lynx_sound_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void lynx_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lynx_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 result = 0; for (int channel = 0; channel < LYNX_AUDIO_CHANNELS; channel++) @@ -489,7 +487,7 @@ void lynx_sound_device::sound_stream_update(sound_stream &stream, std::vector<re execute(channel); result += m_audio[channel].reg.output * 15; // where does the *15 come from? } - buffer.put_int(i, result, 32768); + stream.put_int(0, i, result, 32768); } } @@ -497,12 +495,9 @@ void lynx_sound_device::sound_stream_update(sound_stream &stream, std::vector<re // sound_stream_update - handle a stream update //------------------------------------------------- -void lynx2_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lynx2_sound_device::sound_stream_update(sound_stream &stream) { - auto &left = outputs[0]; - auto &right = outputs[1]; - - for (int i = 0; i < left.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 lsum = 0; s32 rsum = 0; @@ -525,7 +520,7 @@ void lynx2_sound_device::sound_stream_update(sound_stream &stream, std::vector<r rsum += v * 15; } } - left.put_int(i, lsum, 32768); - right.put_int(i, rsum, 32768); + stream.put_int(0, i, lsum, 32768); + stream.put_int(1, i, rsum, 32768); } } diff --git a/src/devices/sound/lynx.h b/src/devices/sound/lynx.h index b729afe4ebe..d0b3b73c961 100644 --- a/src/devices/sound/lynx.h +++ b/src/devices/sound/lynx.h @@ -56,7 +56,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void reset_channel(LYNX_AUDIO *channel); void shift(int chan_nr); @@ -85,7 +85,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; diff --git a/src/devices/sound/mas3507d.cpp b/src/devices/sound/mas3507d.cpp index 25f9d2ab1af..ff9024dc60f 100644 --- a/src/devices/sound/mas3507d.cpp +++ b/src/devices/sound/mas3507d.cpp @@ -449,19 +449,19 @@ void mas3507d_device::fill_buffer() cb_demand(mp3data_count < mp3data.size()); } -void mas3507d_device::append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount) +void mas3507d_device::append_buffer(sound_stream &stream, int &pos, int scount) { const int bytes_per_sample = std::min(frame_channels, 2); // More than 2 channels is unsupported here const int s1 = std::min(scount - pos, sample_count); - const stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - const stream_buffer::sample_t mute_scale = is_muted ? 0.0 : 1.0; + const sound_stream::sample_t sample_scale = 1.0 / 32768.0; + const sound_stream::sample_t mute_scale = is_muted ? 0.0 : 1.0; for(int i = 0; i < s1; i++) { - const stream_buffer::sample_t lsamp_mixed = stream_buffer::sample_t(samples[samples_idx * bytes_per_sample]) * sample_scale * mute_scale * gain_ll; - const stream_buffer::sample_t rsamp_mixed = stream_buffer::sample_t(samples[samples_idx * bytes_per_sample + (bytes_per_sample >> 1)]) * sample_scale * mute_scale * gain_rr; + const sound_stream::sample_t lsamp_mixed = sound_stream::sample_t(samples[samples_idx * bytes_per_sample]) * sample_scale * mute_scale * gain_ll; + const sound_stream::sample_t rsamp_mixed = sound_stream::sample_t(samples[samples_idx * bytes_per_sample + (bytes_per_sample >> 1)]) * sample_scale * mute_scale * gain_rr; - outputs[0].put(pos, lsamp_mixed); - outputs[1].put(pos, rsamp_mixed); + stream.put(0, pos, lsamp_mixed); + stream.put(1, pos, rsamp_mixed); samples_idx++; pos++; @@ -485,21 +485,18 @@ void mas3507d_device::reset_playback() samples_idx = 0; } -void mas3507d_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mas3507d_device::sound_stream_update(sound_stream &stream) { - int csamples = outputs[0].samples(); + int csamples = stream.samples(); int pos = 0; while(pos < csamples) { if(sample_count == 0) fill_buffer(); - if(sample_count <= 0) { - outputs[0].fill(0, pos); - outputs[1].fill(0, pos); + if(sample_count <= 0) return; - } - append_buffer(outputs, pos, csamples); + append_buffer(stream, pos, csamples); } } diff --git a/src/devices/sound/mas3507d.h b/src/devices/sound/mas3507d.h index 5078c050863..c4f77aefc16 100644 --- a/src/devices/sound/mas3507d.h +++ b/src/devices/sound/mas3507d.h @@ -28,7 +28,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void i2c_nak(); @@ -41,7 +41,7 @@ private: void reg_write(uint32_t adr, uint32_t val); void fill_buffer(); - void append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount); + void append_buffer(sound_stream &stream, int &pos, int scount); int gain_to_db(double val); float gain_to_percentage(int val); diff --git a/src/devices/sound/mea8000.cpp b/src/devices/sound/mea8000.cpp index 25381b9ae81..caa0aef5ea0 100644 --- a/src/devices/sound/mea8000.cpp +++ b/src/devices/sound/mea8000.cpp @@ -420,9 +420,9 @@ void mea8000_device::stop_frame() -void mea8000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mea8000_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(stream_buffer::sample_t(m_output) * (1.0 / 32768.0)); + stream.fill(0, sound_stream::sample_t(m_output) * (1.0 / 32768.0)); } /* next sample in frame, sampling at 64 kHz */ diff --git a/src/devices/sound/mea8000.h b/src/devices/sound/mea8000.h index 121b1866912..bcd96e161b0 100644 --- a/src/devices/sound/mea8000.h +++ b/src/devices/sound/mea8000.h @@ -29,7 +29,7 @@ public: protected: // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: /* filter coefficients from frequencies */ diff --git a/src/devices/sound/mm5837.cpp b/src/devices/sound/mm5837.cpp index 40bec2727b8..74f90d01599 100644 --- a/src/devices/sound/mm5837.cpp +++ b/src/devices/sound/mm5837.cpp @@ -109,8 +109,8 @@ void mm5837_stream_device::device_start() // sound_stream_update - fill the sound buffer //------------------------------------------------- -void mm5837_stream_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mm5837_stream_device::sound_stream_update(sound_stream &stream) { - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - outputs[0].put(sampindex, m_source.clock() ? 1.0 : 0.0); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, m_source.clock() ? 1.0 : 0.0); } diff --git a/src/devices/sound/mm5837.h b/src/devices/sound/mm5837.h index 2e8e5406506..169965ef1d5 100644 --- a/src/devices/sound/mm5837.h +++ b/src/devices/sound/mm5837.h @@ -196,7 +196,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; // sound stream diff --git a/src/devices/sound/mmc5.cpp b/src/devices/sound/mmc5.cpp index 2659e36535c..48b976e588d 100644 --- a/src/devices/sound/mmc5.cpp +++ b/src/devices/sound/mmc5.cpp @@ -91,7 +91,7 @@ void mmc5_sound_device::device_start() */ for (int i = 0; i < 31; i++) { - stream_buffer::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); + sound_stream::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); m_square_lut[i] = pulse_out; } @@ -297,19 +297,18 @@ void mmc5_sound_device::pcm_w(u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void mmc5_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mmc5_sound_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t accum = 0.0; - auto &output = outputs[0]; + sound_stream::sample_t accum = 0.0; - for (int sampindex = 0; sampindex < output.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { tick_square(m_core.squ[0]); tick_square(m_core.squ[1]); accum = m_square_lut[m_core.squ[0].output + m_core.squ[1].output]; - accum += stream_buffer::sample_t(m_core.pcm.output) / 255.0f; + accum += sound_stream::sample_t(m_core.pcm.output) / 255.0f; - output.put(sampindex, -accum); + stream.put(0, sampindex, -accum); } } diff --git a/src/devices/sound/mmc5.h b/src/devices/sound/mmc5.h index a8f0ea9f406..a9fd920f63f 100644 --- a/src/devices/sound/mmc5.h +++ b/src/devices/sound/mmc5.h @@ -47,7 +47,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: /* GLOBAL CONSTANTS */ @@ -58,7 +58,7 @@ private: u32 m_samps_per_sync; /* Number of samples per vsync */ u32 m_vbl_times[SYNCS_MAX1]; /* VBL durations in samples */ u32 m_sync_times1[SYNCS_MAX1]; /* Samples per sync table */ - stream_buffer::sample_t m_square_lut[31]; // Non-linear Square wave output LUT + sound_stream::sample_t m_square_lut[31]; // Non-linear Square wave output LUT sound_stream *m_stream; devcb_write_line m_irq_handler; diff --git a/src/devices/sound/mos6560.cpp b/src/devices/sound/mos6560.cpp index 6434621f13d..5f77f5e0781 100644 --- a/src/devices/sound/mos6560.cpp +++ b/src/devices/sound/mos6560.cpp @@ -865,12 +865,11 @@ void mos6560_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mos6560_device::sound_stream_update(sound_stream &stream) { int i, v; - auto &buffer = outputs[0]; - for (i = 0; i < buffer.samples(); i++) + for (i = 0; i < stream.samples(); i++) { v = 0; if (TONE1_ON /*||(m_tone1pos != 0) */ ) @@ -883,7 +882,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ if (m_tone1pos >= m_tone1samples) { m_tone1pos = 0; - m_tone1samples = buffer.sample_rate() / TONE1_FREQUENCY; + m_tone1samples = stream.sample_rate() / TONE1_FREQUENCY; if (m_tone1samples == 0) m_tone1samples = 1; } @@ -899,7 +898,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ if (m_tone2pos >= m_tone2samples) { m_tone2pos = 0; - m_tone2samples = buffer.sample_rate() / TONE2_FREQUENCY; + m_tone2samples = stream.sample_rate() / TONE2_FREQUENCY; if (m_tone2samples == 0) m_tone2samples = 1; } @@ -915,7 +914,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ if (m_tone3pos >= m_tone3samples) { m_tone3pos = 0; - m_tone3samples = buffer.sample_rate() / TONE3_FREQUENCY; + m_tone3samples = stream.sample_rate() / TONE3_FREQUENCY; if (m_tone3samples == 0) m_tone3samples = 1; } @@ -935,6 +934,6 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ v = 8191; else if (v < -8191) v = -8191; - buffer.put_int(i, v, 8192); + stream.put_int(0, i, v, 8192); } } diff --git a/src/devices/sound/mos6560.h b/src/devices/sound/mos6560.h index 13b29ba363f..e48e4601466 100644 --- a/src/devices/sound/mos6560.h +++ b/src/devices/sound/mos6560.h @@ -118,7 +118,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; inline uint8_t read_videoram(offs_t offset); inline uint8_t read_colorram(offs_t offset); diff --git a/src/devices/sound/mos6581.cpp b/src/devices/sound/mos6581.cpp index 941472a58f0..af195f6fa0c 100644 --- a/src/devices/sound/mos6581.cpp +++ b/src/devices/sound/mos6581.cpp @@ -235,9 +235,9 @@ void mos6581_device::device_post_load() // our sound stream //------------------------------------------------- -void mos6581_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mos6581_device::sound_stream_update(sound_stream &stream) { - m_token->fill_buffer(outputs[0]); + m_token->fill_buffer(stream); } diff --git a/src/devices/sound/mos6581.h b/src/devices/sound/mos6581.h index 6f9c87a5abb..d4868606768 100644 --- a/src/devices/sound/mos6581.h +++ b/src/devices/sound/mos6581.h @@ -65,7 +65,7 @@ protected: virtual void device_post_load() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void save_state(SID6581_t *token); private: diff --git a/src/devices/sound/mos7360.cpp b/src/devices/sound/mos7360.cpp index 51953d93ecd..6a3d5887b15 100644 --- a/src/devices/sound/mos7360.cpp +++ b/src/devices/sound/mos7360.cpp @@ -439,12 +439,11 @@ TIMER_CALLBACK_MEMBER(mos7360_device::timer_expired) // our sound stream //------------------------------------------------- -void mos7360_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mos7360_device::sound_stream_update(sound_stream &stream) { int i, v, a; - auto &buffer = outputs[0]; - for (i = 0; i < buffer.samples(); i++) + for (i = 0; i < stream.samples(); i++) { v = 0; @@ -487,7 +486,7 @@ void mos7360_device::sound_stream_update(sound_stream &stream, std::vector<read_ v = v * a; - buffer.put_int(i, v, 32768); + stream.put_int(0, i, v, 32768); } } diff --git a/src/devices/sound/mos7360.h b/src/devices/sound/mos7360.h index 1b6c1a8f5b0..9288c752824 100644 --- a/src/devices/sound/mos7360.h +++ b/src/devices/sound/mos7360.h @@ -107,7 +107,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; inline void set_interrupt(int mask); inline void clear_interrupt(int mask); diff --git a/src/devices/sound/msm5205.cpp b/src/devices/sound/msm5205.cpp index f3f1f5e6302..814b3191342 100644 --- a/src/devices/sound/msm5205.cpp +++ b/src/devices/sound/msm5205.cpp @@ -347,20 +347,16 @@ void msm5205_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void msm5205_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void msm5205_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; - /* if this voice is active */ if (m_signal) { - constexpr stream_buffer::sample_t sample_scale = 1.0 / double(1 << 12); + constexpr sound_stream::sample_t sample_scale = 1.0 / double(1 << 12); const int dac_mask = (m_dac_bits >= 12) ? 0 : (1 << (12 - m_dac_bits)) - 1; - stream_buffer::sample_t val = stream_buffer::sample_t(m_signal & ~dac_mask) * sample_scale; - output.fill(val); + sound_stream::sample_t val = sound_stream::sample_t(m_signal & ~dac_mask) * sample_scale; + stream.fill(0, val); } - else - output.fill(0); } @@ -368,8 +364,8 @@ void msm5205_device::sound_stream_update(sound_stream &stream, std::vector<read_ // sound_stream_update - handle a stream update //------------------------------------------------- -void msm6585_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void msm6585_device::sound_stream_update(sound_stream &stream) { // should this be different? - msm5205_device::sound_stream_update(stream, inputs, outputs); + msm5205_device::sound_stream_update(stream); } diff --git a/src/devices/sound/msm5205.h b/src/devices/sound/msm5205.h index d310c8d56fb..9aba7ea6f98 100644 --- a/src/devices/sound/msm5205.h +++ b/src/devices/sound/msm5205.h @@ -59,7 +59,7 @@ protected: TIMER_CALLBACK_MEMBER(update_adpcm); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void compute_tables(); virtual int get_prescaler() const; @@ -101,7 +101,7 @@ protected: virtual double adpcm_capture_divisor() const override { return 2.0; } // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; diff --git a/src/devices/sound/msm5232.cpp b/src/devices/sound/msm5232.cpp index e709b3af16b..1e05483b6e9 100644 --- a/src/devices/sound/msm5232.cpp +++ b/src/devices/sound/msm5232.cpp @@ -708,31 +708,18 @@ void msm5232_device::set_clock(int clock) // sound_stream_update - handle a stream update //------------------------------------------------- -void msm5232_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void msm5232_device::sound_stream_update(sound_stream &stream) { - auto &buf1 = outputs[0]; - auto &buf2 = outputs[1]; - auto &buf3 = outputs[2]; - auto &buf4 = outputs[3]; - auto &buf5 = outputs[4]; - auto &buf6 = outputs[5]; - auto &buf7 = outputs[6]; - auto &buf8 = outputs[7]; - auto &bufsolo1 = outputs[8]; - auto &bufsolo2 = outputs[9]; - auto &bufnoise = outputs[10]; - int i; - - for (i=0; i<buf1.samples(); i++) + for (int i=0; i<stream.samples(); i++) { /* calculate all voices' envelopes */ EG_voices_advance(); TG_group_advance(0); /* calculate tones group 1 */ - buf1.put_int(i, o2, 32768); - buf2.put_int(i, o4, 32768); - buf3.put_int(i, o8, 32768); - buf4.put_int(i, o16, 32768); + stream.put_int(0, i, o2, 32768); + stream.put_int(1, i, o4, 32768); + stream.put_int(2, i, o8, 32768); + stream.put_int(3, i, o16, 32768); SAVE_SINGLE_CHANNEL(0,o2) SAVE_SINGLE_CHANNEL(1,o4) @@ -740,13 +727,13 @@ void msm5232_device::sound_stream_update(sound_stream &stream, std::vector<read_ SAVE_SINGLE_CHANNEL(3,o16) TG_group_advance(1); /* calculate tones group 2 */ - buf5.put_int(i, o2, 32768); - buf6.put_int(i, o4, 32768); - buf7.put_int(i, o8, 32768); - buf8.put_int(i, o16, 32768); + stream.put_int(4, i, o2, 32768); + stream.put_int(5, i, o4, 32768); + stream.put_int(6, i, o8, 32768); + stream.put_int(7, i, o16, 32768); - bufsolo1.put_int(i, solo8, 32768); - bufsolo2.put_int(i, solo16, 32768); + stream.put_int(8, i, solo8, 32768); + stream.put_int(9, i, solo16, 32768); SAVE_SINGLE_CHANNEL(4,o2) SAVE_SINGLE_CHANNEL(5,o4) @@ -774,6 +761,6 @@ void msm5232_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - bufnoise.put(i, (m_noise_rng & (1<<16)) ? 1.0 : 0.0); + stream.put(10, i, (m_noise_rng & (1<<16)) ? 1.0 : 0.0); } } diff --git a/src/devices/sound/msm5232.h b/src/devices/sound/msm5232.h index a79314b89fd..44ab63e46e3 100644 --- a/src/devices/sound/msm5232.h +++ b/src/devices/sound/msm5232.h @@ -25,7 +25,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct VOICE { diff --git a/src/devices/sound/n63701x.cpp b/src/devices/sound/n63701x.cpp index 6f16c988d8e..c6f09efae72 100644 --- a/src/devices/sound/n63701x.cpp +++ b/src/devices/sound/n63701x.cpp @@ -64,13 +64,12 @@ void namco_63701x_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void namco_63701x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_63701x_device::sound_stream_update(sound_stream &stream) { int ch; for (ch = 0;ch < 2;ch++) { - auto &buf = outputs[ch]; voice_63701x *v = &m_voices[ch]; if (v->playing) @@ -80,12 +79,12 @@ void namco_63701x_device::sound_stream_update(sound_stream &stream, std::vector< int vol = vol_table[v->volume]; int p; - for (p = 0;p < buf.samples();p++) + for (p = 0;p < stream.samples();p++) { if (v->silence_counter) { v->silence_counter--; - buf.put(p, 0); + stream.put(0, p, 0); } else { @@ -94,26 +93,24 @@ void namco_63701x_device::sound_stream_update(sound_stream &stream, std::vector< if (data == 0xff) /* end of sample */ { v->playing = 0; - buf.fill(0, p); + stream.fill(0, 0, p); break; } else if (data == 0x00) /* silence compression */ { data = base[(pos++) & 0xffff]; v->silence_counter = data; - buf.put(p, 0); + stream.put(0, p, 0); } else { - buf.put_int(p, vol * (data - 0x80), 32768); + stream.put_int(0, p, vol * (data - 0x80), 32768); } } } v->position = pos; } - else - buf.fill(0); } } diff --git a/src/devices/sound/n63701x.h b/src/devices/sound/n63701x.h index f4d24173e1c..cd66519e0c1 100644 --- a/src/devices/sound/n63701x.h +++ b/src/devices/sound/n63701x.h @@ -25,7 +25,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct voice_63701x diff --git a/src/devices/sound/namco.cpp b/src/devices/sound/namco.cpp index 5842c7ada83..688f1ce98ec 100644 --- a/src/devices/sound/namco.cpp +++ b/src/devices/sound/namco.cpp @@ -233,11 +233,11 @@ void namco_audio_device::build_decoded_waveform(uint8_t *rgnbase) // generate sound by oversampling -uint32_t namco_audio_device::namco_update_one(write_stream_view &buffer, const int16_t *wave, uint32_t counter, uint32_t freq) +uint32_t namco_audio_device::namco_update_one(sound_stream &stream, int output, const int16_t *wave, uint32_t counter, uint32_t freq) { - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.add_int(sampindex, wave[WAVEFORM_POSITION(counter)], 32768); + stream.add_int(output, sampindex, wave[WAVEFORM_POSITION(counter)], 32768); counter += freq; } @@ -679,14 +679,10 @@ void namco_15xx_device::sharedram_w(offs_t offset, uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_audio_device::sound_stream_update(sound_stream &stream) { if (m_stereo) { - // zap the contents of the buffers - outputs[0].fill(0); - outputs[1].fill(0); - // if no sound, we're done if (!m_sound_enable) return; @@ -694,8 +690,6 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r // loop over each voice and add its contribution for (sound_channel *voice = m_channel_list; voice < m_last_channel; voice++) { - auto &lmix = outputs[0]; - auto &rmix = outputs[1]; int lv = voice->volume[0]; int rv = voice->volume[1]; @@ -714,17 +708,17 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r int16_t r_noise_data = OUTPUT_LEVEL(0x07 * (rv >> 1)); // add our contribution - for (int i = 0; i < lmix.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { if (voice->noise_state) { - lmix.add_int(i, l_noise_data, 32768); - rmix.add_int(i, r_noise_data, 32768); + stream.add_int(0, i, l_noise_data, 32768); + stream.add_int(1, i, r_noise_data, 32768); } else { - lmix.add_int(i, -l_noise_data, 32768); - rmix.add_int(i, -r_noise_data, 32768); + stream.add_int(0, i, -l_noise_data, 32768); + stream.add_int(1, i, -r_noise_data, 32768); } if (hold) @@ -762,7 +756,7 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r const int16_t *lw = &m_waveform[lv][voice->waveform_select * 32]; // generate sound into the buffer - c = namco_update_one(lmix, lw, voice->counter, voice->frequency); + c = namco_update_one(stream, 0, lw, voice->counter, voice->frequency); } // only update if we have non-zero right volume @@ -771,7 +765,7 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r const int16_t *rw = &m_waveform[rv][voice->waveform_select * 32]; // generate sound into the buffer - c = namco_update_one(rmix, rw, voice->counter, voice->frequency); + c = namco_update_one(stream, 1, rw, voice->counter, voice->frequency); } // update the counter for this voice @@ -783,11 +777,6 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r { sound_channel *voice; - auto &buffer = outputs[0]; - - // zap the contents of the buffer - buffer.fill(0); - // if no sound, we're done if (!m_sound_enable) return; @@ -810,12 +799,12 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r int16_t noise_data = OUTPUT_LEVEL(0x07 * (v >> 1)); // add our contribution - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { if (voice->noise_state) - buffer.add_int(i, noise_data, 32768); + stream.add_int(0, i, noise_data, 32768); else - buffer.add_int(i, -noise_data, 32768); + stream.add_int(1, i, -noise_data, 32768); if (hold) { @@ -849,24 +838,24 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r const int16_t *w = &m_waveform[v][voice->waveform_select * 32]; // generate sound into buffer and update the counter for this voice - voice->counter = namco_update_one(buffer, w, voice->counter, voice->frequency); + voice->counter = namco_update_one(stream, 0, w, voice->counter, voice->frequency); } } } } } -void namco_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_device::sound_stream_update(sound_stream &stream) { - namco_audio_device::sound_stream_update(stream, inputs, outputs); + namco_audio_device::sound_stream_update(stream); } -void namco_15xx_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_15xx_device::sound_stream_update(sound_stream &stream) { - namco_audio_device::sound_stream_update(stream, inputs, outputs); + namco_audio_device::sound_stream_update(stream); } -void namco_cus30_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_cus30_device::sound_stream_update(sound_stream &stream) { - namco_audio_device::sound_stream_update(stream, inputs, outputs); + namco_audio_device::sound_stream_update(stream); } diff --git a/src/devices/sound/namco.h b/src/devices/sound/namco.h index a5ce6814402..ac37d4d4aa3 100644 --- a/src/devices/sound/namco.h +++ b/src/devices/sound/namco.h @@ -43,7 +43,7 @@ protected: // internal state void build_decoded_waveform( uint8_t *rgnbase ); void update_namco_waveform(int offset, uint8_t data); - uint32_t namco_update_one(write_stream_view &buffer, const int16_t *wave, uint32_t counter, uint32_t freq); + uint32_t namco_update_one(sound_stream &stream, int output, const int16_t *wave, uint32_t counter, uint32_t freq); // waveform region optional_region_ptr<uint8_t> m_wave_ptr; @@ -69,7 +69,7 @@ protected: // decoded waveform table std::unique_ptr<int16_t[]> m_waveform[MAX_VOLUME]; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; class namco_device : public namco_audio_device @@ -86,7 +86,7 @@ protected: // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: std::unique_ptr<uint8_t[]> m_soundregs; @@ -106,7 +106,7 @@ protected: // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: std::unique_ptr<uint8_t[]> m_soundregs; @@ -125,7 +125,7 @@ public: void pacman_sound_w(offs_t offset, uint8_t data); protected: - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; diff --git a/src/devices/sound/namco_163.cpp b/src/devices/sound/namco_163.cpp index 3735e3147df..7f20a25928c 100644 --- a/src/devices/sound/namco_163.cpp +++ b/src/devices/sound/namco_163.cpp @@ -145,16 +145,13 @@ u8 namco_163_sound_device::data_r() } -void namco_163_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_163_sound_device::sound_stream_update(sound_stream &stream) { if (m_disable) - { - outputs[0].fill(0); return; - } // Slightly noisy but closer to real hardware behavior - for (int s = 0; s < outputs[0].samples(); s++) + for (int s = 0; s < stream.samples(); s++) { u32 phase = (m_ram[m_reg_addr + 5] << 16) | (m_ram[m_reg_addr + 3] << 8) | m_ram[m_reg_addr + 1]; const u32 freq = ((m_ram[m_reg_addr + 4] & 0x3) << 16) | (m_ram[m_reg_addr + 2] << 8) | m_ram[m_reg_addr + 0]; @@ -174,6 +171,6 @@ void namco_163_sound_device::sound_stream_update(sound_stream &stream, std::vect { m_reg_addr = 0x78 - ((m_ram[0x7f] & 0x70) >> 1); } - outputs[0].put_int(s, output, 128); + stream.put_int(0, s, output, 128); } } diff --git a/src/devices/sound/namco_163.h b/src/devices/sound/namco_163.h index 953110194c9..61b3af8fe0e 100644 --- a/src/devices/sound/namco_163.h +++ b/src/devices/sound/namco_163.h @@ -34,7 +34,7 @@ protected: // internals inline s8 get_sample(u16 addr); - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; DECLARE_DEVICE_TYPE(NAMCO_163, namco_163_sound_device) diff --git a/src/devices/sound/nes_apu.cpp b/src/devices/sound/nes_apu.cpp index 86c8a8c8934..3f8755398bc 100644 --- a/src/devices/sound/nes_apu.cpp +++ b/src/devices/sound/nes_apu.cpp @@ -131,7 +131,7 @@ void nesapu_device::device_start() */ for (int i = 0; i < 31; i++) { - stream_buffer::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); + sound_stream::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); m_square_lut[i] = pulse_out; } @@ -153,7 +153,7 @@ void nesapu_device::device_start() { for (int d = 0; d < 128; d++) { - stream_buffer::sample_t tnd_out = (t / 8227.0) + (n / 12241.0) + (d / 22638.0); + sound_stream::sample_t tnd_out = (t / 8227.0) + (n / 12241.0) + (d / 22638.0); tnd_out = (tnd_out == 0.0) ? 0.0 : 159.79 / ((1.0 / tnd_out) + 100.0); m_tnd_lut[t][n][d] = tnd_out; } @@ -766,12 +766,11 @@ u8 nesapu_device::status_r() // sound_stream_update - handle a stream update //------------------------------------------------- -void nesapu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void nesapu_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t accum = 0.0; - auto &output = outputs[0]; + sound_stream::sample_t accum = 0.0; - for (int sampindex = 0; sampindex < output.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { apu_square(&m_APU.squ[0]); apu_square(&m_APU.squ[1]); @@ -782,6 +781,6 @@ void nesapu_device::sound_stream_update(sound_stream &stream, std::vector<read_s accum = m_square_lut[m_APU.squ[0].output + m_APU.squ[1].output]; accum += m_tnd_lut[m_APU.tri.output][m_APU.noi.output][m_APU.dpcm.output]; - output.put(sampindex, accum); + stream.put(0, sampindex, accum); } } diff --git a/src/devices/sound/nes_apu.h b/src/devices/sound/nes_apu.h index d5004d99bfb..d43c50cb3d4 100644 --- a/src/devices/sound/nes_apu.h +++ b/src/devices/sound/nes_apu.h @@ -58,7 +58,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void update_lfsr(apu_t::noise_t &chan); @@ -76,8 +76,8 @@ private: u32 m_vbl_times[SYNCS_MAX1]; /* VBL durations in samples */ u32 m_sync_times1[SYNCS_MAX1]; /* Samples per sync table */ u32 m_sync_times2[SYNCS_MAX2]; /* Samples per sync table */ - stream_buffer::sample_t m_square_lut[31]; // Non-linear Square wave output LUT - stream_buffer::sample_t m_tnd_lut[16][16][128]; // Non-linear Triangle, Noise, DMC output LUT + sound_stream::sample_t m_square_lut[31]; // Non-linear Square wave output LUT + sound_stream::sample_t m_tnd_lut[16][16][128]; // Non-linear Triangle, Noise, DMC output LUT sound_stream *m_stream; devcb_write_line m_irq_handler; diff --git a/src/devices/sound/nn71003f.cpp b/src/devices/sound/nn71003f.cpp index b9d926a9855..a0bb5e21ccc 100644 --- a/src/devices/sound/nn71003f.cpp +++ b/src/devices/sound/nn71003f.cpp @@ -78,7 +78,7 @@ void nn71003f_device::clk_w(int state) logerror("clk_w %d\n", state); } -void nn71003f_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void nn71003f_device::sound_stream_update(sound_stream &stream) { } diff --git a/src/devices/sound/nn71003f.h b/src/devices/sound/nn71003f.h index bdf1803cf54..55b72707d6d 100644 --- a/src/devices/sound/nn71003f.h +++ b/src/devices/sound/nn71003f.h @@ -29,7 +29,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: devcb_write_line m_miso; diff --git a/src/devices/sound/okim6258.cpp b/src/devices/sound/okim6258.cpp index 171100e2080..712b3269f36 100644 --- a/src/devices/sound/okim6258.cpp +++ b/src/devices/sound/okim6258.cpp @@ -147,15 +147,13 @@ void okim6258_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6258_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (m_status & STATUS_PLAYING) { int nibble_shift = m_nibble_shift; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* Compute the new amplitude and update the current step */ int nibble = (m_data_in >> nibble_shift) & 0xf; @@ -165,16 +163,12 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read nibble_shift ^= 4; - buffer.put_int(sampindex, sample, 32768); + stream.put_int(0, sampindex, sample, 32768); } /* Update the parameters */ m_nibble_shift = nibble_shift; } - else - { - buffer.fill(0); - } } int16_t okim6258_device::clock_adpcm(uint8_t nibble) diff --git a/src/devices/sound/okim6258.h b/src/devices/sound/okim6258.h index 0efb74d6fb9..e20b4ec4553 100644 --- a/src/devices/sound/okim6258.h +++ b/src/devices/sound/okim6258.h @@ -47,7 +47,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: int16_t clock_adpcm(uint8_t nibble); 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) diff --git a/src/devices/sound/okim6295.h b/src/devices/sound/okim6295.h index ccf8f39f8a4..11a42f84aa1 100644 --- a/src/devices/sound/okim6295.h +++ b/src/devices/sound/okim6295.h @@ -60,7 +60,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; @@ -70,14 +70,14 @@ protected: { public: okim_voice(); - void generate_adpcm(device_rom_interface &rom, write_stream_view &buffer); + void generate_adpcm(device_rom_interface &rom, sound_stream &stream); oki_adpcm_state m_adpcm; // current ADPCM state bool m_playing; offs_t m_base_offset; // pointer to the base memory location uint32_t m_sample; // current sample number uint32_t m_count; // total samples to play - stream_buffer::sample_t m_volume; // output volume + sound_stream::sample_t m_volume; // output volume }; // configuration state @@ -91,7 +91,7 @@ protected: sound_stream * m_stream; uint8_t m_pin7_state; - static const stream_buffer::sample_t s_volume_table[16]; + static const sound_stream::sample_t s_volume_table[16]; }; diff --git a/src/devices/sound/okim6376.cpp b/src/devices/sound/okim6376.cpp index 7807a163e71..383c4a17e1d 100644 --- a/src/devices/sound/okim6376.cpp +++ b/src/devices/sound/okim6376.cpp @@ -386,10 +386,6 @@ void okim6376_device::generate_adpcm(struct ADPCMVoice *voice, int16_t *buffer, voice->count = count; } - /* fill the rest with silence */ - while (samples--) - *buffer++ = 0; - if ((!voice->playing)&&(m_stage[channel]))//end of samples, load anything staged in { m_stage[channel] = 0; @@ -581,14 +577,11 @@ void okim6376_device::write(uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void okim6376_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6376_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - for (int i = 0; i < OKIM6376_VOICES; i++) { struct ADPCMVoice *voice = &m_voice[i]; - auto &buffer = outputs[0]; int16_t sample_data[MAX_SAMPLE_CHUNK]; if (i == 0) //channel 1 is the only channel to affect NAR { @@ -603,19 +596,16 @@ void okim6376_device::sound_stream_update(sound_stream &stream, std::vector<read } /* loop while we have samples remaining */ - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { - int remaining = buffer.samples() - sampindex; + int remaining = stream.samples() - sampindex; int samples = (remaining > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : remaining; generate_adpcm(voice, sample_data, samples,i); for (int samp = 0; samp < samples; samp++) - buffer.add_int(sampindex + samp, sample_data[samp], 32768); + stream.add_int(0, sampindex + samp, sample_data[samp], 32768); sampindex += samples; } } - - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, std::clamp(outputs[0].getraw(i), -1.0f, 1.0f)); } diff --git a/src/devices/sound/okim6376.h b/src/devices/sound/okim6376.h index d7c334a4321..57b188fdf3f 100644 --- a/src/devices/sound/okim6376.h +++ b/src/devices/sound/okim6376.h @@ -32,7 +32,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/okim6588.cpp b/src/devices/sound/okim6588.cpp index de12b18664b..c745b42e555 100644 --- a/src/devices/sound/okim6588.cpp +++ b/src/devices/sound/okim6588.cpp @@ -88,10 +88,10 @@ void okim6588_device::device_reset() // internal handlers //------------------------------------------------- -void okim6588_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6588_device::sound_stream_update(sound_stream &stream) { // simply fill the buffer with the current sample - outputs[0].fill(m_adpcm.output() / 2048.0); + stream.fill(0, m_adpcm.output() / 2048.0); } TIMER_CALLBACK_MEMBER(okim6588_device::clock_adpcm) diff --git a/src/devices/sound/okim6588.h b/src/devices/sound/okim6588.h index 12f66f08c1e..c94ac32393a 100644 --- a/src/devices/sound/okim6588.h +++ b/src/devices/sound/okim6588.h @@ -32,7 +32,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum chip_mode : u8 diff --git a/src/devices/sound/okim9810.cpp b/src/devices/sound/okim9810.cpp index eba777cf227..f9d0d6e26c6 100644 --- a/src/devices/sound/okim9810.cpp +++ b/src/devices/sound/okim9810.cpp @@ -219,21 +219,11 @@ void okim9810_device::rom_bank_pre_change() // our sound stream //------------------------------------------------- -void okim9810_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim9810_device::sound_stream_update(sound_stream &stream) { - // reset the output streams - outputs[0].fill(0); - outputs[1].fill(0); - // iterate over voices and accumulate sample data for (auto & elem : m_voice) - elem.generate_audio(*this, outputs, m_global_volume, m_filter_type); - - for (int i = 0; i < outputs[0].samples(); i++) - { - outputs[0].put(i, std::clamp(outputs[0].getraw(i), -1.0f, 1.0f)); - outputs[1].put(i, std::clamp(outputs[1].getraw(i), -1.0f, 1.0f)); - } + elem.generate_audio(*this, stream, m_global_volume, m_filter_type); } @@ -627,7 +617,7 @@ okim9810_device::okim_voice::okim_voice() //------------------------------------------------- void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, - std::vector<write_stream_view> &outputs, + sound_stream &stream, const uint8_t global_volume, const uint8_t filter_type) { @@ -635,10 +625,6 @@ void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, if (!m_playing) return; - // separate out left and right channels - auto &outL = outputs[0]; - auto &outR = outputs[1]; - // get left and right volumes uint8_t volume_scale_left = volume_scale(global_volume, m_channel_volume, m_pan_volume_left); uint8_t volume_scale_right = volume_scale(global_volume, m_channel_volume, m_pan_volume_right); @@ -649,7 +635,7 @@ void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, return; // loop while we still have samples to generate - for (int sampindex = 0; sampindex < outL.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { if (m_phrase_state == SEQ_PAUSE) { @@ -814,10 +800,10 @@ void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, // output to the stereo buffers, scaling by the volume // signal in range -2048..2047, volume in range 2..128 => signal * volume / 8 in range -32768..32767 int32_t interpValueL = (interpValue * (int32_t)volume_scale_left); - outL.add_int(sampindex, interpValueL, 32768 * 8); + stream.add_int(0, sampindex, interpValueL, 32768 * 8); int32_t interpValueR = (interpValue * (int32_t)volume_scale_right); - outR.add_int(sampindex, interpValueR, 32768 * 8); + stream.add_int(1, sampindex, interpValueR, 32768 * 8); // if the interpsample has reached its end, move on to the next sample m_interpSampleNum++; diff --git a/src/devices/sound/okim9810.h b/src/devices/sound/okim9810.h index f5407702271..d44dcd5f12a 100644 --- a/src/devices/sound/okim9810.h +++ b/src/devices/sound/okim9810.h @@ -95,7 +95,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; @@ -106,7 +106,7 @@ protected: public: okim_voice(); void generate_audio(device_rom_interface &rom, - std::vector<write_stream_view> &buffers, + sound_stream &stream, const uint8_t global_volume, const uint8_t filter_type); diff --git a/src/devices/sound/pcd3311.cpp b/src/devices/sound/pcd3311.cpp index 4b5a4fb87f5..03e5cd2aa81 100644 --- a/src/devices/sound/pcd3311.cpp +++ b/src/devices/sound/pcd3311.cpp @@ -52,7 +52,6 @@ void pcd3311_device::device_start() // our sound stream //------------------------------------------------- -void pcd3311_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void pcd3311_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } diff --git a/src/devices/sound/pcd3311.h b/src/devices/sound/pcd3311.h index 29f6c49650a..840b9da69ad 100644 --- a/src/devices/sound/pcd3311.h +++ b/src/devices/sound/pcd3311.h @@ -48,7 +48,7 @@ protected: virtual void device_start() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: int m_a0; diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp index 35f389fcd58..8b1125495b5 100644 --- a/src/devices/sound/pokey.cpp +++ b/src/devices/sound/pokey.cpp @@ -724,10 +724,8 @@ void pokey_device::step_one_clock() // our sound stream //------------------------------------------------- -void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void pokey_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (m_output_type == LEGACY_LINEAR) { int32_t out = 0; @@ -735,8 +733,8 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st out += ((m_out_raw >> (4*i)) & 0x0f); out *= POKEY_DEFAULT_GAIN; out = (out > 0x7fff) ? 0x7fff : out; - stream_buffer::sample_t outsamp = out * stream_buffer::sample_t(1.0 / 32768.0); - buffer.fill(outsamp); + sound_stream::sample_t outsamp = out * sound_stream::sample_t(1.0 / 32768.0); + stream.fill(0, outsamp); } else if (m_output_type == RC_LOWPASS) { @@ -745,11 +743,11 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st double V0 = rTot / (rTot+m_r_pullup) * m_v_ref / 5.0; double mult = (m_cap == 0.0) ? 1.0 : 1.0 - exp(-(rTot + m_r_pullup) / (m_cap * m_r_pullup * rTot) * m_clock_period.as_double()); - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* store sum of output signals into the buffer */ m_out_filter += (V0 - m_out_filter) * mult; - buffer.put(sampindex, m_out_filter); + stream.put(0, sampindex, m_out_filter); } } else if (m_output_type == OPAMP_C_TO_GROUND) @@ -765,7 +763,7 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st */ double V0 = ((rTot+m_r_pullup) / rTot - 1.0) * m_v_ref / 5.0; - buffer.fill(V0); + stream.fill(0, V0); } else if (m_output_type == OPAMP_LOW_PASS) { @@ -777,16 +775,16 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st double V0 = (m_r_pullup / rTot) * m_v_ref / 5.0; double mult = (m_cap == 0.0) ? 1.0 : 1.0 - exp(-1.0 / (m_cap * m_r_pullup) * m_clock_period.as_double()); - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* store sum of output signals into the buffer */ m_out_filter += (V0 - m_out_filter) * mult; - buffer.put(sampindex, m_out_filter); + stream.put(0, sampindex, m_out_filter); } } else if (m_output_type == DISCRETE_VAR_R) { - buffer.fill(m_voltab[m_out_raw]); + stream.fill(0, m_voltab[m_out_raw]); } } diff --git a/src/devices/sound/pokey.h b/src/devices/sound/pokey.h index 065a98082be..f198b5820fb 100644 --- a/src/devices/sound/pokey.h +++ b/src/devices/sound/pokey.h @@ -182,7 +182,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void execute_run() override; @@ -302,7 +302,7 @@ private: uint32_t m_poly5[0x1f]; uint32_t m_poly9[0x1ff]; uint32_t m_poly17[0x1ffff]; - stream_buffer::sample_t m_voltab[0x10000]; + sound_stream::sample_t m_voltab[0x10000]; output_type m_output_type; double m_r_pullup; diff --git a/src/devices/sound/qs1000.cpp b/src/devices/sound/qs1000.cpp index b3f494890b4..b3e87b1515a 100644 --- a/src/devices/sound/qs1000.cpp +++ b/src/devices/sound/qs1000.cpp @@ -423,12 +423,8 @@ void qs1000_device::wave_w(offs_t offset, uint8_t data) //------------------------------------------------- // sound_stream_update - //------------------------------------------------- -void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void qs1000_device::sound_stream_update(sound_stream &stream) { - // Rset the output stream - outputs[0].fill(0); - outputs[1].fill(0); - // Iterate over voices and accumulate sample data for (auto & chan : m_channels) { @@ -440,7 +436,7 @@ void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_s { if (chan.m_flags & QS1000_ADPCM) { - for (int samp = 0; samp < outputs[0].samples(); samp++) + for (int samp = 0; samp < stream.samples(); samp++) { if (chan.m_addr >= chan.m_loop_end) { @@ -484,13 +480,13 @@ void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_s chan.m_addr = (chan.m_addr + (chan.m_acc >> 18)) & QS1000_ADDRESS_MASK; chan.m_acc &= ((1 << 18) - 1); - outputs[0].add_int(samp, result * 4 * lvol * vol, 32768 << 12); - outputs[1].add_int(samp, result * 4 * rvol * vol, 32768 << 12); + stream.add_int(0, samp, result * 4 * lvol * vol, 32768 << 12); + stream.add_int(1, samp, result * 4 * rvol * vol, 32768 << 12); } } else { - for (int samp = 0; samp < outputs[0].samples(); samp++) + for (int samp = 0; samp < stream.samples(); samp++) { if (chan.m_addr >= chan.m_loop_end) { @@ -513,8 +509,8 @@ void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_s chan.m_addr = (chan.m_addr + (chan.m_acc >> 18)) & QS1000_ADDRESS_MASK; chan.m_acc &= ((1 << 18) - 1); - outputs[0].add_int(samp, result * lvol * vol, 32768 << 12); - outputs[1].add_int(samp, result * rvol * vol, 32768 << 12); + stream.add_int(0, samp, result * lvol * vol, 32768 << 12); + stream.add_int(1, samp, result * rvol * vol, 32768 << 12); } } } diff --git a/src/devices/sound/qs1000.h b/src/devices/sound/qs1000.h index 8f8e83355bf..6a45ce83f6b 100644 --- a/src/devices/sound/qs1000.h +++ b/src/devices/sound/qs1000.h @@ -70,7 +70,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/qsound.cpp b/src/devices/sound/qsound.cpp index e1b4966a78a..306b22d9c0b 100644 --- a/src/devices/sound/qsound.cpp +++ b/src/devices/sound/qsound.cpp @@ -257,10 +257,10 @@ void qsound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void qsound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void qsound_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(stream_buffer::sample_t(m_samples[0]) * (1.0 / 32768.0)); - outputs[1].fill(stream_buffer::sample_t(m_samples[1]) * (1.0 / 32768.0)); + stream.fill(0, sound_stream::sample_t(m_samples[0]) * (1.0 / 32768.0)); + stream.fill(1, sound_stream::sample_t(m_samples[1]) * (1.0 / 32768.0)); } diff --git a/src/devices/sound/qsound.h b/src/devices/sound/qsound.h index bb69f26bbdd..c26f78a405b 100644 --- a/src/devices/sound/qsound.h +++ b/src/devices/sound/qsound.h @@ -33,7 +33,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_post_change() override; diff --git a/src/devices/sound/qsoundhle.cpp b/src/devices/sound/qsoundhle.cpp index ed69b569cb5..f1f5684038e 100644 --- a/src/devices/sound/qsoundhle.cpp +++ b/src/devices/sound/qsoundhle.cpp @@ -162,13 +162,13 @@ void qsound_hle_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void qsound_hle_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void qsound_hle_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i ++) + for (int i = 0; i < stream.samples(); i ++) { update_sample(); - outputs[0].put_int(i, m_out[0], 32768); - outputs[1].put_int(i, m_out[1], 32768); + stream.put_int(0, i, m_out[0], 32768); + stream.put_int(1, i, m_out[1], 32768); } } diff --git a/src/devices/sound/qsoundhle.h b/src/devices/sound/qsoundhle.h index c978ddf1719..166a01aabfe 100644 --- a/src/devices/sound/qsoundhle.h +++ b/src/devices/sound/qsoundhle.h @@ -30,7 +30,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/rf5c400.cpp b/src/devices/sound/rf5c400.cpp index fc466fb0a0f..b4311fc7c57 100644 --- a/src/devices/sound/rf5c400.cpp +++ b/src/devices/sound/rf5c400.cpp @@ -205,7 +205,7 @@ void rf5c400_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void rf5c400_device::sound_stream_update(sound_stream &stream) { int i, ch; uint64_t start, end, loop; @@ -214,18 +214,9 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_ uint8_t env_phase; double env_level, env_step, env_rstep; - outputs[0].fill(0); - outputs[1].fill(0); - outputs[2].fill(0); - outputs[3].fill(0); - for (ch=0; ch < 32; ch++) { rf5c400_channel *channel = &m_channels[ch]; - auto &buf0 = outputs[0]; - auto &buf1 = outputs[1]; - auto &buf2 = outputs[2]; - auto &buf3 = outputs[3]; start = ((uint32_t)(channel->startH & 0xFF00) << 8) | channel->startL; end = ((uint32_t)(channel->endHloopH & 0xFF) << 16) | channel->endL; @@ -249,7 +240,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_ continue; } - for (i=0; i < buf0.samples(); i++) + for (i=0; i < stream.samples(); i++) { int16_t tmp; int32_t sample; @@ -319,10 +310,10 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_ sample *= volume_table[vol]; sample = (sample >> 9) * env_level; - buf0.add_int(i, sample * pan_table[lvol], 32768); - buf1.add_int(i, sample * pan_table[rvol], 32768); - buf2.add_int(i, sample * pan_table[effect_lvol], 32768); - buf3.add_int(i, sample * pan_table[effect_rvol], 32768); + stream.add_int(0, i, sample * pan_table[lvol], 32768); + stream.add_int(1, i, sample * pan_table[rvol], 32768); + stream.add_int(2, i, sample * pan_table[effect_lvol], 32768); + stream.add_int(3, i, sample * pan_table[effect_rvol], 32768); pos += channel->step; if ((pos>>16) > end) diff --git a/src/devices/sound/rf5c400.h b/src/devices/sound/rf5c400.h index e7789817903..bc380571086 100644 --- a/src/devices/sound/rf5c400.h +++ b/src/devices/sound/rf5c400.h @@ -34,7 +34,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/rf5c68.cpp b/src/devices/sound/rf5c68.cpp index 09fd397d4fb..c7c062ddbd8 100644 --- a/src/devices/sound/rf5c68.cpp +++ b/src/devices/sound/rf5c68.cpp @@ -119,26 +119,19 @@ device_memory_interface::space_config_vector rf5c68_device::memory_space_config( // sound_stream_update - handle a stream update //------------------------------------------------- -void rf5c68_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void rf5c68_device::sound_stream_update(sound_stream &stream) { - auto &left = outputs[0]; - auto &right = outputs[1]; - /* bail if not enabled */ if (!m_enable) - { - left.fill(0); - right.fill(0); return; - } - if (m_mixleft.size() < left.samples()) - m_mixleft.resize(left.samples()); - if (m_mixright.size() < right.samples()) - m_mixright.resize(right.samples()); + if (m_mixleft.size() < stream.samples()) + m_mixleft.resize(stream.samples()); + if (m_mixright.size() < stream.samples()) + m_mixright.resize(stream.samples()); - std::fill_n(&m_mixleft[0], left.samples(), 0); - std::fill_n(&m_mixright[0], right.samples(), 0); + std::fill_n(&m_mixleft[0], stream.samples(), 0); + std::fill_n(&m_mixright[0], stream.samples(), 0); /* loop over channels */ for (pcm_channel &chan : m_chan) @@ -150,7 +143,7 @@ void rf5c68_device::sound_stream_update(sound_stream &stream, std::vector<read_s int rv = ((chan.pan >> 4) & 0x0f) * chan.env; /* loop over the sample buffer */ - for (int j = 0; j < left.samples(); j++) + for (int j = 0; j < stream.samples(); j++) { int sample; @@ -196,10 +189,10 @@ void rf5c68_device::sound_stream_update(sound_stream &stream, std::vector<read_s */ const u8 output_shift = (m_output_bits > 16) ? 0 : (16 - m_output_bits); const s32 output_nandmask = (1 << output_shift) - 1; - for (int j = 0; j < left.samples(); j++) + for (int j = 0; j < stream.samples(); j++) { - left.put_int_clamp(j, m_mixleft[j] & ~output_nandmask, 32768); - right.put_int_clamp(j, m_mixright[j] & ~output_nandmask, 32768); + stream.put_int_clamp(0, j, m_mixleft[j] & ~output_nandmask, 32768); + stream.put_int_clamp(1, j, m_mixright[j] & ~output_nandmask, 32768); } } diff --git a/src/devices/sound/rf5c68.h b/src/devices/sound/rf5c68.h index 5b67e2e65b5..f95dc124650 100644 --- a/src/devices/sound/rf5c68.h +++ b/src/devices/sound/rf5c68.h @@ -45,7 +45,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/roland_gp.cpp b/src/devices/sound/roland_gp.cpp index fb6c4f208c2..9ae0d449ae7 100644 --- a/src/devices/sound/roland_gp.cpp +++ b/src/devices/sound/roland_gp.cpp @@ -73,6 +73,6 @@ void tc6116_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void tc6116_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tc6116_device::sound_stream_update(sound_stream &stream) { } diff --git a/src/devices/sound/roland_gp.h b/src/devices/sound/roland_gp.h index 555d814bb07..48854950817 100644 --- a/src/devices/sound/roland_gp.h +++ b/src/devices/sound/roland_gp.h @@ -25,7 +25,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/roland_lp.cpp b/src/devices/sound/roland_lp.cpp index fd63f56cf76..fe918d080f0 100644 --- a/src/devices/sound/roland_lp.cpp +++ b/src/devices/sound/roland_lp.cpp @@ -256,17 +256,14 @@ void mb87419_mb87420_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void mb87419_mb87420_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mb87419_mb87420_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - for (auto& chn : m_chns) { if (! chn.enable || chn.play_dir == 0) continue; - for (int smpl = 0; smpl < outputs[0].samples(); smpl ++) + for (int smpl = 0; smpl < stream.samples(); smpl ++) { s32 smp_data; if (chn.play_dir > 0) @@ -274,8 +271,8 @@ void mb87419_mb87420_device::sound_stream_update(sound_stream &stream, std::vect else smp_data = sample_interpolate(chn.smpl_nxt, chn.smpl_cur, chn.addr & 0x3FFF); smp_data = smp_data * chn.volume; - outputs[0].add_int(smpl, smp_data, 32768 << 14); // >>14 results in a good overall volume - outputs[1].add_int(smpl, smp_data, 32768 << 14); + stream.add_int(0, smpl, smp_data, 32768 << 14); // >>14 results in a good overall volume + stream.add_int(1, smpl, smp_data, 32768 << 14); uint32_t old_addr = chn.addr; if (chn.play_dir > 0) diff --git a/src/devices/sound/roland_lp.h b/src/devices/sound/roland_lp.h index 3d9ced433d2..cc40a33d8c5 100644 --- a/src/devices/sound/roland_lp.h +++ b/src/devices/sound/roland_lp.h @@ -23,7 +23,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/roland_sa.cpp b/src/devices/sound/roland_sa.cpp index 9802d371368..2c365e2552d 100644 --- a/src/devices/sound/roland_sa.cpp +++ b/src/devices/sound/roland_sa.cpp @@ -264,12 +264,8 @@ void roland_sa_device::write(offs_t offset, u8 data) m_ctrl_mem[offset] = data; } -void roland_sa_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void roland_sa_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - - std::unique_ptr<int32_t []> int_buffer = make_unique_clear<int32_t []>(outputs[0].samples()); - for (size_t voiceI = 0; voiceI < NUM_VOICES; voiceI++) { for (size_t partI = 0; partI < PARTS_PER_VOICE; partI++) @@ -393,7 +389,7 @@ void roland_sa_device::sound_stream_update(sound_stream &stream, std::vector<rea exp_val2 = exp_val2 - 0x8000; int32_t exp_val = exp_val1 + exp_val2; - int_buffer[i] += exp_val; + stream.add_int(0, i, exp_val, 0x10000); } } @@ -405,7 +401,4 @@ void roland_sa_device::sound_stream_update(sound_stream &stream, std::vector<rea } } } - - for (size_t i = 0; i < outputs[0].samples(); i++) - outputs[0].put_int(i, int_buffer[i], 0xffff); } diff --git a/src/devices/sound/roland_sa.h b/src/devices/sound/roland_sa.h index 21c6440722c..3f88e910625 100644 --- a/src/devices/sound/roland_sa.h +++ b/src/devices/sound/roland_sa.h @@ -24,7 +24,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned NUM_VOICES = 16; diff --git a/src/devices/sound/rp2c33_snd.cpp b/src/devices/sound/rp2c33_snd.cpp index e50ce857f89..43cfbf46049 100644 --- a/src/devices/sound/rp2c33_snd.cpp +++ b/src/devices/sound/rp2c33_snd.cpp @@ -221,9 +221,9 @@ void rp2c33_sound_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void rp2c33_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void rp2c33_sound_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { m_output = 0; if (!m_env_halt && !m_wave_halt) @@ -234,7 +234,7 @@ void rp2c33_sound_device::sound_stream_update(sound_stream &stream, std::vector< exec_mod(); exec_wave(); /* Update the buffers */ - outputs[0].put_int(i, m_output * m_mvol_table[m_mvol], 32768); + stream.put_int(0, i, m_output * m_mvol_table[m_mvol], 32768); } } diff --git a/src/devices/sound/rp2c33_snd.h b/src/devices/sound/rp2c33_snd.h index fb125b56747..f6005092344 100644 --- a/src/devices/sound/rp2c33_snd.h +++ b/src/devices/sound/rp2c33_snd.h @@ -43,7 +43,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream = nullptr; diff --git a/src/devices/sound/s14001a.cpp b/src/devices/sound/s14001a.cpp index 64e23033206..6e8c871d6f5 100644 --- a/src/devices/sound/s14001a.cpp +++ b/src/devices/sound/s14001a.cpp @@ -297,13 +297,13 @@ void s14001a_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void s14001a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void s14001a_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { Clock(); s16 sample = m_uOutputP2 - 7; // range -7..8 - outputs[0].put_int(i, sample, 8); + stream.put_int(0, i, sample, 8); } } diff --git a/src/devices/sound/s14001a.h b/src/devices/sound/s14001a.h index 814f0a7795c..c430963f4e4 100644 --- a/src/devices/sound/s14001a.h +++ b/src/devices/sound/s14001a.h @@ -32,7 +32,7 @@ protected: virtual void rom_bank_pre_change() override { m_stream->update(); } // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: u8 ReadMem(u16 offset, bool phase); diff --git a/src/devices/sound/s_dsp.cpp b/src/devices/sound/s_dsp.cpp index cb29aa52eb2..b2248b4ef71 100644 --- a/src/devices/sound/s_dsp.cpp +++ b/src/devices/sound/s_dsp.cpp @@ -979,17 +979,17 @@ void s_dsp_device::state_register() // sound_stream_update - handle a stream update //------------------------------------------------- -void s_dsp_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void s_dsp_device::sound_stream_update(sound_stream &stream) { s16 mix[2]; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { mix[0] = mix[1] = 0; dsp_update(mix); /* Update the buffers */ - outputs[0].put_int_clamp(i, (s32)mix[0], 32768); - outputs[1].put_int_clamp(i, (s32)mix[1], 32768); + stream.put_int(0, i, (s32)mix[0], 32768); + stream.put_int(1, i, (s32)mix[1], 32768); } } diff --git a/src/devices/sound/s_dsp.h b/src/devices/sound/s_dsp.h index 568c5c51fe3..7102d077b47 100644 --- a/src/devices/sound/s_dsp.h +++ b/src/devices/sound/s_dsp.h @@ -30,7 +30,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/saa1099.cpp b/src/devices/sound/saa1099.cpp index 682cbb5873f..dd5f6154afd 100644 --- a/src/devices/sound/saa1099.cpp +++ b/src/devices/sound/saa1099.cpp @@ -203,17 +203,12 @@ void saa1099_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void saa1099_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void saa1099_device::sound_stream_update(sound_stream &stream) { int j, ch; /* if the channels are disabled we're done */ if (!m_all_ch_enable) - { - /* init output data */ - outputs[LEFT].fill(0); - outputs[RIGHT].fill(0); return; - } for (ch = 0; ch < 2; ch++) { @@ -227,7 +222,7 @@ void saa1099_device::sound_stream_update(sound_stream &stream, std::vector<read_ } /* fill all data needed */ - for( j = 0; j < outputs[0].samples(); j++ ) + for( j = 0; j < stream.samples(); j++ ) { int output_l = 0, output_r = 0; @@ -300,8 +295,8 @@ void saa1099_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_noise[ch].counter -= clock_divider; } /* write sound data to the buffer */ - outputs[LEFT].put_int(j, output_l, 32768 * 6); - outputs[RIGHT].put_int(j, output_r, 32768 * 6); + stream.put_int(LEFT, j, output_l, 32768 * 6); + stream.put_int(RIGHT, j, output_r, 32768 * 6); } } diff --git a/src/devices/sound/saa1099.h b/src/devices/sound/saa1099.h index fec5ccdc692..25433940c99 100644 --- a/src/devices/sound/saa1099.h +++ b/src/devices/sound/saa1099.h @@ -32,7 +32,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct saa1099_channel diff --git a/src/devices/sound/samples.cpp b/src/devices/sound/samples.cpp index afd72f5391a..4a1d527a958 100644 --- a/src/devices/sound/samples.cpp +++ b/src/devices/sound/samples.cpp @@ -315,34 +315,33 @@ void samples_device::device_post_load() // sound_stream_update - update a sound stream //------------------------------------------------- -void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void samples_device::sound_stream_update(sound_stream &stream) { // find the channel with this stream - constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; + constexpr sound_stream::sample_t sample_scale = 1.0 / 32768.0; for (int channel = 0; channel < m_channels; channel++) if (&stream == m_channel[channel].stream) { channel_t &chan = m_channel[channel]; - auto &buffer = outputs[0]; // process if we still have a source and we're not paused if (chan.source != nullptr && !chan.paused) { // load some info locally - double step = double(chan.curfreq) / double(buffer.sample_rate()); + double step = double(chan.curfreq) / double(stream.sample_rate()); double endpos = chan.source_len; const int16_t *sample = chan.source; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // do a linear interp on the sample double pos_floor = floor(chan.pos); double frac = chan.pos - pos_floor; int32_t ipos = int32_t(pos_floor); - stream_buffer::sample_t sample1 = stream_buffer::sample_t(sample[ipos++]); - stream_buffer::sample_t sample2 = stream_buffer::sample_t(sample[(ipos + 1) % chan.source_len]); - buffer.put(sampindex, sample_scale * ((1.0 - frac) * sample1 + frac * sample2)); + sound_stream::sample_t sample1 = sound_stream::sample_t(sample[ipos++]); + sound_stream::sample_t sample2 = sound_stream::sample_t(sample[(ipos + 1) % chan.source_len]); + stream.put(0, sampindex, sample_scale * ((1.0 - frac) * sample1 + frac * sample2)); // advance chan.pos += step; @@ -356,14 +355,11 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_ { chan.source = nullptr; chan.source_num = -1; - buffer.fill(0, sampindex); break; } } } } - else - buffer.fill(0); break; } } diff --git a/src/devices/sound/samples.h b/src/devices/sound/samples.h index dae042016c6..975b85e5bdf 100644 --- a/src/devices/sound/samples.h +++ b/src/devices/sound/samples.h @@ -78,7 +78,7 @@ protected: virtual void device_post_load() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // internal classes struct channel_t diff --git a/src/devices/sound/scsp.cpp b/src/devices/sound/scsp.cpp index 2caec3580ae..ee0d31e4778 100644 --- a/src/devices/sound/scsp.cpp +++ b/src/devices/sound/scsp.cpp @@ -310,9 +310,9 @@ void scsp_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void scsp_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void scsp_device::sound_stream_update(sound_stream &stream) { - DoMasterSamples(inputs, outputs); + DoMasterSamples(stream); } u8 scsp_device::DecodeSCI(u8 irq) @@ -1264,12 +1264,9 @@ inline s32 scsp_device::UpdateSlot(SCSP_SLOT *slot) return sample; } -void scsp_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void scsp_device::DoMasterSamples(sound_stream &stream) { - auto &bufr = outputs[1]; - auto &bufl = outputs[0]; - - for (int s = 0; s < bufl.samples(); ++s) + for (int s = 0; s < stream.samples(); ++s) { s32 smpl = 0, smpr = 0; @@ -1325,7 +1322,7 @@ void scsp_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, s SCSP_SLOT *slot = m_Slots + i + 16; // 100217, 100237 EFSDL, EFPAN for EXTS0/1 if (EFSDL(slot)) { - m_DSP.EXTS[i] = s32(inputs[i].get(s) * 32768.0); + m_DSP.EXTS[i] = s32(stream.get(i, s) * 32768.0); u16 Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd); smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT; smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT; @@ -1334,13 +1331,13 @@ void scsp_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, s if (DAC18B()) { - bufl.put_int_clamp(s, smpl, 131072); - bufr.put_int_clamp(s, smpr, 131072); + stream.put_int_clamp(0, s, smpl, 131072); + stream.put_int_clamp(1, s, smpr, 131072); } else { - bufl.put_int_clamp(s, smpl >> 2, 32768); - bufr.put_int_clamp(s, smpr >> 2, 32768); + stream.put_int_clamp(0, s, smpl >> 2, 32768); + stream.put_int_clamp(1, s, smpr >> 2, 32768); } } } diff --git a/src/devices/sound/scsp.h b/src/devices/sound/scsp.h index 9b02afd4767..4ec5d60f44b 100644 --- a/src/devices/sound/scsp.h +++ b/src/devices/sound/scsp.h @@ -48,7 +48,7 @@ protected: virtual void rom_bank_pre_change() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum SCSP_STATE { SCSP_ATTACK, SCSP_DECAY1, SCSP_DECAY2, SCSP_RELEASE }; @@ -184,7 +184,7 @@ private: void w16(u32 addr, u16 val); u16 r16(u32 addr); inline s32 UpdateSlot(SCSP_SLOT *slot); - void DoMasterSamples(std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs); + void DoMasterSamples(sound_stream &stream); //LFO void LFO_Init(); diff --git a/src/devices/sound/segapcm.cpp b/src/devices/sound/segapcm.cpp index 9f7a9b6fc63..81f6ceffec9 100644 --- a/src/devices/sound/segapcm.cpp +++ b/src/devices/sound/segapcm.cpp @@ -72,12 +72,8 @@ void segapcm_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void segapcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void segapcm_device::sound_stream_update(sound_stream &stream) { - /* clear the buffers */ - outputs[0].fill(0); - outputs[1].fill(0); - // reg function // ------------------------------------------------ // 0x00 ? @@ -114,7 +110,7 @@ void segapcm_device::sound_stream_update(sound_stream &stream, std::vector<read_ int i; /* loop over samples on this channel */ - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int8_t v; @@ -133,8 +129,8 @@ void segapcm_device::sound_stream_update(sound_stream &stream, std::vector<read_ v = read_byte(offset + (addr >> 8)) - 0x80; /* apply panning and advance */ - outputs[0].add_int(i, v * (regs[2] & 0x7f), 32768); - outputs[1].add_int(i, v * (regs[3] & 0x7f), 32768); + stream.add_int(0, i, v * (regs[2] & 0x7f), 32768); + stream.add_int(1, i, v * (regs[3] & 0x7f), 32768); addr = (addr + regs[7]) & 0xffffff; } diff --git a/src/devices/sound/segapcm.h b/src/devices/sound/segapcm.h index c89ab3e1859..673c8075f27 100644 --- a/src/devices/sound/segapcm.h +++ b/src/devices/sound/segapcm.h @@ -41,7 +41,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/setapcm.cpp b/src/devices/sound/setapcm.cpp index ab002f68f10..c2eba36d31d 100644 --- a/src/devices/sound/setapcm.cpp +++ b/src/devices/sound/setapcm.cpp @@ -142,20 +142,17 @@ void setapcm_device<MaxVoices, Divider>::device_clock_changed() //------------------------------------------------- template<unsigned MaxVoices, unsigned Divider> -void setapcm_device<MaxVoices, Divider>::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void setapcm_device<MaxVoices, Divider>::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - - for (int sampleind = 0; sampleind < outputs[0].samples(); sampleind++) + for (int sampleind = 0; sampleind < stream.samples(); sampleind++) { for (int v = 0; v < MAX_VOICES; v++) { // check if voice is activated if (m_voice[v].update()) { - outputs[0].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 16, 32768 * MAX_VOICES); - outputs[1].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 16, 32768 * MAX_VOICES); + stream.add_int(0, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 16, 32768 * MAX_VOICES); + stream.add_int(1, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 16, 32768 * MAX_VOICES); } } } diff --git a/src/devices/sound/setapcm.h b/src/devices/sound/setapcm.h index bf55b14d460..fbd809cab9e 100644 --- a/src/devices/sound/setapcm.h +++ b/src/devices/sound/setapcm.h @@ -38,7 +38,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/sid.cpp b/src/devices/sound/sid.cpp index 86264810fda..7f7292a57be 100644 --- a/src/devices/sound/sid.cpp +++ b/src/devices/sound/sid.cpp @@ -29,9 +29,9 @@ float filterResTable[16]; #define maxLogicalVoices 4 -inline stream_buffer::sample_t mix_mono(uint16_t usum) +inline sound_stream::sample_t mix_mono(uint16_t usum) { - return stream_buffer::sample_t(int16_t(usum - maxLogicalVoices*128)) * (1.0 / (256 * maxLogicalVoices)); + return sound_stream::sample_t(int16_t(usum - maxLogicalVoices*128)) * (1.0 / (256 * maxLogicalVoices)); } } // anonymous namespace @@ -61,13 +61,13 @@ inline void SID6581_t::syncEm() } -void SID6581_t::fill_buffer(write_stream_view &buffer) +void SID6581_t::fill_buffer(sound_stream &stream) { //void* SID6581_t::fill16bitMono(void* buffer, uint32_t numberOfSamples) - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, mix_mono( + stream.put(0, sampindex, mix_mono( (*optr[0].outProc)(&optr[0]) +(*optr[1].outProc)(&optr[1]) +((*optr[2].outProc)(&optr[2])&optr3_outputmask) diff --git a/src/devices/sound/sid.h b/src/devices/sound/sid.h index 0b0af441879..45f900758f5 100644 --- a/src/devices/sound/sid.h +++ b/src/devices/sound/sid.h @@ -63,7 +63,7 @@ struct SID6581_t int port_r(running_machine &machine, int offset); void port_w(int offset, int data); - void fill_buffer(write_stream_view &buffer); + void fill_buffer(sound_stream &stream); private: void syncEm(); diff --git a/src/devices/sound/sn76477.cpp b/src/devices/sound/sn76477.cpp index 1ed2f8b57fe..ec855769be6 100644 --- a/src/devices/sound/sn76477.cpp +++ b/src/devices/sound/sn76477.cpp @@ -1700,7 +1700,7 @@ void sn76477_device::state_save_register() // sound_stream_update - handle a stream update //------------------------------------------------- -void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sn76477_device::sound_stream_update(sound_stream &stream) { double one_shot_cap_charging_step; double one_shot_cap_discharging_step; @@ -1719,8 +1719,6 @@ void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_ double voltage_out; double center_to_peak_voltage_out; - auto &buffer = outputs[0]; - /* compute charging values, doing it here ensures that we always use the latest values */ one_shot_cap_charging_step = compute_one_shot_cap_charging_rate() / m_our_sample_rate; one_shot_cap_discharging_step = compute_one_shot_cap_discharging_rate() / m_our_sample_rate; @@ -1743,7 +1741,7 @@ void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_ /* process 'samples' number of samples */ - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* update the one-shot cap voltage */ if (!m_one_shot_cap_voltage_ext) @@ -1995,7 +1993,7 @@ void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_ sample = | ----------- - 1 | \ Vcen - Vmin / */ - buffer.put(sampindex, ((voltage_out - OUT_LOW_CLIP_THRESHOLD) / (OUT_CENTER_LEVEL_VOLTAGE - OUT_LOW_CLIP_THRESHOLD)) - 1); + stream.put(0, sampindex, ((voltage_out - OUT_LOW_CLIP_THRESHOLD) / (OUT_CENTER_LEVEL_VOLTAGE - OUT_LOW_CLIP_THRESHOLD)) - 1); if (LOG_WAV && (!m_enable || !LOG_WAV_ENABLED_ONLY)) { diff --git a/src/devices/sound/sn76477.h b/src/devices/sound/sn76477.h index c37a7326b4c..dd4e89a50e2 100644 --- a/src/devices/sound/sn76477.h +++ b/src/devices/sound/sn76477.h @@ -149,7 +149,7 @@ protected: virtual void device_stop() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: /* chip's external interface */ diff --git a/src/devices/sound/sn76496.cpp b/src/devices/sound/sn76496.cpp index 923a1d890d8..38a0c71faf5 100644 --- a/src/devices/sound/sn76496.cpp +++ b/src/devices/sound/sn76496.cpp @@ -365,16 +365,14 @@ inline bool sn76496_base_device::in_noise_mode() return ((m_register[6] & 4)!=0); } -void sn76496_base_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sn76496_base_device::sound_stream_update(sound_stream &stream) { int i; - auto *lbuffer = &outputs[0]; - auto *rbuffer = m_stereo ? &outputs[1] : nullptr; int16_t out; int16_t out2 = 0; - for (int sampindex = 0; sampindex < lbuffer->samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // clock chip once if (m_current_clock > 0) // not ready for new divided clock @@ -440,9 +438,9 @@ void sn76496_base_device::sound_stream_update(sound_stream &stream, std::vector< if (m_negate) { out = -out; out2 = -out2; } - lbuffer->put_int(sampindex, out, 32768); + stream.put_int(0, sampindex, out, 32768); if (m_stereo) - rbuffer->put_int(sampindex, out2, 32768); + stream.put_int(1, sampindex, out2, 32768); } } diff --git a/src/devices/sound/sn76496.h b/src/devices/sound/sn76496.h index cbe73e7e6e7..46471398f02 100644 --- a/src/devices/sound/sn76496.h +++ b/src/devices/sound/sn76496.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_ready); diff --git a/src/devices/sound/snkwave.cpp b/src/devices/sound/snkwave.cpp index 9bd3ac62053..d11db0dc957 100644 --- a/src/devices/sound/snkwave.cpp +++ b/src/devices/sound/snkwave.cpp @@ -64,22 +64,17 @@ void snkwave_device::device_start() // for our sound stream //------------------------------------------------- -void snkwave_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void snkwave_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - assert(m_counter < 0x1000); assert(m_frequency < 0x1000); /* if no sound, we're done */ if (m_frequency == 0xfff) - { - buffer.fill(0); return; - } /* generate sound into buffer while updating the counter */ - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int loops; int16_t out = 0; @@ -104,7 +99,7 @@ void snkwave_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - buffer.put_int(sampindex, out, 32768); + stream.put_int(0, sampindex, out, 32768); } } diff --git a/src/devices/sound/snkwave.h b/src/devices/sound/snkwave.h index 091bd4e12e8..75b8c88e5b5 100644 --- a/src/devices/sound/snkwave.h +++ b/src/devices/sound/snkwave.h @@ -26,7 +26,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned WAVEFORM_LENGTH = 16; diff --git a/src/devices/sound/sp0250.cpp b/src/devices/sound/sp0250.cpp index 2c4384888e9..763fc5b11e0 100644 --- a/src/devices/sound/sp0250.cpp +++ b/src/devices/sound/sp0250.cpp @@ -257,18 +257,16 @@ int8_t sp0250_device::next() // sound_stream_update - handle a stream update //------------------------------------------------- -void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sp0250_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; - if (!m_pwm_mode) { - for (int sampindex = 0; sampindex < output.samples(); sampindex++) - output.put_int(sampindex, next(), 128); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put_int(0, sampindex, next(), 128); } else { - for (int sampindex = 0; sampindex < output.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { // see where we're at in the current PWM cycle if (m_pwm_index >= PWM_CLOCKS) @@ -282,7 +280,7 @@ void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_s // determine the value to fill and the number of samples remaining // until it changes - stream_buffer::sample_t value; + sound_stream::sample_t value; int remaining; if (m_pwm_index < m_pwm_count) { @@ -296,13 +294,13 @@ void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_s } // clamp to the number of samples requested and advance the counters - if (remaining > output.samples() - sampindex) - remaining = output.samples() - sampindex; + if (remaining > stream.samples() - sampindex) + remaining = stream.samples() - sampindex; m_pwm_index += remaining; // fill the output while (remaining-- != 0) - outputs[0].put(sampindex++, value); + stream.put(0, sampindex++, value); } } } diff --git a/src/devices/sound/sp0250.h b/src/devices/sound/sp0250.h index fdba7710007..0becd7c93e6 100644 --- a/src/devices/sound/sp0250.h +++ b/src/devices/sound/sp0250.h @@ -22,7 +22,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); } private: diff --git a/src/devices/sound/sp0256.cpp b/src/devices/sound/sp0256.cpp index 3486f710be3..ba84d002eb5 100644 --- a/src/devices/sound/sp0256.cpp +++ b/src/devices/sound/sp0256.cpp @@ -1259,12 +1259,11 @@ void sp0256_device::set_clock(int clock) // sound_stream_update - handle a stream update //------------------------------------------------- -void sp0256_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sp0256_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; int output_index = 0; - while (output_index < output.samples()) + while (output_index < stream.samples()) { /* ---------------------------------------------------------------- */ /* First, drain as much of our scratch buffer as we can into the */ @@ -1272,20 +1271,20 @@ void sp0256_device::sound_stream_update(sound_stream &stream, std::vector<read_s /* ---------------------------------------------------------------- */ while (m_sc_tail != m_sc_head) { - output.put_int(output_index++, m_scratch[m_sc_tail++ & SCBUF_MASK], 32768); + stream.put_int(0, output_index++, m_scratch[m_sc_tail++ & SCBUF_MASK], 32768); m_sc_tail &= SCBUF_MASK; - if (output_index >= output.samples()) + if (output_index >= stream.samples()) break; } /* ---------------------------------------------------------------- */ /* If output outputs is full, then we're done. */ /* ---------------------------------------------------------------- */ - if (output_index > output.samples()) + if (output_index > stream.samples()) break; - int length = output.samples() - output_index; + int length = stream.samples() - output_index; /* ---------------------------------------------------------------- */ /* Process the current set of filter coefficients as long as the */ diff --git a/src/devices/sound/sp0256.h b/src/devices/sound/sp0256.h index bc7beda7433..eee0a3c05a5 100644 --- a/src/devices/sound/sp0256.h +++ b/src/devices/sound/sp0256.h @@ -60,7 +60,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); } private: diff --git a/src/devices/sound/spkrdev.cpp b/src/devices/sound/spkrdev.cpp index 19d1f1813d6..841656ab4ac 100644 --- a/src/devices/sound/spkrdev.cpp +++ b/src/devices/sound/spkrdev.cpp @@ -187,19 +187,18 @@ void speaker_sound_device::device_post_load() //------------------------------------------------- // This can be triggered by the core (based on emulated time) or via level_w(). -void speaker_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void speaker_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; double volume = m_levels[m_level]; double filtered_volume; attotime sampled_time = attotime::zero; - if (buffer.samples() > 0) + if (stream.samples() > 0) { /* Prepare to update time state */ sampled_time = attotime(0, m_channel_sample_period); - if (buffer.samples() > 1) - sampled_time *= buffer.samples(); + if (stream.samples() > 1) + sampled_time *= stream.samples(); /* Note: since the stream is in the process of being updated, * stream->sample_time() will return the time before the update! (MAME 0.130) @@ -207,19 +206,19 @@ void speaker_sound_device::sound_stream_update(sound_stream &stream, std::vector */ } - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { /* Note that first intermediate sample may be composed... */ filtered_volume = update_interm_samples_get_filtered_volume(volume); /* Composite volume is now quantized to the stream resolution */ - buffer.put(sampindex++, filtered_volume); + stream.put(0, sampindex++, filtered_volume); /* Any additional samples will be homogeneous, however may need filtering across samples: */ - while (sampindex < buffer.samples()) + while (sampindex < stream.samples()) { filtered_volume = update_interm_samples_get_filtered_volume(volume); - buffer.put(sampindex++, filtered_volume); + stream.put(0, sampindex++, filtered_volume); } /* Update the time state */ diff --git a/src/devices/sound/spkrdev.h b/src/devices/sound/spkrdev.h index 24a76d78c4c..175cc1f5996 100644 --- a/src/devices/sound/spkrdev.h +++ b/src/devices/sound/spkrdev.h @@ -32,7 +32,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // Length of anti-aliasing filter kernel, measured in number of intermediate samples diff --git a/src/devices/sound/spu.cpp b/src/devices/sound/spu.cpp index 848e432cb02..e6b5d2e5fa3 100644 --- a/src/devices/sound/spu.cpp +++ b/src/devices/sound/spu.cpp @@ -2769,20 +2769,17 @@ void spu_device::update_timing() // // -void spu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void spu_device::sound_stream_update(sound_stream &stream) { int16_t temp[44100], *src; - auto &outL = outputs[0]; - auto &outR = outputs[1]; - - generate(temp, outputs[0].samples()*4); // second parameter is bytes, * 2 (size of int16_t) * 2 (stereo) + generate(temp, stream.samples()*4); // second parameter is bytes, * 2 (size of int16_t) * 2 (stereo) src = &temp[0]; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - outL.put_int(i, *src++, 32768); - outR.put_int(i, *src++, 32768); + stream.put_int(0, i, *src++, 32768); + stream.put_int(1, i, *src++, 32768); } } diff --git a/src/devices/sound/spu.h b/src/devices/sound/spu.h index e2641cd5a49..ff51c9c378d 100644 --- a/src/devices/sound/spu.h +++ b/src/devices/sound/spu.h @@ -36,7 +36,7 @@ protected: virtual void device_post_load() override; virtual void device_stop() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; float spu_base_frequency_hz; float linear_rate[108]; diff --git a/src/devices/sound/ssi263hle.cpp b/src/devices/sound/ssi263hle.cpp index 738b6c61084..8ae56fa93f4 100644 --- a/src/devices/sound/ssi263hle.cpp +++ b/src/devices/sound/ssi263hle.cpp @@ -41,7 +41,7 @@ static const u8 PHONEMES_TO_SC01[0x40] = ssi263hle_device::ssi263hle_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, SSI263HLE, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 1) + , device_mixer_interface(mconfig, *this) , m_votrax(*this, "votrax") , m_ar_cb(*this) , m_phoneme_timer(nullptr) @@ -116,7 +116,7 @@ void ssi263hle_device::device_add_mconfig(machine_config &config) { VOTRAX_SC01(config, m_votrax, DERIVED_CLOCK(1, 1)); m_votrax->ar_callback().set(FUNC(ssi263hle_device::votrax_request)); - m_votrax->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + m_votrax->add_route(ALL_OUTPUTS, *this, 1.0, 0); } TIMER_CALLBACK_MEMBER(ssi263hle_device::phoneme_tick) diff --git a/src/devices/sound/st0016.cpp b/src/devices/sound/st0016.cpp index 39d85aed58b..420ff9955bc 100644 --- a/src/devices/sound/st0016.cpp +++ b/src/devices/sound/st0016.cpp @@ -70,20 +70,17 @@ void st0016_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void st0016_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void st0016_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - - for (int sampleind = 0; sampleind < outputs[0].samples(); sampleind++) + for (int sampleind = 0; sampleind < stream.samples(); sampleind++) { for (int v = 0; v < 8; v++) { // check if voice is activated if (m_voice[v].update()) { - outputs[0].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 8, 32768 << 4); - outputs[1].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 8, 32768 << 4); + stream.add_int(0, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 8, 32768 << 4); + stream.add_int(1, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 8, 32768 << 4); } } } diff --git a/src/devices/sound/st0016.h b/src/devices/sound/st0016.h index 8153e14a288..d40e07b5c6a 100644 --- a/src/devices/sound/st0016.h +++ b/src/devices/sound/st0016.h @@ -25,7 +25,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/stt_sa1.cpp b/src/devices/sound/stt_sa1.cpp index efd9e49e163..29cd61e61ff 100644 --- a/src/devices/sound/stt_sa1.cpp +++ b/src/devices/sound/stt_sa1.cpp @@ -160,22 +160,19 @@ void stt_sa1_device::device_reset() } } -void stt_sa1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void stt_sa1_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - for (int v = 0; v < 8; v++) { voice_t &voice = m_voice[v]; - for (int i = 0; i < outputs[0].samples() && voice.enabled; i++) { + for (int i = 0; i < stream.samples() && voice.enabled; i++) { const offs_t offset = voice.addr_cur >> 12; const int sample = s8(read_byte(offset)) << 8; voice.addr_cur += voice.freq; - outputs[0].add_int(i, (sample * voice.vol_l) >> 16, 32768 * 8); - outputs[1].add_int(i, (sample * voice.vol_r) >> 16, 32768 * 8); + stream.add_int(0, i, (sample * voice.vol_l) >> 16, 32768 * 8); + stream.add_int(1, i, (sample * voice.vol_r) >> 16, 32768 * 8); if (voice.addr_cur >= voice.addr_end) { if (!voice.is_looped) { diff --git a/src/devices/sound/stt_sa1.h b/src/devices/sound/stt_sa1.h index 15b41f79a3a..66bc93a4480 100644 --- a/src/devices/sound/stt_sa1.h +++ b/src/devices/sound/stt_sa1.h @@ -28,7 +28,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct voice_t { diff --git a/src/devices/sound/swp00.cpp b/src/devices/sound/swp00.cpp index 17bbfd45ae3..f04161b22b3 100644 --- a/src/devices/sound/swp00.cpp +++ b/src/devices/sound/swp00.cpp @@ -1259,13 +1259,13 @@ double v2f2(s32 value) return (1.0 - (value & 0xffffff) / 33554432.0) / (1 << (value >> 24)); } -void swp00_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swp00_device::sound_stream_update(sound_stream &stream) { const delay_block brev(this, m_rev_buffer); const delay_block bcho(this, m_cho_buffer); const delay_block bvar(this, m_var_buffer); - for(int i=0; i != outputs[0].samples(); i++) { + for(int i=0; i != stream.samples(); i++) { s32 dry_l = 0, dry_r = 0; s32 rev = 0; s32 cho_l = 0, cho_r = 0; @@ -1838,8 +1838,8 @@ void swp00_device::sound_stream_update(sound_stream &stream, std::vector<read_st dry_l += m9v(rev_out_l, m_rev_vol) + m9v(m9(cho_out_l, 0x17), m_cho_vol) + m9v(m9(var_out_l, 0x18), m_var_vol); dry_r += m9v(rev_out_r, m_rev_vol) + m9v(m9(cho_out_r, 0x0e), m_cho_vol) + m9v(m9(var_out_r, 0x0f), m_var_vol); - outputs[0].put_int(i, dry_l, 32768); - outputs[1].put_int(i, dry_r, 32768); + stream.put_int(0, i, dry_l, 32768); + stream.put_int(1, i, dry_r, 32768); m_buffer_offset --; } diff --git a/src/devices/sound/swp00.h b/src/devices/sound/swp00.h index 22d8bc60db4..72730798e8a 100644 --- a/src/devices/sound/swp00.h +++ b/src/devices/sound/swp00.h @@ -21,7 +21,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void rom_bank_pre_change() override; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; diff --git a/src/devices/sound/swp20.cpp b/src/devices/sound/swp20.cpp index 947d2bb8b0a..ed22a0b74ff 100644 --- a/src/devices/sound/swp20.cpp +++ b/src/devices/sound/swp20.cpp @@ -220,9 +220,7 @@ void swp20_device::snd_w(offs_t offset, u8 data) } } -void swp20_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swp20_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); } diff --git a/src/devices/sound/swp20.h b/src/devices/sound/swp20.h index 5d02a24f8cf..1086fd8b792 100644 --- a/src/devices/sound/swp20.h +++ b/src/devices/sound/swp20.h @@ -20,7 +20,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/devices/sound/swp30.cpp b/src/devices/sound/swp30.cpp index 15d87e4233f..d135a77f16c 100644 --- a/src/devices/sound/swp30.cpp +++ b/src/devices/sound/swp30.cpp @@ -1285,10 +1285,10 @@ void swp30_device::state_string_export(const device_state_entry &entry, std::str { } -void swp30_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swp30_device::sound_stream_update(sound_stream &stream) { - outputs[0].put_int_clamp(0, m_meg_output[0], 32768); - outputs[1].put_int_clamp(0, m_meg_output[1], 32768); + stream.put_int_clamp(0, 0, m_meg_output[0], 32768); + stream.put_int_clamp(1, 0, m_meg_output[1], 32768); } void swp30_device::change_mode_attack_decay1(int chan) diff --git a/src/devices/sound/swp30.h b/src/devices/sound/swp30.h index e6b9d8be03e..eb34fb13eec 100644 --- a/src/devices/sound/swp30.h +++ b/src/devices/sound/swp30.h @@ -22,7 +22,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual uint32_t execute_min_cycles() const noexcept override; virtual uint32_t execute_max_cycles() const noexcept override; virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const noexcept override { return (clocks + 1) / 2; } diff --git a/src/devices/sound/swx00.cpp b/src/devices/sound/swx00.cpp index 1e0bc782777..4643e8e5058 100644 --- a/src/devices/sound/swx00.cpp +++ b/src/devices/sound/swx00.cpp @@ -549,9 +549,9 @@ s32 swx00_sound_device::fpapply(s32 value, s32 sample) return (s64(sample) - ((s64(sample) * ((value >> 9) & 0x7fff)) >> 16)) >> (value >> 24); } -void swx00_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swx00_sound_device::sound_stream_update(sound_stream &stream) { - for(int i=0; i != outputs[0].samples(); i++) { + for(int i=0; i != stream.samples(); i++) { s32 dry_l = 0, dry_r = 0; s32 rev = 0; s32 cho_l = 0, cho_r = 0; @@ -715,7 +715,7 @@ void swx00_sound_device::sound_stream_update(sound_stream &stream, std::vector<r (void)var_l; (void)var_r; - outputs[0].put_int(i, dry_l, 32768); - outputs[1].put_int(i, dry_r, 32768); + stream.put_int(0, i, dry_l, 32768); + stream.put_int(1, i, dry_r, 32768); } } diff --git a/src/devices/sound/swx00.h b/src/devices/sound/swx00.h index e35ddd0a63a..5e7b78808a6 100644 --- a/src/devices/sound/swx00.h +++ b/src/devices/sound/swx00.h @@ -21,7 +21,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; private: diff --git a/src/devices/sound/t6721a.cpp b/src/devices/sound/t6721a.cpp index a094d4dc783..ae4ee8551eb 100644 --- a/src/devices/sound/t6721a.cpp +++ b/src/devices/sound/t6721a.cpp @@ -59,9 +59,8 @@ void t6721a_device::device_start() // our sound stream //------------------------------------------------- -void t6721a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void t6721a_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } diff --git a/src/devices/sound/t6721a.h b/src/devices/sound/t6721a.h index 861c03967da..ed680c0424a 100644 --- a/src/devices/sound/t6721a.h +++ b/src/devices/sound/t6721a.h @@ -65,7 +65,7 @@ protected: virtual void device_start() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum diff --git a/src/devices/sound/t6w28.cpp b/src/devices/sound/t6w28.cpp index 9525794e489..bbb483557d8 100644 --- a/src/devices/sound/t6w28.cpp +++ b/src/devices/sound/t6w28.cpp @@ -104,26 +104,21 @@ void t6w28_device::write(offs_t offset, uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void t6w28_device::sound_stream_update(sound_stream &stream) { - int i; - auto &buffer0 = outputs[0]; - auto &buffer1 = outputs[1]; - - /* If the volume is 0, increase the counter */ - for (i = 0;i < 8;i++) + for (int i = 0;i < 8;i++) { if (m_volume[i] == 0) { /* note that I do count += samples, NOT count = samples + 1. You might think */ /* it's the same since the volume is 0, but doing the latter could cause */ /* interferencies when the program is rapidly modulating the volume. */ - if (m_count[i] <= buffer0.samples()*STEP) m_count[i] += buffer0.samples()*STEP; + if (m_count[i] <= stream.samples()*STEP) m_count[i] += stream.samples()*STEP; } } - for (int sampindex = 0; sampindex < buffer0.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int vol[8]; unsigned int out0, out1; @@ -134,7 +129,7 @@ void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_st /* in the 1 position during the sample period. */ vol[0] = vol[1] = vol[2] = vol[3] = vol[4] = vol[5] = vol[6] = vol[7] = 0; - for (i = 2;i < 3;i++) + for (int i = 2;i < 3;i++) { if (m_output[i]) vol[i] += m_count[i]; m_count[i] -= STEP; @@ -161,7 +156,7 @@ void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_st if (m_output[i]) vol[i] -= m_count[i]; } - for (i = 4;i < 7;i++) + for (int i = 4;i < 7;i++) { if (m_output[i]) vol[i] += m_count[i]; m_count[i] -= STEP; @@ -252,8 +247,8 @@ void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_st if (out0 > MAX_OUTPUT * STEP) out0 = MAX_OUTPUT * STEP; if (out1 > MAX_OUTPUT * STEP) out1 = MAX_OUTPUT * STEP; - buffer0.put_int(sampindex, out0 / STEP, 32768); - buffer1.put_int(sampindex, out1 / STEP, 32768); + stream.put_int(0, sampindex, out0 / STEP, 32768); + stream.put_int(1, sampindex, out1 / STEP, 32768); } } diff --git a/src/devices/sound/t6w28.h b/src/devices/sound/t6w28.h index 8d90c05bbe6..c0cff413c56 100644 --- a/src/devices/sound/t6w28.h +++ b/src/devices/sound/t6w28.h @@ -18,7 +18,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void set_gain(int gain); diff --git a/src/devices/sound/tc8830f.cpp b/src/devices/sound/tc8830f.cpp index f9f65975347..db60e255f0b 100644 --- a/src/devices/sound/tc8830f.cpp +++ b/src/devices/sound/tc8830f.cpp @@ -82,11 +82,11 @@ void tc8830f_device::device_clock_changed() -void tc8830f_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tc8830f_device::sound_stream_update(sound_stream &stream) { int32_t mix = 0; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { if (m_playing) { @@ -128,7 +128,7 @@ void tc8830f_device::sound_stream_update(sound_stream &stream, std::vector<read_ mix = m_output; } - outputs[0].put_int(i, mix, 32768); + stream.put_int(0, i, mix, 32768); } } diff --git a/src/devices/sound/tc8830f.h b/src/devices/sound/tc8830f.h index fa1a3c8f938..808608e6e64 100644 --- a/src/devices/sound/tc8830f.h +++ b/src/devices/sound/tc8830f.h @@ -32,7 +32,7 @@ protected: virtual void device_post_load() override; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/devices/sound/tiaintf.cpp b/src/devices/sound/tiaintf.cpp index 5a64db7bb4c..d2db180b2b2 100644 --- a/src/devices/sound/tiaintf.cpp +++ b/src/devices/sound/tiaintf.cpp @@ -52,9 +52,9 @@ void tia_device::device_stop() // sound_stream_update - handle a stream update //------------------------------------------------- -void tia_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tia_device::sound_stream_update(sound_stream &stream) { - tia_process(m_chip, outputs[0]); + tia_process(m_chip, stream); } diff --git a/src/devices/sound/tiaintf.h b/src/devices/sound/tiaintf.h index 94e8c8510e9..0ebc0d50433 100644 --- a/src/devices/sound/tiaintf.h +++ b/src/devices/sound/tiaintf.h @@ -24,7 +24,7 @@ protected: virtual void device_stop() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_channel; diff --git a/src/devices/sound/tiasound.cpp b/src/devices/sound/tiasound.cpp index 87fa657bfab..31679c71efb 100644 --- a/src/devices/sound/tiasound.cpp +++ b/src/devices/sound/tiasound.cpp @@ -314,7 +314,7 @@ void tia_write(void *chip, offs_t offset, uint8_t data) /* */ /*****************************************************************************/ -void tia_process(void *_chip, write_stream_view &buffer) +void tia_process(void *_chip, sound_stream &stream) { tia *chip = (tia *)_chip; uint8_t audc0, audc1; @@ -336,7 +336,7 @@ void tia_process(void *_chip, write_stream_view &buffer) div_n_cnt1 = chip->Div_n_cnt[1]; /* loop until the buffer is filled */ - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { /* Process channel 0 */ if (div_n_cnt0 > 1) @@ -532,7 +532,7 @@ void tia_process(void *_chip, write_stream_view &buffer) chip->Samp_n_cnt += chip->Samp_n_max; /* calculate the latest output value and place in buffer */ - buffer.put_int(sampindex++, outvol_0 + outvol_1, 32768); + stream.put_int(0, sampindex++, outvol_0 + outvol_1, 32768); } } else @@ -543,9 +543,9 @@ void tia_process(void *_chip, write_stream_view &buffer) * byte contains the fractional part */ chip->Samp_n_cnt -= 256; /* calculate the latest output value and place in buffer */ - buffer.put_int(sampindex++, outvol_0 + outvol_1, 32768); + stream.put_int(0, sampindex++, outvol_0 + outvol_1, 32768); } - while ((chip->Samp_n_cnt >= 256) && (sampindex < buffer.samples())); + while ((chip->Samp_n_cnt >= 256) && (sampindex < stream.samples())); /* adjust the sample counter if necessary */ if (chip->Samp_n_cnt < 256) diff --git a/src/devices/sound/tiasound.h b/src/devices/sound/tiasound.h index 2edafdda912..856a06cc1b4 100644 --- a/src/devices/sound/tiasound.h +++ b/src/devices/sound/tiasound.h @@ -41,7 +41,7 @@ void *tia_sound_init(device_t *device, int clock, int sample_rate, int gain); void tia_sound_free(void *chip); -void tia_process(void *chip, write_stream_view &buffer); +void tia_process(void *chip, sound_stream &stream); void tia_write(void *chip, offs_t offset, uint8_t data); #endif // MAME_SOUND_TIASOUND_H diff --git a/src/devices/sound/tms3615.cpp b/src/devices/sound/tms3615.cpp index 3f595c8a97b..5cdf269f77e 100644 --- a/src/devices/sound/tms3615.cpp +++ b/src/devices/sound/tms3615.cpp @@ -49,17 +49,14 @@ void tms3615_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void tms3615_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms3615_device::sound_stream_update(sound_stream &stream) { - auto &buffer8 = outputs[FOOTAGE_8]; - auto &buffer16 = outputs[FOOTAGE_16]; + int samplerate = stream.sample_rate(); - int samplerate = buffer8.sample_rate(); - - constexpr stream_buffer::sample_t VMAX = 1.0f / stream_buffer::sample_t(TMS3615_TONES); - for (int sampindex = 0; sampindex < buffer8.samples(); sampindex++) + constexpr sound_stream::sample_t VMAX = 1.0f / sound_stream::sample_t(TMS3615_TONES); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - stream_buffer::sample_t sum8 = 0, sum16 = 0; + sound_stream::sample_t sum8 = 0, sum16 = 0; for (int tone = 0; tone < TMS3615_TONES; tone++) { @@ -94,8 +91,8 @@ void tms3615_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - buffer8.put(sampindex, sum8); - buffer16.put(sampindex, sum16); + stream.put(FOOTAGE_8, sampindex, sum8); + stream.put(FOOTAGE_16, sampindex, sum16); } } diff --git a/src/devices/sound/tms3615.h b/src/devices/sound/tms3615.h index bf29b32b9dd..bad0bfa8950 100644 --- a/src/devices/sound/tms3615.h +++ b/src/devices/sound/tms3615.h @@ -28,7 +28,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned TMS3615_TONES = 13; diff --git a/src/devices/sound/tms36xx.cpp b/src/devices/sound/tms36xx.cpp index 08df1d03f51..e969987d129 100644 --- a/src/devices/sound/tms36xx.cpp +++ b/src/devices/sound/tms36xx.cpp @@ -397,19 +397,15 @@ void tms36xx_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void tms36xx_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms36xx_device::sound_stream_update(sound_stream &stream) { int samplerate = m_samplerate; - auto &buffer = outputs[0]; /* no tune played? */ if( !tunes[m_tune_num] || m_voices == 0 ) - { - buffer.fill(0); return; - } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int sum = 0; @@ -443,7 +439,7 @@ void tms36xx_device::sound_stream_update(sound_stream &stream, std::vector<read_ TONE( 0) TONE( 1) TONE( 2) TONE( 3) TONE( 4) TONE( 5) TONE( 6) TONE( 7) TONE( 8) TONE( 9) TONE(10) TONE(11) - buffer.put_int(sampindex, sum, 32768 * m_voices); + stream.put_int(0, sampindex, sum, 32768 * m_voices); } } diff --git a/src/devices/sound/tms36xx.h b/src/devices/sound/tms36xx.h index 307e6787afa..c18d0554615 100644 --- a/src/devices/sound/tms36xx.h +++ b/src/devices/sound/tms36xx.h @@ -63,7 +63,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: // MM6221AA interface functions diff --git a/src/devices/sound/tms5110.cpp b/src/devices/sound/tms5110.cpp index eb09016a035..e2d77d130fc 100644 --- a/src/devices/sound/tms5110.cpp +++ b/src/devices/sound/tms5110.cpp @@ -1192,22 +1192,21 @@ int tms5110_device::romclk_hack_r() ******************************************************************************/ -void tms5110_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms5110_device::sound_stream_update(sound_stream &stream) { int16_t sample_data[MAX_SAMPLE_CHUNK]; - auto &buffer = outputs[0]; /* loop while we still have samples to generate */ - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { - int length = buffer.samples() - sampindex; + int length = stream.samples() - sampindex; if (length > MAX_SAMPLE_CHUNK) length = MAX_SAMPLE_CHUNK; /* generate the samples and copy to the target buffer */ process(sample_data, length); for (int index = 0; index < length; index++) - buffer.put_int(sampindex++, sample_data[index], 32768); + stream.put_int(0, sampindex++, sample_data[index], 32768); } } diff --git a/src/devices/sound/tms5110.h b/src/devices/sound/tms5110.h index 2c9628c3338..0f367323f6d 100644 --- a/src/devices/sound/tms5110.h +++ b/src/devices/sound/tms5110.h @@ -60,7 +60,7 @@ protected: TIMER_CALLBACK_MEMBER(romclk_hack_toggle); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; uint8_t TALK_STATUS() const { return m_SPEN | m_TALKD; } diff --git a/src/devices/sound/tms5220.cpp b/src/devices/sound/tms5220.cpp index f472e9aa86e..77869045bea 100644 --- a/src/devices/sound/tms5220.cpp +++ b/src/devices/sound/tms5220.cpp @@ -2140,20 +2140,19 @@ int tms5220_device::intq_r() // sound_stream_update - handle a stream update //------------------------------------------------- -void tms5220_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms5220_device::sound_stream_update(sound_stream &stream) { int16_t sample_data[MAX_SAMPLE_CHUNK]; - auto &output = outputs[0]; /* loop while we still have samples to generate */ - for (int sampindex = 0; sampindex < output.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { - int length = (output.samples() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : output.samples(); + int length = (stream.samples() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : stream.samples(); /* generate the samples and copy to the target buffer */ process(sample_data, length); for (int index = 0; index < length; index++) - output.put_int(sampindex++, sample_data[index], 32768); + stream.put_int(0, sampindex++, sample_data[index], 32768); } } diff --git a/src/devices/sound/tms5220.h b/src/devices/sound/tms5220.h index 6aa0494164b..1dee49d8f1f 100644 --- a/src/devices/sound/tms5220.h +++ b/src/devices/sound/tms5220.h @@ -68,7 +68,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(set_io_ready); diff --git a/src/devices/sound/tt5665.cpp b/src/devices/sound/tt5665.cpp index 363481669ff..1949c90e36c 100644 --- a/src/devices/sound/tt5665.cpp +++ b/src/devices/sound/tt5665.cpp @@ -88,24 +88,24 @@ DEFINE_DEVICE_TYPE(TT5665, tt5665_device, "tt5665", "Tontek TT5665 ADPCM Voice Synthesis LSI") // same as MSM6295 -const stream_buffer::sample_t tt5665_device::s_volume_table[16] = +const sound_stream::sample_t tt5665_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), }; @@ -210,16 +210,13 @@ void tt5665_device::device_clock_changed() // our sound stream //------------------------------------------------- -void tt5665_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tt5665_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - outputs[1].fill(0); bool update_daol = false; // iterate over voices and accumulate sample data // loop while we still have samples to generate - for (int s = 0; s < outputs[0].samples(); s++) + for (int s = 0; s < stream.samples(); s++) { // adjust DAOL clock timing m_daol_timing--; @@ -239,8 +236,8 @@ void tt5665_device::sound_stream_update(sound_stream &stream, std::vector<read_s // refresh DAOR output m_voice[b + 4].generate_adpcm(*this, &daor_output); } - outputs[0].put_int(s, m_daol_output, 2048); - outputs[1].put_int(s, daor_output, 2048); + stream.put_int(0, s, m_daol_output, 2048); + stream.put_int(1, s, daor_output, 2048); if (update_daol) { update_daol = false; diff --git a/src/devices/sound/tt5665.h b/src/devices/sound/tt5665.h index 2bbd1c73822..811e2f278e2 100644 --- a/src/devices/sound/tt5665.h +++ b/src/devices/sound/tt5665.h @@ -69,7 +69,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; @@ -87,7 +87,7 @@ private: offs_t m_base_offset; // pointer to the base memory location u32 m_sample; // current sample number u32 m_count; // total samples to play - stream_buffer::sample_t m_volume; // output volume + sound_stream::sample_t m_volume; // output volume }; // configuration state @@ -105,7 +105,7 @@ private: inline int freq_divider() const { return m_ss_state ? 136 : 170; } - static const stream_buffer::sample_t s_volume_table[16]; + static const sound_stream::sample_t s_volume_table[16]; }; diff --git a/src/devices/sound/uda1344.cpp b/src/devices/sound/uda1344.cpp index b8d445ef3b8..3031ea2e75d 100644 --- a/src/devices/sound/uda1344.cpp +++ b/src/devices/sound/uda1344.cpp @@ -88,25 +88,21 @@ void uda1344_device::device_reset() memset(m_bufout, 0, sizeof(uint32_t) * 2); } -void uda1344_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void uda1344_device::sound_stream_update(sound_stream &stream) { - for (int channel = 0; channel < 2 && channel < outputs.size(); channel++) + for (int channel = 0; channel < 2 && channel < stream.output_count(); channel++) { - auto &output = outputs[channel]; uint32_t curout = m_bufout[channel]; uint32_t curin = m_bufin[channel]; // feed as much as we can int sampindex; - for (sampindex = 0; curout != curin && sampindex < output.samples(); sampindex++) + for (sampindex = 0; curout != curin && sampindex < stream.samples(); sampindex++) { - output.put(sampindex, stream_buffer::sample_t(m_buffer[channel][curout]) * m_volume); + stream.put(channel, sampindex, sound_stream::sample_t(m_buffer[channel][curout]) * m_volume); curout = (curout + 1) % BUFFER_SIZE; } - // fill the rest with silence - output.fill(0, sampindex); - // save the new output pointer m_bufout[channel] = curout; } @@ -116,8 +112,8 @@ void uda1344_device::ingest_samples(int16_t left, int16_t right) { const int16_t samples[2] = { left, right }; - const stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - const stream_buffer::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; + const sound_stream::sample_t sample_scale = 1.0 / 32768.0; + const sound_stream::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; m_stream->update(); @@ -126,7 +122,7 @@ void uda1344_device::ingest_samples(int16_t left, int16_t right) int maxin = (m_bufout[channel] + BUFFER_SIZE - 1) % BUFFER_SIZE; if (m_bufin[channel] != maxin) { - m_buffer[channel][m_bufin[channel]] = stream_buffer::sample_t(samples[channel]) * sample_scale * enable_scale; + m_buffer[channel][m_bufin[channel]] = sound_stream::sample_t(samples[channel]) * sample_scale * enable_scale; m_bufin[channel] = (m_bufin[channel] + 1) % BUFFER_SIZE; } else diff --git a/src/devices/sound/uda1344.h b/src/devices/sound/uda1344.h index 5ba1df90cdf..6cc895e2245 100644 --- a/src/devices/sound/uda1344.h +++ b/src/devices/sound/uda1344.h @@ -30,7 +30,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void ingest_samples(int16_t left, int16_t right); @@ -79,10 +79,10 @@ protected: }; sound_stream *m_stream; - std::vector<stream_buffer::sample_t> m_buffer[2]; + std::vector<sound_stream::sample_t> m_buffer[2]; uint32_t m_bufin[2]; uint32_t m_bufout[2]; - stream_buffer::sample_t m_volume; + sound_stream::sample_t m_volume; double m_frequency; uint8_t m_data_transfer_mode; diff --git a/src/devices/sound/upd65043gfu01.cpp b/src/devices/sound/upd65043gfu01.cpp index 7ef6c9d98de..f8f517b746f 100644 --- a/src/devices/sound/upd65043gfu01.cpp +++ b/src/devices/sound/upd65043gfu01.cpp @@ -205,9 +205,9 @@ void upd65043gfu01_device::update_noise() } //************************************************************************** -void upd65043gfu01_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd65043gfu01_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s16 sample = 0; @@ -244,6 +244,6 @@ void upd65043gfu01_device::sound_stream_update(sound_stream &stream, std::vector if (!BIT(m_control, 4)) sample += m_pcm_buffer[m_pcm_buffer_read & 0x1ff]; - outputs[0].put_int_clamp(i, sample, 1 << 10); + stream.put_int_clamp(0, i, sample, 1 << 10); } } diff --git a/src/devices/sound/upd65043gfu01.h b/src/devices/sound/upd65043gfu01.h index 29c1a74e3a8..482771d9471 100644 --- a/src/devices/sound/upd65043gfu01.h +++ b/src/devices/sound/upd65043gfu01.h @@ -23,7 +23,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: TIMER_CALLBACK_MEMBER(irq_timer); diff --git a/src/devices/sound/upd7752.cpp b/src/devices/sound/upd7752.cpp index 8f8a3a6f9a3..ca0f47c46ea 100644 --- a/src/devices/sound/upd7752.cpp +++ b/src/devices/sound/upd7752.cpp @@ -98,9 +98,8 @@ void upd7752_device::device_stop() // sound_stream_update - handle a stream update //------------------------------------------------- -void upd7752_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd7752_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } //************************************************************************** diff --git a/src/devices/sound/upd7752.h b/src/devices/sound/upd7752.h index c9890e19588..30c663d8fb5 100644 --- a/src/devices/sound/upd7752.h +++ b/src/devices/sound/upd7752.h @@ -30,7 +30,7 @@ protected: virtual void device_stop() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual space_config_vector memory_space_config() const override; private: diff --git a/src/devices/sound/upd7759.cpp b/src/devices/sound/upd7759.cpp index 1579fd8ee39..ff23e9dd6ec 100644 --- a/src/devices/sound/upd7759.cpp +++ b/src/devices/sound/upd7759.cpp @@ -684,19 +684,19 @@ int upd775x_device::busy_r() // sound_stream_update - handle a stream update //------------------------------------------------- -void upd775x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd775x_device::sound_stream_update(sound_stream &stream) { - constexpr stream_buffer::sample_t sample_scale = 128.0 / 32768.0; - stream_buffer::sample_t sample = stream_buffer::sample_t(m_sample) * sample_scale; + constexpr sound_stream::sample_t sample_scale = 128.0 / 32768.0; + sound_stream::sample_t sample = sound_stream::sample_t(m_sample) * sample_scale; int32_t clocks_left = m_clocks_left; uint32_t step = m_step; uint32_t pos = m_pos; u32 index = 0; if (m_state != STATE_IDLE) - for ( ; index < outputs[0].samples(); index++) + for ( ; index < stream.samples(); index++) { - outputs[0].put(index, sample); + stream.put(0, index, sample); pos += step; @@ -716,14 +716,14 @@ void upd775x_device::sound_stream_update(sound_stream &stream, std::vector<read_ break; clocks_left = m_clocks_left; - sample = stream_buffer::sample_t(m_sample) * sample_scale; + sample = sound_stream::sample_t(m_sample) * sample_scale; } } } // if we got out early, just zap the rest of the buffer - for (; index < outputs[0].samples(); index++) - outputs[0].put(index, 0); + for (; index < stream.samples(); index++) + stream.put(0, index, 0); m_clocks_left = clocks_left; m_pos = pos; diff --git a/src/devices/sound/upd7759.h b/src/devices/sound/upd7759.h index b45fff6d95e..99720af5983 100644 --- a/src/devices/sound/upd7759.h +++ b/src/devices/sound/upd7759.h @@ -74,7 +74,7 @@ protected: virtual void rom_bank_pre_change() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void update_adpcm(int data); virtual void advance_state(); diff --git a/src/devices/sound/upd931.cpp b/src/devices/sound/upd931.cpp index f2986ed68cd..9f3d3efad40 100644 --- a/src/devices/sound/upd931.cpp +++ b/src/devices/sound/upd931.cpp @@ -159,9 +159,9 @@ void upd931_device::device_clock_changed() } /**************************************************************************/ -void upd931_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd931_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sample = 0; for (voice_t &voice : m_voice) @@ -172,7 +172,7 @@ void upd931_device::sound_stream_update(sound_stream &stream, std::vector<read_s sample += voice.m_wave_out[0] * (voice.m_env_level[0] >> VOLUME_SHIFT); sample += voice.m_wave_out[1] * (voice.m_env_level[1] >> VOLUME_SHIFT); } - outputs[0].put_int_clamp(i, sample, 1 << 16); + stream.put_int_clamp(0, i, sample, 1 << 16); } } diff --git a/src/devices/sound/upd931.h b/src/devices/sound/upd931.h index a97397fc11b..ea982ac5b58 100644 --- a/src/devices/sound/upd931.h +++ b/src/devices/sound/upd931.h @@ -40,7 +40,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned PITCH_SHIFT = 15; diff --git a/src/devices/sound/upd933.cpp b/src/devices/sound/upd933.cpp index 6167ec2a3c1..e8b3d2e6f2f 100644 --- a/src/devices/sound/upd933.cpp +++ b/src/devices/sound/upd933.cpp @@ -371,9 +371,9 @@ u32 upd933_device::env_rate(u8 data) const } /**************************************************************************/ -void upd933_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd933_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sample = 0; @@ -385,7 +385,7 @@ void upd933_device::sound_stream_update(sound_stream &stream, std::vector<read_s for (int j : voice_map) sample += update(j); - outputs[0].put_int_clamp(i, sample, 1 << 15); + stream.put_int_clamp(0, i, sample, 1 << 15); m_sample_count++; } } diff --git a/src/devices/sound/upd933.h b/src/devices/sound/upd933.h index b29c2f2c879..1f8049d0dfd 100644 --- a/src/devices/sound/upd933.h +++ b/src/devices/sound/upd933.h @@ -31,7 +31,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned NOTE_SHIFT = 9; diff --git a/src/devices/sound/upd934g.cpp b/src/devices/sound/upd934g.cpp index 1178ef0a930..3d56c102d09 100644 --- a/src/devices/sound/upd934g.cpp +++ b/src/devices/sound/upd934g.cpp @@ -80,7 +80,7 @@ void upd934g_device::device_reset() // our sound stream //------------------------------------------------- -void upd934g_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd934g_device::sound_stream_update(sound_stream &stream) { for (unsigned ch = 0; ch < 4; ch++) { @@ -88,7 +88,7 @@ void upd934g_device::sound_stream_update(sound_stream &stream, std::vector<read_ { uint16_t end = m_addr[m_channel[ch].playing + 1] - 1; - for (unsigned i = 0; i < outputs[ch].samples(); i++) + for (unsigned i = 0; i < stream.samples(); i++) { int16_t raw = static_cast<int8_t>(read_byte(m_channel[ch].pos)) * 4; @@ -96,18 +96,15 @@ void upd934g_device::sound_stream_update(sound_stream &stream, std::vector<read_ const double adjust[] = { 0, 0.7, 0.4, 1.0 }; raw *= adjust[m_channel[ch].effect]; - outputs[ch].put_int(i, raw, 32768 / 64); + stream.put_int(ch, i, raw, 32768 / 64); if (++m_channel[ch].pos >= end) { m_channel[ch].playing = -1; - outputs[ch].fill(0, i + 1); break; } } } - else - outputs[ch].fill(0); } } diff --git a/src/devices/sound/upd934g.h b/src/devices/sound/upd934g.h index 6652fb62c8e..1a7d9671275 100644 --- a/src/devices/sound/upd934g.h +++ b/src/devices/sound/upd934g.h @@ -34,7 +34,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/devices/sound/va_eg.cpp b/src/devices/sound/va_eg.cpp index 401d5c34197..5a718832d1a 100644 --- a/src/devices/sound/va_eg.cpp +++ b/src/devices/sound/va_eg.cpp @@ -99,23 +99,22 @@ void va_rc_eg_device::device_start() save_item(NAME(m_t_end_approx)); } -void va_rc_eg_device::sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) +void va_rc_eg_device::sound_stream_update(sound_stream &stream) { assert(inputs.size() == 0 && outputs.size() == 1); - write_stream_view &out = outputs[0]; - attotime t = out.start_time(); + attotime t = stream.start_time(); if (t >= m_t_end_approx) { // Avoid expensive get_v() calls if the envelope stage has completed. - out.fill(m_v_end); + stream.fill(0, m_v_end); return; } - const int n = out.samples(); - const attotime dt = out.sample_period(); + const int n = stream.samples(); + const attotime dt = stream.sample_period(); for (int i = 0; i < n; ++i, t += dt) - out.put(i, get_v(t)); + stream.put(0, i, get_v(t)); } void va_rc_eg_device::snapshot() diff --git a/src/devices/sound/va_eg.h b/src/devices/sound/va_eg.h index bd8c00cd722..29675145810 100644 --- a/src/devices/sound/va_eg.h +++ b/src/devices/sound/va_eg.h @@ -39,7 +39,7 @@ public: protected: void device_start() override ATTR_COLD; - void sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: // Takes a snapshot of the current voltage into m_v_start and m_t_start. diff --git a/src/devices/sound/va_vca.cpp b/src/devices/sound/va_vca.cpp index d918dd25fba..63ba220ae86 100644 --- a/src/devices/sound/va_vca.cpp +++ b/src/devices/sound/va_vca.cpp @@ -55,17 +55,17 @@ void va_vca_device::device_start() save_item(NAME(m_fixed_gain)); } -void va_vca_device::sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) +void va_vca_device::sound_stream_update(sound_stream &stream) { if (m_has_cv_stream) { - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, inputs[0].get(i) * cv_to_gain(inputs[1].get(i))); + for (int i = 0; i < stream.samples(); i++) + stream.put(0, i, stream.get(0, i) * cv_to_gain(stream.get(1, i))); } else { - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, inputs[0].get(i) * m_fixed_gain); + for (int i = 0; i < stream.samples(); i++) + stream.put(0, i, stream.get(0, i) * m_fixed_gain); } } diff --git a/src/devices/sound/va_vca.h b/src/devices/sound/va_vca.h index ee155426019..9d9c3963ce1 100644 --- a/src/devices/sound/va_vca.h +++ b/src/devices/sound/va_vca.h @@ -37,7 +37,7 @@ public: protected: void device_start() override ATTR_COLD; - void sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: float cv_to_gain(float cv) const; diff --git a/src/devices/sound/vgm_visualizer.cpp b/src/devices/sound/vgm_visualizer.cpp index e62ffe07785..13d25bcb6ca 100644 --- a/src/devices/sound/vgm_visualizer.cpp +++ b/src/devices/sound/vgm_visualizer.cpp @@ -54,7 +54,7 @@ DEFINE_DEVICE_TYPE(VGMVIZ, vgmviz_device, "vgmviz", "VGM Visualizer") vgmviz_device::vgmviz_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, VGMVIZ, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_sound_interface(mconfig, *this) , m_screen(*this, "screen") , m_palette(*this, "palette") { @@ -76,6 +76,7 @@ vgmviz_device::~vgmviz_device() void vgmviz_device::device_start() { + stream_alloc(2, 2, machine().sample_rate()); WDL_fft_init(); fill_window(); m_bitmap.resize(SCREEN_WIDTH, SCREEN_HEIGHT); @@ -283,18 +284,19 @@ void vgmviz_device::cycle_viz_mode() // audio stream and process as necessary //------------------------------------------------- -void vgmviz_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vgmviz_device::sound_stream_update(sound_stream &stream) { - // call the normal interface to actually mix - device_mixer_interface::sound_stream_update(stream, inputs, outputs); + // Passthrough the audio + stream.copy(0, 0); + stream.copy(1, 1); - // now consume the outputs - for (int pos = 0; pos < outputs[0].samples(); pos++) + // now consume the inputs + for (int pos = 0; pos < stream.samples(); pos++) { - for (int i = 0; i < outputs.size(); i++) + for (int i = 0; i < stream.output_count(); i++) { // Original code took 16-bit sample / 65536.0 instead of 32768.0, so multiply by 0.5 here but is it necessary? - const float sample = outputs[i].get(pos) * 0.5f; + const float sample = stream.get(i, pos) * 0.5f; m_audio_buf[m_audio_fill_index][i][m_audio_count[m_audio_fill_index]] = sample + 0.5f; } diff --git a/src/devices/sound/vgm_visualizer.h b/src/devices/sound/vgm_visualizer.h index f201b117461..ee671535a24 100644 --- a/src/devices/sound/vgm_visualizer.h +++ b/src/devices/sound/vgm_visualizer.h @@ -35,7 +35,7 @@ DECLARE_DEVICE_TYPE(VGMVIZ, vgmviz_device) // ======================> vgmviz_device -class vgmviz_device : public device_t, public device_mixer_interface +class vgmviz_device : public device_t, public device_sound_interface { public: // construction/destruction @@ -91,7 +91,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface-level overrides - void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; void update_waveform(); void update_fft(); diff --git a/src/devices/sound/vlm5030.cpp b/src/devices/sound/vlm5030.cpp index 03381d3460f..8f6e3715360 100644 --- a/src/devices/sound/vlm5030.cpp +++ b/src/devices/sound/vlm5030.cpp @@ -498,19 +498,18 @@ void vlm5030_device::st(int state) // sound_stream_update - handle a stream update //------------------------------------------------- -void vlm5030_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vlm5030_device::sound_stream_update(sound_stream &stream) { int interp_effect; int i; int u[11]; - auto &buffer = outputs[0]; /* running */ int sampindex = 0; if (m_phase == PH_RUN || m_phase == PH_STOP) { /* playing speech */ - for ( ; sampindex < buffer.samples(); sampindex++) + for ( ; sampindex < stream.samples(); sampindex++) { int current_val; @@ -603,7 +602,7 @@ void vlm5030_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_x[0] = u[0]; /* clipping, buffering */ - buffer.put_int_clamp(sampindex, u[0], 512); + stream.put_int_clamp(0, sampindex, u[0], 512); /* sample count */ m_sample_count--; @@ -622,7 +621,7 @@ phase_stop: switch (m_phase) { case PH_SETUP: - if (m_sample_count <= buffer.samples()) + if (m_sample_count <= stream.samples()) { m_sample_count = 0; /* logerror("VLM5030 BSY=H\n"); */ @@ -631,11 +630,11 @@ phase_stop: } else { - m_sample_count -= buffer.samples(); + m_sample_count -= stream.samples(); } break; case PH_END: - if (m_sample_count <= buffer.samples()) + if (m_sample_count <= stream.samples()) { m_sample_count = 0; /* logerror("VLM5030 BSY=L\n"); */ @@ -644,10 +643,7 @@ phase_stop: } else { - m_sample_count -= buffer.samples(); + m_sample_count -= stream.samples(); } } - - /* silent buffering */ - buffer.fill(0, sampindex); } diff --git a/src/devices/sound/vlm5030.h b/src/devices/sound/vlm5030.h index ca34110b285..f9d05749882 100644 --- a/src/devices/sound/vlm5030.h +++ b/src/devices/sound/vlm5030.h @@ -34,7 +34,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/votrax.cpp b/src/devices/sound/votrax.cpp index f1da1134415..3ad167f9145 100644 --- a/src/devices/sound/votrax.cpp +++ b/src/devices/sound/votrax.cpp @@ -157,13 +157,13 @@ void votrax_sc01_device::inflection_w(uint8_t data) // for our sound stream //------------------------------------------------- -void votrax_sc01_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void votrax_sc01_device::sound_stream_update(sound_stream &stream) { - for(int i=0; i<outputs[0].samples(); i++) { + for(int i=0; i<stream.samples(); i++) { m_sample_count++; if(m_sample_count & 1) chip_update(); - outputs[0].put(i, analog_calc()); + stream.put(0, i, analog_calc()); } } @@ -596,7 +596,7 @@ void votrax_sc01_device::filters_commit(bool force) LOGMASKED(LOG_FILTER, "filter fa=%x va=%x fc=%x f1=%x f2=%02x f2q=%x f3=%x\n", m_filt_fa, m_filt_va, m_filt_fc, m_filt_f1, m_filt_f2, m_filt_f2q, m_filt_f3); } -stream_buffer::sample_t votrax_sc01_device::analog_calc() +sound_stream::sample_t votrax_sc01_device::analog_calc() { // Voice-only path. // 1. Pick up the pitch wave diff --git a/src/devices/sound/votrax.h b/src/devices/sound/votrax.h index a3b2ab12114..498d6ed36eb 100644 --- a/src/devices/sound/votrax.h +++ b/src/devices/sound/votrax.h @@ -36,7 +36,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(phone_tick); @@ -178,7 +178,7 @@ private: void chip_update(); // Global update called at 20KHz (main/36) void filters_commit(bool force); // Commit the currently computed interpolation values to the filters void phone_commit(); // Commit the current phone id - stream_buffer::sample_t analog_calc(); // Compute one more sample + sound_stream::sample_t analog_calc(); // Compute one more sample }; class votrax_sc01a_device : public votrax_sc01_device diff --git a/src/devices/sound/vrc6.cpp b/src/devices/sound/vrc6.cpp index d9b36f5b8a6..40f2ddf8946 100644 --- a/src/devices/sound/vrc6.cpp +++ b/src/devices/sound/vrc6.cpp @@ -93,16 +93,13 @@ void vrc6snd_device::device_reset() // our sound stream //------------------------------------------------- -void vrc6snd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vrc6snd_device::sound_stream_update(sound_stream &stream) { // check global halt bit if (m_freqctrl & 1) - { - outputs[0].fill(0); return; - } - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { // update pulse1 if (m_pulsefrqh[0] & 0x80) @@ -200,7 +197,7 @@ void vrc6snd_device::sound_stream_update(sound_stream &stream, std::vector<read_ // sum 2 4-bit pulses, 1 5-bit saw = unsigned 6 bit output s16 tmp = (s16)(u8)(m_output[0] + m_output[1] + m_output[2]); - outputs[0].put_int(i, tmp, 128); + stream.put_int(0, i, tmp, 128); } } diff --git a/src/devices/sound/vrc6.h b/src/devices/sound/vrc6.h index 9dcc2fa1cee..8ca9102bc2d 100644 --- a/src/devices/sound/vrc6.h +++ b/src/devices/sound/vrc6.h @@ -31,7 +31,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: u8 m_freqctrl, m_pulsectrl[2], m_sawrate, m_master_freq; diff --git a/src/devices/sound/vrender0.cpp b/src/devices/sound/vrender0.cpp index a364ed8ef67..e91fea403b0 100644 --- a/src/devices/sound/vrender0.cpp +++ b/src/devices/sound/vrender0.cpp @@ -205,9 +205,9 @@ device_memory_interface::space_config_vector vr0sound_device::memory_space_confi // for our sound stream //------------------------------------------------- -void vr0sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vr0sound_device::sound_stream_update(sound_stream &stream) { - VR0_RenderAudio(outputs[0], outputs[1]); + VR0_RenderAudio(stream); } u16 vr0sound_device::channel_r(offs_t offset) @@ -493,7 +493,7 @@ void vr0sound_device::channel_t::write(offs_t offset, u16 data, u16 mem_mask) } } -void vr0sound_device::VR0_RenderAudio(write_stream_view &l, write_stream_view &r) +void vr0sound_device::VR0_RenderAudio(sound_stream &stream) { int div; if (m_ChnClkNum) @@ -501,7 +501,7 @@ void vr0sound_device::VR0_RenderAudio(write_stream_view &l, write_stream_view &r else div = 1 << 16; - for (int s = 0; s < l.samples(); s++) + for (int s = 0; s < stream.samples(); s++) { s32 lsample = 0, rsample = 0; for (int i = 0; i <= m_MaxChn; i++) @@ -583,7 +583,7 @@ void vr0sound_device::VR0_RenderAudio(write_stream_view &l, write_stream_view &r lsample += (sample * channel->LChnVol) >> 8; rsample += (sample * channel->RChnVol) >> 8; } - l.put_int_clamp(s, lsample, 32768); - r.put_int_clamp(s, rsample, 32768); + stream.put_int_clamp(0, s, lsample, 32768); + stream.put_int_clamp(1, s, rsample, 32768); } } diff --git a/src/devices/sound/vrender0.h b/src/devices/sound/vrender0.h index 87f16302cf3..5a2d64183f0 100644 --- a/src/devices/sound/vrender0.h +++ b/src/devices/sound/vrender0.h @@ -78,7 +78,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; @@ -151,7 +151,7 @@ private: u8 m_MaxChn = 0x1f; // Max Channels - 1 u8 m_ChnClkNum = 0; // Clock Number per Channel u16 m_Ctrl = 0; // 0x602 Control Functions - void VR0_RenderAudio(write_stream_view &l, write_stream_view &r); + void VR0_RenderAudio(sound_stream &stream); }; DECLARE_DEVICE_TYPE(SOUND_VRENDER0, vr0sound_device) diff --git a/src/devices/sound/wave.cpp b/src/devices/sound/wave.cpp index 1a53aaa95f7..3540d3a08fa 100644 --- a/src/devices/sound/wave.cpp +++ b/src/devices/sound/wave.cpp @@ -45,7 +45,7 @@ void wave_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void wave_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void wave_device::sound_stream_update(sound_stream &stream) { cassette_state state = m_cass->get_state() & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER); @@ -53,21 +53,16 @@ void wave_device::sound_stream_update(sound_stream &stream, std::vector<read_str { cassette_image *cassette = m_cass->get_image(); double time_index = m_cass->get_position(); - double duration = double(outputs[0].samples()) / outputs[0].sample_rate(); + double duration = double(stream.samples()) / stream.sample_rate(); - if (m_sample_buf.size() < outputs[0].samples()) - m_sample_buf.resize(outputs[0].samples()); + if (m_sample_buf.size() < stream.samples()) + m_sample_buf.resize(stream.samples()); for (int ch = 0; ch < 2; ch++) { - cassette->get_samples(ch, time_index, duration, outputs[ch].samples(), 2, &m_sample_buf[0], cassette_image::WAVEFORM_16BIT); - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - outputs[ch].put_int(sampindex, m_sample_buf[sampindex], 32768); + cassette->get_samples(ch, time_index, duration, stream.samples(), 2, &m_sample_buf[0], cassette_image::WAVEFORM_16BIT); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put_int(ch, sampindex, m_sample_buf[sampindex], 32768); } } - else - { - outputs[0].fill(0); - outputs[1].fill(0); - } } diff --git a/src/devices/sound/wave.h b/src/devices/sound/wave.h index 0d2db370f66..723c0b93fb6 100644 --- a/src/devices/sound/wave.h +++ b/src/devices/sound/wave.h @@ -36,7 +36,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: required_device<cassette_image_device> m_cass; diff --git a/src/devices/sound/x1_010.cpp b/src/devices/sound/x1_010.cpp index 2947ed66654..0c5a4accfaa 100644 --- a/src/devices/sound/x1_010.cpp +++ b/src/devices/sound/x1_010.cpp @@ -206,16 +206,10 @@ void x1_010_device::word_w(offs_t offset, u16 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void x1_010_device::sound_stream_update(sound_stream &stream) { - // mixer buffer zero clear - outputs[0].fill(0); - outputs[1].fill(0); - // if (m_sound_enable == 0) return; - auto &bufL = outputs[0]; - auto &bufR = outputs[1]; for (int ch = 0; ch < NUM_CHANNELS; ch++) { X1_010_CHANNEL *reg = (X1_010_CHANNEL *)&(m_reg[ch*sizeof(X1_010_CHANNEL)]); @@ -239,7 +233,7 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s LOGMASKED(LOG_SOUND, "Play sample %p - %p, channel %X volume %d:%d freq %X step %X offset %X\n", start, end, ch, volL, volR, freq, smp_step, smp_offs); } - for (int i = 0; i < bufL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { const u32 delta = smp_offs >> 4; // sample ended? @@ -249,8 +243,8 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s break; } const s8 data = (s8)(read_byte(start+delta)); - bufL.add_int(i, data * volL, 32768 * 256); - bufR.add_int(i, data * volR, 32768 * 256); + stream.add_int(0, i, data * volL, 32768 * 256); + stream.add_int(1, i, data * volR, 32768 * 256); smp_offs += smp_step; } m_smp_offset[ch] = smp_offs; @@ -271,7 +265,7 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s LOGMASKED(LOG_SOUND, "Play waveform %X, channel %X volume %X freq %4X step %X offset %X\n", reg->volume, ch, reg->end, freq, smp_step, smp_offs); } - for (int i = 0; i < bufL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { const u32 delta = env_offs >> 10; // Envelope one shot mode @@ -284,8 +278,8 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s const int volL = ((vol >> 4) & 0xf) * VOL_BASE; const int volR = ((vol >> 0) & 0xf) * VOL_BASE; const s8 data = (s8)(m_reg[start + ((smp_offs >> 10) & 0x7f)]); - bufL.add_int(i, data * volL, 32768 * 256); - bufR.add_int(i, data * volR, 32768 * 256); + stream.add_int(0, i, data * volL, 32768 * 256); + stream.add_int(1, i, data * volR, 32768 * 256); smp_offs += smp_step; env_offs += env_step; } @@ -294,10 +288,4 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s } } } - - for (int i = 0; i < bufL.samples(); i++) - { - bufL.put(i, std::clamp(bufL.getraw(i), -1.0f, 1.0f)); - bufR.put(i, std::clamp(bufR.getraw(i), -1.0f, 1.0f)); - } } diff --git a/src/devices/sound/x1_010.h b/src/devices/sound/x1_010.h index 2b206210dd6..1c636d0bd98 100644 --- a/src/devices/sound/x1_010.h +++ b/src/devices/sound/x1_010.h @@ -26,7 +26,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/xt446.cpp b/src/devices/sound/xt446.cpp index 8136f43ed90..93a7c9687fa 100644 --- a/src/devices/sound/xt446.cpp +++ b/src/devices/sound/xt446.cpp @@ -37,7 +37,7 @@ ROM_END xt446_device::xt446_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, XT446, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_maincpu(*this, "maincpu") , m_swp30(*this, "swp30") { @@ -91,7 +91,7 @@ void xt446_device::device_add_mconfig(machine_config &config) SWP30(config, m_swp30); m_swp30->set_addrmap(AS_DATA, &xt446_device::swp30_map); - m_swp30->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_swp30->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_swp30->add_route(0, *this, 1.0, 0); + m_swp30->add_route(1, *this, 1.0, 1); } diff --git a/src/devices/sound/ym2154.cpp b/src/devices/sound/ym2154.cpp index b52c4e49532..7d7c8bdd420 100644 --- a/src/devices/sound/ym2154.cpp +++ b/src/devices/sound/ym2154.cpp @@ -245,16 +245,10 @@ TIMER_CALLBACK_MEMBER(ym2154_device::delayed_irq) // sound_stream_update - generate sound data //------------------------------------------------- -void ym2154_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ym2154_device::sound_stream_update(sound_stream &stream) { static const uint16_t voltable[8] = { 0x7fa,0x751,0x6b5,0x627,0x5a4,0x52c,0x4be,0x45a }; - auto &outl = outputs[0]; - auto &outr = outputs[1]; - - outl.fill(0); - outr.fill(0); - for (int chan = 0; chan < 12; chan++) { auto &channel = m_channel[chan]; @@ -279,7 +273,7 @@ void ym2154_device::sound_stream_update(sound_stream &stream, std::vector<read_s rvol = voltable[rvol & 7] >> (rvol >> 3); auto &source = space(chan / 6); - for (int sampindex = 0; sampindex < outl.samples() && (channel.m_pos >> ADDR_SHIFT) <= channel.m_end; sampindex++) + for (int sampindex = 0; sampindex < stream.samples() && (channel.m_pos >> ADDR_SHIFT) <= channel.m_end; sampindex++) { uint8_t raw = source.read_byte(channel.m_pos++); @@ -291,8 +285,8 @@ void ym2154_device::sound_stream_update(sound_stream &stream, std::vector<read_s if (BIT(raw, 7)) sample = -sample; - outl.add_int(sampindex, sample * lvol, 0x2000 * 0x800); - outr.add_int(sampindex, sample * rvol, 0x2000 * 0x800); + stream.add_int(0, sampindex, sample * lvol, 0x2000 * 0x800); + stream.add_int(1, sampindex, sample * rvol, 0x2000 * 0x800); } } } diff --git a/src/devices/sound/ym2154.h b/src/devices/sound/ym2154.h index 65eeb8d3a0c..f74225dd3d3 100644 --- a/src/devices/sound/ym2154.h +++ b/src/devices/sound/ym2154.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // memory space configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/ymf271.cpp b/src/devices/sound/ymf271.cpp index 3f748656d91..aaa11319381 100644 --- a/src/devices/sound/ymf271.cpp +++ b/src/devices/sound/ymf271.cpp @@ -566,7 +566,7 @@ void ymf271_device::set_feedback(int slotnum, int64_t inp) // sound_stream_update - handle a stream update //------------------------------------------------- -void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymf271_device::sound_stream_update(sound_stream &stream) { int i, j; int op; @@ -599,7 +599,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s if (m_slots[slot1].active) { - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int64_t output1 = 0, output2 = 0, output3 = 0, output4 = 0; int64_t phase_mod1, phase_mod2, phase_mod3; @@ -833,7 +833,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s mixp = &m_mix_buffer[0]; if (m_slots[slot1].active) { - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int64_t output1 = 0, output3 = 0; int64_t phase_mod1, phase_mod3; @@ -900,7 +900,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s if (m_slots[slot1].active) { - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int64_t output1 = 0, output2 = 0, output3 = 0; int64_t phase_mod1, phase_mod3; @@ -1006,29 +1006,29 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s } mixp = &m_mix_buffer[0]; - update_pcm(j + (3*12), mixp, outputs[0].samples()); + update_pcm(j + (3*12), mixp, stream.samples()); break; } // PCM case 3: { - update_pcm(j + (0*12), mixp, outputs[0].samples()); - update_pcm(j + (1*12), mixp, outputs[0].samples()); - update_pcm(j + (2*12), mixp, outputs[0].samples()); - update_pcm(j + (3*12), mixp, outputs[0].samples()); + update_pcm(j + (0*12), mixp, stream.samples()); + update_pcm(j + (1*12), mixp, stream.samples()); + update_pcm(j + (2*12), mixp, stream.samples()); + update_pcm(j + (3*12), mixp, stream.samples()); break; } } } mixp = &m_mix_buffer[0]; - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { - outputs[0].put_int(i, *mixp++, 32768 << 2); - outputs[1].put_int(i, *mixp++, 32768 << 2); - outputs[2].put_int(i, *mixp++, 32768 << 2); - outputs[3].put_int(i, *mixp++, 32768 << 2); + stream.put_int(0, i, *mixp++, 32768 << 2); + stream.put_int(1, i, *mixp++, 32768 << 2); + stream.put_int(2, i, *mixp++, 32768 << 2); + stream.put_int(3, i, *mixp++, 32768 << 2); } } diff --git a/src/devices/sound/ymf271.h b/src/devices/sound/ymf271.h index 535631d664b..489e0f87143 100644 --- a/src/devices/sound/ymf271.h +++ b/src/devices/sound/ymf271.h @@ -27,7 +27,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/ymfm_mame.h b/src/devices/sound/ymfm_mame.h index e6400e76d6c..fa64d3c5ab9 100644 --- a/src/devices/sound/ymfm_mame.h +++ b/src/devices/sound/ymfm_mame.h @@ -240,9 +240,9 @@ protected: } // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override + virtual void sound_stream_update(sound_stream &stream) override { - update_internal(outputs); + update_internal(stream); } // update streams @@ -253,15 +253,15 @@ protected: } // internal update helper - void update_internal(std::vector<write_stream_view> &outputs, int output_shift = 0) + void update_internal(sound_stream &stream, int output_shift = 0) { // local buffer to hold samples constexpr int MAX_SAMPLES = 256; typename ChipClass::output_data output[MAX_SAMPLES]; // parameters - int const outcount = std::min(outputs.size(), std::size(output[0].data)); - int const numsamples = outputs[0].samples(); + int const outcount = std::min(stream.output_count(), u32(std::size(output[0].data))); + int const numsamples = stream.samples(); // generate the FM/ADPCM stream for (int sampindex = 0; sampindex < numsamples; sampindex += MAX_SAMPLES) @@ -272,7 +272,7 @@ protected: { int eff_outnum = (outnum + output_shift) % OUTPUTS; for (int index = 0; index < cursamples; index++) - outputs[eff_outnum].put_int(sampindex + index, output[index].data[outnum], 32768); + stream.put_int(eff_outnum, sampindex + index, output[index].data[outnum], 32768); } } } @@ -302,17 +302,17 @@ public: protected: // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override + virtual void sound_stream_update(sound_stream &stream) override { // ymfm outputs FM first, then SSG, while MAME traditionally // wants SSG streams first; to do this, we rotate the outputs // by the number of SSG output channels - parent::update_internal(outputs, ChipClass::SSG_OUTPUTS); + parent::update_internal(stream, ChipClass::SSG_OUTPUTS); // for the single-output case, also apply boost the gain to better match // previous version, which summed instead of averaged the outputs if (ChipClass::SSG_OUTPUTS == 1) - outputs[0].apply_gain(3.0); + stream.apply_output_gain(0, 3.0); } }; diff --git a/src/devices/sound/ymopl.cpp b/src/devices/sound/ymopl.cpp index 92e9eb99928..e6c1c588734 100644 --- a/src/devices/sound/ymopl.cpp +++ b/src/devices/sound/ymopl.cpp @@ -174,10 +174,10 @@ void ymf278b_device::ymfm_external_write(ymfm::access_class type, uint32_t offse // default address space //------------------------------------------------- -void ymf278b_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymf278b_device::sound_stream_update(sound_stream &stream) { // rotate the outputs so that the DO2 outputs are first - parent::update_internal(outputs, 2); + parent::update_internal(stream, 2); } diff --git a/src/devices/sound/ymopl.h b/src/devices/sound/ymopl.h index f0f44e9b5ac..a3831364175 100644 --- a/src/devices/sound/ymopl.h +++ b/src/devices/sound/ymopl.h @@ -109,7 +109,7 @@ protected: virtual void rom_bank_pre_change() override; // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // ADPCM read/write callbacks diff --git a/src/devices/sound/ymz280b.cpp b/src/devices/sound/ymz280b.cpp index 8eced2f7fa8..6873048624f 100644 --- a/src/devices/sound/ymz280b.cpp +++ b/src/devices/sound/ymz280b.cpp @@ -417,16 +417,10 @@ int ymz280b_device::generate_pcm16(YMZ280BVoice *voice, s16 *buffer, int samples // sound_stream_update - handle a stream update //------------------------------------------------- -void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymz280b_device::sound_stream_update(sound_stream &stream) { - auto &lacc = outputs[0]; - auto &racc = outputs[1]; int v; - /* clear out the accumulator */ - lacc.fill(0); - racc.fill(0); - /* loop over voices */ for (v = 0; v < 8; v++) { @@ -437,7 +431,7 @@ void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_ s32 sampindex = 0; u32 new_samples, samples_left; u32 final_pos; - int remaining = lacc.samples(); + int remaining = stream.samples(); int lvol = voice->output_left; int rvol = voice->output_right; @@ -454,8 +448,8 @@ void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_ while (remaining > 0 && voice->output_pos < FRAC_ONE) { int interp_sample = ((s32(prev) * (FRAC_ONE - voice->output_pos)) + (s32(curr) * voice->output_pos)) >> FRAC_BITS; - lacc.add_int(sampindex, interp_sample * lvol / 2, 32768 * 256); - racc.add_int(sampindex, interp_sample * rvol / 2, 32768 * 256); + stream.add_int(0, sampindex, interp_sample * lvol / 2, 32768 * 256); + stream.add_int(1, sampindex, interp_sample * rvol / 2, 32768 * 256); sampindex++; voice->output_pos += voice->output_step; remaining--; @@ -519,8 +513,8 @@ void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_ while (remaining > 0 && voice->output_pos < FRAC_ONE) { int interp_sample = ((s32(prev) * (FRAC_ONE - voice->output_pos)) + (s32(curr) * voice->output_pos)) >> FRAC_BITS; - lacc.add_int(sampindex, interp_sample * lvol / 2, 32768 * 256); - racc.add_int(sampindex, interp_sample * rvol / 2, 32768 * 256); + stream.add_int(0, sampindex, interp_sample * lvol / 2, 32768 * 256); + stream.add_int(1, sampindex, interp_sample * rvol / 2, 32768 * 256); sampindex++; voice->output_pos += voice->output_step; remaining--; diff --git a/src/devices/sound/ymz280b.h b/src/devices/sound/ymz280b.h index 1d6f95b1b17..a5c3d754ac9 100644 --- a/src/devices/sound/ymz280b.h +++ b/src/devices/sound/ymz280b.h @@ -35,7 +35,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/ymz770.cpp b/src/devices/sound/ymz770.cpp index 9c3abac4a17..f175cac853d 100644 --- a/src/devices/sound/ymz770.cpp +++ b/src/devices/sound/ymz770.cpp @@ -182,12 +182,9 @@ void ymz770_device::device_reset() // our sound stream //------------------------------------------------- -void ymz770_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymz770_device::sound_stream_update(sound_stream &stream) { - auto &outL = outputs[0]; - auto &outR = outputs[1]; - - for (int i = 0; i < outL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { sequencer(); @@ -280,8 +277,8 @@ retry: } if (m_mute) mixr = mixl = 0; - outL.put_int(i, mixl, 32768); - outR.put_int(i, mixr, 32768); + stream.put_int(0, i, mixl, 32768); + stream.put_int(1, i, mixr, 32768); } } diff --git a/src/devices/sound/ymz770.h b/src/devices/sound/ymz770.h index f9bf1eab823..70b110029b9 100644 --- a/src/devices/sound/ymz770.h +++ b/src/devices/sound/ymz770.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void internal_reg_write(uint8_t reg, uint8_t data); virtual uint32_t get_phrase_offs(int phrase) { return m_rom[(4 * phrase) + 1] << 16 | m_rom[(4 * phrase) + 2] << 8 | m_rom[(4 * phrase) + 3]; } diff --git a/src/devices/sound/zsg2.cpp b/src/devices/sound/zsg2.cpp index 786afbd475e..c1a93d874ca 100644 --- a/src/devices/sound/zsg2.cpp +++ b/src/devices/sound/zsg2.cpp @@ -283,9 +283,9 @@ void zsg2_device::filter_samples(zchan *ch) // sound_stream_update - handle a stream update //------------------------------------------------- -void zsg2_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void zsg2_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int32_t mix[4] = {}; @@ -355,7 +355,7 @@ void zsg2_device::sound_stream_update(sound_stream &stream, std::vector<read_str } for (int output = 0; output < 4; output++) - outputs[output].put_int_clamp(i, mix[output], 32768); + stream.put_int_clamp(output, i, mix[output], 32768); } m_sample_count++; } diff --git a/src/devices/sound/zsg2.h b/src/devices/sound/zsg2.h index 91a06e27a2e..0595208a142 100644 --- a/src/devices/sound/zsg2.h +++ b/src/devices/sound/zsg2.h @@ -29,7 +29,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: const uint16_t STATUS_ACTIVE = 0x8000; diff --git a/src/devices/video/315_5124.cpp b/src/devices/video/315_5124.cpp index 8bfef88e451..3d4f2817ffd 100644 --- a/src/devices/video/315_5124.cpp +++ b/src/devices/video/315_5124.cpp @@ -257,7 +257,7 @@ sega315_5124_device::sega315_5124_device(const machine_config &mconfig, device_t : device_t(mconfig, type, tag, owner, clock) , device_memory_interface(mconfig, *this) , device_video_interface(mconfig, *this) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_hcounter_divide(1) , m_cram_size(cram_size) , m_line_timing(line_timing) @@ -2094,7 +2094,7 @@ void sega315_5124_device::device_add_mconfig(machine_config &config) { PALETTE(config, m_palette_lut, FUNC(sega315_5124_device::sega315_5124_palette), SEGA315_5124_PALETTE_SIZE); - SEGAPSG(config, m_snsnd, DERIVED_CLOCK(1, 3)).add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + SEGAPSG(config, m_snsnd, DERIVED_CLOCK(1, 3)).add_route(ALL_OUTPUTS, *this, 1.0, 0); } void sega315_5246_device::device_add_mconfig(machine_config &config) @@ -2121,8 +2121,8 @@ void sega315_5377_device::device_add_mconfig(machine_config &config) m_palette_lut->set_init(FUNC(sega315_5377_device::sega315_5377_palette)); GAMEGEAR(config.replace(), m_snsnd, DERIVED_CLOCK(1, 3)); - m_snsnd->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_snsnd->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_snsnd->add_route(0, *this, 1.0, 0); + m_snsnd->add_route(1, *this, 1.0, 1); } //------------------------------------------------- diff --git a/src/devices/video/315_5313.cpp b/src/devices/video/315_5313.cpp index f48468963be..86c3436de01 100644 --- a/src/devices/video/315_5313.cpp +++ b/src/devices/video/315_5313.cpp @@ -245,7 +245,7 @@ void sega315_5313_device::device_add_mconfig(machine_config &config) { sega315_5313_mode4_device::device_add_mconfig(config); - SEGAPSG(config.replace(), m_snsnd, DERIVED_CLOCK(1, 15)).add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0); + SEGAPSG(config.replace(), m_snsnd, DERIVED_CLOCK(1, 15)).add_route(ALL_OUTPUTS, *this, 0.5, 0); PALETTE(config, m_gfx_palette, palette_device::BLACK).set_entries(PALETTE_PER_FRAME); PALETTE(config, m_gfx_palette_shadow, palette_device::BLACK).set_entries(PALETTE_PER_FRAME); diff --git a/src/devices/video/i8244.cpp b/src/devices/video/i8244.cpp index 3a1fb8c696f..b92b7ce9c56 100644 --- a/src/devices/video/i8244.cpp +++ b/src/devices/video/i8244.cpp @@ -769,16 +769,16 @@ u32 i8244_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, con SOUND ***************************************************************************/ -void i8244_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void i8244_device::sound_stream_update(sound_stream &stream) { u8 volume = m_vdc.s.sound & 0xf; - stream_buffer::sample_t sample_on = (m_sh_output & m_vdc.s.sound >> 7) * 0.5; + sound_stream::sample_t sample_on = (m_sh_output & m_vdc.s.sound >> 7) * 0.5; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { // clock duty cycle m_sh_duty = (m_sh_duty + 1) & 0xf; - outputs[0].put(i, (m_sh_duty < volume) ? sample_on : 0.0); + stream.put(0, i, (m_sh_duty < volume) ? sample_on : 0.0); } } diff --git a/src/devices/video/i8244.h b/src/devices/video/i8244.h index 5b631e9b2b5..a231eff3030 100644 --- a/src/devices/video/i8244.h +++ b/src/devices/video/i8244.h @@ -112,7 +112,7 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(hblank_start); TIMER_CALLBACK_MEMBER(vblank_start); |