22 #ifndef SCUMM_IMUSE_INTERNAL 23 #define SCUMM_IMUSE_INTERNAL 25 #include "common/scummsys.h" 26 #include "common/serializer.h" 27 #include "scumm/imuse/imuse.h" 28 #include "scumm/imuse/instrument.h" 29 #include "audio/mididrv.h" 36 struct ParameterFader;
37 struct DeferredCommand;
39 struct SustainingNotes;
45 class IMuseSysex_Scumm;
55 #define TICKS_PER_BEAT 480 60 #define MUS_REDUCTION_TIMER_TICKS 16667 // 60 Hz 69 inline int clamp(
int val,
int min,
int max) {
77 inline int transpose_clamp(
int a,
int b,
int c) {
79 a += (b - a + 11) / 12 * 12;
81 a -= (a - c + 11) / 12 * 12;
101 byte _part_onoff[16];
102 byte _part_volume[16];
103 byte _part_program[16];
104 byte _part_transpose[16];
106 int query_param(
int param, byte chan);
107 int set(byte cls, byte value, byte chan);
111 memset(_jump, 0,
sizeof(_jump));
112 memset(_part_onoff, 0,
sizeof(_part_onoff));
113 memset(_part_volume, 0,
sizeof(_part_volume));
114 memset(_part_program, 0,
sizeof(_part_program));
115 memset(_part_transpose, 0,
sizeof(_part_transpose));
135 ParameterFader() : param(0), dir(0), incr(0), ifrac(0), irem(0), ttime(0), cntdwn(0), state(0) {}
136 void init() { param = 0; }
141 int a, b, c, d, e, f;
173 #ifdef SYSEX_CALLBACK_FUNCTION 174 friend void SYSEX_CALLBACK_FUNCTION(
Player *,
const byte *, uint16);
180 static uint16 _active_notes[128];
192 ParserType _parserType;
208 uint _loop_from_beat;
211 uint _loop_from_tick;
215 uint32 _transitionTimer;
228 bool _supportsPercussion;
234 void part_set_transpose(uint8 chan, byte relative, int8 b);
235 void maybe_jump(byte cmd, uint track, uint beat, uint tick);
236 void maybe_set_transpose(byte *data);
237 void maybe_part_onoff(byte *data);
238 void maybe_set_volume(byte *data);
239 void maybe_set_program(byte *data);
240 void maybe_set_transpose_part(byte *data);
241 void turn_off_pedals();
242 int query_part_param(
int param, byte chan);
243 void turn_off_parts();
244 void play_active_notes();
246 void transitionParameters();
248 static void decode_sysex_bytes(
const byte *src, byte *dst,
int len);
251 int start_seq_sound(
int sound,
bool reset_vars =
true);
252 void loadStartParameters(
int sound);
262 int addParameterFader(
int param,
int target,
int time);
266 Part *getActivePart(uint8 part);
268 int16 getDetune()
const {
return _detune; }
269 byte getEffectiveVolume()
const {
return _vol_eff; }
270 int getID()
const {
return _id; }
271 MidiDriver *getMidiDriver()
const {
return _midi; }
272 int getParam(
int param, byte chan);
273 int8 getPan()
const {
return _pan; }
274 Part *getPart(uint8 part);
275 byte getPriority()
const {
return _priority; }
276 uint getTicksPerBeat()
const {
return TICKS_PER_BEAT; }
277 int8 getTranspose()
const {
return _transpose; }
278 byte getVolume()
const {
return _volume; }
279 bool isActive()
const {
return _active; }
280 bool isFadingOut()
const;
281 bool isMIDI()
const {
return _isMIDI; }
282 bool isMT32()
const {
return _isMT32; }
283 bool jump(uint track, uint beat, uint tick);
285 void removePart(
Part *part);
286 int scan(uint totrack, uint tobeat, uint totick);
288 int setHook(byte cls, byte value, byte chan) {
return _hook.set(cls, value, chan); }
289 void setDetune(
int detune);
290 void setOffsetNote(
int offset);
291 bool setLoop(uint count, uint tobeat, uint totick, uint frombeat, uint fromtick);
292 void setPan(
int pan);
293 void setPriority(
int pri);
294 void setSpeed(byte speed);
295 int setTranspose(byte relative,
int b);
296 int setVolume(byte vol);
298 int getMusicTimer()
const;
302 void send(uint32 b)
override;
303 void sysEx(
const byte *msg, uint16 length)
override;
304 uint16 sysExNoDelay(
const byte *msg, uint16 length)
override;
305 void metaEvent(byte type, byte *data, uint16 length)
override;
323 byte _pitchbend_factor;
324 byte _volControlSensitivity;
325 int8 _transpose, _transpose_eff;
344 bool _unassigned_instrument;
349 void noteOff(byte note);
350 void noteOn(byte note, byte velocity);
351 void programChange(byte value);
352 void pitchBend(int16 value);
353 void modulationWheel(byte value);
354 void volume(byte value);
355 void volControlSensitivity(byte value);
356 void pitchBendFactor(byte value);
357 void sustain(
bool value);
358 void effectLevel(byte value);
359 void chorusLevel(byte value);
362 void set_param(byte param,
int value) { }
363 void init(
bool useNativeMT32);
364 void setup(
Player *player);
367 void set_instrument(uint b);
368 void set_instrument(byte *data);
369 void load_global_instrument(byte b);
371 void set_transpose(int8 transpose, int8 clipRangeLow, int8 clipRangeHi);
372 void set_detune(int8 detune);
373 void set_pri(int8 pri);
374 void set_pan(int8 pan);
376 void set_polyphony(byte val);
377 void set_onoff(
bool on);
378 void fix_after_load();
381 bool clearToTransmit();
388 void sendPitchBend();
389 void sendVolume(int8 fadeModifier);
390 void sendVolumeFade();
391 void sendTranspose();
393 void sendPanPosition(uint8 value);
394 void sendEffectLevel(uint8 value);
395 void sendPolyphony();
414 #ifdef SYSEX_CALLBACK_FUNCTION 415 friend void SYSEX_CALLBACK_FUNCTION(
Player *,
const byte *, uint16);
420 const bool _native_mt32;
421 const bool _newSystem;
422 const bool _dynamicChanAllocation;
429 const uint32 _game_id;
447 bool _recycle_players;
449 int _musicVolumeReductionTimer = 0;
451 uint _queue_end, _queue_pos, _queue_sound;
458 byte _music_volume_eff;
460 uint16 _trigger_count;
462 uint16 _snm_trigger_index;
464 uint16 _channel_volume[8];
465 uint16 _channel_volume_eff[8];
466 uint16 _volchan_table[8];
478 RhyState(byte volume, byte polyphony, byte priority) : vol(volume), poly(polyphony), prio(priority) {}
490 static void midiTimerCallback(
void *data);
500 byte *findStartOfSound(
int sound,
int ct = (kMThd | kFORM));
501 bool isMT32(
int sound);
502 bool isMIDI(
int sound);
503 bool supportsPercussion(
int sound);
504 int get_queue_sound_status(
int sound)
const;
505 void handle_marker(uint
id, byte data);
506 int get_channel_volume(uint a);
515 Player *allocate_player(byte priority);
518 int32 ImSetTrigger(
int sound,
int id,
int a,
int b,
int c,
int d,
int e,
int f,
int g,
int h);
519 int32 ImClearTrigger(
int sound,
int id);
520 int32 ImFireAllTriggers(
int sound);
522 void addDeferredCommand(
int time,
int a,
int b,
int c,
int d,
int e,
int f);
523 void handleDeferredCommands(
MidiDriver *midi);
525 int enqueue_command(
int a,
int b,
int c,
int d,
int e,
int f,
int g);
526 int enqueue_trigger(
int sound,
int marker);
527 int clear_queue()
override;
528 int query_queue(
int param);
529 Player *findActivePlayer(
int id);
531 int get_volchan_entry(uint a);
532 int set_volchan_entry(uint a, uint b);
533 int set_channel_volume(uint chan, uint vol);
534 void update_volumes();
537 int set_volchan(
int sound,
int volchan);
539 void fix_parts_after_load();
541 int setImuseMasterVolume(uint vol);
544 bool reassignChannelAndResumePart(
MidiChannel *mc);
545 void suspendPart(
Part *part);
546 void removeSuspendedPart(
Part *part);
547 void reallocateMidiChannels(
MidiDriver *midi);
548 void setGlobalInstrument(byte slot, byte *data);
549 void copyGlobalInstrument(byte slot,
Instrument *dest);
550 bool isNativeMT32() {
return _native_mt32; }
557 bool startSound_internal(
int sound,
int offset = 0);
558 int stopSound_internal(
int sound);
559 int stopAllSounds_internal();
560 int getSoundStatus_internal(
int sound,
bool ignoreFadeouts)
const;
561 int32 doCommand_internal(
int a,
int b,
int c,
int d,
int e,
int f,
int g,
int h);
562 int32 doCommand_internal(
int numargs,
int args[]);
566 void pause(
bool paused)
override;
568 bool get_sound_active(
int sound)
const override;
569 int32 doCommand(
int numargs,
int args[])
override;
570 uint32 property(
int prop, uint32 value)
override;
571 void addSysexHandler(byte mfgID, sysexfunc handler)
override;
574 void startSoundWithNoteOffset(
int sound,
int offset)
override;
577 void setMusicVolume(
int vol)
override;
578 void setSfxVolume(
int vol)
override;
579 void startSound(
int sound)
override;
580 void stopSound(
int sound)
override;
581 void stopAllSounds()
override;
582 int getSoundStatus(
int sound)
const override;
583 int getMusicTimer()
override;
593 const bool _lowLevelVolumeControl;
Definition: imuse_internal.h:316
Definition: imuse_internal.h:98
Definition: imuse_internal.h:145
Definition: imuse_internal.h:404
MidiDriverFlags
Definition: mididrv.h:81
Definition: serializer.h:79
Definition: mididrv.h:309
Definition: imuse_internal.h:153
Definition: imuse_internal.h:476
Definition: mididrv.h:112
Definition: imuse_internal.h:166
Definition: serializer.h:308
Definition: mididrv.h:537
Definition: instrument.h:43
Definition: imuse_internal.h:93
Definition: imuse_internal.h:139
Definition: midiparser.h:289
Definition: imuse_internal.h:119