selcal/src/synth.h

53 lines
971 B
C++

#pragma once
#include <fluidsynth.h>
#include <vector>
#include <string>
#include <array>
constexpr int NUM_MIDI_NOTES = 128;
typedef std::array<double, NUM_MIDI_NOTES> Tuning;
/**
* C++ wrapper around the fluidsynth API.
*/
class Synth {
public:
Synth();
~Synth();
struct Soundfont {
std::string name;
int id;
};
struct Program {
std::string name;
int soundfontId;
int bankNumber;
int programNumber;
};
bool loadSoundfont(const std::string& filepath);
bool loadProgram(const Program& program);
bool setTuning(const Tuning& pitches);
bool resetTuning();
const std::vector<Program>& getPrograms() const;
// TODO JMT: remove this
fluid_synth_t* getSynth();
private:
std::vector<Soundfont> soundfonts;
std::vector<Program> programs;
fluid_settings_t* settings = NULL;
fluid_synth_t* synth = NULL;
fluid_audio_driver_t* adriver = NULL;
};