MCPcopy Create free account
hub / github.com/EasyRPG/Player / Initialize

Method Initialize

src/decoder_fluidsynth.cpp:226–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226bool FluidSynthDecoder::Initialize(std::string& status_message) {
227 // only initialize once until a new game starts
228 if (once) {
229 if (!init && global_settings && !global_synth) {
230 global_synth.reset(create_synth(status_message));
231 if (global_synth) {
232 if (!load_default_sf(status_message, global_synth.get())) {
233 global_synth.reset();
234 }
235 }
236
237 init = (global_synth != nullptr);
238 }
239 return init;
240 }
241
242 once = true;
243
244#ifdef HAVE_FLUIDLITE
245 fluid_set_default_fileapi(&fluidlite_vio);
246#endif
247
248 global_settings.reset(new_fluid_settings());
249 if (!global_settings) {
250 return false;
251 }
252 fluid_settings_setstr(global_settings.get(), "player.timing-source", "sample");
253 fluid_settings_setint(global_settings.get(), "synth.lock-memory", 0);
254
255 fluid_settings_setnum(global_settings.get(), "synth.gain", 0.6);
256 fluid_settings_setnum(global_settings.get(), "synth.sample-rate", EP_MIDI_FREQ);
257 fluid_settings_setint(global_settings.get(), "synth.polyphony", 256);
258
259#if defined(HAVE_FLUIDSYNTH) && FLUIDSYNTH_VERSION_MAJOR > 1
260 fluid_settings_setint(global_settings.get(), "synth.reverb.active", 0);
261 fluid_settings_setint(global_settings.get(), "synth.chorus.active", 0);
262#else
263 fluid_settings_setstr(global_settings.get(), "synth.reverb.active", "no");
264 fluid_settings_setstr(global_settings.get(), "synth.chorus.active", "no");
265#endif
266
267 global_synth.reset(create_synth(status_message));
268 if (!global_synth) {
269 return false;
270 }
271
272 if (!load_default_sf(status_message, global_synth.get())) {
273 global_synth.reset();
274 return false;
275 }
276
277 init = true;
278
279 return init;
280}
281
282void FluidSynthDecoder::ResetState() {
283 once = false;

Callers

nothing calls this directly

Calls 4

create_synthFunction · 0.85
load_default_sfFunction · 0.85
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected