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 BSynth(); 39 BSynth(synth_mode synth); 40 virtual ~BSynth(); 41 42 status_t LoadSynthData(entry_ref* instrumentsFile); 43 status_t LoadSynthData(synth_mode synth); 44 synth_mode SynthMode(void); 45 46 void Unload(void); 47 bool IsLoaded(void) const; 48 49 /* change audio modes */ 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 /* change voice allocation */ 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 /* get and set the master mix volume. A volume level of 1.0 */ 72 /* is normal, and volume level of 4.0 will overdrive 4 times */ 73 void SetSynthVolume(double theVolume); 74 double SynthVolume(void) const; 75 76 void SetSampleVolume(double theVolume); 77 double SampleVolume(void) const; 78 79 /* display feedback information */ 80 /* This will return the number of 16-bit samples stored into the pLeft*/ 81 /* and pRight arrays. Usually 1024. This returns the current data*/ 82 /* points being sent to the hardware.*/ 83 status_t GetAudio( 84 int16* pLeft, int16* pRight, int32 max_samples) const; 85 86 /* disengage from audio output streams*/ 87 void Pause(void); 88 89 /* reengage to audio output streams*/ 90 void Resume(void); 91 92 /* Set a call back on controller events*/ 93 void SetControllerHook(int16 controller, synth_controller_hook cback); 94 95 int32 CountClients(void) const; 96 97 private: 98 99 virtual void _ReservedSynth1(); 100 virtual void _ReservedSynth2(); 101 virtual void _ReservedSynth3(); 102 virtual void _ReservedSynth4(); 103 104 friend BMidiSynth; 105 friend BMidiSynthFile; 106 107 int32 fClientCount; 108 void _init(); 109 status_t _do_load(synth_mode synth); 110 status_t _load_insts(entry_ref* ref); 111 synth_mode fMode; 112 int16 fMaxSynthVox; 113 int16 fMaxSampleVox; 114 int16 fLimiter; 115 116 int32 fSRate; 117 interpolation_mode fInterp; 118 int32 fModifiers; 119 reverb_mode fReverb; 120 sem_id fSetupLock; 121 uint32 _reserved[4]; 122 }; 123 124 extern _IMPEXP_MIDI BSynth* be_synth; 125 126 #endif // _SYNTH_H 127 128