From f8ddfc19fa6964fd7893c46ed8c54a8900f7a6b6 Mon Sep 17 00:00:00 2001 From: Couriersud Date: Sun, 20 Jan 2008 22:38:21 +0000 Subject: [PATCH] sound: * added MDRV_SOUND_ROUTE_EX to specify target input channel * added input id to route struct discrete sound: * fixed DISCRETE_INPUT_STREAM * added input channel # to DISCRETE_INPUT_STREAM --- src/emu/driver.h | 5 ++++- src/emu/sound.c | 17 ++++++++++++++--- src/emu/sound.h | 1 + src/emu/sound/disc_inp.c | 15 ++++++++++++--- src/emu/sound/discrete.c | 16 ++++++++++++---- src/emu/sound/discrete.h | 24 ++++++++++-------------- 6 files changed, 53 insertions(+), 25 deletions(-) diff --git a/src/emu/driver.h b/src/emu/driver.h index 6afd9f3e302..52565b9e203 100644 --- a/src/emu/driver.h +++ b/src/emu/driver.h @@ -493,15 +493,18 @@ struct _game_driver sound->routes = 0; \ } \ -#define MDRV_SOUND_ROUTE(_output, _target, _gain) \ +#define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input) \ if (sound) \ { \ sound->route[sound->routes].output = (_output); \ sound->route[sound->routes].target = (_target); \ sound->route[sound->routes].gain = (_gain); \ + sound->route[sound->routes].input = (_input); \ sound->routes++; \ } \ +#define MDRV_SOUND_ROUTE(_output, _target, _gain) \ + MDRV_SOUND_ROUTE_EX(_output, _target, _gain, -1) \ /*************************************************************************** diff --git a/src/emu/sound.c b/src/emu/sound.c index b3921a12010..d0eb4d15b85 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -489,9 +489,20 @@ static void route_sound(void) /* 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); + 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); + } + } } } diff --git a/src/emu/sound.h b/src/emu/sound.h index b8e188371bd..e62b9d0c8ef 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -36,6 +36,7 @@ struct _sound_route int output; /* output ID */ const char *target; /* tag of the target */ float gain; /* gain */ + int input; /* input ID, -1 is default behavior */ }; diff --git a/src/emu/sound/disc_inp.c b/src/emu/sound/disc_inp.c index 856e8077544..25c7c08a9c9 100644 --- a/src/emu/sound/disc_inp.c +++ b/src/emu/sound/disc_inp.c @@ -255,7 +255,16 @@ void dss_input_pulse_step(node_description *node) void dss_input_stream_step(node_description *node) { // the context pointer is set to point to the current input stream data in discrete_stream_update - stream_sample_t *data = node->context; - - node->output = data ? *data++ * DSS_INPUT_STREAM__GAIN + DSS_INPUT_STREAM__OFFSET : 0; + stream_sample_t **ptr = node->context; + stream_sample_t *data = *ptr; + + node->output = data ? (*data) * DSS_INPUT_STREAM__GAIN + DSS_INPUT_STREAM__OFFSET : 0; +} + +void dss_input_stream_reset(node_description *node) +{ + int istream = DSS_INPUT_STREAM__STREAM; + /* we will use the node's context pointer to point to the input stream data */ + assert(istream < discrete_current_context->discrete_input_streams); + node->context = &discrete_current_context->input_stream_data[istream]; } diff --git a/src/emu/sound/discrete.c b/src/emu/sound/discrete.c index c010c863769..084a19ec302 100644 --- a/src/emu/sound/discrete.c +++ b/src/emu/sound/discrete.c @@ -74,7 +74,7 @@ struct _discrete_info /* the input streams */ int discrete_input_streams; - stream_sample_t **input_stream_data[DISCRETE_MAX_OUTPUTS]; + stream_sample_t *input_stream_data[DISCRETE_MAX_OUTPUTS]; /* output node tracking */ int discrete_outputs; @@ -175,7 +175,7 @@ static const discrete_module module_list[] = { DSS_INPUT_LOGIC ,"DSS_INPUT_LOGIC" ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, { DSS_INPUT_NOT ,"DSS_INPUT_NOT" ,sizeof(UINT8) ,dss_input_reset ,dss_input_step }, { DSS_INPUT_PULSE ,"DSS_INPUT_PULSE" ,sizeof(UINT8) ,dss_input_reset ,dss_input_pulse_step }, - { DSS_INPUT_STREAM,"DSS_INPUT_STREAM",0 ,NULL ,dss_input_stream_step}, + { DSS_INPUT_STREAM,"DSS_INPUT_STREAM",0 ,dss_input_stream_reset,dss_input_stream_step}, /* from disc_wav.c */ /* Generic modules */ @@ -443,7 +443,7 @@ static void discrete_stream_update(void *param, stream_sample_t **inputs, stream /* Setup any input streams */ for (nodenum = 0; nodenum < info->discrete_input_streams; nodenum++) { - *info->input_stream_data[nodenum] = inputs[nodenum]; + info->input_stream_data[nodenum] = inputs[nodenum]; } /* Now we must do length iterations of the node list, one output for each step */ @@ -500,6 +500,12 @@ static void discrete_stream_update(void *param, stream_sample_t **inputs, stream wav_add_data_16lr(info->disc_wav_file[outputnum], &wave_data_l, &wave_data_r, 1); } } + + /* advance input streams */ + for (nodenum = 0; nodenum < info->discrete_input_streams; nodenum++) + { + info->input_stream_data[nodenum]++; + } } discrete_current_context = NULL; @@ -616,7 +622,9 @@ static void init_nodes(discrete_info *info, discrete_sound_block *block_list) if (info->discrete_input_streams == DISCRETE_MAX_OUTPUTS) fatalerror("init_nodes() - There can not be more then %d input stream nodes", DISCRETE_MAX_OUTPUTS); /* we will use the node's context pointer to point to the input stream data */ - *info->input_stream_data[info->discrete_input_streams++] = (stream_sample_t *)&node->context; + //node->context = &info->input_stream_data[info->discrete_input_streams++]; + node->context = NULL; + info->discrete_input_streams++; } } diff --git a/src/emu/sound/discrete.h b/src/emu/sound/discrete.h index 01fcac9598b..b7077751243 100644 --- a/src/emu/sound/discrete.h +++ b/src/emu/sound/discrete.h @@ -126,8 +126,8 @@ * DISCRETE_INPUT_NOT(NODE) * DISCRETE_INPUTX_NOT(NODE,GAIN,OFFSET,INIT) * DISCRETE_INPUT_PULSE(NODE,INIT) - * DISCRETE_INPUT_STREAM(NODE) - * DISCRETE_INPUTX_STREAM(NODE,GAIN,OFFSET) + * DISCRETE_INPUT_STREAM(NODE, NUM) + * DISCRETE_INPUTX_STREAM(NODE,NUM, GAIN,OFFSET) * * DISCRETE_COUNTER(NODE,ENAB,RESET,CLK,MAX,DIR,INIT0,CLKTYPE) * DISCRETE_COUNTER_7492(NODE,ENAB,RESET,CLK) @@ -349,20 +349,16 @@ * *********************************************************************** * - * !!!!! NOT WORKING YET !!!!! - * - * DISCRETE_INPUT_STREAM(NODE) - Accepts a stream input - * DISCRETE_INPUTX_STREAM(NODE,GAIN,OFFSET) - Accepts a stream input and - * applies a gain and offset. + * DISCRETE_INPUT_STREAM(NODE,NUM) - Accepts stream input NUM + * DISCRETE_INPUTX_STREAM(NODE,NUM,GAIN,OFFSET) - Accepts a stream input and + * applies a gain and offset. * * Declaration syntax * - * DISCRETE_INPUT_STREAM (name of node) - * DISCRETE_INPUTX_STREAM(name of node, gain, offset) + * DISCRETE_INPUT_STREAM (name of node, stream number, ) + * DISCRETE_INPUTX_STREAM(name of node, stream nubmer, gain, offset) * - * Note: These inputs must be defined in the same order that the sound routes - * are defined in the game's MACHINE_DRIVER. - * The discrete system is floating point based. So when routing a stream + * Note: The discrete system is floating point based. So when routing a stream * set it's gain to 100% and then use DISCRETE_INPUTX_STREAM to adjust * it if needed. * @@ -3828,8 +3824,8 @@ enum #define DISCRETE_INPUT_NOT(NODE) { NODE, DSS_INPUT_NOT , 3, { NODE_NC,NODE_NC,NODE_NC }, { 1,0,0 }, NULL, "Input Not" }, #define DISCRETE_INPUTX_NOT(NODE,GAIN,OFFSET,INIT) { NODE, DSS_INPUT_NOT , 3, { NODE_NC,NODE_NC,NODE_NC }, { GAIN,OFFSET,INIT }, NULL, "InputX Not" }, #define DISCRETE_INPUT_PULSE(NODE,INIT) { NODE, DSS_INPUT_PULSE , 3, { NODE_NC,NODE_NC,NODE_NC }, { 1,0,INIT }, NULL, "Input Pulse" }, -#define DISCRETE_INPUT_STREAM(NODE) { NODE, DSS_INPUT_STREAM, 2, { NODE_NC,NODE_NC }, { 1,0 }, NULL, "Input Stream" }, -#define DISCRETE_INPUTX_STREAM(NODE,GAIN,OFFSET) { NODE, DSS_INPUT_STREAM, 2, { NODE_NC,NODE_NC }, { GAIN,OFFSET }, NULL, "InputX Stream" }, +#define DISCRETE_INPUT_STREAM(NODE, NUM) { NODE, DSS_INPUT_STREAM, 3, { NUM,NODE_NC,NODE_NC }, { NUM,1,0 }, NULL, "Input Stream" }, +#define DISCRETE_INPUTX_STREAM(NODE, NUM, GAIN,OFFSET) { NODE, DSS_INPUT_STREAM, 3, { NUM,NODE_NC,NODE_NC }, { NUM,GAIN,OFFSET }, NULL, "InputX Stream" }, /* from disc_wav.c */ /* generic modules */