Esempio n. 1
0
static void route_sound(running_machine *machine)
{
	/* iterate again over all the sound chips */
	device_sound_interface *sound = NULL;
	for (bool gotone = machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
	{
		int numoutputs = stream_get_device_outputs(*sound);

		/* iterate over all routes */
		for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next)
		{
			device_t *target_device = machine->device(route->m_target);
			if (target_device->type() == SPEAKER)
				continue;

			int inputnum = route->m_input;

			/* iterate over all outputs, matching any that apply */
			for (int outputnum = 0; outputnum < numoutputs; outputnum++)
				if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS)
				{
					sound_stream *inputstream, *stream;
					int streaminput, streamoutput;

					if (stream_device_input_to_stream_input(target_device, inputnum++, &inputstream, &streaminput))
						if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput))
							stream_set_input(inputstream, streaminput, stream, streamoutput, route->m_gain);
				}
		}
	}
}
Esempio n. 2
0
static DISCRETE_START(dss_input_stream)
{
	struct dss_input_context *context = (struct dss_input_context *)node->context;

	assert(DSS_INPUT_STREAM__STREAM < linked_list_count(node->info->input_list));

	context->is_stream = TRUE;
	/* Stream out number is set during start */
	context->stream_in_number = DSS_INPUT_STREAM__STREAM;
	context->gain = DSS_INPUT_STREAM__GAIN;
	context->offset = DSS_INPUT_STREAM__OFFSET;
	context->ptr = NULL;
	//context->data = 0;

	if (node->block->type == DSS_INPUT_BUFFER)
	{
		context->is_buffered = TRUE;
		context->buffer_stream = stream_create(node->info->device, 0, 1, node->info->sample_rate, (void *) node, buffer_stream_update);

		stream_set_input(node->info->discrete_stream, context->stream_in_number,
			context->buffer_stream, 0, 1.0);
	}
	else
	{
		context->is_buffered = FALSE;
		context->buffer_stream = NULL;
	}
}
Esempio n. 3
0
void device_sound_interface::interface_post_start()
{
	// count the outputs
	for (int outputnum = 0; outputnum < MAX_OUTPUTS; outputnum++)
	{
		// stop when we run out of streams
		sound_stream *stream = stream_find_by_device(&m_device, outputnum);
		if (stream == NULL)
			break;

		// accumulate the number of outputs from this stream
		int numoutputs = stream_get_outputs(stream);
		assert(m_outputs + numoutputs < MAX_OUTPUTS);

		// fill in the array
		for (int curoutput = 0; curoutput < numoutputs; curoutput++)
		{
			sound_output *output = &m_output[m_outputs++];
			output->stream = stream;
			output->output = curoutput;
		}
	}

	// iterate over all the sound devices
	device_sound_interface *sound = NULL;
	for (bool gotone = m_device.machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
	{
		// scan each route on the device
		for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next)
		{
			// if we are the target of this route, hook it up
			device_t *target_device = m_device.machine->device(route->m_target);
			if (target_device == &m_device)
			{
				// iterate over all outputs, matching any that apply
				int inputnum = route->m_input;
				int numoutputs = stream_get_device_outputs(*sound);
				for (int outputnum = 0; outputnum < numoutputs; outputnum++)
					if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS)
					{
						sound_stream *inputstream, *stream;
						int streaminput, streamoutput;

						// get the input and output streams and wire them together
						if (stream_device_input_to_stream_input(target_device, inputnum++, &inputstream, &streaminput))
							if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput))
								stream_set_input(inputstream, streaminput, stream, streamoutput, route->m_gain);
					}
			}
		}
	}
}
Esempio n. 4
0
static void route_sound(void)
{
	int sndnum, spknum, routenum, outputnum;

	/* iterate over all the sound chips */
	for (sndnum = 0; sndnum < totalsnd; sndnum++)
	{
		sound_info *info = &sound[sndnum];

		/* iterate over all routes */
		for (routenum = 0; routenum < info->sound->routes; routenum++)
		{
			const sound_route *mroute = &info->sound->route[routenum];
			speaker_info *speaker;
			sound_info *sound;

			/* find the target */
			speaker = find_speaker_by_tag(mroute->target);
			sound = find_sound_by_tag(mroute->target);

			/* if neither found, it's fatal */
			if (speaker == NULL && sound == NULL)
				fatalerror("Sound route \"%s\" not found!\n", mroute->target);

			/* if we got a speaker, bump its input count */
			if (speaker != NULL)
			{
				if (mroute->output >= 0 && mroute->output < info->outputs)
					speaker->inputs++;
				else if (mroute->output == ALL_OUTPUTS)
					speaker->inputs += info->outputs;
			}
		}
	}

	/* now allocate the mixers and input data */
	streams_set_tag(Machine, NULL);
	for (spknum = 0; spknum < totalspeakers; spknum++)
	{
		speaker_info *info = &speaker[spknum];
		if (info->inputs != 0)
		{
			info->mixer_stream = stream_create(info->inputs, 1, Machine->sample_rate, info, mixer_update);
			info->input = auto_malloc(info->inputs * sizeof(*info->input));
			info->inputs = 0;
		}
		else
			logerror("Warning: speaker \"%s\" has no inputs\n", info->speaker->tag);
	}

	/* iterate again over all the sound chips */
	for (sndnum = 0; sndnum < totalsnd; sndnum++)
	{
		sound_info *info = &sound[sndnum];

		/* iterate over all routes */
		for (routenum = 0; routenum < info->sound->routes; routenum++)
		{
			const sound_route *mroute = &info->sound->route[routenum];
			speaker_info *speaker;
			sound_info *sound;

			/* find the target */
			speaker = find_speaker_by_tag(mroute->target);
			sound = find_sound_by_tag(mroute->target);

			/* if it's a speaker, set the input */
			if (speaker != NULL)
			{
				for (outputnum = 0; outputnum < info->outputs; outputnum++)
					if (mroute->output == outputnum || mroute->output == ALL_OUTPUTS)
					{
						char namebuf[256];
						int index;

						sndnum_to_sndti(sndnum, &index);

						/* fill in the input data on this speaker */
						speaker->input[speaker->inputs].gain = mroute->gain;
						speaker->input[speaker->inputs].default_gain = mroute->gain;
						sprintf(namebuf, "%s:%s #%d.%d", speaker->speaker->tag, sndnum_name(sndnum), index, outputnum);
						speaker->input[speaker->inputs].name = auto_strdup(namebuf);

						/* connect the output to the input */
						stream_set_input(speaker->mixer_stream, speaker->inputs++, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
					}
			}

			/* if it's a sound chip, set the input */
			else
			{
				for (outputnum = 0; outputnum < info->outputs; outputnum++)
					if (mroute->output == outputnum || mroute->output == ALL_OUTPUTS)
						stream_set_input(sound->output[0].stream, 0, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
			}
		}
	}
}
Esempio n. 5
0
static void route_sound(void)
{
	int sndnum, routenum, outputnum;
	const device_config *curspeak;

	/* iterate over all the sound chips */
	for (sndnum = 0; sndnum < totalsnd; sndnum++)
	{
		sound_info *info = &sound[sndnum];

		/* iterate over all routes */
		for (routenum = 0; routenum < info->sound->routes; routenum++)
		{
			const sound_route *mroute = &info->sound->route[routenum];
			speaker_info *speaker;
			sound_info *sound;

			/* find the target */
			speaker = find_speaker_by_tag(mroute->target);
			sound = find_sound_by_tag(mroute->target);

			/* if neither found, it's fatal */
			if (speaker == NULL && sound == NULL)
				fatalerror("Sound route \"%s\" not found!\n", mroute->target);

			/* if we got a speaker, bump its input count */
			if (speaker != NULL)
			{
				if (mroute->output >= 0 && mroute->output < info->outputs)
					speaker->inputs++;
				else if (mroute->output == ALL_OUTPUTS)
					speaker->inputs += info->outputs;
			}
		}
	}

	/* now allocate the mixers and input data */
	streams_set_tag(Machine, NULL);
	for (curspeak = speaker_output_first(Machine->config); curspeak != NULL; curspeak = speaker_output_next(curspeak))
	{
		speaker_info *info = curspeak->token;
		if (info->inputs != 0)
		{
			info->mixer_stream = stream_create(info->inputs, 1, Machine->sample_rate, info, mixer_update);
			info->input = auto_malloc(info->inputs * sizeof(*info->input));
			info->inputs = 0;
		}
		else
			logerror("Warning: speaker \"%s\" has no inputs\n", info->tag);
	}

	/* iterate again over all the sound chips */
	for (sndnum = 0; sndnum < totalsnd; sndnum++)
	{
		sound_info *info = &sound[sndnum];

		/* iterate over all routes */
		for (routenum = 0; routenum < info->sound->routes; routenum++)
		{
			const sound_route *mroute = &info->sound->route[routenum];
			speaker_info *speaker;
			sound_info *sound;

			/* find the target */
			speaker = find_speaker_by_tag(mroute->target);
			sound = find_sound_by_tag(mroute->target);

			/* if it's a speaker, set the input */
			if (speaker != NULL)
			{
				for (outputnum = 0; outputnum < info->outputs; outputnum++)
					if (mroute->output == outputnum || mroute->output == ALL_OUTPUTS)
					{
						char namebuf[256];
						int index;

						sound_type sndtype = sndnum_to_sndti(sndnum, &index);

						/* built the display name */
                        namebuf[0] = '\0';

                        /* speaker name, if more than one speaker */
						if (speaker_output_count(Machine->config) > 1)
							sprintf(namebuf, "%sSpeaker '%s': ", namebuf, speaker->tag);

                        /* device name */
						sprintf(namebuf, "%s%s ", namebuf, sndnum_name(sndnum));

						/* device index, if more than one of this type */
						if (sndtype_count(sndtype) > 1)
							sprintf(namebuf, "%s#%d ", namebuf, index);

						/* channel number, if more than channel for this device */
						if (info->outputs > 1)
							sprintf(namebuf, "%sCh.%d", namebuf, outputnum);

						/* remove final space */
						if (namebuf[strlen(namebuf) - 1] == ' ')
	                        namebuf[strlen(namebuf) - 1] = '\0';

						/* fill in the input data on this speaker */
						speaker->input[speaker->inputs].gain = mroute->gain;
						speaker->input[speaker->inputs].default_gain = mroute->gain;
						speaker->input[speaker->inputs].name = auto_strdup(namebuf);

						/* connect the output to the input */
						stream_set_input(speaker->mixer_stream, speaker->inputs++, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
					}
			}

			/* if it's a sound chip, set the input */
			else
			{
				if (mroute->input < 0)
				{
					for (outputnum = 0; outputnum < info->outputs; outputnum++)
						if (mroute->output == outputnum || mroute->output == ALL_OUTPUTS)
							stream_set_input(sound->output[0].stream, 0, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
				}
				else
				{
					assert(mroute->output != ALL_OUTPUTS);
					for (outputnum = 0; outputnum < info->outputs; outputnum++)
						if (mroute->output == outputnum)
							stream_set_input(sound->output[0].stream, mroute->input, info->output[outputnum].stream, info->output[outputnum].output, mroute->gain);
				}

			}
		}
	}
}
Esempio n. 6
0
void speaker_device::device_start()
{
	// scan all the sound devices and count our inputs
	int inputs = 0;
	device_sound_interface *sound = NULL;
	for (bool gotone = machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
	{
		// scan each route on the device
		for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next)
		{
			// if we are the target of this route, accumulate inputs
			device_t *target_device = machine->device(route->m_target);
			if (target_device == this)
			{
				// if the sound device is not yet started, bail however -- we need the its stream
				if (!sound->device().started())
					throw device_missing_dependencies();

				// accumulate inputs
				inputs += (route->m_output == ALL_OUTPUTS) ? stream_get_device_outputs(*sound) : 1;
			}
		}
	}

	// no inputs? that's weird
	if (inputs == 0)
	{
		logerror("Warning: speaker \"%s\" has no inputs\n", tag());
		return;
	}

	// now we know how many inputs; allocate the mixers and input data
	m_mixer_stream = stream_create(this, inputs, 1, machine->sample_rate, NULL, static_mixer_update);
	m_input = auto_alloc_array(machine, speaker_input, inputs);
	m_inputs = 0;

	// iterate again over all the sound devices
	for (bool gotone = machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound))
	{
		// scan each route on the device
		for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next)
		{
			// if we are the target of this route, hook it up
			device_t *target_device = machine->device(route->m_target);
			if (target_device == this)
			{
				// iterate over all outputs, matching any that apply
				int numoutputs = stream_get_device_outputs(*sound);
				for (int outputnum = 0; outputnum < numoutputs; outputnum++)
					if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS)
					{
						// fill in the input data on this speaker
						m_input[m_inputs].m_gain = route->m_gain;
						m_input[m_inputs].m_default_gain = route->m_gain;
						m_input[m_inputs].m_name.printf("Speaker '%s': %s '%s'", tag(), sound->device().name(), sound->device().tag());
						if (numoutputs > 1)
							m_input[m_inputs].m_name.catprintf(" Ch.%d", outputnum);

						// connect the output to the input
						sound_stream *stream;
						int streamoutput;
						if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput))
							stream_set_input(m_mixer_stream, m_inputs++, stream, streamoutput, route->m_gain);
					}
			}
		}
	}
}