void sf2Instrument::freeFont() { m_synthMutex.lock(); if ( m_font != NULL ) { s_fontsMutex.lock(); --(m_font->refCount); // No more references if( m_font->refCount <= 0 ) { qDebug() << "Really deleting " << m_filename; fluid_synth_sfunload( m_synth, m_fontId, true ); s_fonts.remove( m_filename ); delete m_font; } // Just remove our reference else { qDebug() << "un-referencing " << m_filename; fluid_synth_remove_sfont( m_synth, m_font->fluidFont ); } s_fontsMutex.unlock(); m_font = NULL; } m_synthMutex.unlock(); }
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); }
JNIEXPORT void JNICALL Java_org_herac_tuxguitar_player_impl_midiport_fluidsynth_MidiSynth_unloadFont(JNIEnv* env, jobject obj, jlong ptr) { fluid_handle_t *handle = NULL; memcpy(&handle, &ptr, sizeof(handle)); if(handle != NULL && handle->synth != NULL && handle->soundfont_id > 0){ fluid_synth_sfunload(handle->synth, handle->soundfont_id, 1); handle->soundfont_id = 0; } }
static gboolean gst_fluid_dec_close (GstFluidDec * fluiddec) { if (fluiddec->sf) { fluid_synth_sfunload (fluiddec->synth, fluiddec->sf, 1); fluiddec->sf = -1; } return TRUE; }
void MusicPlayer::LoadSF2(const void *data) { if (this->sfont_id > 0 && fluid_synth_sfunload(this->synth, this->sfont_id, true) != 0) { printf("Error unloading soundfont"); } // Our memory sfont loader will treat the filename param as a pointer to the sf2 in memory. // No other choice short of changing the fluidsynth code. this->sfont_id = fluid_synth_sfload(this->synth, (const char *)data, 0); }
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; }
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; }
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; }
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)); }
void ISynth::noRTHelper() { for (;;) { char c; int n = read(readFd, &c, 1); if (n != 1) { perror("ISynth::read ipc failed\n"); continue; } int id = getFontId(); if (id != -1) { #ifdef FS_DEBUG fprintf(stderr, "ISynth: unload old font\n"); #endif fluid_synth_sfunload(synth(), (unsigned)id, true); } const char* fontname = getFont(); int rv = fluid_synth_sfload(synth(), fontname, true); if (rv == -1) { fprintf(stderr, "ISynth: sfload %s failed\n", fluid_synth_error(synth())); } else { setFontId(rv); // Inform the gui. p4.0.27 Tim int slen = strlen(fontname); int n = slen + 2; unsigned char d[n]; d[0] = FS_SEND_SOUNDFONT_NAME; if(slen != 0) memcpy(d + 1, fontname, slen); d[1 + slen] = 0; MusECore::MidiPlayEvent ev(0,0, MusECore::ME_SYSEX, d, n); gui->writeEvent(ev); #ifdef FS_DEBUG fprintf(stderr, "ISynth: sfont %s loaded as %d\n ", getFont(), rv); #endif } fluid_synth_set_gain(synth(), 1.0); //? _busy = false; } }
static ALenum FSynth_loadSoundfont(FSynth *self, const char *filename) { int fontid; filename = MidiSynth_getFontName(STATIC_CAST(MidiSynth, self), filename); if(!filename[0]) return AL_INVALID_VALUE; fontid = fluid_synth_sfload(self->Synth, filename, 1); if(fontid == FLUID_FAILED) { ERR("Failed to load soundfont '%s'\n", filename); return AL_INVALID_VALUE; } if(self->FontID != FLUID_FAILED) fluid_synth_sfunload(self->Synth, self->FontID, 1); self->FontID = fontid; return AL_NO_ERROR; }
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; }
void DMFluid_SetSoundFont(const char* fileName) { if(sfontId >= 0) { // First unload the previous font. fluid_synth_sfunload(DMFluid_Synth(), sfontId, false); sfontId = -1; } if(!fileName) return; // Load the new one. sfontId = fluid_synth_sfload(DMFluid_Synth(), fileName, true); if(sfontId >= 0) { App_Log(DE2_LOG_VERBOSE, "FluidSynth: Loaded SF2 soundfont \"%s\" with id:%i", fileName, sfontId); } else { App_Log(DE2_LOG_VERBOSE, "FluidSynth: Failed to load soundfont \"%s\" (not SF2 or not found)", fileName); } }
virtual bool SetPatchset(const char *sfont) { if(UsingSTDIO) { int newid = fluid_synth_sfload(fluidSynth, sfont, true); if(newid == FLUID_FAILED) { SetError("Failed to load soundfont"); return false; } if(fontID != FLUID_FAILED) fluid_synth_sfunload(fluidSynth, fontID, true); fontID = newid; doFontLoad = false; return true; } /* FluidSynth has no way to load a soundfont using IO callbacks. So we * have to copy the specified file using the callbacks to a regular * file that FluidSynth can open. */ int newid = FLUID_FAILED; InStream istream(sfont); if(istream.fail()) { SetError("Failed to open file"); return false; } /* First, get a temp filename */ const char *str = getenv("TEMP"); if(!str || !str[0]) str = getenv("TMP"); #ifdef _WIN32 if(!str || !str[0]) str = "."; #else if(!str || !str[0]) str = "/tmp"; #endif std::string fname = str; fname += "/alure-sfont-XXXXXX"; for(size_t i = 0;i < fname.size();i++) { if(fname[i] == '\\') fname[i] = '/'; } std::vector<char> tmpfname(fname.begin(), fname.end()); tmpfname.push_back(0); /* Open a temp file */ int fd = -1; FILE *file; #ifdef _WIN32 if(mktemp(&tmpfname[0]) == NULL || (file=fopen(&tmpfname[0], "wb")) == NULL) #else if((fd=mkstemp(&tmpfname[0])) == -1 || (file=fdopen(fd, "wb")) == NULL) #endif { if(fd >= 0) { close(fd); remove(&tmpfname[0]); } SetError("Failed to create temp file"); return false; } bool copyok = false; char buf[4096]; size_t got; do { istream.read(buf, sizeof(buf)); if((got=istream.gcount()) == 0) { copyok = true; break; } } while(fwrite(buf, 1, got, file) == got); if(copyok) { fflush(file); newid = fluid_synth_sfload(fluidSynth, &tmpfname[0], true); } fclose(file); remove(&tmpfname[0]); if(!copyok) { SetError("Failed to copy file"); return false; } if(newid == FLUID_FAILED) { SetError("Failed to load soundfont"); return false; } if(fontID != FLUID_FAILED) fluid_synth_sfunload(fluidSynth, fontID, true); fontID = newid; doFontLoad = false; return true; }