summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/wave.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/wave.cpp')
-rw-r--r--src/devices/sound/wave.cpp56
1 files changed, 14 insertions, 42 deletions
diff --git a/src/devices/sound/wave.cpp b/src/devices/sound/wave.cpp
index ac564f70226..3540d3a08fa 100644
--- a/src/devices/sound/wave.cpp
+++ b/src/devices/sound/wave.cpp
@@ -2,17 +2,15 @@
// copyright-holders:Nathan Woods
/***************************************************************************
- wave.c
+ Cassette wave samples sound driver
- Code that interfaces
- Functions to handle loading, creation, recording and playback
- of wave samples for IO_CASSETTE
+ Code that interfaces functions to handle loading, creation,
+ recording and playback of wave samples for IO_CASSETTE
2010-06-19 - Found that since 0.132, the right channel is badly out of
sync on a mono system, causing bad sound. Added code to disable
the second channel on a mono system.
-
****************************************************************************/
#include "emu.h"
@@ -40,57 +38,31 @@ wave_device::wave_device(const machine_config &mconfig, const char *tag, device_
void wave_device::device_start()
{
- speaker_device_iterator spkiter(*owner());
- int speakers = spkiter.count();
- if (speakers > 1)
- machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate());
- else
- machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate());
+ stream_alloc(0, 2, machine().sample_rate());
}
//-------------------------------------------------
// sound_stream_update - handle a stream update
//-------------------------------------------------
-void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
+void wave_device::sound_stream_update(sound_stream &stream)
{
- cassette_state state;
- double time_index;
- double duration;
- stream_sample_t *left_buffer = outputs[0];
- stream_sample_t *right_buffer = nullptr;
- int i;
-
- speaker_device_iterator spkiter(*owner());
- int speakers = spkiter.count();
- if (speakers>1)
- right_buffer = outputs[1];
-
- state = m_cass->get_state();
-
- state = (cassette_state)(state & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER));
+ cassette_state state = m_cass->get_state() & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER);
if (m_cass->exists() && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))))
{
cassette_image *cassette = m_cass->get_image();
- time_index = m_cass->get_position();
- duration = ((double) samples) / m_cass->machine().sample_rate();
+ double time_index = m_cass->get_position();
+ double duration = double(stream.samples()) / stream.sample_rate();
- cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT);
- if (speakers > 1)
- cassette_get_samples(cassette, 1, time_index, duration, samples, 2, right_buffer, CASSETTE_WAVEFORM_16BIT);
+ if (m_sample_buf.size() < stream.samples())
+ m_sample_buf.resize(stream.samples());
- for (i = samples - 1; i >= 0; i--)
+ for (int ch = 0; ch < 2; ch++)
{
- left_buffer[i] = ((int16_t *) left_buffer)[i];
- if (speakers > 1)
- right_buffer[i] = ((int16_t *) right_buffer)[i];
+ 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
- {
- memset(left_buffer, 0, sizeof(*left_buffer) * samples);
- if (speakers > 1)
- memset(right_buffer, 0, sizeof(*right_buffer) * samples);
- }
}