2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 #ifndef _ardour_fluidsynth_h_
19 #define _ardour_fluidsynth_h_
25 #include "ardour/libardour_visibility.h"
26 #include "ardour/types.h"
28 #include "fluidsynth.h"
32 class LIBARDOUR_API FluidSynth {
34 /** instantiate a Synth
36 * @param samplerate samplerate
37 * @param polyphony polyphony
39 FluidSynth (float samplerate, int polyphony = 32);
42 bool load_sf2 (const std::string& fn);
44 bool synth (float* left, float* right, uint32_t n_samples);
45 bool midi_event (uint8_t const* const data, size_t len);
49 * @pgm BankProgram index
50 * @chan midi channel (0..15)
51 * @return true on succcess
53 bool select_program (uint32_t pgm, uint8_t chan);
55 uint32_t program_count () const { return _presets.size(); }
57 std::string program_name (uint32_t pgm) const {
58 if (pgm >= _presets.size()) { return ""; }
59 return _presets[pgm].name;
63 fluid_settings_t* _settings;
64 fluid_synth_t* _synth;
66 fluid_midi_event_t* _f_midi_event;
69 BankProgram (const std::string& n, int b, int p)
75 BankProgram (const BankProgram& other)
78 , program (other.program)
86 std::vector<BankProgram> _presets;