|
|
|
09-14-2021, 07:34 AM
|
#1
|
Human being with feelings
Join Date: Feb 2019
Location: Austin, TX
Posts: 413
|
MIDI Editor: how to determine if last note
I think I understand how to work If [note is selected] then
DO THIS but I want to specify If [note is selected] then
If [is selected note the last note?] then —how do I do this??
DO THIS else
DO THAT I thought MIDI_EnumSelNotes but now I’m completely stumped.
In my searching for answers I came across these additional functions, like FNG_GetMidiNote which are apparently SWS functions… now I feel stumped in the dark!
Hoping for a wise guide to help me find my way…
|
|
|
09-14-2021, 08:32 AM
|
#2
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Not a MIDI guy (so maybe someone knows a better way), but in one script I made I put the index of the selected notes into a table first, then I loop thru that table to do stuff.
So one way might be to use the length of the table to determine if the last selected note, something like,...
Code:
local take=reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive())
if take ~= nil then
-- add selected notes index to a table
local cnt, index = 0, {}
local val = reaper.MIDI_EnumSelNotes(take, -1)
while val ~= - 1 do
cnt = cnt + 1
index[cnt] = val
val = reaper.MIDI_EnumSelNotes(take, val)
end
-- loop thru selected note table
for i = 1, #index do
local retval, sel, muted, ppq_start, ppq_end, chan, pitch, vel = reaper.MIDI_GetNote(take, index[i])
if i ~= #index then
-- do this
reaper.ShowConsoleMsg("Sel note #" .. i .. ", pitch = " .. pitch ..'\n')
else
-- do this for last selected note
reaper.ShowConsoleMsg("Last sel note #" .. i .. ", pitch = " .. pitch ..'\n')
end
end
end
|
|
|
09-14-2021, 08:47 AM
|
#3
|
Human being with feelings
Join Date: Feb 2019
Location: Austin, TX
Posts: 413
|
Ah! I was on this path last night but fell into the abyss. 🤪
In my case, I mean "last note" to refer to the last note in the current MIDI take, but I think this should help me get back on track. Thank you!!
|
|
|
09-14-2021, 08:57 AM
|
#4
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Maybe use the reaper.MIDI_CountEvts() function?
Doc says, Count the number of notes, CC events, and text/sysex events in a given MIDI item.
EDIT seems to work as expected here,
Code:
take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive())
retval, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts(take)
reaper.ShowConsoleMsg( notecnt ) -- number of notes in take
Last edited by Edgemeal; 09-14-2021 at 09:10 AM.
|
|
|
09-14-2021, 08:58 AM
|
#5
|
Human being with feelings
Join Date: Feb 2019
Location: Austin, TX
Posts: 413
|
working with that now... will report back, hopefully with success!
Thanks again!
|
|
|
09-16-2021, 01:20 PM
|
#6
|
Human being with feelings
Join Date: Feb 2019
Location: Austin, TX
Posts: 413
|
Quote:
Originally Posted by Edgemeal
Maybe use the reaper.MIDI_CountEvts() function?
Doc says, Count the number of notes, CC events, and text/sysex events in a given MIDI item.
EDIT seems to work as expected here,
Code:
take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive())
retval, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts(take)
reaper.ShowConsoleMsg( notecnt ) -- number of notes in take
|
THANK YOU!! This got me back up and running and I was able to accomplish EXACTLY what I set out to do!
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:33 PM.
|