Пример #1
0
void flower_sound_device::device_start()
{
	flower_sound_channel *voice;

	m_effect_timer = timer_alloc(TIMER_CLOCK_EFFECT);
	m_stream = machine().sound().stream_alloc(*this, 0, 1, MIXER_SAMPLERATE);
	m_mixer_buffer = auto_alloc_array(machine(), short, MIXER_SAMPLERATE);
	make_mixer_table(8, MIXER_DEFGAIN);

	/* extract globals from the interface */
	m_last_channel = m_channel_list + 8;

	m_sample_rom = machine().root_device().memregion("sound1")->base();
	m_volume_rom = machine().root_device().memregion("sound2")->base();

	/* register for savestates */
	for (int i = 0; i < 8; i++)
	{
		voice = &m_channel_list[i];

		save_item(NAME(voice->freq), i+1);
		save_item(NAME(voice->pos), i+1);
		save_item(NAME(voice->volume), i+1);
		save_item(NAME(voice->voltab), i+1);
		save_item(NAME(voice->effect), i+1);
		save_item(NAME(voice->ecount), i+1);
		save_item(NAME(voice->oneshot), i+1);
		save_item(NAME(voice->active), i+1);
		save_item(NAME(voice->start), i+1);
	}
}
Пример #2
0
void k005289_device::device_start()
{
	/* get stream channels */
	m_rate = clock() / CLOCK_DIVIDER;
	m_stream = stream_alloc(0, 1, m_rate);

	/* allocate a pair of buffers to mix into - 1 second's worth should be more than enough */
	m_mixer_buffer = std::make_unique<short[]>(2 * m_rate);

	/* build the mixer table */
	make_mixer_table(2);

	/* reset all the voices */
	for (int i = 0; i < 2; i++)
	{
		m_counter[i] = 0;
		m_frequency[i] = 0;
		m_freq_latch[i] = 0;
		m_waveform[i] = i * 0x100;
		m_volume[i] = 0;
	}

	save_item(NAME(m_counter));
	save_item(NAME(m_frequency));
	save_item(NAME(m_freq_latch));
	save_item(NAME(m_waveform));
	save_item(NAME(m_volume));
}
Пример #3
0
int TMS3617_sh_start(const struct MachineSound *msound)
{
	int voice;
	struct TMS3617_interface *intf = &monsterb_intf;

	buffer_len = intf->samplerate / Machine->drv->frames_per_second;
	emulation_rate = buffer_len * Machine->drv->frames_per_second;

	channel = mixer_allocate_channel(intf->volume);

	if ((output_buffer = malloc(buffer_len)) == 0)
		return 1;

	if ((mixer_buffer = malloc(sizeof(short) * buffer_len)) == 0)
	{
		free (output_buffer);
		return 1;
	}

	if (make_mixer_table (intf->gain))
	{
		free (mixer_buffer);
		free (output_buffer);
		return 1;
	}

	sample_pos = 0;
	TMS3617_pitch = 0;
	interface = intf;

	for (voice = 0;voice < NUM_VOICES;voice++)
	{
		counter[voice] = 0;
		voice_enable[voice] = 1;
	}

	return 0;
}