Old 10-15-2021, 05:52 AM   #1
manymanyhaha
Human being with feelings
 
Join Date: Jul 2009
Posts: 13
Default Generate a CC every quarter beat from Midi Clock?

Is it possible to write a script that will take a Midi Clock beat being input into Reaper(filtering out everything but F8 messages) and generate a CC every quarter beat?
manymanyhaha is offline   Reply With Quote
Old 10-15-2021, 06:09 AM   #2
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 654
Default

You can form a row of quarter notes, and then select the note to insert CC.
Code:
retval, shuzhi = reaper.GetUserInputs('insert CC 按选中音符 Multi Track', 3, 'CC Num=,CC Val=,Tick(-+)', '11,127,0')
if retval==false then return end
num_sub,val_sub,tick_sub=string.match(shuzhi,"(%d+),(%d+),([+-]?%d+)")
num=tonumber (num_sub)
val=tonumber (val_sub)  tick=tonumber (tick_sub)
local editor=reaper.MIDIEditor_GetActive()

takeindex = 0
take=reaper.MIDIEditor_EnumTakes(editor, takeindex, true)
while take~=nil do

retval,notecnt,ccevtcnt, extsyxevtcnt = reaper.MIDI_CountEvts(take)
tb={}
for i=0 ,notecnt,1 do
retval, sel, mute, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take, i)
if (sel==true)
then
tb[i]=startppqpos

if num >= 0 and num <= 127 then
if val >= 0 and val <= 127 then
reaper.MIDI_InsertCC(take, false,false, startppqpos+tick, 176, 0, num, val)
end
end
end
end

takeindex=takeindex+1
take=reaper.MIDIEditor_EnumTakes(editor, takeindex, true)
end -- while take end

if num >= 0 and num <= 119 then
ID = num + 40238
reaper.MIDIEditor_OnCommand(editor, ID)
end
reaper.SN_FocusMIDIEditor()
dangguidan is offline   Reply With Quote
Old 10-15-2021, 06:16 AM   #3
manymanyhaha
Human being with feelings
 
Join Date: Jul 2009
Posts: 13
Default

Wow, really? If so, that's amazing. I can't wait to find some time later to try this out, thank you!
manymanyhaha 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 07:45 AM.


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