Author Topic: translate MIDI_EVENT to MidiMsg  (Read 116 times)

johnvantelli

  • Posts: 86
translate MIDI_EVENT to MidiMsg
« on: 31 Mar '23 - 21:45 »
I'm trying to complete my MIDI_EVENT_to_MidiMsg function that converts BASS EVENTS
in MidiMsg for Windows but I need help from someone more experienced than me.

Code: [Select]
MIDI_EVENT_NOTE:         midiMsg := $90 or ch or (par shl 8);
MIDI_EVENT_PROGRAM:      midiMsg := $C0 or ch or (par shl 8);
MIDI_EVENT_CHANPRES:     midiMsg := $D0 or ch or (par shl 8);
MIDI_EVENT_PITCH:        midiMsg := $E0 or (par and $7F) or ((par shr 7) and $7F);
MIDI_EVENT_BANK:         midiMsg := $B0 or ch or (0 shl 8) or (par shl 16);
MIDI_EVENT_MODULATION:   midiMsg := $B0 or ch or (1 shl 8) or (par shl 16);
MIDI_EVENT_PORTATIME:    midiMsg := $B0 or ch or (5 shl 8) or (par shl 16);
MIDI_EVENT_VOLUME:       midiMsg := $B0 or ch or (7 shl 8) or (par shl 16);
MIDI_EVENT_PAN:          midiMsg := $B0 or ch or (10 shl 8) or (par shl 16);
MIDI_EVENT_EXPRESSION:   midiMsg := $B0 or ch or (11 shl 8) or (par shl 16);
MIDI_EVENT_BANK_LSB:     midiMsg := $B0 or ch or (32 shl 8) or (par shl 16);
MIDI_EVENT_SUSTAIN:      midiMsg := $B0 or ch or (64 shl 8) or (par shl 16);
MIDI_EVENT_PORTAMENTO:   midiMsg := $B0 or ch or (65 shl 8) or (par shl 16);
MIDI_EVENT_SOSTENUTO:    midiMsg := $B0 or ch or (66 shl 8) or (par shl 16);
MIDI_EVENT_SOFT:         midiMsg := $B0 or ch or (67 shl 8) or (par shl 16);
MIDI_EVENT_RESONANCE:    midiMsg := $B0 or ch or (71 shl 8) or (par shl 16);
MIDI_EVENT_RELEASE:      midiMsg := $B0 or ch or (72 shl 8) or (par shl 16);
MIDI_EVENT_ATTACK:       midiMsg := $B0 or ch or (73 shl 8) or (par shl 16);
MIDI_EVENT_CUTOFF:       midiMsg := $B0 or ch or (74 shl 8) or (par shl 16);
MIDI_EVENT_DECAY:        midiMsg := $B0 or ch or (75 shl 8) or (par shl 16);
MIDI_EVENT_PORTANOTE:    midiMsg := $B0 or ch or (84 shl 8) or (par shl 16);
MIDI_EVENT_REVERB:       midiMsg := $B0 or ch or (91 shl 8) or (par shl 16);
MIDI_EVENT_CHORUS:       midiMsg := $B0 or ch or (93 shl 8) or (par shl 16);
MIDI_EVENT_SOUNDOFF:     midiMsg := $B0 or ch or (120 shl 8);
MIDI_EVENT_RESET:        midiMsg := $B0 or ch or (121 shl 8);
MIDI_EVENT_NOTESOFF:     midiMsg := $B0 or ch or (123 shl 8);

I'm not able to find how to convert these BASS MIDI EVENTS but
I think this may be useful for other users

Code: [Select]
MIDI_EVENT_PITCHRANGE      = 5;
MIDI_EVENT_DRUMS           = 6;
MIDI_EVENT_FINETUNE        = 7;
MIDI_EVENT_COARSETUNE      = 8;
MIDI_EVENT_MASTERVOL       = 9;
MIDI_EVENT_PORTATIME       = 20;
MIDI_EVENT_MODE            = 22;
MIDI_EVENT_REVERB_MACRO    = 30;
MIDI_EVENT_CHORUS_MACRO    = 31;
MIDI_EVENT_REVERB_TIME     = 32;
MIDI_EVENT_REVERB_DELAY    = 33;
MIDI_EVENT_REVERB_LOCUTOFF = 34;
MIDI_EVENT_REVERB_HICUTOFF = 35;
MIDI_EVENT_REVERB_LEVEL    = 36;
MIDI_EVENT_CHORUS_DELAY    = 37;
MIDI_EVENT_CHORUS_DEPTH    = 38;
MIDI_EVENT_CHORUS_RATE     = 39;
MIDI_EVENT_CHORUS_FEEDBACK = 40;
MIDI_EVENT_CHORUS_LEVEL    = 41;
MIDI_EVENT_CHORUS_REVERB   = 42;
MIDI_EVENT_USERFX          = 43;
MIDI_EVENT_USERFX_LEVEL    = 44;
MIDI_EVENT_USERFX_REVERB   = 45;
MIDI_EVENT_USERFX_CHORUS   = 46;
MIDI_EVENT_DRUM_FINETUNE   = 50;
MIDI_EVENT_DRUM_COARSETUNE = 51;
MIDI_EVENT_DRUM_PAN        = 52;
MIDI_EVENT_DRUM_REVERB     = 53;
MIDI_EVENT_DRUM_CHORUS     = 54;
MIDI_EVENT_DRUM_CUTOFF     = 55;
MIDI_EVENT_DRUM_RESONANCE  = 56;
MIDI_EVENT_DRUM_LEVEL      = 57;
MIDI_EVENT_DRUM_USERFX     = 58;
MIDI_EVENT_SYSTEM          = 61;
MIDI_EVENT_TEMPO           = 62;
MIDI_EVENT_SCALETUNING     = 63;
MIDI_EVENT_CONTROL         = 64;
MIDI_EVENT_CHANPRES_VIBRATO = 65;
MIDI_EVENT_CHANPRES_PITCH  = 66;
MIDI_EVENT_CHANPRES_FILTER = 67;
MIDI_EVENT_CHANPRES_VOLUME = 68;
MIDI_EVENT_MOD_VIBRATO     = 69;
MIDI_EVENT_MODRANGE        = 69;
MIDI_EVENT_KEYPRES         = 71;
MIDI_EVENT_KEYPRES_VIBRATO = 72;
MIDI_EVENT_KEYPRES_PITCH   = 73;
MIDI_EVENT_KEYPRES_FILTER  = 74;
MIDI_EVENT_KEYPRES_VOLUME  = 75;
MIDI_EVENT_MOD_PITCH       = 77;
MIDI_EVENT_MOD_FILTER      = 78;
MIDI_EVENT_MOD_VOLUME      = 79;
MIDI_EVENT_VIBRATO_RATE    = 80;
MIDI_EVENT_VIBRATO_DEPTH   = 81;
MIDI_EVENT_VIBRATO_DELAY   = 82;
MIDI_EVENT_MASTER_FINETUNE = 83;
MIDI_EVENT_MASTER_COARSETUNE = 84;

Can anyone help me complete this function?

Falcosoft

  • Posts: 134
Re: translate MIDI_EVENT to MidiMsg
« Reply #1 on: 1 Apr '23 - 11:09 »
Hi,
The majority of the remaining BASS MIDI EVENTS cannot be converted to a single short Midi message (that I suppose you want to send with the help of midiOutShortMsg WinMM function).
Some of them like MIDI_EVENT_PITCHRANGE  require a sequence of short Midi messages (to set RPN 0,0 in this case) or require SysEx messages like MIDI_EVENT_MASTERVOL (SysEx messages can be sent  only with midiOutLongMsg WinMM function).
To further complicate things some of the messages like MIDI_EVENT_DRUMS have to be translated to SysEx messages in case of GS mode but can be translated to bank select short messages in case of XG/GM2 mode.
And translating the Reverb and Chorus effect related events  requires different SysEx messages in case of GS and XG mode (MIDI_EVENT_REVERB_MACRO, MIDI_EVENT_CHORUS_MACRO, MIDI_EVENT_REVERB_TIME, etc.). 
So overall translating the remaining ones are much more complicated than the ready ones and I do not think it's worth the effort.
« Last Edit: 1 Apr '23 - 11:14 by Falcosoft »

Ian @ un4seen

  • Administrator
  • Posts: 25060
Re: translate MIDI_EVENT to MidiMsg
« Reply #2 on: 3 Apr '23 - 12:27 »
A few of those unhandled events are MIDI controlers, so you can do the same for them as you did for the other MIDI controller events:

Code: [Select]
MIDI_EVENT_VIBRATO_RATE:        midiMsg := $B0 or ch or (76 shl 8) or (par shl 16);
MIDI_EVENT_VIBRATO_DEPTH:       midiMsg := $B0 or ch or (77 shl 8) or (par shl 16);
MIDI_EVENT_VIBRATO_DELAY:       midiMsg := $B0 or ch or (78 shl 8) or (par shl 16);
MIDI_EVENT_USERFX:              midiMsg := $B0 or ch or (94 shl 8) or (par shl 16);
MIDI_EVENT_CONTROL:             midiMsg := $B0 or ch or (par shl 8);

As Falcosoft says, the rest of them won't fit in a single short message.