mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-04-18 21:51:22 +00:00
introduced info message
This commit is contained in:
parent
d9baebda38
commit
1ea508e4e4
3 changed files with 549 additions and 83 deletions
|
@ -27,28 +27,23 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* versions:
|
||||
* (6): introduced message 'info'
|
||||
* (5): fixed bogus path translation at file loading
|
||||
*
|
||||
*/
|
||||
#define VERSION "04/2004 (6)"
|
||||
|
||||
#include "ftmax.h"
|
||||
#include "fluidsynth.h"
|
||||
#include "fluid_synth.h"
|
||||
#include "fluid_sfont.h"
|
||||
#include "fluid_chan.h"
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* These functions were added after the v1.0 API freeze. They are not
|
||||
* in synth.h, yet.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
int fluid_synth_program_select2(fluid_synth_t* synth,
|
||||
int chan,
|
||||
char* sfont_name,
|
||||
unsigned int bank_num,
|
||||
unsigned int preset_num);
|
||||
|
||||
|
||||
#define VERSION "02/2004 (4)"
|
||||
/* these functions were added after the v1.0 API freeze. They are not in synth.h, yet */
|
||||
extern int fluid_synth_program_select2(fluid_synth_t* synth, int chan, char* sfont_name, unsigned int bank_num, unsigned int preset_num);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -56,6 +51,8 @@ typedef struct
|
|||
|
||||
fluid_synth_t *synth;
|
||||
fluid_settings_t *settings;
|
||||
int reverb;
|
||||
int chorus;
|
||||
int mute;
|
||||
void *outlet;
|
||||
} fluidmax_t;
|
||||
|
@ -64,6 +61,15 @@ static t_messlist *fluidmax_class;
|
|||
|
||||
static ftmax_symbol_t sym_on = NULL;
|
||||
static ftmax_symbol_t sym_off = NULL;
|
||||
static ftmax_symbol_t sym_gain = NULL;
|
||||
static ftmax_symbol_t sym_channels = NULL;
|
||||
static ftmax_symbol_t sym_channel = NULL;
|
||||
static ftmax_symbol_t sym_soundfonts = NULL;
|
||||
static ftmax_symbol_t sym_soundfont = NULL;
|
||||
static ftmax_symbol_t sym_presets = NULL;
|
||||
static ftmax_symbol_t sym_preset = NULL;
|
||||
static ftmax_symbol_t sym_reverb = NULL;
|
||||
static ftmax_symbol_t sym_chorus = NULL;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
|
@ -123,9 +129,10 @@ fluidmax_translate_fullpath(char *maxpath, char *fullpath)
|
|||
return fullpath;
|
||||
}
|
||||
|
||||
static const char *
|
||||
fluidmax_strip_path(const char *fullpath)
|
||||
static ftmax_symbol_t
|
||||
fluidmax_get_stripped_name(const char *fullpath)
|
||||
{
|
||||
char stripped[1024];
|
||||
int i;
|
||||
|
||||
for(i=strlen(fullpath)-1; i>=0; i--)
|
||||
|
@ -137,9 +144,46 @@ fluidmax_strip_path(const char *fullpath)
|
|||
if(i != 0)
|
||||
i++;
|
||||
|
||||
return fullpath + i;
|
||||
strcpy(stripped, fullpath + i);
|
||||
|
||||
for(i=0; stripped[i] != '\0'; i++)
|
||||
{
|
||||
if((stripped[i] == '.') &&
|
||||
(stripped[i + 1] == 's' || stripped[i + 1] == 'S') &&
|
||||
(stripped[i + 2] == 'f' || stripped[i + 2] == 'F') &&
|
||||
(stripped[i + 3] == '2'))
|
||||
{
|
||||
stripped[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ftmax_new_symbol(stripped);
|
||||
}
|
||||
|
||||
static ftmax_symbol_t
|
||||
fluidmax_sfont_get_name(fluid_sfont_t *sfont)
|
||||
{
|
||||
return fluidmax_get_stripped_name(fluid_sfont_get_name(sfont));
|
||||
}
|
||||
|
||||
static fluid_sfont_t *
|
||||
fluidmax_sfont_get_by_name(fluidmax_t *self, ftmax_symbol_t name)
|
||||
{
|
||||
int n = fluid_synth_sfcount(self->synth);
|
||||
int i;
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
{
|
||||
fluid_sfont_t *sfont = fluid_synth_get_sfont(self->synth, i);
|
||||
|
||||
if(fluidmax_sfont_get_name(sfont) == name)
|
||||
return sfont;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
fluidmax_do_load(t_object *o, Symbol *s, short ac, Atom *at)
|
||||
{
|
||||
|
@ -147,18 +191,30 @@ fluidmax_do_load(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
|
||||
if(ac > 0 && ftmax_is_symbol(at))
|
||||
{
|
||||
const char* filename = ftmax_symbol_name(ftmax_get_symbol(at));
|
||||
const char *filename = ftmax_symbol_name(ftmax_get_symbol(at));
|
||||
ftmax_symbol_t name = fluidmax_get_stripped_name(filename);
|
||||
fluid_sfont_t *sf = fluidmax_sfont_get_by_name(self, name);
|
||||
|
||||
if(fluid_synth_sfload(self->synth, filename, 0) >= 0)
|
||||
{
|
||||
post("fluidsynth~: loaded soundfont '%s'", fluidmax_strip_path(filename));
|
||||
if(sf == NULL)
|
||||
{
|
||||
int id = fluid_synth_sfload(self->synth, filename, 0);
|
||||
|
||||
if(id >= 0)
|
||||
{
|
||||
post("fluidsynth~: loaded soundfont '%s'", ftmax_symbol_name(name));
|
||||
|
||||
fluid_synth_program_reset(self->synth);
|
||||
|
||||
outlet_bang(self->outlet);
|
||||
fluid_synth_program_reset(self->synth);
|
||||
|
||||
outlet_bang(self->outlet);
|
||||
}
|
||||
else
|
||||
error("fluidsynth~: cannot load soundfont from file '%s'", filename);
|
||||
}
|
||||
else
|
||||
error("fluidsynth~: cannot load soundfont from file '%s'", filename);
|
||||
{
|
||||
error("soundfont named '%s' is already loaded", ftmax_symbol_name(name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +261,7 @@ fluidmax_load(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
char *string = (char *)ftmax_symbol_name(name);
|
||||
|
||||
if(string[0] == '/')
|
||||
fluidmax_do_load(o, NULL, ac, at);
|
||||
defer(o, (method)fluidmax_do_load, NULL, ac, at);
|
||||
else
|
||||
{
|
||||
char maxpath[1024];
|
||||
|
@ -221,7 +277,7 @@ fluidmax_load(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
}
|
||||
|
||||
ftmax_set_symbol(&a, ftmax_new_symbol(fluidmax_translate_fullpath(maxpath, fullpath)));
|
||||
fluidmax_do_load(o, NULL, 1, &a);
|
||||
defer(o, (method)fluidmax_do_load, NULL, 1, &a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,11 +297,11 @@ fluidmax_unload(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
|
||||
if(sf != NULL)
|
||||
{
|
||||
char *name = fluid_sfont_get_name(sf);
|
||||
ftmax_symbol_t name = fluidmax_sfont_get_name(sf);
|
||||
|
||||
if(fluid_synth_sfunload(self->synth, id, 0) >= 0)
|
||||
{
|
||||
post("fluidsynth~: unloaded soundfont %d: %s", id, name);
|
||||
post("fluidsynth~: unloaded soundfont '%s' (%d)", ftmax_symbol_name(name), id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -256,6 +312,78 @@ fluidmax_unload(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
{
|
||||
ftmax_symbol_t sym = ftmax_get_symbol(at);
|
||||
|
||||
if(sym == ftmax_new_symbol("all"))
|
||||
{
|
||||
fluid_sfont_t *sf = fluid_synth_get_sfont(self->synth, 0);
|
||||
int i;
|
||||
|
||||
fluid_synth_system_reset(self->synth);
|
||||
|
||||
while(sf != NULL)
|
||||
{
|
||||
ftmax_symbol_t name = fluidmax_sfont_get_name(sf);
|
||||
unsigned int id = fluid_sfont_get_id(sf);
|
||||
|
||||
if(fluid_synth_sfunload(self->synth, id, 0) >= 0)
|
||||
post("fluidsynth~: unloaded soundfont '%s' (%d)", ftmax_symbol_name(name), id);
|
||||
else
|
||||
error("fluidsynth~: cannot unload soundfont '%s' (%d)", ftmax_symbol_name(name), id);
|
||||
|
||||
sf = fluid_synth_get_sfont(self->synth, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fluid_sfont_t *sf = fluidmax_sfont_get_by_name(self, sym);
|
||||
|
||||
if(sf != NULL)
|
||||
{
|
||||
unsigned int id = fluid_sfont_get_id(sf);
|
||||
|
||||
if(fluid_synth_sfunload(self->synth, id, 0) >= 0)
|
||||
{
|
||||
post("fluidsynth~: unloaded soundfont '%s' (%d)", ftmax_symbol_name(sym), id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
error("fluidsynth~: cannot unload soundfont '%s'", ftmax_symbol_name(sym));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fluidmax_reload(t_object *o, Symbol *s, short ac, Atom *at)
|
||||
{
|
||||
fluidmax_t *self = (fluidmax_t *)o;
|
||||
|
||||
if(ac > 0)
|
||||
{
|
||||
int id;
|
||||
|
||||
if(ftmax_is_number(at))
|
||||
{
|
||||
int id = ftmax_get_number_int(at);
|
||||
fluid_sfont_t *sf = fluid_synth_get_sfont_by_id(self->synth, id);
|
||||
|
||||
if(sf != NULL)
|
||||
{
|
||||
ftmax_symbol_t name = fluidmax_sfont_get_name(sf);
|
||||
|
||||
if (fluid_synth_sfreload(self->synth, id) >= 0)
|
||||
{
|
||||
post("fluidsynth~: reloaded soundfont '%s' (%d)", id);
|
||||
return;
|
||||
}
|
||||
|
||||
error("fluidsynth~: cannot reload soundfont %d", id);
|
||||
}
|
||||
}
|
||||
else if (ftmax_is_symbol(at))
|
||||
{
|
||||
ftmax_symbol_t sym = ftmax_get_symbol(at);
|
||||
|
||||
if(sym == ftmax_new_symbol("all"))
|
||||
{
|
||||
int n = fluid_synth_sfcount(self->synth);
|
||||
|
@ -266,32 +394,37 @@ fluidmax_unload(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
for(i=0; i<n; i++)
|
||||
{
|
||||
fluid_sfont_t *sf = fluid_synth_get_sfont(self->synth, i);
|
||||
char *name = fluid_sfont_get_name(sf);
|
||||
ftmax_symbol_t name = fluidmax_sfont_get_name(sf);
|
||||
unsigned int id = fluid_sfont_get_id(sf);
|
||||
|
||||
post("fluidsynth~: unloaded soundfont %d", id);
|
||||
|
||||
if (fluid_synth_sfreload(self->synth, id) >= 0)
|
||||
post("fluidsynth~: reloaded soundfont '%s' (%d)", ftmax_symbol_name(name), id);
|
||||
else
|
||||
error("fluidsynth~: cannot reload soundfont '%s' (%d)", ftmax_symbol_name(name), id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fluid_sfont_t *sf = fluidmax_sfont_get_by_name(self, sym);
|
||||
|
||||
if(sf != NULL)
|
||||
{
|
||||
unsigned int id = fluid_sfont_get_id(sf);
|
||||
|
||||
if(fluid_synth_sfreload(self->synth, id) >= 0)
|
||||
{
|
||||
post("fluidsynth~: reloaded soundfont '%s' (%d)", ftmax_symbol_name(sym), id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
error("fluidsynth~: cannot reload soundfont '%s'", ftmax_symbol_name(sym));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fluidmax_reload(t_object *o, Symbol *s, short ac, Atom *at)
|
||||
{
|
||||
fluidmax_t *self = (fluidmax_t *)o;
|
||||
|
||||
if(ac > 0 && ftmax_is_number(at))
|
||||
{
|
||||
int id = ftmax_get_number_int(at);
|
||||
|
||||
if (fluid_synth_sfreload(self->synth, id) >= 0)
|
||||
post("fluidsynth~: reloaded soundfont %d", id);
|
||||
else
|
||||
error("fluidsynth~: cannot reload soundfont %d", id);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fluidmax_note(t_object *o, Symbol *s, short ac, Atom *at)
|
||||
{
|
||||
|
@ -534,6 +667,7 @@ fluidmax_reverb(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
{
|
||||
fluid_synth_set_reverb_on(self->synth, 1);
|
||||
fluid_revmodel_reset(self->synth->reverb);
|
||||
self->reverb = 1;
|
||||
}
|
||||
else if(ftmax_is_number(at))
|
||||
{
|
||||
|
@ -542,6 +676,7 @@ fluidmax_reverb(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
double width = fluid_synth_get_reverb_width(self->synth);
|
||||
|
||||
fluid_synth_set_reverb_on(self->synth, 1);
|
||||
self->reverb = 1;
|
||||
|
||||
switch(ac)
|
||||
{
|
||||
|
@ -566,9 +701,15 @@ fluidmax_reverb(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
ftmax_symbol_t sym = ftmax_get_symbol(at);
|
||||
|
||||
if(sym == sym_on)
|
||||
{
|
||||
fluid_synth_set_reverb_on(self->synth, 1);
|
||||
self->reverb = 1;
|
||||
}
|
||||
else if(sym == sym_off)
|
||||
{
|
||||
fluid_synth_set_reverb_on(self->synth, 0);
|
||||
self->reverb = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -581,6 +722,7 @@ fluidmax_chorus(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
{
|
||||
fluid_synth_set_chorus_on(self->synth, 1);
|
||||
fluid_chorus_reset(self->synth->chorus);
|
||||
self->chorus = 1;
|
||||
}
|
||||
else if(ftmax_is_number(at))
|
||||
{
|
||||
|
@ -590,7 +732,8 @@ fluidmax_chorus(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
int nr = fluid_synth_get_chorus_nr(self->synth);
|
||||
|
||||
fluid_synth_set_chorus_on(self->synth, 1);
|
||||
|
||||
self->chorus = 1;
|
||||
|
||||
switch(ac)
|
||||
{
|
||||
default:
|
||||
|
@ -617,9 +760,15 @@ fluidmax_chorus(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
ftmax_symbol_t sym = ftmax_get_symbol(at);
|
||||
|
||||
if(sym == sym_on)
|
||||
{
|
||||
fluid_synth_set_chorus_on(self->synth, 1);
|
||||
self->chorus = 1;
|
||||
}
|
||||
else if(sym == sym_off)
|
||||
{
|
||||
fluid_synth_set_chorus_on(self->synth, 0);
|
||||
self->chorus = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -716,32 +865,38 @@ fluidmax_print(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
{
|
||||
ftmax_symbol_t sym = ftmax_get_symbol(at);
|
||||
|
||||
if(sym == ftmax_new_symbol("gain"))
|
||||
if(sym == sym_gain)
|
||||
{
|
||||
double gain = fluid_synth_get_gain(self->synth);
|
||||
|
||||
post("gain: %g", gain);
|
||||
}
|
||||
else if(sym == ftmax_new_symbol("channels"))
|
||||
else if(sym == sym_channels)
|
||||
{
|
||||
int n = fluid_synth_count_midi_channels(self->synth);
|
||||
int i;
|
||||
|
||||
post("fluidsynth~ channels:");
|
||||
post("fluidsynth~ MIDI channels:");
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
{
|
||||
unsigned int sfont;
|
||||
unsigned int bank;
|
||||
unsigned int preset;
|
||||
fluid_preset_t *preset = fluid_synth_get_channel_preset(self->synth, i);
|
||||
char *preset_str = fluid_preset_get_name(preset);
|
||||
ftmax_symbol_t preset_name = ftmax_new_symbol(preset_str);
|
||||
unsigned int sf_id;
|
||||
unsigned int bank_num;
|
||||
unsigned int preset_num;
|
||||
fluid_sfont_t *sf;
|
||||
|
||||
fluid_synth_get_program(self->synth, i, &sfont, &bank, &preset);
|
||||
post(" %d: font %d, bank %d, preset %d", i + 1, sfont, bank, preset);
|
||||
fluid_synth_get_program(self->synth, i, &sf_id, &bank_num, &preset_num);
|
||||
sf = fluid_synth_get_sfont_by_id(self->synth, sf_id);
|
||||
|
||||
post(" channel %d: soundfont '%s', bank %d, preset %d: '%s'",
|
||||
i + 1, ftmax_symbol_name(fluidmax_sfont_get_name(sf)), bank_num, preset_num, ftmax_symbol_name(preset_name));
|
||||
|
||||
/*fluid_preset_t *fluid_synth_get_channel_preset(fluid_synth_t *synth, int chan);*/
|
||||
}
|
||||
}
|
||||
else if(sym == ftmax_new_symbol("soundfonts"))
|
||||
else if(sym == sym_soundfonts)
|
||||
{
|
||||
int n = fluid_synth_sfcount(self->synth);
|
||||
int i;
|
||||
|
@ -754,14 +909,96 @@ fluidmax_print(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
for(i=0; i<n; i++)
|
||||
{
|
||||
fluid_sfont_t *sf = fluid_synth_get_sfont(self->synth, i);
|
||||
char *name = fluid_sfont_get_name(sf);
|
||||
ftmax_symbol_t name = fluidmax_sfont_get_name(sf);
|
||||
unsigned int id = fluid_sfont_get_id(sf);
|
||||
|
||||
post(" %d: %s", id, name);
|
||||
|
||||
/*fluid_preset_t *preset = fluid_sfont_get_preset(sf, bank, preset);*/
|
||||
post(" soundfont %d '%s' (%d)", i, ftmax_symbol_name(name), id);
|
||||
}
|
||||
}
|
||||
else if(sym == sym_presets)
|
||||
{
|
||||
int n = fluid_synth_sfcount(self->synth);
|
||||
|
||||
if(n > 0)
|
||||
{
|
||||
if(ac > 1)
|
||||
{
|
||||
fluid_sfont_t *sf = NULL;
|
||||
ftmax_symbol_t name;
|
||||
|
||||
if(ftmax_is_symbol(at + 1))
|
||||
{
|
||||
name = ftmax_get_symbol(at + 1);
|
||||
sf = fluidmax_sfont_get_by_name(self, name);
|
||||
}
|
||||
else if(ftmax_is_int(at + 1))
|
||||
{
|
||||
int id = ftmax_get_int(at + 1);
|
||||
|
||||
sf = fluid_synth_get_sfont_by_id(self->synth, id);
|
||||
name = fluidmax_sfont_get_name(sf);
|
||||
}
|
||||
|
||||
if(sf != NULL)
|
||||
{
|
||||
fluid_preset_t preset;
|
||||
|
||||
fluid_sfont_iteration_start(sf);
|
||||
|
||||
post("fluidsynth~ presets of soundfont '%s':", ftmax_symbol_name(name));
|
||||
|
||||
while(fluid_sfont_iteration_next(sf, &preset) > 0)
|
||||
{
|
||||
char *preset_str = fluid_preset_get_name(&preset);
|
||||
ftmax_symbol_t preset_name = ftmax_new_symbol(preset_str);
|
||||
int bank_num = fluid_preset_get_banknum(&preset);
|
||||
int preset_num = fluid_preset_get_num(&preset);
|
||||
|
||||
post(" preset '%s': bank %d, program %d)", ftmax_symbol_name(preset_name), bank_num, preset_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
post("fluidsynth~ presets:");
|
||||
|
||||
for(i=0; i<128; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
for(j=0; j<128; j++)
|
||||
{
|
||||
fluid_preset_t *preset = NULL;
|
||||
fluid_sfont_t *sf = NULL;
|
||||
int k;
|
||||
|
||||
for(k=0; k<n; k++)
|
||||
{
|
||||
sf = fluid_synth_get_sfont(self->synth, k);
|
||||
preset = fluid_sfont_get_preset(sf, i, j);
|
||||
|
||||
if(preset != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if(preset != NULL)
|
||||
{
|
||||
ftmax_symbol_t sf_name = fluidmax_sfont_get_name(sf);
|
||||
char *preset_str = fluid_preset_get_name(preset);
|
||||
ftmax_symbol_t preset_name = ftmax_new_symbol(preset_str);
|
||||
|
||||
post(" preset '%s': soundfont '%s', bank %d, program %d)",
|
||||
ftmax_symbol_name(preset_name), ftmax_symbol_name(sf_name), i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
error("fluidsynth~: no soundfonts loaded");
|
||||
}
|
||||
else if(sym == ftmax_new_symbol("modulators"))
|
||||
{
|
||||
int channel = 1;
|
||||
|
@ -781,33 +1018,247 @@ fluidmax_print(t_object *o, Symbol *s, short ac, Atom *at)
|
|||
for(i=0; i<n; i++)
|
||||
post(" %d: %f", i, fluid_synth_get_gen(self->synth, channel - 1, i));
|
||||
}
|
||||
else if(sym == ftmax_new_symbol("reverb"))
|
||||
else if(sym == sym_reverb)
|
||||
{
|
||||
double level = fluid_synth_get_reverb_level(self->synth);
|
||||
double room = fluid_synth_get_reverb_roomsize(self->synth);
|
||||
double damping = fluid_synth_get_reverb_damp(self->synth);
|
||||
double width = fluid_synth_get_reverb_width(self->synth);
|
||||
|
||||
post("fluidsynth~ current reverb parameters:");
|
||||
post(" level: %f", level);
|
||||
post(" room size: %f", room);
|
||||
post(" damping: %f", damping);
|
||||
post(" width: %f", width);
|
||||
if(self->reverb != 0)
|
||||
{
|
||||
post("fluidsynth~ current reverb parameters:");
|
||||
post(" level: %f", level);
|
||||
post(" room size: %f", room);
|
||||
post(" damping: %f", damping);
|
||||
post(" width: %f", width);
|
||||
}
|
||||
else
|
||||
post("fluidsynth~ reverb off");
|
||||
}
|
||||
else if(sym == ftmax_new_symbol("chorus"))
|
||||
else if(sym == sym_chorus)
|
||||
{
|
||||
double level = fluid_synth_get_chorus_level(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed_Hz(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth_ms(self->synth);
|
||||
int type = fluid_synth_get_chorus_type(self->synth);
|
||||
int nr = fluid_synth_get_chorus_nr(self->synth);
|
||||
if(self->chorus != 0)
|
||||
{
|
||||
double level = fluid_synth_get_chorus_level(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed_Hz(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth_ms(self->synth);
|
||||
int type = fluid_synth_get_chorus_type(self->synth);
|
||||
int nr = fluid_synth_get_chorus_nr(self->synth);
|
||||
|
||||
post("fluidsynth~ current chorus parameters:");
|
||||
post(" level: %f", level);
|
||||
post(" speed: %f Hz", speed);
|
||||
post(" depth: %f msec", depth);
|
||||
post(" type: %d (%s)", type, type? "triangle": "sine");
|
||||
post(" %d units", nr);
|
||||
}
|
||||
else
|
||||
post("fluidsynth~ chorus off");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
fluidmax_info(t_object *o, Symbol *s, short ac, Atom *at)
|
||||
{
|
||||
fluidmax_t *self = (fluidmax_t *)o;
|
||||
|
||||
if(ac > 0)
|
||||
{
|
||||
if(ftmax_is_symbol(at))
|
||||
{
|
||||
ftmax_symbol_t sym = ftmax_get_symbol(at);
|
||||
|
||||
if(sym == sym_gain)
|
||||
{
|
||||
ftmax_atom_t a;
|
||||
double gain = fluid_synth_get_gain(self->synth);
|
||||
|
||||
ftmax_set_float(&a, gain);
|
||||
outlet_anything(self->outlet, sym_channel, 1, &a);
|
||||
}
|
||||
else if(sym == sym_channels)
|
||||
{
|
||||
int n = fluid_synth_count_midi_channels(self->synth);
|
||||
int i;
|
||||
|
||||
post("fluidsynth~ current chorus parameters:");
|
||||
post(" level: %f", level);
|
||||
post(" speed: %f Hz", speed);
|
||||
post(" depth: %f msec", depth);
|
||||
post(" type: %d (%s)", type, type? "triangle": "sine");
|
||||
post(" %d units", nr);
|
||||
for(i=0; i<n; i++)
|
||||
{
|
||||
fluid_preset_t *preset = fluid_synth_get_channel_preset(self->synth, i);
|
||||
char *preset_str = fluid_preset_get_name(preset);
|
||||
ftmax_symbol_t preset_name = ftmax_new_symbol(preset_str);
|
||||
unsigned int sf_id, bank_num, preset_num;
|
||||
fluid_sfont_t *sf;
|
||||
ftmax_atom_t a[5];
|
||||
|
||||
fluid_synth_get_program(self->synth, i, &sf_id, &bank_num, &preset_num);
|
||||
sf = fluid_synth_get_sfont_by_id(self->synth, sf_id);
|
||||
|
||||
ftmax_set_int(a, i + 1);
|
||||
ftmax_set_symbol(a + 1, fluidmax_sfont_get_name(sf));
|
||||
ftmax_set_int(a + 2, bank_num);
|
||||
ftmax_set_int(a + 3, preset_num);
|
||||
ftmax_set_symbol(a + 4, preset_name);
|
||||
outlet_anything(self->outlet, sym_channel, 5, a);
|
||||
}
|
||||
}
|
||||
else if(sym == sym_soundfonts)
|
||||
{
|
||||
int n = fluid_synth_sfcount(self->synth);
|
||||
int i;
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
{
|
||||
fluid_sfont_t *sf = fluid_synth_get_sfont(self->synth, i);
|
||||
ftmax_symbol_t name = fluidmax_sfont_get_name(sf);
|
||||
unsigned int id = fluid_sfont_get_id(sf);
|
||||
ftmax_atom_t a[2];
|
||||
|
||||
ftmax_set_int(a, i);
|
||||
ftmax_set_symbol(a + 1, fluidmax_sfont_get_name(sf));
|
||||
outlet_anything(self->outlet, sym_soundfont, 2, a);
|
||||
}
|
||||
}
|
||||
else if(sym == sym_presets)
|
||||
{
|
||||
int n = fluid_synth_sfcount(self->synth);
|
||||
|
||||
if(n > 0)
|
||||
{
|
||||
if(ac > 1)
|
||||
{
|
||||
fluid_sfont_t *sf = NULL;
|
||||
ftmax_symbol_t sf_name;
|
||||
|
||||
if(ftmax_is_symbol(at + 1))
|
||||
{
|
||||
sf_name = ftmax_get_symbol(at + 1);
|
||||
sf = fluidmax_sfont_get_by_name(self, sf_name);
|
||||
}
|
||||
else if(ftmax_is_int(at + 1))
|
||||
{
|
||||
int id = ftmax_get_int(at + 1);
|
||||
|
||||
sf = fluid_synth_get_sfont_by_id(self->synth, id);
|
||||
sf_name = fluidmax_sfont_get_name(sf);
|
||||
}
|
||||
|
||||
if(sf != NULL)
|
||||
{
|
||||
fluid_preset_t preset;
|
||||
|
||||
fluid_sfont_iteration_start(sf);
|
||||
|
||||
while(fluid_sfont_iteration_next(sf, &preset) > 0)
|
||||
{
|
||||
char *preset_str = fluid_preset_get_name(&preset);
|
||||
ftmax_symbol_t preset_name = ftmax_new_symbol(preset_str);
|
||||
int bank_num = fluid_preset_get_banknum(&preset);
|
||||
int preset_num = fluid_preset_get_num(&preset);
|
||||
ftmax_atom_t a[4];
|
||||
|
||||
ftmax_set_symbol(a , preset_name);
|
||||
ftmax_set_symbol(a + 1, sf_name);
|
||||
ftmax_set_int(a + 2, bank_num);
|
||||
ftmax_set_int(a + 3, preset_num);
|
||||
outlet_anything(self->outlet, sym_preset, 4, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0; i<128; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
for(j=0; j<128; j++)
|
||||
{
|
||||
fluid_preset_t *preset = NULL;
|
||||
fluid_sfont_t *sf = NULL;
|
||||
int k;
|
||||
|
||||
for(k=0; k<n; k++)
|
||||
{
|
||||
sf = fluid_synth_get_sfont(self->synth, k);
|
||||
preset = fluid_sfont_get_preset(sf, i, j);
|
||||
|
||||
if(preset != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if(preset != NULL)
|
||||
{
|
||||
ftmax_symbol_t sf_name = fluidmax_sfont_get_name(sf);
|
||||
char *preset_str = fluid_preset_get_name(preset);
|
||||
ftmax_symbol_t preset_name = ftmax_new_symbol(preset_str);
|
||||
ftmax_atom_t a[4];
|
||||
|
||||
ftmax_set_symbol(a , preset_name);
|
||||
ftmax_set_symbol(a + 1, sf_name);
|
||||
ftmax_set_int(a + 2, i);
|
||||
ftmax_set_int(a + 3, j);
|
||||
outlet_anything(self->outlet, sym_preset, 4, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
error("fluidsynth~ info: no soundfonts loaded");
|
||||
}
|
||||
else if(sym == sym_reverb)
|
||||
{
|
||||
if(self->reverb != 0)
|
||||
{
|
||||
double level = fluid_synth_get_reverb_level(self->synth);
|
||||
double room = fluid_synth_get_reverb_roomsize(self->synth);
|
||||
double damping = fluid_synth_get_reverb_damp(self->synth);
|
||||
double width = fluid_synth_get_reverb_width(self->synth);
|
||||
ftmax_atom_t a[4];
|
||||
|
||||
ftmax_set_float(a, level);
|
||||
ftmax_set_float(a + 1, room);
|
||||
ftmax_set_float(a + 2, damping);
|
||||
ftmax_set_float(a + 3, width);
|
||||
outlet_anything(self->outlet, sym_reverb, 4, a);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftmax_atom_t a;
|
||||
|
||||
ftmax_set_symbol(&a, sym_off);
|
||||
outlet_anything(self->outlet, sym_reverb, 1, &a);
|
||||
}
|
||||
}
|
||||
else if(sym == sym_chorus)
|
||||
{
|
||||
if(self->chorus != 0)
|
||||
{
|
||||
double level = fluid_synth_get_chorus_level(self->synth);
|
||||
double speed = fluid_synth_get_chorus_speed_Hz(self->synth);
|
||||
double depth = fluid_synth_get_chorus_depth_ms(self->synth);
|
||||
int type = fluid_synth_get_chorus_type(self->synth);
|
||||
int nr = fluid_synth_get_chorus_nr(self->synth);
|
||||
ftmax_atom_t a[5];
|
||||
|
||||
ftmax_set_float(a, level);
|
||||
ftmax_set_float(a + 1, speed);
|
||||
ftmax_set_float(a + 2, depth);
|
||||
ftmax_set_int(a + 3, type);
|
||||
ftmax_set_int(a + 4, nr);
|
||||
outlet_anything(self->outlet, sym_chorus, 5, a);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftmax_atom_t a;
|
||||
|
||||
ftmax_set_symbol(&a, sym_off);
|
||||
outlet_anything(self->outlet, sym_chorus, 1, &a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -825,7 +1276,7 @@ fluidmax_new(Symbol *s, short ac, Atom *at)
|
|||
int polyphony = 256;
|
||||
int midi_channels = 16;
|
||||
|
||||
self->outlet = outlet_new(self, "bang");
|
||||
self->outlet = outlet_new(self, "anything");
|
||||
|
||||
dsp_setup((t_pxobject *)self, 0);
|
||||
outlet_new(self, "signal");
|
||||
|
@ -833,6 +1284,8 @@ fluidmax_new(Symbol *s, short ac, Atom *at)
|
|||
|
||||
self->synth = NULL;
|
||||
self->settings = new_fluid_settings();
|
||||
self->reverb = 0;
|
||||
self->chorus = 0;
|
||||
self->mute = 0;
|
||||
|
||||
if(ac > 0 && ftmax_is_number(at))
|
||||
|
@ -867,6 +1320,9 @@ fluidmax_new(Symbol *s, short ac, Atom *at)
|
|||
|
||||
if(self->synth != NULL)
|
||||
{
|
||||
fluid_synth_set_reverb_on(self->synth, 0);
|
||||
fluid_synth_set_chorus_on(self->synth, 0);
|
||||
|
||||
if(ac > 0 && ftmax_is_symbol(at))
|
||||
fluidmax_load((t_object *)self, NULL, ac, at);
|
||||
|
||||
|
@ -909,6 +1365,7 @@ main(void)
|
|||
addmess((method)fluidmax_load, "load", A_GIMME, 0);
|
||||
addmess((method)fluidmax_unload, "unload", A_GIMME, 0);
|
||||
addmess((method)fluidmax_reload, "reload", A_GIMME, 0);
|
||||
addmess((method)fluidmax_info, "info", A_GIMME, 0);
|
||||
|
||||
addmess((method)fluidmax_panic, "panic", A_GIMME, 0);
|
||||
addmess((method)fluidmax_reset, "reset", A_GIMME, 0);
|
||||
|
@ -934,6 +1391,15 @@ main(void)
|
|||
|
||||
sym_on = ftmax_new_symbol("on");
|
||||
sym_off = ftmax_new_symbol("off");
|
||||
sym_gain = ftmax_new_symbol("gain");
|
||||
sym_channels = ftmax_new_symbol("channels");
|
||||
sym_channel = ftmax_new_symbol("channel");
|
||||
sym_soundfonts = ftmax_new_symbol("soundfonts");
|
||||
sym_soundfont = ftmax_new_symbol("soundfont");
|
||||
sym_presets = ftmax_new_symbol("presets");
|
||||
sym_preset = ftmax_new_symbol("preset");
|
||||
sym_reverb = ftmax_new_symbol("reverb");
|
||||
sym_chorus = ftmax_new_symbol("chorus");
|
||||
|
||||
fluidmax_version(NULL);
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue