int main(int argc, char** argv) { int i; fluid_settings_t* settings; fluid_synth_t* synth; fluid_player_t* player; fluid_audio_driver_t* adriver; settings = new_fluid_settings(); synth = new_fluid_synth(settings); player = new_fluid_player(synth); adriver = new_fluid_audio_driver(settings, synth); /* process command line arguments */ for (i = 1; i < argc; i++) { if (fluid_is_soundfont(argv[i])) { fluid_synth_sfload(synth, argv[1], 1); } if (fluid_is_midifile(argv[i])) { fluid_player_add(player, argv[i]); } } /* play the midi files, if any */ fluid_player_play(player); /* wait for playback termination */ fluid_player_join(player); /* cleanup */ delete_fluid_audio_driver(adriver); delete_fluid_player(player); delete_fluid_synth(synth); delete_fluid_settings(settings); return 0; }
void MusicPlayer::Shutdown() { delete_fluid_audio_driver(this->adriver); delete_fluid_player(this->player); delete_fluid_synth(this->synth); delete_fluid_settings(this->settings); }
void MusicDriver_FluidSynth::Stop() { this->StopSong(); delete_fluid_audio_driver(_midi.adriver); delete_fluid_synth(_midi.synth); delete_fluid_settings(_midi.settings); }
~fluidsynth() { delete_fluid_settings(m_settings); m_settings = NULL; delete_fluid_synth(m_synth); m_synth = NULL; }
MidiPlayer::~MidiPlayer() { /* cleanup */ delete_fluid_audio_driver(adriver); delete_fluid_player(player); delete_fluid_synth(synth); delete_fluid_settings(settings); }
void soundfonts_free(t_soundfonts *instance) { delete_fluid_settings(instance->settings); delete_fluid_synth(instance->synth); outlet_free(instance->x_outL); outlet_free(instance->x_outR); }
static void Close (vlc_object_t *p_this) { decoder_sys_t *p_sys = ((decoder_t *)p_this)->p_sys; fluid_synth_sfunload (p_sys->synth, p_sys->soundfont, 1); delete_fluid_synth (p_sys->synth); delete_fluid_settings (p_sys->settings); free (p_sys); }
static int fluidsynth_init(sfx_softseq_t *self, byte *data_ptr, int data_length, byte *data2_ptr, int data2_length) { int sfont_id; double min, max; if (0) { sciprintf("FluidSynth ERROR: Mono sound output not supported.\n"); return SFX_ERROR; } gmseq = sfx_find_sequencer("General MIDI"); if (!gmseq) { sciprintf("FluidSynth ERROR: Unable to find General MIDI sequencer.\n"); return SFX_ERROR; } settings = new_fluid_settings(); fluid_settings_getnum_range(settings, "synth.sample-rate", &min, &max); if (SAMPLE_RATE < min || SAMPLE_RATE > max) { sciprintf("FluidSynth ERROR: Sample rate '%i' not supported. Valid " "range is (%i-%i).\n", SAMPLE_RATE, (int) min, (int) max); delete_fluid_settings(settings); return SFX_ERROR; } fluid_settings_setnum(settings, "synth.sample-rate", SAMPLE_RATE); fluid_settings_setnum(settings, "synth.gain", 0.5f); synth = new_fluid_synth(settings); if ((sfont_id = fluid_synth_sfload(synth, soundfont, 1)) < 0) { delete_fluid_synth(synth); delete_fluid_settings(settings); return SFX_ERROR; } gmseq->open(data_length, data_ptr, data2_length, data2_ptr, &midi_writer_fluidsynth); return SFX_OK; }
static void midoflus_done(void *arg) { pthread_cancel(syn_thr); pthread_join(syn_thr, NULL); sem_destroy(&syn_sem); delete_fluid_sequencer(sequencer); delete_fluid_synth(synth); delete_fluid_settings(settings); }
JNIEXPORT void JNICALL Java_org_herac_tuxguitar_player_impl_midiport_fluidsynth_MidiSynth_free(JNIEnv* env, jobject obj, jlong ptr) { fluid_handle_t *handle = NULL; memcpy(&handle, &ptr, sizeof(handle)); if(handle != NULL){ delete_fluid_audio_driver(handle->driver); delete_fluid_synth(handle->synth); delete_fluid_settings(handle->settings); free ( handle ); } }
void FluidSynthMidiDriver::close() { if (_soundFont != -1) fluid_synth_sfunload(_synth, _soundFont, 1); _soundFont = -1; delete_fluid_synth(_synth); _synth = 0; delete_fluid_settings(_settings); _settings = 0; }
static void gst_fluid_dec_finalize (GObject * object) { GstFluidDec *fluiddec = GST_FLUID_DEC (object); delete_fluid_synth (fluiddec->synth); delete_fluid_settings (fluiddec->settings); g_free (fluiddec->soundfont); G_OBJECT_CLASS (parent_class)->finalize (object); }
void FluidSynthMidiDriver::close() { while (!_soundFont.empty()) { int soundfont = _soundFont.top(); _soundFont.pop(); fluid_synth_sfunload(_synth, soundfont, 1); } delete_fluid_synth(_synth); _synth = 0; delete_fluid_settings(_settings); _settings = 0; }
sf2Instrument::~sf2Instrument() { engine::mixer()->removePlayHandles( instrumentTrack() ); freeFont(); delete_fluid_synth( m_synth ); delete_fluid_settings( m_settings ); if( m_srcState != NULL ) { src_delete( m_srcState ); } }
void MidiDriver_FluidSynth::close() { if (!_isOpen) return; _isOpen = false; _mixer->stopHandle(_mixerSoundHandle); if (_soundFont != -1) fluid_synth_sfunload(_synth, _soundFont, 1); delete_fluid_synth(_synth); delete_fluid_settings(_settings); }
virtual ~fluidStream() { if(fontID != FLUID_FAILED) fluid_synth_sfunload(fluidSynth, fontID, true); fontID = FLUID_FAILED; if(fluidSynth != NULL) delete_fluid_synth(fluidSynth); fluidSynth = NULL; if(fluidSettings != NULL) delete_fluid_settings(fluidSettings); fluidSettings = NULL; }
sf2Instrument::~sf2Instrument() { Engine::mixer()->removePlayHandlesOfTypes( instrumentTrack(), PlayHandle::TypeNotePlayHandle | PlayHandle::TypeInstrumentPlayHandle ); freeFont(); delete_fluid_synth( m_synth ); delete_fluid_settings( m_settings ); if( m_srcState != NULL ) { src_delete( m_srcState ); } }
int main (int argc, char *argv[]) { int n; fluid_settings_t *settings; settings = new_fluid_settings (); if (argc < 2) { usage (argv[0]); } else { /* create the synth, driver and sequencer instances */ synth = new_fluid_synth (settings); audiodriver = new_fluid_audio_driver (settings, synth); sequencer = new_fluid_sequencer (); /* register the synth with the sequencer */ synth_destination = fluid_sequencer_register_fluidsynth (sequencer, synth); /* register the client name and callback */ client_destination = fluid_sequencer_register_client (sequencer, "fluidsynth_metronome", sequencer_callback, NULL); /* load a SoundFont */ n = fluid_synth_sfload (synth, argv[1], 1); if (n != -1) { if (argc > 2) { n = atoi (argv[2]); if (n > 0) pattern_size = n; } if (argc > 3) { n = atoi (argv[3]); if (n > 0) note_duration = 60000 / n; } /* get the current time in ticks */ time_marker = fluid_sequencer_get_tick (sequencer); /* schedule patterns */ schedule_pattern (); schedule_timer_event (); schedule_pattern (); /* wait for user input */ printf ("press <Enter> to stop\n"); n = getchar (); } /* clean and exit */ delete_fluid_sequencer (sequencer); delete_fluid_audio_driver (audiodriver); delete_fluid_synth (synth); } delete_fluid_settings (settings); return 0; }
static void FSynth_Destruct(FSynth *self) { if(self->FontID != FLUID_FAILED) fluid_synth_sfunload(self->Synth, self->FontID, 0); self->FontID = FLUID_FAILED; if(self->Synth != NULL) delete_fluid_synth(self->Synth); self->Synth = NULL; if(self->Settings != NULL) delete_fluid_settings(self->Settings); self->Settings = NULL; MidiSynth_Destruct(STATIC_CAST(MidiSynth, self)); }
/** Create temporary fluid synthesiser and get the list of presets for the combo box. */ static void get_presets(FluidUI *self) { fluid_preset_t p; fluid_settings_t *settings = new_fluid_settings(); fluid_synth_t *synth = new_fluid_synth(settings); fluid_synth_sfload(synth, SOUNDFONT_FILE, 1); fluid_sfont_t *sfont = fluid_synth_get_sfont_by_id(synth, 1); sfont->iteration_start(sfont); while (sfont->iteration_next(sfont, &p)) { gtk_combo_box_text_append_text((GtkComboBoxText *)self->combo_box, p.get_name(&p)); } delete_fluid_synth(synth); delete_fluid_settings(settings); }
static void fluid_jni_delete_synth(JNIEnv *env, jobject obj, fluid_settings_t* settings, fluid_synth_t* synth, fluid_audio_driver_t* adriver) { get_fluidclassinfo(env); if (adriver) { delete_fluid_audio_driver(adriver); (*env)->SetLongField(env, obj, audioDriverPtrFieldID, (jlong) 0); } if (synth) { delete_fluid_synth(synth); (*env)->SetLongField(env, obj, synthPtrFieldID, (jlong) 0); } if (settings) { delete_fluid_settings(settings); (*env)->SetLongField(env, obj, settingsPtrFieldID, (jlong) 0); } }
PUBLIC int csoundModuleDestroy(CSOUND *csound) { #pragma omp critical (critical_section_fluidopcodes) { std::map<CSOUND *, std::vector<fluid_synth_t *> > &fluidEngines = getFluidSynthsForCsoundInstances(); std::vector<fluid_synth_t *> &fluidSynths = fluidEngines[csound]; for (size_t i = 0, n = fluidSynths.size(); i < n; i++) { fluid_synth_t *fluidSynth = fluidSynths[i]; //csound->Message(csound, "deleting engine %p \n", fluidSynth); fluid_settings_t *fluidSettings = fluid_synth_get_settings(fluidSynth); delete_fluid_synth(fluidSynth); delete_fluid_settings(fluidSettings); } fluidSynths.clear(); fluidEngines.erase(csound); } return 0; }
int main(int argc, char** argv) { fluid_settings_t* settings; fluid_synth_t* synth; fluid_audio_driver_t* adriver1, *adriver2, *adriver3; int sfont_id; int i, key; /* Create the settings. */ settings = new_fluid_settings(); /* Change the settings if necessary*/ /* Create the synthesizer. */ synth = new_fluid_synth(settings); /* Create the audio driver. The synthesizer starts playing as soon as the driver is created. */ adriver1 = new_fluid_audio_driver(settings, synth); fluid_settings_setstr(settings, "audio.driver", "pulseaudio"); adriver2 = new_fluid_audio_driver(settings, synth); fluid_settings_setstr(settings, "audio.driver", "alsa"); adriver3 = new_fluid_audio_driver(settings, synth); /* Load a SoundFont and reset presets (so that new instruments * get used from the SoundFont) */ sfont_id = fluid_synth_sfload(synth, "/usr/share/soundfonts/SGM-V2.01.sf2", 1); /* Initialize the random number generator */ srand(time(NULL)); for (i = 0; i < 12; i++) { /* Generate a random key */ key = 60 + (int) (12.0f * rand() / (float) RAND_MAX); /* Play a note */ fluid_synth_noteon(synth, 0, key, 80); /* Sleep for 1 second */ sleep(1); /* Stop the note */ fluid_synth_noteoff(synth, 0, key); } /* Clean up */ delete_fluid_audio_driver(adriver1); delete_fluid_audio_driver(adriver2); delete_fluid_audio_driver(adriver3); delete_fluid_synth(synth); delete_fluid_settings(settings); return 0; }
static void delete_data(Data *data){ if(data->event!=NULL) delete_fluid_event(data->event); if(data->sequencer!=NULL) delete_fluid_sequencer(data->sequencer); if(data->synth!=NULL) delete_fluid_synth(data->synth); if(data->settings!=NULL) delete_fluid_settings(data->settings); if(data->filename!=NULL) free((wchar_t*)data->filename); if(data->signal_from_RT!=NULL) RSEMAPHORE_delete(data->signal_from_RT); free(data); }
void fluidsynth_shutdown () { g_debug ("\nStopping FLUIDSYNTH\n"); if (sfont_id != -1) { fluid_synth_sfunload (synth, sfont_id, FALSE); } if (synth) { delete_fluid_synth (synth); } synth = NULL; if (settings) { delete_fluid_settings (settings); } settings = NULL; }
int main(int argc, char** argv) { int i; fluid_settings_t* settings; fluid_synth_t* synth; fluid_player_t* player; fluid_audio_driver_t* adriver; settings = new_fluid_settings(); fluid_settings_setstr(settings, "audio.driver", "alsa"); fluid_settings_setint(settings, "synth.polyphony", 64); synth = new_fluid_synth(settings); player = new_fluid_player(synth); /* Set the MIDI event callback to our own functions rather than the system default */ fluid_player_set_playback_callback(player, event_callback, synth); /* Add an onload callback so we can get information from new data before it plays */ fluid_player_set_onload_callback(player, onload_callback, NULL); adriver = new_fluid_audio_driver(settings, synth); /* process command line arguments */ for (i = 1; i < argc; i++) { if (fluid_is_soundfont(argv[i])) { fluid_synth_sfload(synth, argv[1], 1); } else { fluid_player_add(player, argv[i]); } } /* play the midi files, if any */ fluid_player_play(player); /* wait for playback termination */ fluid_player_join(player); /* cleanup */ delete_fluid_audio_driver(adriver); delete_fluid_player(player); delete_fluid_synth(synth); delete_fluid_settings(settings); return 0; }
void free() { if (s_initialized) { stop(); if (s_midiFormat == MFMT_GUS_PATCH) { WildMidi_Shutdown(); } else if (s_midiFormat == MFMT_SOUND_FONT) { delete_fluid_settings(s_fluidSettings); delete_fluid_synth(s_fluidSynth); delete_fluid_sequencer(s_fluidSeq); delete_fluid_player(s_fluidPlayer); unloadFluidsynthDLL(); } s_initialized = false; delete s_mutex; } }
FluidSynthSoundController::~FluidSynthSoundController() { deleteEngine(); if (m_synth) delete_fluid_synth(m_synth); if (m_settings) delete_fluid_settings(m_settings); }
static int Open (vlc_object_t *p_this) { decoder_t *p_dec = (decoder_t *)p_this; if (p_dec->fmt_in.i_codec != VLC_CODEC_MIDI) return VLC_EGENERIC; decoder_sys_t *p_sys = (decoder_sys_t *)malloc (sizeof (*p_sys)); // sunqueen modify if (unlikely(p_sys == NULL)) return VLC_ENOMEM; p_sys->settings = new_fluid_settings (); p_sys->synth = new_fluid_synth (p_sys->settings); p_sys->soundfont = -1; char *font_path = var_InheritString (p_this, "soundfont"); if (font_path != NULL) { msg_Dbg (p_this, "loading sound fonts file %s", font_path); p_sys->soundfont = fluid_synth_sfload (p_sys->synth, font_path, 1); if (p_sys->soundfont == -1) msg_Err (p_this, "cannot load sound fonts file %s", font_path); free (font_path); } #ifdef _POSIX_VERSION else { glob_t gl; glob ("/usr/share/sounds/sf2/*.sf2", GLOB_NOESCAPE, NULL, &gl); for (size_t i = 0; i < gl.gl_pathc; i++) { const char *path = gl.gl_pathv[i]; msg_Dbg (p_this, "loading sound fonts file %s", path); p_sys->soundfont = fluid_synth_sfload (p_sys->synth, path, 1); if (p_sys->soundfont != -1) break; /* it worked! */ msg_Err (p_this, "cannot load sound fonts file %s", path); } globfree (&gl); } #endif if (p_sys->soundfont == -1) { msg_Err (p_this, "sound font file required for synthesis"); dialog_Fatal (p_this, _("MIDI synthesis not set up"), _("A sound font file (.SF2) is required for MIDI synthesis.\n" "Please install a sound font and configure it " "from the VLC preferences " "(Input / Codecs > Audio codecs > FluidSynth).\n")); delete_fluid_synth (p_sys->synth); delete_fluid_settings (p_sys->settings); free (p_sys); return VLC_EGENERIC; } fluid_synth_set_chorus_on (p_sys->synth, var_InheritBool (p_this, "synth-chorus")); fluid_synth_set_gain (p_sys->synth, var_InheritFloat (p_this, "synth-gain")); fluid_synth_set_polyphony (p_sys->synth, var_InheritInteger (p_this, "synth-polyphony")); fluid_synth_set_reverb_on (p_sys->synth, var_InheritBool (p_this, "synth-reverb")); p_dec->fmt_out.i_cat = AUDIO_ES; p_dec->fmt_out.audio.i_rate = var_InheritInteger (p_this, "synth-sample-rate");; fluid_synth_set_sample_rate (p_sys->synth, p_dec->fmt_out.audio.i_rate); p_dec->fmt_out.audio.i_channels = 2; p_dec->fmt_out.audio.i_original_channels = p_dec->fmt_out.audio.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; p_dec->fmt_out.i_codec = VLC_CODEC_FL32; p_dec->fmt_out.audio.i_bitspersample = 32; date_Init (&p_sys->end_date, p_dec->fmt_out.audio.i_rate, 1); date_Set (&p_sys->end_date, 0); p_dec->p_sys = p_sys; p_dec->pf_decode_audio = DecodeBlock; return VLC_SUCCESS; }
/* * print_help */ void print_help (fluid_settings_t *settings) { char *audio_options; char *midi_options; audio_options = fluid_settings_option_concat (settings, "audio.driver", NULL); midi_options = fluid_settings_option_concat (settings, "midi.driver", NULL); printf("Usage: \n"); printf(" fluidsynth [options] [soundfonts] [midifiles]\n"); printf("Possible options:\n"); printf(" -a, --audio-driver=[label]\n" " The name of the audio driver to use.\n" " Valid values: %s\n", audio_options ? audio_options : "ERROR"); printf(" -c, --audio-bufcount=[count]\n" " Number of audio buffers\n"); printf(" -C, --chorus\n" " Turn the chorus on or off [0|1|yes|no, default = on]\n"); printf(" -d, --dump\n" " Dump incoming and outgoing MIDI events to stdout\n"); printf(" -E, --audio-file-endian\n" " Audio file endian for fast rendering or aufile driver (\"help\" for list)\n"); printf(" -f, --load-config\n" " Load command configuration file (shell commands)\n"); printf(" -F, --fast-render=[file]\n" " Render MIDI file to raw audio data and store in [file]\n"); printf(" -g, --gain\n" " Set the master gain [0 < gain < 10, default = 0.2]\n"); printf(" -G, --audio-groups\n" " Defines the number of LADSPA audio nodes\n"); printf(" -h, --help\n" " Print out this help summary\n"); printf(" -i, --no-shell\n" " Don't read commands from the shell [default = yes]\n"); printf(" -j, --connect-jack-outputs\n" " Attempt to connect the jack outputs to the physical ports\n"); printf(" -K, --midi-channels=[num]\n" " The number of midi channels [default = 16]\n"); #ifdef LASH_ENABLED printf(" -l, --disable-lash\n" " Don't connect to LASH server\n"); #endif printf(" -L, --audio-channels=[num]\n" " The number of stereo audio channels [default = 1]\n"); printf(" -m, --midi-driver=[label]\n" " The name of the midi driver to use.\n" " Valid values: %s\n", midi_options ? midi_options : "ERROR"); printf(" -n, --no-midi-in\n" " Don't create a midi driver to read MIDI input events [default = yes]\n"); printf(" -o\n" " Define a setting, -o name=value (\"-o help\" to dump current values)\n"); printf(" -O, --audio-file-format\n" " Audio file format for fast rendering or aufile driver (\"help\" for list)\n"); printf(" -p, --portname=[label]\n" " Set MIDI port name (alsa_seq, coremidi drivers)\n"); printf(" -r, --sample-rate\n" " Set the sample rate\n"); printf(" -R, --reverb\n" " Turn the reverb on or off [0|1|yes|no, default = on]\n"); printf(" -s, --server\n" " Start FluidSynth as a server process\n"); printf(" -T, --audio-file-type\n" " Audio file type for fast rendering or aufile driver (\"help\" for list)\n"); printf(" -v, --verbose\n" " Print out verbose messages about midi events\n"); printf(" -V, --version\n" " Show version of program\n"); printf(" -z, --audio-bufsize=[size]\n" " Size of each audio buffer\n"); if (audio_options) FLUID_FREE (audio_options); if (midi_options) FLUID_FREE (midi_options); delete_fluid_settings (settings); exit(0); }