Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
bsesoundfontrepo.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BSE_SOUND_FONT_REPO_HH__
3 #define __BSE_SOUND_FONT_REPO_HH__
4 
5 #include <bse/bsesuper.hh>
6 #include <fluidsynth.h>
7 #include <bse/bsesoundfontosc.hh>
8 #include <bse/bseengine.hh>
9 
10 #define BSE_TYPE_SOUND_FONT_REPO (BSE_TYPE_ID (BseSoundFontRepo))
11 #define BSE_SOUND_FONT_REPO(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SOUND_FONT_REPO, BseSoundFontRepo))
12 #define BSE_SOUND_FONT_REPO_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), BSE_TYPE_SOUND_FONT_REPO, BseSoundFontRepoClass))
13 #define BSE_IS_SOUND_FONT_REPO(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SOUND_FONT_REPO))
14 #define BSE_IS_SOUND_FONT_REPO_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SOUND_FONT_REPO))
15 #define BSE_SOUND_FONT_REPO_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SOUND_FONT_REPO, BseSoundFontRepoClass))
16 
17 #define BSE_FLUID_SYNTH_PROGRAM_SELECT -1
18 
19 struct BseFluidEvent {
20  guint64 tick_stamp;
21  guint channel;
22  int command;
23  int arg1;
24  int arg2;
25  int sfont_id; /* required for program selection only */
26 };
27 
29 };
30 
32 {};
33 
34 
35 /* --- prototypes --- */
36 void bse_sound_font_repo_list_all_presets (BseSoundFontRepo *sfrepo,
37  BseIt3mSeq *items);
38 Bse::Mutex& bse_sound_font_repo_mutex (BseSoundFontRepo *sfrepo);
39 fluid_synth_t* bse_sound_font_repo_fluid_synth (BseSoundFontRepo *sfrepo);
40 int bse_sound_font_repo_add_osc (BseSoundFontRepo *sfrepo,
41  BseSoundFontOsc *osc);
42 void bse_sound_font_repo_remove_osc (BseSoundFontRepo *sfrepo,
43  guint osc_id);
44 
45 namespace Bse {
46 
47 class SoundFontRepoImpl : public SuperImpl, public virtual SoundFontRepoIface {
48 public:
49  Bse::Mutex fluid_synth_mutex;
50  struct ChannelState {
51  std::vector<float> values_left;
52  std::vector<float> values_right;
53  int n_silence_samples;
54  };
55  std::vector<ChannelState> channel_state; /* [0..n_fluid_channels-1] */
56 
57  struct Osc {
58  BseSoundFontOsc *osc;
59  guint channel;
60  };
61  std::vector<Osc> oscs;
62  std::vector<BseSoundFont *> sound_fonts;
63 
64  fluid_settings_t *fluid_settings;
65  fluid_synth_t *fluid_synth;
66  guint fluid_mix_freq;
67 
68  SfiRing *fluid_events;
69 
70  guint n_fluid_channels;
71  guint64 channel_values_tick_stamp;
72 
73  int n_channel_oscs_active; /* SoundFontOscs with an active module in the engine thread */
74 
75 protected:
76 
77  virtual ~SoundFontRepoImpl ();
78 public:
79  explicit SoundFontRepoImpl (BseObject*);
80  virtual Error load_file (const String &file_name) override;
81  virtual Error remove_sound_font (SoundFontIface &wave) override;
82 };
83 
84 } // Bse
85 
86 
87 #endif /* __BSE_SOUND_FONT_REPO_HH__ */
Definition: bsesoundfontrepo.hh:31
Definition: bsesoundfontrepo.hh:19
The Bse namespace contains all functions of the synthesis engine.
Definition: bstbseutils.cc:91
Definition: bsesoundfontrepo.hh:57
Definition: bsesuper.hh:23
Definition: bsesuper.hh:29
STL class.
Definition: bsesoundfontrepo.hh:50
Definition: bseobject.hh:57
Definition: bsesuper.hh:40
Definition: sfiring.hh:21
Definition: bsesoundfontosc.hh:33
Definition: bsesoundfontrepo.hh:47
Definition: bsesoundfontrepo.hh:28