NudgeItemVolume pl

From CockosWiki

Jump to: navigation, search

NudgeItemVolume.pl

This script increases the volume of all selected items by 1dB.

Set up two copies of this script: one version increase the volume by a 1dB and the other version decreasing it by 1dB. Assign these two scripts to convenient keys (under the fingers) while playing a drum loop in Reaper (using sliced up drum breaks, one hit per Media Item.). You can then nudge the volume of the selected items up or down very accurately and easily.

Note that the script does nothing if nothing is selected.

#
# Nudge Item Volume
# sfzgeek
#
 
use strict;
use warnings;
 
# Get number of items currently selected
$Item_Count = RPR_CountSelectedMediaItems(0);
$Item_Index = 0;
 
# Update volume for each selected item
while ($Item_Index < $Item_Count) {
	# Get ID for current item index
	$Item_ID = RPR_GetSelectedMediaItem(0, $Item_Index);
 
	# Get volume value for current item
	$D_VOL = RPR_GetMediaItemInfo_Value($Item_ID, "D_VOL");
 
	# Convert volume to dB units
	$Volume_dB = (20 * log($D_VOL)) / log(10);
 
	# Round item volume to nearest dB
	$Volume_dB = sprintf "%.0f", $Volume_dB;
 
	# Increase item volume by 1 dB
	$Volume_dB += 1;
 
	# Convert dB value back to power ratio
	$D_VOL = 10 ** ($Volume_dB / 20);
 
	# Set new volume value for current item
	RPR_SetMediaItemInfo_Value($Item_ID, "D_VOL", $D_VOL);
 
	# Redraw item to update volume envelope
	RPR_UpdateItemInProject($Item_ID);
 
	$Item_Index++;
}