Skip to content

Commit

Permalink
Added DoomSquirrel_Set velocity of selected notes to 96
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomiorava committed Jul 26, 2024
1 parent 2b03cc1 commit c3394e2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions MIDI Editor/DoomSquirrel_Set velocity of selected notes to 96.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- @description DoomSquirrel_Set velocity of selected notes to 96
-- @author DoomSquirrel
-- @license GPL v3
-- @about
-- # Set velocity of selected notes to 96 <VELOCITY VALUE>
-- You can change the velocity to set the notes to by renaming this script.
-- The last number in the script name determines the velocity value.
--
-- Valid velocity values are between 1-127.
-- Anything outside of this will be corrected to the closest valid value.
-- @repository
-- https://github.com/tuomiorava/REAPER-ReaScripts
-- @links
-- Personal Website http://iki.fi/atolonen
-- @donation
-- Donate via PayPal https://www.paypal.com/donate/?hosted_button_id=2BEA2GHZMAW9A
-- @version 1.0
-- @changelog
-- Initial release

-- Get the name of the script and parse the last word as number (= VELOCITY)
local name = ({reaper.get_action_context()})[2]:match("([^/\\_]+).lua$")
local VELOCITY = tonumber(name:match("%d+$"))

local take = reaper.MIDIEditor_GetTake(reaper.MIDIEditor_GetActive())
local _, notecnt = reaper.MIDI_CountEvts(take)

for i = 0, notecnt + 1 do
local midi_note, sel, muted, startppqpos, endppqpos, chan, pitch, vel = reaper.MIDI_GetNote(take, i)

if sel then -- If note is selected
local VELOCITY = VELOCITY < 1 and 1 or VELOCITY > 127 and 127 or VELOCITY -- Limit values to the standard range
reaper.MIDI_SetNote(take, i, sel, muted, startppqpos, endppqpos, chan, pitch, VELOCITY)
end
end

reaper.UpdateArrange()

0 comments on commit c3394e2

Please sign in to comment.