• 注意:这个脚本设定的弯音范围是12个半音,并非通用的2个半音。如果使用VSTi插件,需要设置弯音范围为12。

    当然,也可以通过发送MIDI控制器信息来设置弯音范围:

    MIDI cc101 = 0
    MIDI cc100 = 0
    MIDI cc6 = 12
    

    弯音的完整数值范围为 -8192 到 8191 之间,将8191除于12得到每一个半音为683。利用表存储这12个半音的数值,再通过用户输入获得弯音参数。比如,用户输入1得到683的数值。脚本最终再将参数拆分为低7位 LSB 和高7位 MSB ,插入CC。以下为代码内容:

    --[[
        Description: 插入弯音(半音值)
        Version: 1.0.2
        Author: 再補一刀
    ]]--
    
    local take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive())
    local pos = reaper.GetCursorPositionEx(0)
    local ppq = reaper.MIDI_GetPPQPosFromProjTime(take, pos)
    local retval, userinput = reaper.GetUserInputs('Insert Wheel', 1, 'Wheel Value =', '0')
    if not retval then return reaper.SN_FocusMIDIEditor() end
    userinput = tonumber(userinput)
    if userinput > 12 or userinput < -12 then return reaper.MB( "数值超出!\n取值范围 -12 到 12 之间.", "错误", 0 ), reaper.SN_FocusMIDIEditor() end
    
    tbl={}
    tbl["12"]="8191"
    tbl["11"]="7513"
    tbl["10"]="6830"
    tbl["9"]="6147"
    tbl["8"]="5464"
    tbl["7"]="4781"
    tbl["6"]="4098"
    tbl["5"]="3415"
    tbl["4"]="2732"
    tbl["3"]="2049"
    tbl["2"]="1366"
    tbl["1"]="683"
    tbl["0"]="0"
    tbl["-1"]="-683"
    tbl["-2"]="-1366"
    tbl["-3"]="-2049"
    tbl["-4"]="-2732"
    tbl["-5"]="-3415"
    tbl["-6"]="-4098"
    tbl["-7"]="-4781"
    tbl["-8"]="-5464"
    tbl["-9"]="-6147"
    tbl["-10"]="-6830"
    tbl["-11"]="-7513"
    tbl["-12"]="-8192"
    
    local value = tonumber(tbl[tostring(userinput)])
    value = value + 8192
    local lsb = value & 0x7f
    local msb = value >> 7 & 0x7f
    reaper.MIDI_InsertCC(take, false, false, ppq, 224, 0, lsb, msb)
    reaper.UpdateArrange()
    reaper.SN_FocusMIDIEditor()
    

    下载脚本:
    Insert Wheel.lua


  • 这个真是方便啊。

建议的主题

  • 1
  • 1
  • 1
  • 1
  • 37