View Single Post
Old 08-23-2016, 03:21 AM   #13
dream_of_the_night
Human being with feelings
 
Join Date: Mar 2013
Posts: 86
Default

Quote:
Originally Posted by juliansader View Post
Is the BPM constant? If it is, you can convert the milliseconds to ticks and use the Properties popup window to change the position of the selected notes. (For example, enter "-0.0.480" or "+0.0.480" in the Position field to move the notes back or forward 1 eighth note, respectively.)

EDIT:
What to do if the BPM changes? I don't know if there is a better, native method, but sometimes it is easier to just write a quick script:

Code:
-- Quick script that is intended to nudge selected notes in the active take
--    by a user-defined number of milliseconds
-- WARNING: Do not use if there are overlapping notes in the take, since 
--    ReaScripts are not compatible with such notes.

reaper.Undo_BeginBlock()

editor = reaper.MIDIEditor_GetActive()
take = reaper.MIDIEditor_GetTake(editor)
reaper.MIDI_Sort(take)

repeat
    OKorCancel, userTime = reaper.GetUserInputs("Nudge notes by millisecs", 1, "Time (in milliseconds)", "0")
until OKorCancel == false or (OKorCancel == true and type(tonumber(userTime)) == "number")

if OKorCancel == false then 
    return(0) 
else
    nudgeTime = tonumber(userTime) / 1000
end

i = reaper.MIDI_EnumSelNotes(take, -1)
while i ~= -1 do
    noteOK, selected, _, noteStartPPQ, noteEndPPQ, _, _, _ = reaper.MIDI_GetNote(take, i)
    if noteOK and selected then
        noteStartTime = reaper.MIDI_GetProjTimeFromPPQPos(take, noteStartPPQ)
        newNoteStartPPQ = reaper.MIDI_GetPPQPosFromProjTime(take, noteStartTime + nudgeTime)
        newNoteEndPPQ = noteEndPPQ + (newNoteStartPPQ - noteStartPPQ)
        reaper.MIDI_SetNote(take, i, nil, nil, newNoteStartPPQ, newNoteEndPPQ, nil, nil, nil, true)
    end
    i = reaper.MIDI_EnumSelNotes(take, i)
end

reaper.MIDI_Sort(take)

reaper.Undo_EndBlock("Nudge notes by milliseconds", -1)
EDIT 2: BTW, if you use the MIDI Inspector while working in the MIDI editor, you can choose to display note position info in time or seconds instead of the usual measure:beat:ticks.
Thank you very much, the script works nicely and just what I was looking for!

Can I share your script in other forums?
dream_of_the_night is offline   Reply With Quote