mirror of
https://github.com/holub/mame
synced 2025-05-17 19:24:59 +03:00
Fixed bad cassette wave sound [Robbbert]
This commit is contained in:
parent
ea8dd94677
commit
dbeb8f1b61
@ -6,6 +6,11 @@
|
|||||||
Functions to handle loading, creation, recording and playback
|
Functions to handle loading, creation, recording and playback
|
||||||
of wave samples for IO_CASSETTE
|
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"
|
#include "emu.h"
|
||||||
@ -22,7 +27,8 @@
|
|||||||
static STREAM_UPDATE( wave_sound_update )
|
static STREAM_UPDATE( wave_sound_update )
|
||||||
{
|
{
|
||||||
#ifdef MESS
|
#ifdef MESS
|
||||||
running_device *image = (running_device *)param;
|
device_image_interface *image = (device_image_interface *)param;
|
||||||
|
int speakers = speaker_output_count(image->device().machine->config);
|
||||||
cassette_image *cassette;
|
cassette_image *cassette;
|
||||||
cassette_state state;
|
cassette_state state;
|
||||||
double time_index;
|
double time_index;
|
||||||
@ -31,29 +37,32 @@ static STREAM_UPDATE( wave_sound_update )
|
|||||||
stream_sample_t *right_buffer = outputs[1];
|
stream_sample_t *right_buffer = outputs[1];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
state = cassette_get_state(image);
|
state = cassette_get_state(&image->device());
|
||||||
|
|
||||||
state = (cassette_state)(state & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER));
|
state = (cassette_state)(state & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER));
|
||||||
|
|
||||||
if (image_exists(image) && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))))
|
if (image->exists() && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))))
|
||||||
{
|
{
|
||||||
cassette = cassette_get_image(image);
|
cassette = cassette_get_image(&image->device());
|
||||||
time_index = cassette_get_position(image);
|
time_index = cassette_get_position(&image->device());
|
||||||
duration = ((double) samples) / image->machine->sample_rate;
|
duration = ((double) samples) / image->device().machine->sample_rate;
|
||||||
|
|
||||||
cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT);
|
cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT);
|
||||||
cassette_get_samples(cassette, 1, time_index, duration, samples, 2, right_buffer, CASSETTE_WAVEFORM_16BIT);
|
if (speakers > 1)
|
||||||
|
cassette_get_samples(cassette, 1, time_index, duration, samples, 2, right_buffer, CASSETTE_WAVEFORM_16BIT);
|
||||||
|
|
||||||
for (i = samples - 1; i >= 0; i--)
|
for (i = samples - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
left_buffer[i] = ((INT16 *) left_buffer)[i];
|
left_buffer[i] = ((INT16 *) left_buffer)[i];
|
||||||
right_buffer[i] = ((INT16 *) right_buffer)[i];
|
if (speakers > 1)
|
||||||
|
right_buffer[i] = ((INT16 *) right_buffer)[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memset(left_buffer, 0, sizeof(*left_buffer) * samples);
|
memset(left_buffer, 0, sizeof(*left_buffer) * samples);
|
||||||
memset(right_buffer, 0, sizeof(*right_buffer) * samples);
|
if (speakers > 1)
|
||||||
|
memset(right_buffer, 0, sizeof(*right_buffer) * samples);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -62,15 +71,18 @@ static STREAM_UPDATE( wave_sound_update )
|
|||||||
|
|
||||||
static DEVICE_START( wave )
|
static DEVICE_START( wave )
|
||||||
{
|
{
|
||||||
running_device *image = NULL;
|
device_image_interface *image = NULL;
|
||||||
|
|
||||||
assert( device != NULL );
|
assert( device != NULL );
|
||||||
assert( device->baseconfig().static_config() != NULL );
|
assert( device->baseconfig().static_config() != NULL );
|
||||||
|
int speakers = speaker_output_count(device->machine->config);
|
||||||
#ifdef MESS
|
#ifdef MESS
|
||||||
image = device->machine->device( (const char *)device->baseconfig().static_config() );
|
image = dynamic_cast<device_image_interface *>(device->machine->device( (const char *)device->baseconfig().static_config()));
|
||||||
#endif
|
#endif
|
||||||
stream_create(device, 0, 2, device->machine->sample_rate, (void *)image, wave_sound_update);
|
if (speakers > 1)
|
||||||
|
stream_create(device, 0, 2, device->machine->sample_rate, (void *)image, wave_sound_update);
|
||||||
|
else
|
||||||
|
stream_create(device, 0, 1, device->machine->sample_rate, (void *)image, wave_sound_update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user