mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-04-22 07:30:50 +00:00
Add function API to set default mapping
- Add fluid_synth_mixer_reset_mapping() in fluid_synth.c. - Add command resetchanmap in fluid_cmd.c.
This commit is contained in:
parent
f62419a367
commit
27a398851e
4 changed files with 127 additions and 0 deletions
|
@ -397,6 +397,7 @@ FLUIDSYNTH_API int fluid_synth_mixer_set_mapping(fluid_synth_t *synth,
|
|||
int chan_to_out, int out_from_chan,
|
||||
int chan_to_fx, int fx_from_chan,
|
||||
int chanfx_to_out, int out_from_fx);
|
||||
FLUIDSYNTH_API int fluid_synth_mixer_reset_mapping(fluid_synth_t *synth, int chan);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -194,6 +194,10 @@ static const fluid_cmd_t fluid_commands[] =
|
|||
"chanmap", "mixer", fluid_handle_chanmap,
|
||||
"chanmap [chan1 chan2..] Print mapping of all or some MIDI channels"
|
||||
},
|
||||
{
|
||||
"resetchanmap", "mixer", fluid_handle_resetchanmap,
|
||||
"resetchanmap [chan1 chan2..] Set default mapping of MIDI channels"
|
||||
},
|
||||
{
|
||||
"setchanmapout", "mixer", fluid_handle_setchanmapout,
|
||||
"setchanmapout chan0 out0 [chan1 out1..] Set mapping MIDI channel to dry output"
|
||||
|
@ -3422,6 +3426,56 @@ int fluid_handle_chanmap(void *data, int ac, char **av,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
resetchanmap
|
||||
|
||||
With no parameter the command set default mapping for all MIDI channels.
|
||||
|
||||
resetchanmap chan0 [chan1 . . .]
|
||||
|
||||
Set default mapping for MIDI channels chan0 chan1 ..
|
||||
*/
|
||||
int fluid_handle_resetchanmap(void *data, int ac, char **av,
|
||||
fluid_ostream_t out)
|
||||
|
||||
{
|
||||
static const char name_cde[] = "resetchanmap";
|
||||
FLUID_ENTRY_COMMAND(data);
|
||||
fluid_synth_t *synth = handler->synth;
|
||||
|
||||
/* checks channels arguments: chan1 chan2 .... */
|
||||
if(check_channels_arguments(ac, av, out, name_cde) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ac)
|
||||
{
|
||||
/* resetchanmap chan0 [chan1 . . .] */
|
||||
int i;
|
||||
|
||||
for(i = 0; i < ac; i++)
|
||||
{
|
||||
int chan = atoi(av[i]);
|
||||
int result = fluid_synth_mixer_reset_mapping (synth, chan);
|
||||
|
||||
if(result == FLUID_FAILED)
|
||||
{
|
||||
fluid_ostream_printf(out, "%s: channel %3d, %s", name_cde, chan,
|
||||
invalid_arg_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set default mapping for all channels */
|
||||
fluid_synth_mixer_reset_mapping(synth, -1);
|
||||
}
|
||||
|
||||
/* prints result */
|
||||
return fluid_handle_chanmap(data, 0, av, out);
|
||||
}
|
||||
|
||||
/* type of MIDI channel mapping */
|
||||
enum channel_mapping_type
|
||||
{
|
||||
|
|
|
@ -104,6 +104,7 @@ int fluid_handle_setbreathmode(void *data, int ac, char **av, fluid_ostream_t ou
|
|||
int fluid_handle_sleep(void *data, int ac, char **av, fluid_ostream_t out);
|
||||
|
||||
int fluid_handle_chanmap(void *data, int ac, char **av,fluid_ostream_t out);
|
||||
int fluid_handle_resetchanmap(void *data, int ac, char **av, fluid_ostream_t out);
|
||||
int fluid_handle_setchanmapout(void *data, int ac, char **av, fluid_ostream_t out);
|
||||
int fluid_handle_setchanmapfx(void *data, int ac, char **av, fluid_ostream_t out);
|
||||
int fluid_handle_setchanfxmapout(void *data, int ac, char **av, fluid_ostream_t out);
|
||||
|
|
|
@ -7599,3 +7599,74 @@ fluid_synth_mixer_set_mapping(fluid_synth_t *synth,
|
|||
|
||||
FLUID_API_RETURN(FLUID_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mixer MIDI channel default mapping to audio buffers.
|
||||
* The default mapping are:
|
||||
* (1) default MIDI channel mapping to audio dry buffers.
|
||||
* (2) default MIDI channel mapping to fx unit input .
|
||||
* (3) default unit fx output mapping to audio dry buffers.
|
||||
*
|
||||
* The function allows to set default mapping (1)(2) and (3)
|
||||
* for channel chan.
|
||||
* 1) set default mapping between MIDI channel chan and audio dry
|
||||
* output index out_from_chan:
|
||||
* out_from_chan = chan % synth.audio-groups.
|
||||
*
|
||||
* 2) set default mapping between MIDI channel chan and
|
||||
* fx unit input index fx_from_chan:
|
||||
* fx_from_chan = chan % synth.effects-groups.
|
||||
*
|
||||
* 3) set default mapping between fx unit fxunit_idx (which is mapped to chan)
|
||||
* and audio dry output index out_from_fx:
|
||||
* out_from_fx = fxunit_idx % synth.audio-groups.
|
||||
*
|
||||
* @param synth FluidSynth instance.
|
||||
* @param chan, MIDI channel to set default mapping to.
|
||||
* Must be in the range (-1 to MIDI channel count - 1).
|
||||
* If -1, all MIDI channels are set to default mapping.
|
||||
*
|
||||
* @return #FLUID_OK on success, #FLUID_FAILED otherwise
|
||||
*/
|
||||
int
|
||||
fluid_synth_mixer_reset_mapping(fluid_synth_t *synth, int chan)
|
||||
{
|
||||
int nbr_chan;
|
||||
|
||||
fluid_return_val_if_fail(synth != NULL, FLUID_FAILED);
|
||||
fluid_synth_api_enter(synth);
|
||||
|
||||
/* check parameters first */
|
||||
if(chan < 0)
|
||||
{
|
||||
/* The range is all MIDI channels from 0 to MIDI channel count -1 */
|
||||
chan = 0; /* beginning chan */
|
||||
nbr_chan = synth->midi_channels; /* MIDI Channels number */
|
||||
}
|
||||
else
|
||||
{
|
||||
if(chan >= synth->midi_channels)
|
||||
{
|
||||
FLUID_API_RETURN(FLUID_FAILED);
|
||||
}
|
||||
|
||||
/* The range is only chan */
|
||||
nbr_chan = chan + 1;
|
||||
}
|
||||
|
||||
/* now set the default mapping */
|
||||
for(; chan < nbr_chan; chan++)
|
||||
{
|
||||
int fxunit_idx = chan % synth->effects_groups;
|
||||
synth->channel[chan]->mapping_to_out = chan % synth->audio_groups;
|
||||
synth->channel[chan]->mapping_to_fx = fxunit_idx;
|
||||
/* default mapping between fxunit_idx (which is mapped to chan)
|
||||
and audio dry output.
|
||||
*/
|
||||
fluid_rvoice_mixer_set_fx_out_mapping(synth->eventhandler->mixer,
|
||||
fxunit_idx,
|
||||
fxunit_idx % synth->audio_groups);
|
||||
}
|
||||
|
||||
FLUID_API_RETURN(FLUID_OK);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue