#include "fluidsynth_backend.hpp" #include #include #include #include #include "file_backend.hpp" #include #include #include #include void FluidSynthBackend::fluidsynth_get_property_list_wrapper(void *udata, const char *name, int type) { ((FluidSynthBackend*)udata)->fluidsynth_get_property_list(name, type); } void FluidSynthBackend::fluidsynth_get_property_list(const char *name, int type) { Property property; property.set_path(fmt::format("fluidsynth/{0}", name)); property.set_name(name); switch (type) { case FLUID_NUM_TYPE: { property.set_type(PropertyType::Double); } break; case FLUID_INT_TYPE: { property.set_type(PropertyType::Int); } break; case FLUID_STR_TYPE: { property.set_type(PropertyType::String); } break; } property.set_id(PropertyId::BackendSpecific); fluidsynth_properties.push_back(property); } std::vector FluidSynthBackend::get_property_list() { return fluidsynth_properties; } void FluidSynthBackend::load(const char *filename) { memset(&spec, 0, sizeof(spec)); current_file = filename; spec.format = AUDIO_F32SYS; spec.samples = 100; spec.channels = 2; spec.freq = 48000; spec.size = 100 * 2 * sizeof(int16_t); file = open_file(filename); this->settings = new_fluid_settings(); fluid_settings_foreach(settings, (void*)this, &fluidsynth_get_property_list_wrapper); } extern SDL_AudioSpec obtained; void FluidSynthBackend::switch_stream(int idx) { } void FluidSynthBackend::cleanup() { delete file; file = nullptr; } size_t FluidSynthBackend::render(void *buf, size_t maxlen) { size_t sample_type_len = 2; maxlen /= sample_type_len; maxlen *= sample_type_len; return copied; } void FluidSynthBackend::seek(double position) { } double FluidSynthBackend::get_position() { return position; } int FluidSynthBackend::get_stream_idx() { return 0; }