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 MDPG_TAG "MDpg" 62 #define MUS_REDUCTION_TIMER_TICKS 16667 // 60 Hz 71 inline int clamp(
int val,
int min,
int max) {
79 inline int transpose_clamp(
int a,
int b,
int c) {
81 a += (b - a + 11) / 12 * 12;
83 a -= (a - c + 11) / 12 * 12;
103 byte _part_onoff[16];
104 byte _part_volume[16];
105 byte _part_program[16];
106 byte _part_transpose[16];
108 int query_param(
int param, byte chan);
109 int set(byte cls, byte value, byte chan);
113 memset(_jump, 0,
sizeof(_jump));
114 memset(_part_onoff, 0,
sizeof(_part_onoff));
115 memset(_part_volume, 0,
sizeof(_part_volume));
116 memset(_part_program, 0,
sizeof(_part_program));
117 memset(_part_transpose, 0,
sizeof(_part_transpose));
137 ParameterFader() : param(0), dir(0), incr(0), ifrac(0), irem(0), ttime(0), cntdwn(0), state(0) {}
138 void init() { param = 0; }
143 int a, b, c, d, e, f;
175 #ifdef SYSEX_CALLBACK_FUNCTION 176 friend void SYSEX_CALLBACK_FUNCTION(
Player *,
const byte *, uint16);
182 static uint16 _active_notes[128];
194 ParserType _parserType;
210 uint _loop_from_beat;
213 uint _loop_from_tick;
217 uint32 _transitionTimer;
230 bool _supportsPercussion;
236 void part_set_transpose(uint8 chan, byte relative, int8 b);
237 void maybe_jump(byte cmd, uint track, uint beat, uint tick);
238 void maybe_set_transpose(byte *data);
239 void maybe_part_onoff(byte *data);
240 void maybe_set_volume(byte *data);
241 void maybe_set_program(byte *data);
242 void maybe_set_transpose_part(byte *data);
243 void turn_off_pedals();
244 int query_part_param(
int param, byte chan);
245 void turn_off_parts();
246 void play_active_notes();
248 void transitionParameters();
250 static void decode_sysex_bytes(
const byte *src, byte *dst,
int len);
253 int start_seq_sound(
int sound,
bool reset_vars =
true);
254 void loadStartParameters(
int sound);
264 int addParameterFader(
int param,
int target,
int time);
268 Part *getActivePart(uint8 part);
270 int16 getDetune()
const {
return _detune; }
271 byte getEffectiveVolume()
const {
return _vol_eff; }
272 int getID()
const {
return _id; }
273 MidiDriver *getMidiDriver()
const {
return _midi; }
274 int getParam(
int param, byte chan);
275 int8 getPan()
const {
return _pan; }
276 Part *getPart(uint8 part);
277 byte getPriority()
const {
return _priority; }
278 uint getTicksPerBeat()
const {
return TICKS_PER_BEAT; }
279 int8 getTranspose()
const {
return _transpose; }
280 byte getVolume()
const {
return _volume; }
281 bool isActive()
const {
return _active; }
282 bool isFadingOut()
const;
283 bool isMIDI()
const {
return _isMIDI; }
284 bool isMT32()
const {
return _isMT32; }
285 bool jump(uint track, uint beat, uint tick);
287 void removePart(
Part *part);
288 int scan(uint totrack, uint tobeat, uint totick);
290 int setHook(byte cls, byte value, byte chan) {
return _hook.set(cls, value, chan); }
291 void setDetune(
int detune);
292 void setOffsetNote(
int offset);
293 bool setLoop(uint count, uint tobeat, uint totick, uint frombeat, uint fromtick);
294 void setPan(
int pan);
295 void setPriority(
int pri);
296 void setSpeed(byte speed);
297 int setTranspose(byte relative,
int b);
298 int setVolume(byte vol);
300 int getMusicTimer()
const;
304 void send(uint32 b)
override;
305 void sysEx(
const byte *msg, uint16 length)
override;
306 uint16 sysExNoDelay(
const byte *msg, uint16 length)
override;
307 void metaEvent(byte type, byte *data, uint16 length)
override;
325 byte _pitchbend_factor;
326 byte _volControlSensitivity;
327 int8 _transpose, _transpose_eff;
346 bool _unassigned_instrument;
351 void noteOff(byte note);
352 void noteOn(byte note, byte velocity);
353 void programChange(byte value);
354 void pitchBend(int16 value);
355 void modulationWheel(byte value);
356 void volume(byte value);
357 void volControlSensitivity(byte value);
358 void pitchBendFactor(byte value);
359 void sustain(
bool value);
360 void effectLevel(byte value);
361 void chorusLevel(byte value);
364 void set_param(byte param,
int value) { }
365 void init(
bool useNativeMT32);
366 void setup(
Player *player);
369 void set_instrument(uint b);
370 void set_instrument(byte *data);
371 void load_global_instrument(byte b);
373 void set_transpose(int8 transpose, int8 clipRangeLow, int8 clipRangeHi);
374 void set_detune(int8 detune);
375 void set_pri(int8 pri);
376 void set_pan(int8 pan);
378 void set_polyphony(byte val);
379 void set_onoff(
bool on);
380 void fix_after_load();
383 bool clearToTransmit();
390 void sendPitchBend();
391 void sendVolume(int8 fadeModifier);
392 void sendVolumeFade();
393 void sendTranspose();
395 void sendPanPosition(uint8 value);
396 void sendEffectLevel(uint8 value);
397 void sendPolyphony();
416 #ifdef SYSEX_CALLBACK_FUNCTION 417 friend void SYSEX_CALLBACK_FUNCTION(
Player *,
const byte *, uint16);
422 const bool _native_mt32;
423 const bool _newSystem;
424 const bool _dynamicChanAllocation;
431 const uint32 _game_id;
449 bool _recycle_players;
451 int _musicVolumeReductionTimer = 0;
453 uint _queue_end, _queue_pos, _queue_sound;
460 byte _music_volume_eff;
462 uint16 _trigger_count;
464 uint16 _snm_trigger_index;
466 uint16 _channel_volume[8];
467 uint16 _channel_volume_eff[8];
468 uint16 _volchan_table[8];
480 RhyState(byte volume, byte polyphony, byte priority) : vol(volume), poly(polyphony), prio(priority) {}
492 static void midiTimerCallback(
void *data);
502 byte *findStartOfSound(
int sound,
int ct = (kMThd | kFORM));
503 bool isMT32(
int sound);
504 bool isMIDI(
int sound);
505 bool supportsPercussion(
int sound);
506 int get_queue_sound_status(
int sound)
const;
507 void handle_marker(uint
id, byte data);
508 int get_channel_volume(uint a);
517 Player *allocate_player(byte priority);
520 int32 ImSetTrigger(
int sound,
int id,
int a,
int b,
int c,
int d,
int e,
int f,
int g,
int h);
521 int32 ImClearTrigger(
int sound,
int id);
522 int32 ImFireAllTriggers(
int sound);
524 void addDeferredCommand(
int time,
int a,
int b,
int c,
int d,
int e,
int f);
525 void handleDeferredCommands(
MidiDriver *midi);
527 int enqueue_command(
int a,
int b,
int c,
int d,
int e,
int f,
int g);
528 int enqueue_trigger(
int sound,
int marker);
529 int clear_queue()
override;
530 int query_queue(
int param);
531 Player *findActivePlayer(
int id);
533 int get_volchan_entry(uint a);
534 int set_volchan_entry(uint a, uint b);
535 int set_channel_volume(uint chan, uint vol);
536 void update_volumes();
539 int set_volchan(
int sound,
int volchan);
541 void fix_parts_after_load();
543 int setImuseMasterVolume(uint vol);
546 bool reassignChannelAndResumePart(
MidiChannel *mc);
547 void suspendPart(
Part *part);
548 void removeSuspendedPart(
Part *part);
549 void reallocateMidiChannels(
MidiDriver *midi);
550 void setGlobalInstrument(byte slot, byte *data);
551 void copyGlobalInstrument(byte slot,
Instrument *dest);
552 bool isNativeMT32() {
return _native_mt32; }
559 bool startSound_internal(
int sound,
int offset = 0);
560 int stopSound_internal(
int sound);
561 int stopAllSounds_internal();
562 int getSoundStatus_internal(
int sound,
bool ignoreFadeouts)
const;
563 int32 doCommand_internal(
int a,
int b,
int c,
int d,
int e,
int f,
int g,
int h);
564 int32 doCommand_internal(
int numargs,
int args[]);
568 void pause(
bool paused)
override;
570 bool get_sound_active(
int sound)
const override;
571 int32 doCommand(
int numargs,
int args[])
override;
572 uint32 property(
int prop, uint32 value)
override;
573 void addSysexHandler(byte mfgID, sysexfunc handler)
override;
576 void startSoundWithNoteOffset(
int sound,
int offset)
override;
579 void setMusicVolume(
int vol)
override;
580 void startSound(
int sound)
override;
581 void stopSound(
int sound)
override;
582 void stopAllSounds()
override;
583 int getSoundStatus(
int sound)
const override;
584 int getMusicTimer()
override;
Definition: imuse_internal.h:318
Definition: imuse_internal.h:100
Definition: imuse_internal.h:147
Definition: imuse_internal.h:406
MidiDriverFlags
Definition: mididrv.h:81
Definition: serializer.h:79
Definition: mididrv.h:309
Definition: imuse_internal.h:155
Definition: imuse_internal.h:478
Definition: mididrv.h:112
Definition: imuse_internal.h:168
Definition: serializer.h:308
Definition: mididrv.h:537
Definition: instrument.h:43
Definition: imuse_internal.h:95
Definition: imuse_internal.h:141
Definition: midiparser.h:289
Definition: imuse_internal.h:121