Ardour  9.0-pre0-582-g084a23a80d
fluid_synth.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
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.
8  *
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.
13  *
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.
17  */
18 #ifndef _ardour_fluidsynth_h_
19 #define _ardour_fluidsynth_h_
20 
21 #include <stdint.h>
22 #include <string.h>
23 #include <glib.h>
24 
26 #include "ardour/types.h"
27 
28 #include "fluidsynth.h"
29 
30 namespace ARDOUR {
31 
33  public:
39  FluidSynth (float samplerate, int polyphony = 256);
41 
42  bool load_sf2 (const std::string& fn);
43 
44  bool synth (float* left, float* right, uint32_t n_samples);
45  bool midi_event (uint8_t const* const data, size_t len);
46  void panic ();
47 
48  /* load a preset
49  * @pgm BankProgram index
50  * @chan midi channel (0..15)
51  * @return true on succcess
52  */
53  bool select_program (uint32_t pgm, uint8_t chan);
54 
55  uint32_t program_count () const { return _presets.size(); }
56 
57  std::string program_name (uint32_t pgm) const {
58  if (pgm >= _presets.size()) { return ""; }
59  return _presets[pgm].name;
60  }
61 
62  private:
63  fluid_settings_t* _settings;
64  fluid_synth_t* _synth;
65  int _synth_id;
66  fluid_midi_event_t* _f_midi_event;
67 
68  struct BankProgram {
69  BankProgram (const std::string& n, int b, int p)
70  : name (n)
71  , bank (b)
72  , program (p)
73  {}
74 
75  BankProgram (const BankProgram& other)
76  : name (other.name)
77  , bank (other.bank)
78  , program (other.program)
79  {}
80 
81  std::string name;
82  int bank;
83  int program;
84  };
85 
86  std::vector<BankProgram> _presets;
87  };
88 
89 } /* namespace */
90 #endif
fluid_midi_event_t * _f_midi_event
Definition: fluid_synth.h:66
fluid_settings_t * _settings
Definition: fluid_synth.h:63
std::vector< BankProgram > _presets
Definition: fluid_synth.h:86
bool synth(float *left, float *right, uint32_t n_samples)
bool select_program(uint32_t pgm, uint8_t chan)
std::string program_name(uint32_t pgm) const
Definition: fluid_synth.h:57
uint32_t program_count() const
Definition: fluid_synth.h:55
FluidSynth(float samplerate, int polyphony=256)
fluid_synth_t * _synth
Definition: fluid_synth.h:64
bool load_sf2(const std::string &fn)
bool midi_event(uint8_t const *const data, size_t len)
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
BankProgram(const BankProgram &other)
Definition: fluid_synth.h:75
BankProgram(const std::string &n, int b, int p)
Definition: fluid_synth.h:69