Old 12-13-2020, 05:44 PM   #1
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default Delete a channel from a MIDI item

So I need for a script a part to delete all MIDI events from certain channels.

I have some doubts :O ,

1)why MIDI_GetEvt needs variables like ppqpos ? will it use it?
2)I tried use MIDI_GetEvt to know the event channel, but it seems the output is only binary? Any way to convert or this is not the right path?
3) If not MIDI_GetEvt should I use

--To know the channel
MIDI_GetCC
reaper.MIDI_GetNote

--if channel == want_to_delete_ch
reaper.MIDI_DeleteCC
reaper.MIDI_DeleteNote

besides CC and Notes anything more can be adress to channels?
daniellumertz is offline   Reply With Quote
Old 12-14-2020, 06:49 AM   #2
jrk
Human being with feelings
 
Join Date: Aug 2015
Posts: 2,969
Default

Is ppqpos a return value? It's ppqposOut in C, so I guess it is...

I dunno about the "endianness" of msg, but channel should be the second most significant nibble I think? Shouldn't be too hard to parse...
__________________
it's meant to sound like that...
jrk is offline   Reply With Quote
Old 12-14-2020, 11:18 AM   #3
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
Default

Pitchbend for example.
TonE is offline   Reply With Quote
Old 12-16-2020, 03:57 AM   #4
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

DeleteCC and DeleteNote should take care of everything. Pitchbends fall under CC, in this case.

Sysex and text events don't have channel information, so you can skip them.

REAPER's internal notation and CC envelope information is encoded inside text events, with channel info, but DeleteCC and DeleteNote should automatically delete all related notation and envelope events too.


EDIT: If you are working in the MIDI editor, ReaScripts don't play nice with multiple editable items (except if you are using one MIDI editor per project, and editability is linked to item selection). To reach all events in all editable items, the Filter Events dialog can be used to select everything in a channel, which can then be deleted.

Last edited by juliansader; 12-16-2020 at 04:05 AM.
juliansader is offline   Reply With Quote
Old 12-16-2020, 01:43 PM   #5
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

thaks for the help julian sanders! good to know delete note and CC should do it will get back to work in my script soon !
daniellumertz is offline   Reply With Quote
Old 12-19-2020, 01:35 AM   #6
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

@jualiansanders, the text events don't have an channel inside reaper ? ( I don't know if inside the .mid they have, but when importing an .mid it can changes the track names according to the text events, wondering if they have an channel after importing.

For future readers I am using this to solo an MIDI Channel

Code:
 
function SoloChannel(item, ch) 
    local take = reaper.GetMediaItemTake( item, 0 )
    local retval, notecnt, ccevtcnt, textsyxevtcnt = reaper.MIDI_CountEvts( take )
    --NOTES
    for i = notecnt, 1, -1  do
        local retval, selected, muted, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take, i-1)
        if ch ~= 0 and chan ~= (ch-1) then
            reaper.MIDI_DeleteNote(take, i-1)
        end
    end
    --CC
    for i = ccevtcnt, 1, -1  do
        local retval, selected, muted, ppqpos, chanmsg, chan, msg2, msg3 = reaper.MIDI_GetCC( take, i-1 )
        if ch ~= 0 and chan ~= (ch-1) then
            reaper.MIDI_DeleteCC( take, i-1 )
        end
    end
end

Last edited by daniellumertz; 12-19-2020 at 01:40 AM.
daniellumertz is offline   Reply With Quote
Old 12-24-2020, 10:34 PM   #7
zaibuyidao
Human being with feelings
 
Join Date: Jan 2020
Location: Amoy
Posts: 179
Default

The script can delete the events of the specified MIDI channel.

https://github.com/zaibuyidao/ReaScr...l%20Events.lua
zaibuyidao is online now   Reply With Quote
Old 12-25-2020, 01:55 PM   #8
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by daniellumertz View Post
@jualiansanders, the text events don't have an channel inside reaper ? ( I don't know if inside the .mid they have, but when importing an .mid it can changes the track names according to the text events, wondering if they have an channel after importing.
The ones that you are referring to are probably "Track name" text events. REAPER will automatically name MIDI tracks according to these events, but they do not carry channel info, and apply to the whole track and all channel inside it.
juliansader is offline   Reply With Quote
Old 12-26-2020, 01:27 AM   #9
bjclulu
Human being with feelings
 
Join Date: Feb 2016
Posts: 52
Default

Quote:
Originally Posted by zaibuyidao View Post
The script can delete the events of the specified MIDI channel.

https://github.com/zaibuyidao/ReaScr...l%20Events.lua
Hi zaibuyidao
I get this error :
zaibuyidao_Delete Channel Events.lua:7: unexpected symbol near '<'

Thank you !
bjclulu is offline   Reply With Quote
Old 12-26-2020, 02:52 AM   #10
zaibuyidao
Human being with feelings
 
Join Date: Jan 2020
Location: Amoy
Posts: 179
Default

Quote:
Originally Posted by bjclulu View Post
Hi zaibuyidao
I get this error :
zaibuyidao_Delete Channel Events.lua:7: unexpected symbol near '<'

Thank you !
The code may not be fully copied?

Please try this, see attachment.

In addition, the script requires SWS to be installed. If not installed, please download here:

https://www.sws-extension.org/
Attached Files
File Type: lua zaibuyidao_Delete Channel Events.lua (4.5 KB, 63 views)
zaibuyidao is online now   Reply With Quote
Old 12-26-2020, 03:45 AM   #11
bjclulu
Human being with feelings
 
Join Date: Feb 2016
Posts: 52
Default

Quote:
Originally Posted by zaibuyidao View Post
The code may not be fully copied?

Please try this, see attachment.

In addition, the script requires SWS to be installed. If not installed, please download here:

https://www.sws-extension.org/
Hi zaibuyidao


感謝!! 現在OK沒問題了!
bjclulu is offline   Reply With Quote
Old 12-01-2021, 04:01 AM   #12
GeneralMidi
Human being with feelings
 
Join Date: Dec 2020
Posts: 226
Default

Quote:
Originally Posted by juliansader View Post
The ones that you are referring to are probably "Track name" text events. REAPER will automatically name MIDI tracks according to these events, but they do not carry channel info, and apply to the whole track and all channel inside it.
I have imported midi items and they all have text event cc lanes, although nothing is visible in these text event lanes. I use the action "show used cc lanes" and I'd like to remove these text event lanes from the midi item. Is it possible?
GeneralMidi is offline   Reply With Quote
Old 12-01-2021, 07:30 AM   #13
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

You want a script to automatically delete all text events of selected midi items?
daniellumertz is offline   Reply With Quote
Old 12-01-2021, 07:39 AM   #14
GeneralMidi
Human being with feelings
 
Join Date: Dec 2020
Posts: 226
Default

Not particularly. I just can't find a way of deleting the text events (none are visible in the lane to manually select and delete).

Whenever I use the action "show used cc lanes", the text event lane is displayed, even though there is nothing visibly there...
GeneralMidi 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 11:13 PM.


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