* 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
This commit is contained in:
Couriersud 2008-01-20 22:38:21 +00:00
parent 50f7b75476
commit f8ddfc19fa
6 changed files with 53 additions and 25 deletions

View File

@ -493,15 +493,18 @@ struct _game_driver
sound->routes = 0; \ sound->routes = 0; \
} \ } \
#define MDRV_SOUND_ROUTE(_output, _target, _gain) \ #define MDRV_SOUND_ROUTE_EX(_output, _target, _gain, _input) \
if (sound) \ if (sound) \
{ \ { \
sound->route[sound->routes].output = (_output); \ sound->route[sound->routes].output = (_output); \
sound->route[sound->routes].target = (_target); \ sound->route[sound->routes].target = (_target); \
sound->route[sound->routes].gain = (_gain); \ sound->route[sound->routes].gain = (_gain); \
sound->route[sound->routes].input = (_input); \
sound->routes++; \ sound->routes++; \
} \ } \
#define MDRV_SOUND_ROUTE(_output, _target, _gain) \
MDRV_SOUND_ROUTE_EX(_output, _target, _gain, -1) \
/*************************************************************************** /***************************************************************************

View File

@ -488,11 +488,22 @@ static void route_sound(void)
/* if it's a sound chip, set the input */ /* if it's a sound chip, set the input */
else else
{
if (mroute->input < 0)
{ {
for (outputnum = 0; outputnum < info->outputs; outputnum++) for (outputnum = 0; outputnum < info->outputs; outputnum++)
if (mroute->output == outputnum || mroute->output == ALL_OUTPUTS) 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); 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);
}
}
} }
} }
} }

View File

@ -36,6 +36,7 @@ struct _sound_route
int output; /* output ID */ int output; /* output ID */
const char *target; /* tag of the target */ const char *target; /* tag of the target */
float gain; /* gain */ float gain; /* gain */
int input; /* input ID, -1 is default behavior */
}; };

View File

@ -255,7 +255,16 @@ void dss_input_pulse_step(node_description *node)
void dss_input_stream_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 // the context pointer is set to point to the current input stream data in discrete_stream_update
stream_sample_t *data = node->context; stream_sample_t **ptr = node->context;
stream_sample_t *data = *ptr;
node->output = data ? *data++ * DSS_INPUT_STREAM__GAIN + DSS_INPUT_STREAM__OFFSET : 0; 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];
} }

View File

@ -74,7 +74,7 @@ struct _discrete_info
/* the input streams */ /* the input streams */
int discrete_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 */ /* output node tracking */
int discrete_outputs; 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_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_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_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 */ /* from disc_wav.c */
/* Generic modules */ /* Generic modules */
@ -443,7 +443,7 @@ static void discrete_stream_update(void *param, stream_sample_t **inputs, stream
/* Setup any input streams */ /* Setup any input streams */
for (nodenum = 0; nodenum < info->discrete_input_streams; nodenum++) 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 */ /* 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); 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; 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) if (info->discrete_input_streams == DISCRETE_MAX_OUTPUTS)
fatalerror("init_nodes() - There can not be more then %d input stream nodes", 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 */ /* 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++;
} }
} }

View File

@ -126,8 +126,8 @@
* DISCRETE_INPUT_NOT(NODE) * DISCRETE_INPUT_NOT(NODE)
* DISCRETE_INPUTX_NOT(NODE,GAIN,OFFSET,INIT) * DISCRETE_INPUTX_NOT(NODE,GAIN,OFFSET,INIT)
* DISCRETE_INPUT_PULSE(NODE,INIT) * DISCRETE_INPUT_PULSE(NODE,INIT)
* DISCRETE_INPUT_STREAM(NODE) * DISCRETE_INPUT_STREAM(NODE, NUM)
* DISCRETE_INPUTX_STREAM(NODE,GAIN,OFFSET) * DISCRETE_INPUTX_STREAM(NODE,NUM, GAIN,OFFSET)
* *
* DISCRETE_COUNTER(NODE,ENAB,RESET,CLK,MAX,DIR,INIT0,CLKTYPE) * DISCRETE_COUNTER(NODE,ENAB,RESET,CLK,MAX,DIR,INIT0,CLKTYPE)
* DISCRETE_COUNTER_7492(NODE,ENAB,RESET,CLK) * DISCRETE_COUNTER_7492(NODE,ENAB,RESET,CLK)
@ -349,20 +349,16 @@
* *
*********************************************************************** ***********************************************************************
* *
* !!!!! NOT WORKING YET !!!!! * DISCRETE_INPUT_STREAM(NODE,NUM) - Accepts stream input NUM
* * DISCRETE_INPUTX_STREAM(NODE,NUM,GAIN,OFFSET) - Accepts a stream input and
* DISCRETE_INPUT_STREAM(NODE) - Accepts a stream input
* DISCRETE_INPUTX_STREAM(NODE,GAIN,OFFSET) - Accepts a stream input and
* applies a gain and offset. * applies a gain and offset.
* *
* Declaration syntax * Declaration syntax
* *
* DISCRETE_INPUT_STREAM (name of node) * DISCRETE_INPUT_STREAM (name of node, stream number, )
* DISCRETE_INPUTX_STREAM(name of node, gain, offset) * DISCRETE_INPUTX_STREAM(name of node, stream nubmer, gain, offset)
* *
* Note: These inputs must be defined in the same order that the sound routes * Note: The discrete system is floating point based. So when routing a stream
* are defined in the game's MACHINE_DRIVER.
* 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 * set it's gain to 100% and then use DISCRETE_INPUTX_STREAM to adjust
* it if needed. * 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_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_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_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_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,GAIN,OFFSET) { NODE, DSS_INPUT_STREAM, 2, { NODE_NC,NODE_NC }, { GAIN,OFFSET }, NULL, "InputX 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 */ /* from disc_wav.c */
/* generic modules */ /* generic modules */