generated from cfillion/reapack-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DoomSquirrel_Set velocity of selected notes to 96
- Loading branch information
1 parent
2b03cc1
commit c3394e2
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
MIDI Editor/DoomSquirrel_Set velocity of selected notes to 96.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |