|
|
|
10-28-2021, 01:15 PM
|
#41
|
Human being with feelings
Join Date: Aug 2011
Location: Los Angeles, CA
Posts: 308
|
By the way has the situation changed regarding the playback start issue, or is it still a problem to determine where the latest playthrough starts?
The Cubase behavior seems the most correct when using retrospective record during playback, i.e. the buffer gets cleared every time you start playing after hitting play.
|
|
|
10-28-2021, 01:39 PM
|
#42
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
|
Quote:
Originally Posted by paaltio
By the way has the situation changed regarding the playback start issue, or is it still a problem to determine where the latest playthrough starts?
The Cubase behavior seems the most correct when using retrospective record during playback, i.e. the buffer gets cleared every time you start playing after hitting play.
|
Yes, internal buffer clearing is also planned (though it will not be actually cleared, only filtered for adding).
|
|
|
10-28-2021, 02:04 PM
|
#43
|
Human being with feelings
Join Date: Aug 2011
Location: Los Angeles, CA
Posts: 308
|
Quote:
Originally Posted by mpl
Yes, internal buffer clearing is also planned (though it will not be actually cleared, only filtered for adding).
|
Sounds great, thanks!
|
|
|
11-01-2021, 07:53 AM
|
#44
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
There's a function missing for flushing the buffer. Will make a FR for that later.
|
|
|
12-04-2022, 07:52 AM
|
#45
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
I came across this issue about MIDI_GetRecentInputEvent
Code:
local retval, buf, ts, devIdx, projPos, projLoopCnt = reaper.MIDI_GetRecentInputEvent(0)
local stateCur, keyCur=string.byte(buf,1), string.byte(buf,2)
At first it worked, but after a while, suddenly the stateCur value was always 128, even I was keep pressing the midi key(built in virtual midi keyboard). Then I restart Reaper, and it became normal again. I'm not sure if it happend after I woke up the system from sleep(Win10).
|
|
|
01-18-2024, 11:25 AM
|
#46
|
Human being with feelings
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
|
Guys, hello! I apologize for the necroposting, I found this topic in Google.
Is there a way inside the Defer function to get NoteOff data “in real time”? I see that the data for each subsequent note arrives sequentially, but I have absolutely no idea how to separate the notes in the stream and assign NoteOff (releasing the key of one note while another is playing, for example) to the notes individually.
|
|
|
01-18-2024, 01:49 PM
|
#47
|
Human being with feelings
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
|
Quote:
Originally Posted by cool
Guys, hello! I apologize for the necroposting, I found this topic in Google.
Is there a way inside the Defer function to get NoteOff data “in real time”? I see that the data for each subsequent note arrives sequentially, but I have absolutely no idea how to separate the notes in the stream and assign NoteOff (releasing the key of one note while another is playing, for example) to the notes individually.
|
Something like this:
Code:
---Get MIDI input. Use for get MIDI between defer loops.
---@param midi_last_retval number need to store the last MIDI retval from MIDI_GetRecentInputEvent. Start the script with `MIDILastRetval = reaper.MIDI_GetRecentInputEvent(0)` and feed it here. Optionally pass nill here and it will create a global variable called "MIDILastRetval_Hidden" and manage that alone.
---@return table midi_table midi table with all the midi values. each index have another table = {msg = midi message, ts = time, device = midi device idx}
---@return number midi_last_retval updated reval number.
function GetMIDIInput(last_retval)
local idx = 0
local first_retval
local midi_table = {}
local is_save_hidden_retval -- if not last_retval then it will save it in a global variable MIDILastRetval_Hidden and use it later
-- if last_retval == true then it will manage the retval alone.
if not last_retval then
if not MIDILastRetval_Hidden then
MIDILastRetval_Hidden = reaper.MIDI_GetRecentInputEvent(0)
last_retval = MIDILastRetval_Hidden
else
last_retval = MIDILastRetval_Hidden
end
is_save_hidden_retval = true
end
-- Get all recent inputs
while true do
local retval, msg, ts, device_idx = reaper.MIDI_GetRecentInputEvent(idx)
if idx == 0 then
first_retval = retval
end
if retval == 0 or retval == last_retval then
last_retval = first_retval
if is_save_hidden_retval then
MIDILastRetval_Hidden = first_retval
end
return midi_table, last_retval
end
midi_table[#midi_table+1] = {msg = msg, ts = ts, device = device_idx}
idx = idx + 1
end
end
---Unpack a packed string MIDI message in different values
---@param msg string midi as packed string
---@return number msg_type midi message type: Note Off = 8; Note On = 9; Aftertouch = 10; CC = 11; Program Change = 12; Channel Pressure = 13; Pitch Vend = 14; text = 15.
---@return number msg_ch midi message channel 1 based (1-16)
---@return number data2 databyte1 -- like note pitch, cc num
---@return number data3 databyte2 -- like note velocity, cc val. Some midi messages dont have databyte2 and this will return nill. For getting the value of the pitchbend do databyte1 + databyte2
---@return string text if message is a text return the text
---@return table allbytes all bytes in a table in order, starting with statusbyte. usefull for longer midi messages like text
function UnpackMIDIMessage(msg)
local msg_type = msg:byte(1)>>4
local msg_ch = (msg:byte(1)&0x0F)+1 --msg:byte(1)&0x0F -- 0x0F = 0000 1111 in binary. this is a bitmask. +1 to be 1 based
local text
if msg_type == 15 then
text = msg:sub(3)
end
local val1 = msg:byte(2)
local val2 = (msg_type ~= 15) and msg:byte(3) -- return nil if is text
return msg_type,msg_ch,val1,val2,text,msg
end
function loop()
local midi_in = GetMIDIInput()
for k, midi_table in ipairs(midi_in) do
--midi_table:
--msg: string midi message
--ts: n time
--device: n midi device idx
local type, ch, data1, data2 = UnpackMIDIMessage(midi_table.msg)
if type == 9 and data2 ~= 0 then -- filter note ON
print('note:', data1)
elseif type == 8 or type == 9 and data2 == 0 then -- filter note OFF
print('noteoff:', data1)
end
end
reaper.defer(loop)
end
reaper.defer(loop)
|
|
|
01-18-2024, 11:40 PM
|
#48
|
Human being with feelings
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 957
|
Quote:
Originally Posted by daniellumertz
Something like this:
code
|
Thank you! Looks quite complicated, I'll try to figure it out.
At least I see that the script allows to get independent NoteOffs, this is good news for me.
|
|
|
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 02:03 AM.
|