コード例 #1
0
void wave_device::device_start()
{
	speaker_device_iterator spkiter(machine().root_device());
	int speakers = spkiter.count();
	if (speakers > 1)
		machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate(), this);
	else
		machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this);
}
コード例 #2
0
ファイル: wave.cpp プロジェクト: kara1001000/mame
void wave_device::device_start()
{
	speaker_device_iterator spkiter(machine().root_device());
	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());
	m_cass = machine().device<cassette_image_device>(m_cassette_tag);
}
コード例 #3
0
void info_xml_creator::output_sound(device_t &device)
{
	speaker_device_iterator spkiter(device);
	int speakers = spkiter.count();

	// if we have no sound, zero m_output the speaker count
	sound_interface_iterator snditer(device);
	if (snditer.first() == NULL)
		speakers = 0;

	fprintf(m_output, "\t\t<sound channels=\"%d\"/>\n", speakers);
}
コード例 #4
0
ファイル: wave.c プロジェクト: LibXenonProject/mame-lx
static DEVICE_START( wave )
{
	cassette_image_device *image = NULL;

	assert( device != NULL );
	assert( device->static_config() != NULL );
	speaker_device_iterator spkiter(device->machine().root_device());
	int speakers = spkiter.count();
	image = dynamic_cast<cassette_image_device *>(device->machine().device( (const char *)device->static_config()));
	if (speakers > 1)
		device->machine().sound().stream_alloc(*device, 0, 2, device->machine().sample_rate(), (void *)image, wave_sound_update);
	else
		device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), (void *)image, wave_sound_update);
}
コード例 #5
0
ファイル: wave.c プロジェクト: LibXenonProject/mame-lx
static STREAM_UPDATE( wave_sound_update )
{
	cassette_image_device *cass = (cassette_image_device *)param;
	cassette_image *cassette;
	cassette_state state;
	double time_index;
	double duration;
	stream_sample_t *left_buffer = outputs[0];
	stream_sample_t *right_buffer = NULL;
	int i;

	speaker_device_iterator spkiter(cass->machine().root_device());
	int speakers = spkiter.count();
	if (speakers>1)
		right_buffer = outputs[1];

	state = cass->get_state();

	state = (cassette_state)(state & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER));

	if (cass->exists() && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))))
	{
		cassette = cass->get_image();
		time_index = cass->get_position();
		duration = ((double) samples) / cass->machine().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);

		for (i = samples - 1; i >= 0; i--)
		{
			left_buffer[i] = ((INT16 *) left_buffer)[i];
			if (speakers > 1)
				right_buffer[i] = ((INT16 *) right_buffer)[i];
		}
	}
	else
	{
		memset(left_buffer, 0, sizeof(*left_buffer) * samples);
		if (speakers > 1)
			memset(right_buffer, 0, sizeof(*right_buffer) * samples);
	}
}