summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/nes_apu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/nes_apu.cpp')
-rw-r--r--src/devices/sound/nes_apu.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/devices/sound/nes_apu.cpp b/src/devices/sound/nes_apu.cpp
index 3f5c7787a93..483b337475f 100644
--- a/src/devices/sound/nes_apu.cpp
+++ b/src/devices/sound/nes_apu.cpp
@@ -83,8 +83,8 @@ void nesapu_device::create_syncs(unsigned long sps)
DEFINE_DEVICE_TYPE(NES_APU, nesapu_device, "nesapu", "N2A03 APU")
-nesapu_device::nesapu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
- : device_t(mconfig, NES_APU, tag, owner, clock)
+nesapu_device::nesapu_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, type, tag, owner, clock)
, device_sound_interface(mconfig, *this)
, m_samps_per_sync(0)
, m_buffer_size(0)
@@ -108,6 +108,11 @@ nesapu_device::nesapu_device(const machine_config &mconfig, const char *tag, dev
}
}
+nesapu_device::nesapu_device(const machine_config& mconfig, const char* tag, device_t* owner, u32 clock)
+ : nesapu_device(mconfig, NES_APU, tag, owner, clock)
+{
+}
+
void nesapu_device::device_reset()
{
write(0x15, 0x00);
@@ -134,7 +139,7 @@ void nesapu_device::calculate_rates()
if (m_stream != nullptr)
m_stream->set_sample_rate(rate);
else
- m_stream = machine().sound().stream_alloc(*this, 0, 1, rate);
+ m_stream = stream_alloc(0, 1, rate);
}
//-------------------------------------------------
@@ -728,12 +733,12 @@ void nesapu_device::write(offs_t address, u8 value)
// sound_stream_update - handle a stream update
//-------------------------------------------------
-void nesapu_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+void nesapu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)
{
int accum;
- memset( outputs[0], 0, samples*sizeof(*outputs[0]) );
+ auto &output = outputs[0];
- while (samples--)
+ for (int sampindex = 0; sampindex < output.samples(); sampindex++)
{
accum = apu_square(&m_APU.squ[0]);
accum += apu_square(&m_APU.squ[1]);
@@ -741,12 +746,6 @@ void nesapu_device::sound_stream_update(sound_stream &stream, stream_sample_t **
accum += apu_noise(&m_APU.noi);
accum += apu_dpcm(&m_APU.dpcm);
- /* 8-bit clamps */
- if (accum > 127)
- accum = 127;
- else if (accum < -128)
- accum = -128;
-
- *(outputs[0]++)=accum<<8;
+ output.put_int_clamp(sampindex, accum, 128);
}
}