1 /******************************************************************************* 2 / 3 / File: Synth.h 4 / 5 / Description: Interface to the General MIDI synthesizer. 6 / 7 / Copyright 1993-98, Be Incorporated, All Rights Reserved. 8 / 9 *******************************************************************************/ 10 11 #ifndef _SYNTH_H 12 #define _SYNTH_H 13 14 #ifndef _BE_BUILD_H 15 #include <BeBuild.h> 16 #endif 17 #include <Entry.h> 18 #include <MidiDefs.h> 19 #include <OS.h> 20 21 typedef enum interpolation_mode 22 { 23 B_DROP_SAMPLE = 0, 24 B_2_POINT_INTERPOLATION, 25 B_LINEAR_INTERPOLATION 26 } interpolation_mode; 27 28 typedef enum reverb_mode 29 { 30 B_REVERB_NONE = 1, 31 B_REVERB_CLOSET, 32 B_REVERB_GARAGE, 33 B_REVERB_BALLROOM, 34 B_REVERB_CAVERN, 35 B_REVERB_DUNGEON 36 } reverb_mode; 37 38 typedef void (*synth_controller_hook) (int16 channel, 39 int16 controller, 40 int16 value); 41 class BMidiSynth; 42 class BMidiSynthFile; 43 44 class BSynth 45 { 46 public: 47 BSynth(); 48 BSynth(synth_mode synth); 49 50 #if !_PR3_COMPATIBLE_ 51 virtual ~BSynth(); 52 #else 53 ~BSynth(); 54 #endif 55 56 status_t LoadSynthData(entry_ref *instrumentsFile); 57 status_t LoadSynthData(synth_mode synth); 58 synth_mode SynthMode(void); 59 60 void Unload(void); 61 bool IsLoaded(void) const; 62 63 /* change audio modes*/ 64 status_t SetSamplingRate(int32 sample_rate); 65 int32 SamplingRate() const; 66 67 status_t SetInterpolation(interpolation_mode interp_mode); 68 interpolation_mode Interpolation() const; 69 70 void SetReverb(reverb_mode rev_mode); 71 reverb_mode Reverb() const; 72 73 status_t EnableReverb(bool reverb_enabled); 74 bool IsReverbEnabled() const; 75 76 /* change voice allocation*/ 77 status_t SetVoiceLimits(int16 maxSynthVoices, 78 int16 maxSampleVoices, 79 int16 limiterThreshhold); 80 81 int16 MaxSynthVoices(void) const; 82 int16 MaxSampleVoices(void) const; 83 int16 LimiterThreshhold(void) const; 84 85 /* get and set the master mix volume. A volume level of 1.0*/ 86 /* is normal, and volume level of 4.0 will overdrive 4 times*/ 87 void SetSynthVolume(double theVolume); 88 double SynthVolume(void) const; 89 90 void SetSampleVolume(double theVolume); 91 double SampleVolume(void) const; 92 93 /* display feedback information*/ 94 /* This will return the number of 16-bit samples stored into the pLeft*/ 95 /* and pRight arrays. Usually 1024. This returns the current data*/ 96 /* points being sent to the hardware.*/ 97 status_t GetAudio(int16 *pLeft, int16 *pRight, 98 int32 max_samples) const; 99 100 /* disengage from audio output streams*/ 101 void Pause(void); 102 /* reengage to audio output streams*/ 103 void Resume(void); 104 105 /* Set a call back on controller events*/ 106 void SetControllerHook(int16 controller, 107 synth_controller_hook cback); 108 109 int32 CountClients(void) const; 110 111 private: 112 113 virtual void _ReservedSynth1(); 114 virtual void _ReservedSynth2(); 115 virtual void _ReservedSynth3(); 116 virtual void _ReservedSynth4(); 117 118 friend BMidiSynth; 119 friend BMidiSynthFile; 120 121 int32 fClientCount; 122 void _init(); 123 status_t _do_load(synth_mode synth); 124 status_t _load_insts(entry_ref *ref); 125 synth_mode fMode; 126 int16 fMaxSynthVox; 127 int16 fMaxSampleVox; 128 int16 fLimiter; 129 130 int32 fSRate; 131 interpolation_mode fInterp; 132 int32 fModifiers; 133 reverb_mode fReverb; 134 sem_id fSetupLock; 135 uint32 _reserved[4]; 136 }; 137 138 extern _IMPEXP_MIDI BSynth *be_synth; 139 140 141 #endif 142