xref: /haiku/headers/os/midi/Synth.h (revision 173d0cd7692da7b7a0b74759305c77da5f1fe0fa)
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
15*173d0cd7Smahlzeit }
16*173d0cd7Smahlzeit 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
26*173d0cd7Smahlzeit }
27*173d0cd7Smahlzeit reverb_mode;
284b867062Sbeveloper 
29*173d0cd7Smahlzeit typedef void (*synth_controller_hook) (
30*173d0cd7Smahlzeit 	int16 channel, int16 controller, int16 value);
31*173d0cd7Smahlzeit 
324b867062Sbeveloper class BMidiSynth;
334b867062Sbeveloper class BMidiSynthFile;
344b867062Sbeveloper 
354b867062Sbeveloper class BSynth
364b867062Sbeveloper {
374b867062Sbeveloper public:
384b867062Sbeveloper 	BSynth();
394b867062Sbeveloper 	BSynth(synth_mode synth);
404b867062Sbeveloper 	virtual ~BSynth();
414b867062Sbeveloper 
424b867062Sbeveloper 	status_t LoadSynthData(entry_ref* instrumentsFile);
434b867062Sbeveloper 	status_t LoadSynthData(synth_mode synth);
444b867062Sbeveloper 	synth_mode SynthMode(void);
454b867062Sbeveloper 
464b867062Sbeveloper 	void Unload(void);
474b867062Sbeveloper 	bool IsLoaded(void) const;
484b867062Sbeveloper 
494b867062Sbeveloper 	/* change audio modes */
504b867062Sbeveloper 	status_t SetSamplingRate(int32 sample_rate);
514b867062Sbeveloper 	int32 SamplingRate() const;
524b867062Sbeveloper 
534b867062Sbeveloper 	status_t SetInterpolation(interpolation_mode interp_mode);
544b867062Sbeveloper 	interpolation_mode Interpolation() const;
554b867062Sbeveloper 
564b867062Sbeveloper 	void SetReverb(reverb_mode rev_mode);
574b867062Sbeveloper 	reverb_mode Reverb() const;
584b867062Sbeveloper 
594b867062Sbeveloper 	status_t EnableReverb(bool reverb_enabled);
604b867062Sbeveloper 	bool IsReverbEnabled() const;
614b867062Sbeveloper 
624b867062Sbeveloper 	/* change voice allocation */
63*173d0cd7Smahlzeit 	status_t SetVoiceLimits(
64*173d0cd7Smahlzeit 		int16 maxSynthVoices, int16 maxSampleVoices,
654b867062Sbeveloper 		int16 limiterThreshhold);
664b867062Sbeveloper 
674b867062Sbeveloper 	int16 MaxSynthVoices(void) const;
684b867062Sbeveloper 	int16 MaxSampleVoices(void) const;
694b867062Sbeveloper 	int16 LimiterThreshhold(void) const;
704b867062Sbeveloper 
714b867062Sbeveloper 	/* get and set the master mix volume. A volume level of 1.0 */
724b867062Sbeveloper 	/* is normal, and volume level of 4.0 will overdrive 4 times */
734b867062Sbeveloper 	void SetSynthVolume(double theVolume);
744b867062Sbeveloper 	double SynthVolume(void) const;
754b867062Sbeveloper 
764b867062Sbeveloper 	void SetSampleVolume(double theVolume);
774b867062Sbeveloper 	double SampleVolume(void) const;
784b867062Sbeveloper 
794b867062Sbeveloper 	/* display feedback information */
804b867062Sbeveloper 	/* This will return the number of 16-bit samples stored into the pLeft*/
814b867062Sbeveloper 	/*  and pRight arrays. Usually 1024. This returns the current data*/
824b867062Sbeveloper 	/*  points being sent to the hardware.*/
83*173d0cd7Smahlzeit 	status_t GetAudio(
84*173d0cd7Smahlzeit 		int16* pLeft, int16* pRight, int32 max_samples) const;
854b867062Sbeveloper 
864b867062Sbeveloper 	/* disengage from audio output streams*/
874b867062Sbeveloper 	void Pause(void);
88*173d0cd7Smahlzeit 
894b867062Sbeveloper 	/* reengage to audio output streams*/
904b867062Sbeveloper 	void Resume(void);
914b867062Sbeveloper 
924b867062Sbeveloper 	/* Set a call back on controller events*/
93*173d0cd7Smahlzeit 	void SetControllerHook(int16 controller, synth_controller_hook cback);
944b867062Sbeveloper 
954b867062Sbeveloper 	int32 CountClients(void) const;
964b867062Sbeveloper 
974b867062Sbeveloper private:
984b867062Sbeveloper 
994b867062Sbeveloper 	virtual void _ReservedSynth1();
1004b867062Sbeveloper 	virtual void _ReservedSynth2();
1014b867062Sbeveloper 	virtual void _ReservedSynth3();
1024b867062Sbeveloper 	virtual void _ReservedSynth4();
1034b867062Sbeveloper 
1044b867062Sbeveloper 	friend BMidiSynth;
1054b867062Sbeveloper 	friend BMidiSynthFile;
1064b867062Sbeveloper 
1074b867062Sbeveloper 	int32 fClientCount;
1084b867062Sbeveloper 	void _init();
1094b867062Sbeveloper 	status_t _do_load(synth_mode synth);
1104b867062Sbeveloper 	status_t _load_insts(entry_ref* ref);
1114b867062Sbeveloper 	synth_mode fMode;
1124b867062Sbeveloper 	int16 fMaxSynthVox;
1134b867062Sbeveloper 	int16 fMaxSampleVox;
1144b867062Sbeveloper 	int16 fLimiter;
1154b867062Sbeveloper 
1164b867062Sbeveloper 	int32 fSRate;
1174b867062Sbeveloper 	interpolation_mode fInterp;
1184b867062Sbeveloper 	int32 fModifiers;
1194b867062Sbeveloper 	reverb_mode fReverb;
1204b867062Sbeveloper 	sem_id fSetupLock;
1214b867062Sbeveloper 	uint32 _reserved[4];
1224b867062Sbeveloper };
1234b867062Sbeveloper 
1244b867062Sbeveloper extern _IMPEXP_MIDI BSynth* be_synth;
1254b867062Sbeveloper 
126*173d0cd7Smahlzeit #endif // _SYNTH_H
1274b867062Sbeveloper 
128