xref: /haiku/headers/os/midi/Synth.h (revision 1b13b75f49bf90e0cf79452610de2d3cab3864a5)
14b867062Sbeveloper 
24b867062Sbeveloper #ifndef _SYNTH_H
34b867062Sbeveloper #define _SYNTH_H
44b867062Sbeveloper 
54b867062Sbeveloper #include <BeBuild.h>
64b867062Sbeveloper #include <Entry.h>
74b867062Sbeveloper #include <MidiDefs.h>
84b867062Sbeveloper #include <OS.h>
94b867062Sbeveloper 
104b867062Sbeveloper typedef enum interpolation_mode
114b867062Sbeveloper {
124b867062Sbeveloper 	B_DROP_SAMPLE = 0,
134b867062Sbeveloper 	B_2_POINT_INTERPOLATION,
144b867062Sbeveloper 	B_LINEAR_INTERPOLATION
15173d0cd7Smahlzeit }
16173d0cd7Smahlzeit interpolation_mode;
174b867062Sbeveloper 
184b867062Sbeveloper typedef enum reverb_mode
194b867062Sbeveloper {
204b867062Sbeveloper 	B_REVERB_NONE = 1,
214b867062Sbeveloper 	B_REVERB_CLOSET,
224b867062Sbeveloper 	B_REVERB_GARAGE,
234b867062Sbeveloper 	B_REVERB_BALLROOM,
244b867062Sbeveloper 	B_REVERB_CAVERN,
254b867062Sbeveloper 	B_REVERB_DUNGEON
26173d0cd7Smahlzeit }
27173d0cd7Smahlzeit reverb_mode;
284b867062Sbeveloper 
29173d0cd7Smahlzeit typedef void (*synth_controller_hook) (
30173d0cd7Smahlzeit 	int16 channel, int16 controller, int16 value);
31173d0cd7Smahlzeit 
324b867062Sbeveloper class BMidiSynth;
334b867062Sbeveloper class BMidiSynthFile;
344b867062Sbeveloper 
35*1b13b75fSmahlzeit namespace BPrivate { class BSoftSynth; }
36*1b13b75fSmahlzeit 
374b867062Sbeveloper class BSynth
384b867062Sbeveloper {
394b867062Sbeveloper public:
4038c7401eSmahlzeit 
414b867062Sbeveloper 	BSynth();
424b867062Sbeveloper 	BSynth(synth_mode synth);
434b867062Sbeveloper 	virtual ~BSynth();
444b867062Sbeveloper 
454b867062Sbeveloper 	status_t LoadSynthData(entry_ref* instrumentsFile);
464b867062Sbeveloper 	status_t LoadSynthData(synth_mode synth);
474b867062Sbeveloper 	synth_mode SynthMode(void);
484b867062Sbeveloper 
494b867062Sbeveloper 	void Unload(void);
504b867062Sbeveloper 	bool IsLoaded(void) const;
514b867062Sbeveloper 
524b867062Sbeveloper 	status_t SetSamplingRate(int32 sample_rate);
534b867062Sbeveloper 	int32 SamplingRate() const;
544b867062Sbeveloper 
554b867062Sbeveloper 	status_t SetInterpolation(interpolation_mode interp_mode);
564b867062Sbeveloper 	interpolation_mode Interpolation() const;
574b867062Sbeveloper 
584b867062Sbeveloper 	void SetReverb(reverb_mode rev_mode);
594b867062Sbeveloper 	reverb_mode Reverb() const;
604b867062Sbeveloper 
614b867062Sbeveloper 	status_t EnableReverb(bool reverb_enabled);
624b867062Sbeveloper 	bool IsReverbEnabled() const;
634b867062Sbeveloper 
64173d0cd7Smahlzeit 	status_t SetVoiceLimits(
65173d0cd7Smahlzeit 		int16 maxSynthVoices, int16 maxSampleVoices,
664b867062Sbeveloper 		int16 limiterThreshhold);
674b867062Sbeveloper 
684b867062Sbeveloper 	int16 MaxSynthVoices(void) const;
694b867062Sbeveloper 	int16 MaxSampleVoices(void) const;
704b867062Sbeveloper 	int16 LimiterThreshhold(void) const;
714b867062Sbeveloper 
724b867062Sbeveloper 	void SetSynthVolume(double theVolume);
734b867062Sbeveloper 	double SynthVolume(void) const;
744b867062Sbeveloper 
754b867062Sbeveloper 	void SetSampleVolume(double theVolume);
764b867062Sbeveloper 	double SampleVolume(void) const;
774b867062Sbeveloper 
78173d0cd7Smahlzeit 	status_t GetAudio(
79173d0cd7Smahlzeit 		int16* pLeft, int16* pRight, int32 max_samples) const;
804b867062Sbeveloper 
814b867062Sbeveloper 	void Pause(void);
824b867062Sbeveloper 	void Resume(void);
834b867062Sbeveloper 
84173d0cd7Smahlzeit 	void SetControllerHook(int16 controller, synth_controller_hook cback);
854b867062Sbeveloper 
864b867062Sbeveloper 	int32 CountClients(void) const;
874b867062Sbeveloper 
884b867062Sbeveloper private:
894b867062Sbeveloper 
9038c7401eSmahlzeit 	friend BMidiSynth;
9138c7401eSmahlzeit 	friend BMidiSynthFile;
9238c7401eSmahlzeit 
934b867062Sbeveloper 	virtual void _ReservedSynth1();
944b867062Sbeveloper 	virtual void _ReservedSynth2();
954b867062Sbeveloper 	virtual void _ReservedSynth3();
964b867062Sbeveloper 	virtual void _ReservedSynth4();
974b867062Sbeveloper 
98*1b13b75fSmahlzeit 	void Init();
99*1b13b75fSmahlzeit 
100*1b13b75fSmahlzeit 	BPrivate::BSoftSynth* synth;
101*1b13b75fSmahlzeit 	synth_mode synthMode;
102*1b13b75fSmahlzeit 	int32 clientCount;
103*1b13b75fSmahlzeit 
104*1b13b75fSmahlzeit 	uint32 _reserved[10];
1054b867062Sbeveloper };
1064b867062Sbeveloper 
1074b867062Sbeveloper extern _IMPEXP_MIDI BSynth* be_synth;
1084b867062Sbeveloper 
109173d0cd7Smahlzeit #endif // _SYNTH_H
110