xref: /haiku/headers/os/midi/Synth.h (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
1 
2 #ifndef _SYNTH_H
3 #define _SYNTH_H
4 
5 #include <BeBuild.h>
6 #include <Entry.h>
7 #include <MidiDefs.h>
8 #include <OS.h>
9 
10 typedef enum interpolation_mode
11 {
12 	B_DROP_SAMPLE = 0,
13 	B_2_POINT_INTERPOLATION,
14 	B_LINEAR_INTERPOLATION
15 }
16 interpolation_mode;
17 
18 typedef enum reverb_mode
19 {
20 	B_REVERB_NONE = 1,
21 	B_REVERB_CLOSET,
22 	B_REVERB_GARAGE,
23 	B_REVERB_BALLROOM,
24 	B_REVERB_CAVERN,
25 	B_REVERB_DUNGEON
26 }
27 reverb_mode;
28 
29 typedef void (*synth_controller_hook) (
30 	int16 channel, int16 controller, int16 value);
31 
32 class BMidiSynth;
33 class BMidiSynthFile;
34 
35 class BSynth
36 {
37 public:
38 
39 	BSynth();
40 	BSynth(synth_mode synth);
41 	virtual ~BSynth();
42 
43 	status_t LoadSynthData(entry_ref* instrumentsFile);
44 	status_t LoadSynthData(synth_mode synth);
45 	synth_mode SynthMode(void);
46 
47 	void Unload(void);
48 	bool IsLoaded(void) const;
49 
50 	status_t SetSamplingRate(int32 sample_rate);
51 	int32 SamplingRate() const;
52 
53 	status_t SetInterpolation(interpolation_mode interp_mode);
54 	interpolation_mode Interpolation() const;
55 
56 	void SetReverb(reverb_mode rev_mode);
57 	reverb_mode Reverb() const;
58 
59 	status_t EnableReverb(bool reverb_enabled);
60 	bool IsReverbEnabled() const;
61 
62 	status_t SetVoiceLimits(
63 		int16 maxSynthVoices, int16 maxSampleVoices,
64 		int16 limiterThreshhold);
65 
66 	int16 MaxSynthVoices(void) const;
67 	int16 MaxSampleVoices(void) const;
68 	int16 LimiterThreshhold(void) const;
69 
70 	void SetSynthVolume(double theVolume);
71 	double SynthVolume(void) const;
72 
73 	void SetSampleVolume(double theVolume);
74 	double SampleVolume(void) const;
75 
76 	status_t GetAudio(
77 		int16* pLeft, int16* pRight, int32 max_samples) const;
78 
79 	void Pause(void);
80 	void Resume(void);
81 
82 	void SetControllerHook(int16 controller, synth_controller_hook cback);
83 
84 	int32 CountClients(void) const;
85 
86 private:
87 
88 	friend BMidiSynth;
89 	friend BMidiSynthFile;
90 
91 	virtual void _ReservedSynth1();
92 	virtual void _ReservedSynth2();
93 	virtual void _ReservedSynth3();
94 	virtual void _ReservedSynth4();
95 
96 	uint32 _reserved[13];
97 };
98 
99 extern _IMPEXP_MIDI BSynth* be_synth;
100 
101 #endif // _SYNTH_H
102