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
38 FluidSynth (float samplerate, int polyphony = 32);
41 bool load_sf2 (const std::string& fn);
43 bool synth (float* left, float* right, uint32_t n_samples);
44 bool midi_event (uint8_t const* const data, size_t len);
48 * @pgm BankProgram index
49 * @chan midi channel (0..15)
50 * @return true on succcess
52 bool select_program (uint32_t pgm, uint8_t chan);
54 uint32_t program_count () const { return _presets.size(); }
56 std::string program_name (uint32_t pgm) const {
57 if (pgm >= _presets.size()) { return ""; }
58 return _presets[pgm].name;
62 fluid_settings_t* _settings;
63 fluid_synth_t* _synth;
65 fluid_midi_event_t* _f_midi_event;
68 BankProgram (const std::string& n, int b, int p)
74 BankProgram (const BankProgram& other)
77 , program (other.program)
85 std::vector<BankProgram> _presets;