trunk/src/emu/sound/wave.c
| r248603 | r248604 | |
| 16 | 16 | ****************************************************************************/ |
| 17 | 17 | |
| 18 | 18 | #include "emu.h" |
| 19 | | #include "imagedev/cassette.h" |
| 20 | 19 | #include "wave.h" |
| 21 | 20 | |
| 22 | 21 | #define ALWAYS_PLAY_SOUND 0 |
| r248603 | r248604 | |
| 60 | 59 | machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate()); |
| 61 | 60 | else |
| 62 | 61 | machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate()); |
| 62 | m_cass = machine().device<cassette_image_device>(m_cassette_tag); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //------------------------------------------------- |
| r248603 | r248604 | |
| 68 | 68 | |
| 69 | 69 | void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 70 | 70 | { |
| 71 | | cassette_image_device *cass = machine().device<cassette_image_device>(m_cassette_tag); |
| 72 | | cassette_image *cassette; |
| 73 | 71 | cassette_state state; |
| 74 | 72 | double time_index; |
| 75 | 73 | double duration; |
| r248603 | r248604 | |
| 77 | 75 | stream_sample_t *right_buffer = NULL; |
| 78 | 76 | int i; |
| 79 | 77 | |
| 80 | | speaker_device_iterator spkiter(cass->machine().root_device()); |
| 78 | speaker_device_iterator spkiter(m_cass->machine().root_device()); |
| 81 | 79 | int speakers = spkiter.count(); |
| 82 | 80 | if (speakers>1) |
| 83 | 81 | right_buffer = outputs[1]; |
| 84 | 82 | |
| 85 | | state = cass->get_state(); |
| 83 | state = m_cass->get_state(); |
| 86 | 84 | |
| 87 | 85 | state = (cassette_state)(state & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER)); |
| 88 | 86 | |
| 89 | | if (cass->exists() && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)))) |
| 87 | if (m_cass->exists() && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED)))) |
| 90 | 88 | { |
| 91 | | cassette = cass->get_image(); |
| 92 | | time_index = cass->get_position(); |
| 93 | | duration = ((double) samples) / cass->machine().sample_rate(); |
| 89 | cassette_image *cassette = m_cass->get_image(); |
| 90 | time_index = m_cass->get_position(); |
| 91 | duration = ((double) samples) / m_cass->machine().sample_rate(); |
| 94 | 92 | |
| 95 | 93 | cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT); |
| 96 | 94 | if (speakers > 1) |