|
|
|
03-30-2019, 05:24 PM
|
#81
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
For starters, this change made an improvement:
Code:
...
-- note-off anywhere and note-on after mouse? mute
if note_on_selection[channel][2][pitch] then -- matching note-on tagged for
...
changed [flags&2] to just [2], because, unless note offs were already muted, flags&2 == 0
Last edited by FnA; 03-30-2019 at 05:32 PM.
|
|
|
03-31-2019, 05:38 AM
|
#82
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
FnA, you are my hero! I would not have found that so easily. Thank you!
|
|
|
03-31-2019, 07:01 AM
|
#83
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
You’re welcome. I didn’t thoroughly torture test it or anything. That was a change that first came to the front after trying it on simple item. I am kind of tight on time too at the moment so I’ll let you test it some more yourself when you can.
|
|
|
03-31-2019, 07:11 AM
|
#84
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
I definitely will do some in-depth tests! And more scripts in that manner to come: delete notes before and after mouse. And maybe I'm gonna try to finally nail the "delete under mouse" script.
|
|
|
04-04-2019, 05:39 PM
|
#85
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Okay, everything seems to work fine, did some testing and just released some new scripts, including the ones that have been in this thread for a while, now :P
https://forum.cockos.com/showpost.ph...&postcount=128
|
|
|
04-14-2019, 08:46 AM
|
#86
|
Human being with feelings
Join Date: Aug 2010
Location: They put me in a home.
Posts: 3,432
|
Script: sr_Select all events in CC lane before and under mouse cursor.lua
How can you select all notes and CC before mouse cursor? Please? I only have an action for selecting to the right Thanks!
*edit* sorry I didn't see the update in that thread you just posted to in the previous post. I will check that out.
__________________
47.8% of statistics are made up.
|
|
|
04-14-2019, 08:49 AM
|
#87
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
You mean, selecting CCs and notes? Ah, haven't coded that one, yet.
Good request, will put it on my list!
|
|
|
04-14-2019, 09:20 AM
|
#88
|
Human being with feelings
Join Date: Aug 2010
Location: They put me in a home.
Posts: 3,432
|
Quote:
Originally Posted by _Stevie_
You mean, selecting CCs and notes? Ah, haven't coded that one, yet.
Good request, will put it on my list!
|
Hi there. If that were possible you would absolutely blow my mind and change my whole day to day. Haha. Thank you. I wasn't sure if this would work but yes.
Select notes+CC before edit cursor (in selected item(s) or MIDI editor)
or just
Select notes+CC before edit cursor
Since we already had a to the right select notesCC
__________________
47.8% of statistics are made up.
|
|
|
11-23-2019, 11:22 AM
|
#89
|
Human being with feelings
Join Date: Aug 2016
Posts: 87
|
Quote:
Originally Posted by juliansader
In my scripts, I use a table to store the info of the last note-on in each channel, pitch and flag, so that later note-offs can be matched with the correct note-on.
You can store the channel, pitch and flags info as separate subtables:
Code:
tNoteons[chan][pitch][flags] = {whatever info}
or you can combine the channel, pitch and flag numbers into a single number:
Code:
noteID = (chan<<9) | (pitch<<2) | flags
tNoteons[noteID] = {...
This is an excerpt from one of my scripts:
Code:
-- While parsing the MIDI string, the indices of the last note-ons for each channel/pitch/flag must be temporarily stored until a matching note-off is encountered.
local runningNotes = {}
for channel = 0, 15 do
runningNotes[channel] = {}
for pitch = 0, 127 do
runningNotes[channel][pitch] = {} -- Each pitch will have flags as keys.
end
end
...
if eventType == 9 and msg:byte(3) ~= 0 then -- Note-ons
local channel = msg:byte(1)&0x0F
local pitch = msg:byte(2)
if runningNotes[channel][pitch][flags] then
reaper.ShowMessageBox("The script encountered overlapping notes.\n\nSuch notes are not valid MIDI, and can not be parsed.", "ERROR", 0)
return false
else
tNotes[#tNotes+1] = {noteOnIndex = e}
runningNotes[channel][pitch][flags] = #tNotes
end
elseif eventType == 8 or (eventType == 9 and msg:byte(3) == 0) then
local channel = msg:byte(1)&0x0F
local pitch = msg:byte(2)
local lastNoteOnIndex = runningNotes[channel][pitch][flags]
if lastNoteOnIndex then
tNotes[lastNoteOnIndex].noteOffIndex = e
runningNotes[channel][pitch][flags] = nil
end
|
Hello!
Might I perform some necromancy on this thread and ask you about how you save your MIDI data?
In the bit shift case: Do you perform any kind of type conversion? Or do you unpack the data to an int and just push it up the bits in the data integer?
Also, I studied some of the threads and examples, however, is there a basic introduction into REAPER's MIDI data conventions? Would you be open to answer a set of (quite basic) questions if I prepare them diligently and precisely?
I found your previous answers to my questions most insightful, thank you for that! :-)
Cheers,
Lukas
|
|
|
11-30-2019, 05:04 AM
|
#90
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by LuCsa
Hello!
Might I perform some necromancy on this thread and ask you about how you save your MIDI data?
|
MIDI gets downloaded and uploaded to REAPER as strings using MIDI_GetAllEvts and MIDI_SetAllEvts.
Strings aren't easy to manipulate in Lua, whereas tables are. Fortunately, it is easy -- and fast -- to convert tables to strings using table.concat.
I therefore convert the original string into a table of short strings, edit them as necessary, and then upload using reaper.MIDI_SetAllEvts(table.concat(myMidiTable)).
Quote:
Originally Posted by LuCsa
In the bit shift case: Do you perform any kind of type conversion? Or do you unpack the data to an int and just push it up the bits in the data integer?
|
When unpacking the initial MIDI string, or when storing the info in tables, the char gets converted to an integer byte, so no further conversion is necessary before bit shifting. If the integer becomes a float while applying some mathematical operations, just make sure that you round to an integer before bit shifting.
Quote:
Originally Posted by LuCsa
Would you be open to answer a set of (quite basic) questions if I prepare them diligently and precisely?
|
The API help documentation gives some basic information about formatting, and you can also check the raw MIDI info in the MIDI editor itself.
Quote:
Originally Posted by LuCsa
Would you be open to answer a set of (quite basic) questions if I prepare them diligently and precisely?
|
Ask away!
|
|
|
01-28-2020, 12:53 PM
|
#91
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Hoooray! @FnA and Julian: I finally could get my head around the last use case "select all notes under cursor". However, I literally found that out by creating another script: Nudge notes (mousehweel).
To sum it up:
I iterate thru the MIDI string and extract all the note-ons to a table.
On the second pass (re-iterating the MIDI string), I assign all the note-offs to their corresponding note-ons. That way, I have a column in the table that will contain the string position of the note-on and note-off.
When writing back the MIDI string, I can then only modify the desired notes, based on their position.
I'll upload the script to my repo in a few days.
|
|
|
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 01:58 AM.
|