wesstrak.c (6780B)
1 2 /* ULTRA64 LIBRARIES */ 3 #include <ultra64.h> 4 #include "ultratypes.h" 5 #include <libaudio.h> 6 7 /* WESS API INCLUDES */ 8 #include "wessapi.h" // audio stuff... 9 #include "seqload.h" 10 #include "soundhw.h" 11 #include "wessarc.h" 12 #include "wessseq.h" 13 14 #include "funqueue.h" 15 16 #include "wessedit.h" 17 #include "wesstrak.h" 18 #include "wesshand.h" 19 20 #ifndef NOUSEWESSCODE 21 22 /* 23 PatchChg 7 24 { 25 Tuning Program Change 26 } 27 28 PitchMod 9 29 { 30 Pitch Bend Sensitivity 31 } 32 33 ZeroMod 11 34 { 35 MIDI_Controller = 0 (Bank Select) 36 } 37 38 ModuMod 11 39 { 40 MIDI_Controller = 1 (Modulation Wheel or Lever) 41 } 42 43 VolumeMod 12 44 { 45 MIDI_Controller = 7 (Channel Volume(formerly Main Volume)) 46 } 47 48 PanMod 13 49 { 50 MIDI_Controller = 10 (Pan) 51 } 52 53 PedalMod 14 54 { 55 MIDI_Controller = 64 (Damper Pedal on / off(Sustain)) 56 } 57 58 ReverbMod 15 59 { 60 MIDI_Controller = 91 (Effects 1 Depth->Reverb Send Level) 61 } 62 63 ChorusMod 16 64 { 65 MIDI_Controller = 93 (Effects 3 Depth->Chorus Send Level) 66 } 67 */ 68 69 extern char scratch_area[32];//800B41E0 70 71 extern void patch_chg_action(track_status *ptmp, int patch_num); // 800340E0 72 extern void pitch_mod_action(track_status *ptmp, int pitch_cntr); // 80034144 73 extern void volume_mod_action(track_status *ptmp, int volume_cntr); // 800341A8 74 extern void pan_mod_action(track_status *ptmp, int pan_cntr); // 80034200 75 extern track_status *gethandletrk(int handle, int track); // 80032EE0 76 77 void queue_wess_handle_noteon(int handle, int track, char keynum, char velnum); 78 void wess_handle_parm_mod(int handle, int track, int value, WessAction function); 79 void queue_wess_handle_parm_mod(int handle, int track, int value, WessAction function); 80 81 void wess_handle_patchchg(int handle, int track, short patchnum) // 80034664 82 { 83 wess_handle_parm_mod(handle, track, patchnum, patch_chg_action); 84 } 85 86 void wess_handle_noteon(int handle, int track, char keynum, char velnum) // 8003469C 87 { 88 int _handle; 89 int _track; 90 char _keynum; 91 char _velnum; 92 93 _handle = handle; 94 _track = track; 95 _keynum = keynum; 96 _velnum = velnum; 97 98 wess_disable(); 99 queue_the_function(QUEUE_HANDLE_NOTEON); 100 queue_the_data(&_handle, sizeof(int)); 101 queue_the_data(&_track, sizeof(int)); 102 queue_the_data(&_keynum, sizeof(char)); 103 queue_the_data(&_velnum, sizeof(char)); 104 wess_enable(); 105 } 106 107 void run_queue_wess_handle_noteon(void) // 80034708 108 { 109 int handle; 110 int track; 111 char keynum; 112 char velnum; 113 114 unqueue_the_data(&handle, sizeof(int)); 115 unqueue_the_data(&track, sizeof(int)); 116 unqueue_the_data(&keynum, sizeof(char)); 117 unqueue_the_data(&velnum, sizeof(char)); 118 queue_wess_handle_noteon(handle, track, keynum, velnum); 119 } 120 121 void queue_wess_handle_noteon(int handle, int track, char keynum, char velnum) // 80034768 122 { 123 track_status *ptmp; 124 char *ppos; 125 126 int _handle; 127 int _track; 128 char _keynum; 129 char _velnum; 130 131 _handle = handle; 132 _track = track; 133 _keynum = keynum; 134 _velnum = velnum; 135 136 if (Is_Module_Loaded()) 137 { 138 wess_disable(); 139 ptmp = gethandletrk(_handle, _track); 140 141 if (ptmp) 142 { 143 //save 144 ppos = ptmp->ppos; 145 146 // set tmp buffer ppos 147 ptmp->ppos = scratch_area; 148 ptmp->ppos[0] = NoteOn; 149 ptmp->ppos[1] = _keynum; 150 ptmp->ppos[2] = _velnum; 151 152 CmdFuncArr[ptmp->patchtype][NoteOn](ptmp); 153 154 //restore 155 ptmp->ppos = ppos; 156 } 157 158 wess_enable(); 159 } 160 } 161 162 void noteoff_action(track_status *ptmp, int keynum) // 8003483C 163 { 164 ptmp->ppos[0]= NoteOff; 165 ptmp->ppos[1]= keynum; 166 CmdFuncArr[ptmp->patchtype][NoteOff](ptmp); 167 } 168 169 void wess_handle_noteoff(int handle, int track, char keynum) // 80034894 170 { 171 wess_handle_parm_mod(handle, track, keynum, noteoff_action); 172 } 173 174 void wess_handle_pitchmod(int handle, int track, short pitch_cntrl) // 800348C0 175 { 176 wess_handle_parm_mod(handle, track, pitch_cntrl, pitch_mod_action); 177 } 178 179 void zero_mod_action(track_status *ptmp, int value) // 800348F0 180 { 181 ptmp->ppos[0] = ZeroMod; 182 ptmp->ppos[1] = value; 183 CmdFuncArr[ptmp->patchtype][ZeroMod](ptmp); 184 } 185 186 void wess_handle_zeromod(int handle, int track, char value) // 80034948 187 { 188 wess_handle_parm_mod(handle, track, value, zero_mod_action); 189 } 190 191 void modu_mod_action(track_status *ptmp, int value) // 80034974 192 { 193 ptmp->ppos[0]= ModuMod; 194 ptmp->ppos[1] = value; 195 CmdFuncArr[ptmp->patchtype][ModuMod](ptmp); 196 } 197 198 void wess_handle_modumod(int handle, int track, char value) // 800349CC 199 { 200 wess_handle_parm_mod(handle, track, value, modu_mod_action); 201 } 202 203 void wess_handle_volumemod(int handle, int track, char volume_cntrl) // 800349F8 204 { 205 wess_handle_parm_mod(handle, track, volume_cntrl, volume_mod_action); 206 } 207 208 void wess_handle_panmod(int handle, int track, char pan_cntr) // 80034A24 209 { 210 wess_handle_parm_mod(handle, track, pan_cntr, pan_mod_action); 211 } 212 213 void pedal_mod_action(track_status *ptmp, int value) // 80034A50 214 { 215 ptmp->ppos[0] = PedalMod; 216 ptmp->ppos[1] = value; 217 CmdFuncArr[ptmp->patchtype][PedalMod](ptmp); 218 } 219 220 void wess_handle_pedalmod(int handle, int track, char value) // 80034AA8 221 { 222 wess_handle_parm_mod(handle, track, value, pedal_mod_action); 223 } 224 225 void reverb_mod_action(track_status *ptmp, int reverb) // 80034AD4 226 { 227 ptmp->ppos[0] = ReverbMod; 228 ptmp->ppos[1] = reverb; 229 CmdFuncArr[ptmp->patchtype][ReverbMod](ptmp); 230 } 231 232 void wess_handle_reverbmod(int handle, int track, char reverb) // 80034B2C 233 { 234 wess_handle_parm_mod(handle, track, reverb, reverb_mod_action); 235 } 236 237 void chorus_mod_action(track_status *ptmp, int chorus) // 80034B58 238 { 239 ptmp->ppos[0] = ChorusMod; 240 ptmp->ppos[1] = chorus; 241 CmdFuncArr[ptmp->patchtype][ChorusMod](ptmp); 242 } 243 244 void wess_handle_chorusmod(int handle, int track, char chorus) // 80034BB0 245 { 246 wess_handle_parm_mod(handle, track, chorus, chorus_mod_action); 247 } 248 249 void wess_handle_parm_mod(int handle, int track, int value, WessAction function) // 80034BDC 250 { 251 int _handle; 252 int _track; 253 int _value; 254 WessAction _function; 255 256 _handle = handle; 257 _track = track; 258 _value = value; 259 _function = function; 260 261 wess_disable(); 262 queue_the_function(QUEUE_HANDLE_PARM_MOD); 263 queue_the_data(&_handle, sizeof(int)); 264 queue_the_data(&_track, sizeof(int)); 265 queue_the_data(&_value, sizeof(int)); 266 queue_the_data(&_function, sizeof(WessAction)); 267 wess_enable(); 268 } 269 270 void run_queue_wess_handle_parm_mod(void) // 80034C48 271 { 272 int handle; 273 int track; 274 int value; 275 WessAction function; 276 277 unqueue_the_data(&handle, sizeof(int)); 278 unqueue_the_data(&track, sizeof(int)); 279 unqueue_the_data(&value, sizeof(int)); 280 unqueue_the_data(&function, sizeof(WessAction)); 281 queue_wess_handle_parm_mod(handle, track, value, function); 282 } 283 284 void queue_wess_handle_parm_mod(int handle, int track, int value, WessAction function) // 80034CA8 285 { 286 track_status *ptmp; 287 char *ppos; 288 289 int _handle; 290 int _track; 291 int _value; 292 WessAction _function; 293 294 _handle = handle; 295 _track = track; 296 _value = value; 297 _function = function; 298 299 if (Is_Module_Loaded()) 300 { 301 wess_disable(); 302 ptmp = gethandletrk(_handle, _track); 303 304 if (ptmp) 305 { 306 wess_track_parm_mod(ptmp, _value, _function); 307 } 308 309 wess_enable(); 310 } 311 } 312 #endif // 0