src/emu/sound/wave.c
| r8294 | r8295 | |
| 6 | 6 | Functions to handle loading, creation, recording and playback |
| 7 | 7 | of wave samples for IO_CASSETTE |
| 8 | 8 | |
| 9 | 2010-06-19 - Found that since 0.132, the right channel is badly out of |
| 10 | sync on a mono system, causing bad sound. Added code to disable |
| 11 | the second channel on a mono system. |
| 12 | |
| 13 | |
| 9 | 14 | ****************************************************************************/ |
| 10 | 15 | |
| 11 | 16 | #include "emu.h" |
| r8294 | r8295 | |
| 23 | 28 | { |
| 24 | 29 | #ifdef MESS |
| 25 | 30 | running_device *image = (running_device *)param; |
| 31 | int speakers = speaker_output_count(image->machine->config); |
| 26 | 32 | cassette_image *cassette; |
| 27 | 33 | cassette_state state; |
| 28 | 34 | double time_index; |
| r8294 | r8295 | |
| 42 | 48 | duration = ((double) samples) / image->machine->sample_rate; |
| 43 | 49 | |
| 44 | 50 | cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT); |
| 45 | | cassette_get_samples(cassette, 1, time_index, duration, samples, 2, right_buffer, CASSETTE_WAVEFORM_16BIT); |
| 51 | if (speakers > 1) |
| 52 | cassette_get_samples(cassette, 1, time_index, duration, samples, 2, right_buffer, CASSETTE_WAVEFORM_16BIT); |
| 46 | 53 | |
| 47 | 54 | for (i = samples - 1; i >= 0; i--) |
| 48 | 55 | { |
| 49 | 56 | left_buffer[i] = ((INT16 *) left_buffer)[i]; |
| 50 | | right_buffer[i] = ((INT16 *) right_buffer)[i]; |
| 57 | if (speakers > 1) |
| 58 | right_buffer[i] = ((INT16 *) right_buffer)[i]; |
| 51 | 59 | } |
| 52 | 60 | } |
| 53 | 61 | else |
| 54 | 62 | { |
| 55 | 63 | memset(left_buffer, 0, sizeof(*left_buffer) * samples); |
| 56 | | memset(right_buffer, 0, sizeof(*right_buffer) * samples); |
| 64 | if (speakers > 1) |
| 65 | memset(right_buffer, 0, sizeof(*right_buffer) * samples); |
| 57 | 66 | } |
| 58 | 67 | #endif |
| 59 | 68 | } |
| r8294 | r8295 | |
| 66 | 75 | |
| 67 | 76 | assert( device != NULL ); |
| 68 | 77 | assert( device->baseconfig().static_config != NULL ); |
| 69 | | |
| 78 | int speakers = speaker_output_count(device->machine->config); |
| 70 | 79 | #ifdef MESS |
| 71 | 80 | image = device->machine->device( (const char *)device->baseconfig().static_config ); |
| 72 | 81 | #endif |
| 73 | | stream_create(device, 0, 2, device->machine->sample_rate, (void *)image, wave_sound_update); |
| 82 | if (speakers > 1) |
| 83 | stream_create(device, 0, 2, device->machine->sample_rate, (void *)image, wave_sound_update); |
| 84 | else |
| 85 | stream_create(device, 0, 1, device->machine->sample_rate, (void *)image, wave_sound_update); |
| 74 | 86 | } |
| 75 | 87 | |
| 76 | 88 | |