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
10typedef enum interpolation_mode
11{
12	B_DROP_SAMPLE = 0,
13	B_2_POINT_INTERPOLATION,
14	B_LINEAR_INTERPOLATION
15}
16interpolation_mode;
17
18typedef 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}
27reverb_mode;
28
29typedef void (*synth_controller_hook) (
30	int16 channel, int16 controller, int16 value);
31
32class BMidiSynth;
33class BMidiSynthFile;
34
35namespace BPrivate { class BSoftSynth; }
36
37class BSynth {
38public:
39
40	BSynth();
41	BSynth(synth_mode synth);
42	virtual ~BSynth();
43
44	status_t LoadSynthData(entry_ref* instrumentsFile);
45	status_t LoadSynthData(synth_mode synth);
46	synth_mode SynthMode(void);
47
48	void Unload(void);
49	bool IsLoaded(void) const;
50
51	status_t SetSamplingRate(int32 sample_rate);
52	int32 SamplingRate() const;
53
54	status_t SetInterpolation(interpolation_mode interp_mode);
55	interpolation_mode Interpolation() const;
56
57	void SetReverb(reverb_mode rev_mode);
58	reverb_mode Reverb() const;
59
60	status_t EnableReverb(bool reverb_enabled);
61	bool IsReverbEnabled() const;
62
63	status_t SetVoiceLimits(
64		int16 maxSynthVoices, int16 maxSampleVoices,
65		int16 limiterThreshhold);
66
67	int16 MaxSynthVoices(void) const;
68	int16 MaxSampleVoices(void) const;
69	int16 LimiterThreshhold(void) const;
70
71	void SetSynthVolume(double theVolume);
72	double SynthVolume(void) const;
73
74	void SetSampleVolume(double theVolume);
75	double SampleVolume(void) const;
76
77	status_t GetAudio(
78		int16* pLeft, int16* pRight, int32 max_samples) const;
79
80	void Pause(void);
81	void Resume(void);
82
83	void SetControllerHook(int16 controller, synth_controller_hook cback);
84
85	int32 CountClients(void) const;
86
87private:
88
89	friend class BMidiSynth;
90	friend class BMidiSynthFile;
91
92	virtual void _ReservedSynth1();
93	virtual void _ReservedSynth2();
94	virtual void _ReservedSynth3();
95	virtual void _ReservedSynth4();
96
97	void _Init();
98
99	BPrivate::BSoftSynth* fSynth;
100	synth_mode fSynthMode;
101	int32 fClientCount;
102
103	uint32 _reserved[10];
104};
105
106extern BSynth* be_synth;
107
108#endif // _SYNTH_H
109