Author Topic: it's possible to add this feature?  (Read 260 times)

MIDAPMI

  • Posts: 19
it's possible to add this feature?
« on: 8 Nov '18 - 07:29 »

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: it's possible to add this feature?
« Reply #1 on: 8 Nov '18 - 17:35 »
Sorry, there are currently no plans for that in BASSMIDI. Delaying note-offs (or any other events) is something that can be implemented by the app, ie. it can send them to BASSMIDI later.

MIDAPMI

  • Posts: 19
Re: it's possible to add this feature?
« Reply #2 on: 9 Nov '18 - 03:21 »
Sorry, there are currently no plans for that in BASSMIDI. Delaying note-offs (or any other events) is something that can be implemented by the app, ie. it can send them to BASSMIDI later.
yes, the omni midi owner are interested on this. is a well ideas! but how to implement?

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: it's possible to add this feature?
« Reply #3 on: 9 Nov '18 - 13:37 »
The delay could be implemented by using a non-0 "pos" or "tick" value in a BASS_MIDI_StreamEvents call. A realtime synth/driver would probably be using BASS_MIDI_StreamCreate to create the MIDI stream, which means it won't have ticks, so it would have to use the "pos" option. For example, like this:

Code: [Select]
BASS_MIDI_EVENT e;
e.event = MIDI_EVENT_NOTE;
e.param = MAKEWORD(note, 0);
e.chan = channel;
e.pos = delay;
e.tick = 0;
BASS_MIDI_StreamEvents(midi, BASS_MIDI_EVENTS_STRUCT|BASS_MIDI_EVENTS_TIME, &e, 1); // process the event

BASS_ChannelSeconds2Bytes could be used to calculate the "delay" value (pre-calculate if it will be constant).

KaleidonKep99

  • Posts: 191
Re: it's possible to add this feature?
« Reply #4 on: 10 Nov '18 - 07:15 »
The delay could be implemented by using a non-0 "pos" or "tick" value in a BASS_MIDI_StreamEvents call. A realtime synth/driver would probably be using BASS_MIDI_StreamCreate to create the MIDI stream, which means it won't have ticks, so it would have to use the "pos" option. For example, like this:

Code: [Select]
BASS_MIDI_EVENT e;
e.event = MIDI_EVENT_NOTE;
e.param = MAKEWORD(note, 0);
e.chan = channel;
e.pos = delay;
e.tick = 0;
BASS_MIDI_StreamEvents(midi, BASS_MIDI_EVENTS_STRUCT|BASS_MIDI_EVENTS_TIME, &e, 1); // process the event

BASS_ChannelSeconds2Bytes could be used to calculate the "delay" value (pre-calculate if it will be constant).

This should be correct, right?
Code: [Select]
if ((((dwParam1 & 0xFF) & 0xF0) == 0x90 && ((dwParam1 >> 16) & 0xFF))) {
BASS_MIDI_EVENT e[2];
memset(e, 0, sizeof(e));

e[0].event = MIDI_EVENT_NOTE;
e[0].param = MAKEWORD(HIBYTE(LOWORD(dwParam1)), LOBYTE(HIWORD(dwParam1)));
e[0].chan = dwParam1 & 0xF;
e[0].pos = 0;
e[0].tick = 0;

e[1].event = MIDI_EVENT_NOTE;
e[1].param = MAKEWORD(HIBYTE(LOWORD(dwParam1)), 0);
e[1].chan = dwParam1 & 0xF;
e[1].pos = BASS_ChannelSeconds2Bytes(OMStream, 0.5);
e[1].tick = 0;

BASS_MIDI_StreamEvents(OMStream, BASS_MIDI_EVENTS_STRUCT | BASS_MIDI_EVENTS_TIME, &e, 2);
return;
}
else if (((dwParam1 & 0xFF) & 0xF0) == 0x80) return;

Now, the issue is... The length of a quarter note varies depending on the tempo.
While it's 0.5s for 120BPM, this won't fit for songs with a lower or higher tempo.
I'll figure something out for that...

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: it's possible to add this feature?
« Reply #5 on: 12 Nov '18 - 13:37 »
Are you not forwarding events to BASSMIDI as you receive them? If you are, the note-on will have already been sent, so no need to send that again. You might do something like this to only delay note-offs:

Code: [Select]
if ((dwParam1 & 0xF0) == 0x80 || ((dwParam1 & 0xF0) == 0x90 && !((dwParam1 >> 16) & 0xFF))) { // note-off event
BASS_MIDI_EVENT e;
e.event = MIDI_EVENT_NOTE;
e.param = MAKEWORD((dwParam1 >> 8) & 0xFF, 0);
e.chan = dwParam1 & 15;
e.pos = delay;
e.tick = 0;
BASS_MIDI_StreamEvents(midi, BASS_MIDI_EVENTS_STRUCT|BASS_MIDI_EVENTS_TIME, &e, 1);
} else {
// normal processing here...
}

KaleidonKep99

  • Posts: 191
Re: it's possible to add this feature?
« Reply #6 on: 12 Nov '18 - 16:20 »
Are you not forwarding events to BASSMIDI as you receive them? If you are, the note-on will have already been sent, so no need to send that again. You might do something like this to only delay note-offs:

Code: [Select]
if ((dwParam1 & 0xF0) == 0x80 || ((dwParam1 & 0xF0) == 0x90 && !((dwParam1 >> 16) & 0xFF))) { // note-off event
BASS_MIDI_EVENT e;
e.event = MIDI_EVENT_NOTE;
e.param = MAKEWORD((dwParam1 >> 8) & 0xFF, 0);
e.chan = dwParam1 & 15;
e.pos = delay;
e.tick = 0;
BASS_MIDI_StreamEvents(midi, BASS_MIDI_EVENTS_STRUCT|BASS_MIDI_EVENTS_TIME, &e, 1);
} else {
// normal processing here...
}
Oh no, I am forwarding them to BASSMIDI!
The entire if-else statement is inside another if statement:
Code: [Select]
if (OverrideNoteOff) {
if ((((dwParam1 & 0xFF) & 0xF0) == 0x90 && ((dwParam1 >> 16) & 0xFF))) {
BASS_MIDI_EVENT e[2];
memset(e, 0, sizeof(e));

e[0].event = MIDI_EVENT_NOTE;
e[0].param = MAKEWORD(HIBYTE(LOWORD(dwParam1)), LOBYTE(HIWORD(dwParam1)));
e[0].chan = dwParam1 & 0xF;
e[0].pos = 0;
e[0].tick = 0;

e[1].event = MIDI_EVENT_NOTE;
e[1].param = MAKEWORD(HIBYTE(LOWORD(dwParam1)), 0);
e[1].chan = dwParam1 & 0xF;
e[1].pos = BASS_ChannelSeconds2Bytes(OMStream, 0.25);
e[1].tick = 0;

BASS_MIDI_StreamEvents(OMStream, BASS_MIDI_EVENTS_STRUCT | BASS_MIDI_EVENTS_TIME, &e, 2);
return;
}
else if (((dwParam1 & 0xFF) & 0xF0) == 0x80) return;
}

BASS_MIDI_StreamEvents(OMStream, BASS_MIDI_EVENTS_RAW, &dwParam1, len);

What I don't understand, if he wants to override the length of the note (which is what my code does), or delay the note off (which yours does)...
He clearly wanted to override the length here: https://github.com/KeppySoftware/OmniMIDI/issues/114

Ian @ un4seen

  • Administrator
  • Posts: 21329
Re: it's possible to add this feature?
« Reply #7 on: 12 Nov '18 - 16:48 »
Delaying the note-off makes the note longer :)

In an earlier thread, the same user mentioned a 13-18ms delay:

   www.un4seen.com/forum/?topic=18245

So I guess they will want something in that range for the delay.

KaleidonKep99

  • Posts: 191
Re: it's possible to add this feature?
« Reply #8 on: 12 Nov '18 - 17:05 »
Delaying the note-off makes the note longer :)

In an earlier thread, the same user mentioned a 13-18ms delay:

   www.un4seen.com/forum/?topic=18245

So I guess they will want something in that range for the delay.
Yet in the original issue I sent, he said he wanted to "override the length", which means either making it shorter or longer. :-\
If he wants the note to last *0.013 seconds* only, I guess I'll just use my code to allow him to make it either shorter or longer, depending on what he wants to do.

Thank you for your help btw, I wouldn't have figured it out without your example. ;D ;D