Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 06-29-2016, 02:21 PM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,572
Default ReaScript: MIDI_GetNote returns endppqpos different from visual appearance in editor

Standard MIDI specifications do not provide for overlapping notes. However, overlapping notes can exist in REAPER's MIDI editor (at least temporarily, but they are quite unstable), and the MIDI editor can remember the correct starting PPQ position and endpoint for each overlapping note.

The problem is that the ReaScript MIDI_GetNote function does not always return the same endpoint PPQ value as displayed in the MIDI editor. Instead, MIDI_GetNote sometimes returns the PPQ position of the first note-off after the note's note-on. According to MIDI specifications, the first note-off is indeed the correct endpoint for the note - but it does not correspond to what the user sees in the MIDI editor.

I suggest that MIDI_GetNote should always return the endpoint PPQ that the MIDI editor itself uses. That way, what the script sees and what the script does will correspond to what the user sees and would like to do.

(REAPER v5.21.)
juliansader is online now   Reply With Quote
Old 06-29-2016, 03:23 PM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 5,937
Default

If it helps, FNG_GetMidiNoteIntProperty(midiNote) can return the length directly - note that midiNote in this case is a special data type for the FNG functions, so you have to use the other FNG stuff with it:

Code:
...
local take = reaper.MIDIEditor_GetTake(editor_hwnd)
local FNG_take = reaper.FNG_AllocMidiTake(take)
local FNG_note = reaper.FNG_GetMidiNote(take, index)
local length = reaper.FNG_GetMidiNoteIntProperty(FNG_note, "LENGTH")
I have no idea what format the length is returned in, but I would assume PPQ. If not, you've got all the conversion functions for PPQ<->QN<->Time on hand.
Lokasenna is online now   Reply With Quote
Old 06-30-2016, 10:07 PM   #3
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,572
Default

Quote:
Originally Posted by Lokasenna View Post
If it helps, FNG_GetMidiNoteIntProperty(midiNote) can return the length directly - note that midiNote in this case is a special data type for the FNG functions, so you have to use the other FNG stuff with it:

Code:
...
local take = reaper.MIDIEditor_GetTake(editor_hwnd)
local FNG_take = reaper.FNG_AllocMidiTake(take)
local FNG_note = reaper.FNG_GetMidiNote(take, index)
local length = reaper.FNG_GetMidiNoteIntProperty(FNG_note, "LENGTH")
I have no idea what format the length is returned in, but I would assume PPQ. If not, you've got all the conversion functions for PPQ<->QN<->Time on hand.
Thanks! I will test FNG_GetMidiNoteIntProperty to check if it always returns the displayed length.

(One must be careful about not running FNG_FreeMidiTake at the end, since that function automatically 'corrects' all overlapping notes in the take, which may not be what the user wants.)
juliansader is online now   Reply With Quote
Old 12-17-2017, 05:54 PM   #4
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,339
Default

Julian, how did you like the FNG MIDI commands? Are they more reliable than the default ones? I have the same problem concerning the note length.
It only works correctly if I turn off "MIDI_Sort":
https://forum.cockos.com/showthread.php?p=1927325
_Stevie_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.