looper/backends/playback/fluidsynth/fluidsynth_backend.cpp
Zachary Hall f91ff0f36f
Some checks failed
Build / download-system-deps (push) Successful in 1m12s
Build / build-gentoo (push) Successful in 1m25s
Build / get-source-code (push) Successful in 6m49s
Build / build-appimage (push) Successful in 2m46s
Build / build-android (push) Failing after 7m18s
Build / build-windows (push) Failing after 6m33s
Update
2024-10-26 09:01:16 -07:00

68 lines
No EOL
2 KiB
C++

#include "fluidsynth_backend.hpp"
#include <algorithm>
#include <ipc/common.pb.h>
#include <exception>
#include <filesystem>
#include "file_backend.hpp"
#include <stddef.h>
#include <string.h>
#include <file_backend.hpp>
#include <util.hpp>
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<Property> 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;
}