|
|
|
10-23-2017, 10:03 PM
|
#1
|
Human being with feelings
Join Date: Dec 2015
Posts: 476
|
Convert audio amplitude to Volume envelope
Hello.
Is this possible:
apply the actual volume (or gain) of an audio piece
as Volume envelope to another track or item?
|
|
|
10-24-2017, 03:19 AM
|
#3
|
Human being with feelings
Join Date: Dec 2015
Posts: 476
|
Thanks.
This script seems to be the one I needed:
mpl_Generate track volume automation item from audio take.lua
Last edited by AugerJ; 10-24-2017 at 03:51 AM.
|
|
|
10-24-2017, 09:49 AM
|
#4
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
You can merge AI to envelope by right click on envelope, then 'Delete automation item, preserve points'.
Also it is probably better to generate AI from time selection of selected track ignoring takes selection instead direct item/take selection.
|
|
|
10-24-2017, 11:25 AM
|
#5
|
Human being with feelings
Join Date: Dec 2015
Posts: 476
|
Quote:
Originally Posted by mpl
You can merge AI to envelope by right click on envelope, then 'Delete automation item, preserve points'.
|
Thanks.
Quote:
Also it is probably better to generate AI from time selection of selected track ignoring takes selection instead direct item/take selection.
|
Currently I don't have an access to such a script )
By the way, in my case I had to move created AI 43ms left for it to align with the "source" item better.
|
|
|
06-04-2020, 08:03 PM
|
#6
|
Human being with feelings
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
|
Wow, trying to use this and all I get is a bunch of points at level= -infinity.
Is there some trick to it?
|
|
|
06-05-2020, 09:39 AM
|
#7
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
Pretty sure you have Fader Sacling actiavted on the track
Try to deactuvate it beforer unning the script
and if this solve the problem, the script would need an update o support it :P(just few lines of code)
|
|
|
06-05-2020, 12:25 PM
|
#8
|
Human being with feelings
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
|
How would I do that? A search for fader scaling in the action list doesn't turn anything up, and I don't see it in the menus...
|
|
|
06-05-2020, 02:05 PM
|
#9
|
Human being with feelings
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
|
Changing to Amplitude scaling did not change the results....
I'm using v1.1
EDIT: I right-clicked the envelope and changed its scaling. Now it works!
THANKS!!!!!!!
Last edited by woodslanding; 06-05-2020 at 02:13 PM.
|
|
|
06-05-2020, 04:02 PM
|
#10
|
Human being with feelings
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
|
OMG this is an awesome feature!!!
One FR: Could you make it affect the currently selected envelope, instead of always volume??
Heck, maybe I can figure that out myself...
|
|
|
06-06-2020, 08:42 AM
|
#11
|
Human being with feelings
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
|
oh gosh, stupid easy!
Select an item, select an envelope (even on a different track) and away you go! Envelope must be set to linear mode, NOT fader mode. This is less likely with a non-volume envelope....
Volume is rarely where I want to send this anyway, and I rarely want the destination track the same as the source track...
Thanks MPL for writing this!!
Code:
-- @version 1.1
-- @author MPL (tiny edit by Woodslanding)
-- @description Generate automation item on selected envelope from audio take
-- @website http://forum.cockos.com/showthread.php?t=188335
-- @changelog
-- + respect multiple items
-- + Consolidate undo
-- # fix proper add points positions
for key in pairs(reaper) do _G[key]=reaper[key] end
function m(s) reaper.ShowConsoleMsg(s)end
---------------------------------------------------------------------------------------------------------------------
function Get_take_data(take, window,item_len)
local sum_t = {}
local accessor = CreateTakeAudioAccessor(take)
local src = GetMediaItemTake_Source(take)
local numch = GetMediaSourceNumChannels(src)
local rate = GetMediaSourceSampleRate(src)
local size = math.ceil(window*rate)
for read_pos = 0, item_len, window do
local buffer = new_array(size*2)
local buffer_com = new_array(size*2)
GetAudioAccessorSamples(
accessor , --AudioAccessor
rate, -- samplerate
numch, -- numchannels
read_pos, -- starttime_sec
size, -- numsamplesperchannel
buffer) --samplebuffer
-- merge buffers dy duplicating sum/2
for i = 1, size*numch - 1, numch do
buffer_com[i] = (buffer[i] + buffer[i+1])/numch
buffer_com[i+1] = 0
end
-- Get RMS sum in defined range
local buffer_com_t = buffer_com.table(1,size, true)
local sum_com = 0
for i = 1, size do sum_com = sum_com + math.abs(buffer_com_t[i]) end
table.insert(sum_t, sum_com)
end
DestroyAudioAccessor(accessor)
-- normalize table
local max_com = 0
for i =1, #sum_t do max_com = math.max(max_com, sum_t[i]) end
local com_mult = 1/max_com
for i =1, #sum_t do sum_t[i]= sum_t[i]*com_mult end
table.insert(sum_t, 1, 0)
return sum_t
end
---------------------------------------------------------------------------------------------------------------------
function CalcAI(item, window_ms)
if not item then return end
local take = reaper.GetActiveTake( item )
if TakeIsMIDI( take ) then return end
local i_pos = GetMediaItemInfo_Value( item, 'D_POSITION' )
local i_len = GetMediaItemInfo_Value( item, 'D_LENGTH' )
if not window_ms then return end
local t = Get_take_data(take, window_ms, i_len)
local track = GetMediaItem_Track(item)
SetOnlyTrackSelected(track)
--env = GetTrackEnvelopeByName( track, 'Volume' )
env = GetSelectedEnvelope();
if not env then
Main_OnCommand(40406,0) -- show vol envelope
env = GetTrackEnvelopeByName( track, 'Volume' )
end
local AI_idx = InsertAutomationItem( env, -1, i_pos, i_len )
for i = 1, #t do InsertEnvelopePointEx( env, AI_idx, (i-1)*window_ms+i_pos, t[i], 0, 0, 0, true ) end
Envelope_SortPointsEx( env, AI_idx )
UpdateArrange()
end
local ret, window_ms = reaper.GetUserInputs( 'RMS window', 1, '(seconds)', 0.05 )
if ret then
Undo_BeginBlock()
window_ms = tonumber(window_ms)
for i = 1, CountSelectedMediaItems( 0 ) do
local item = GetSelectedMediaItem(0,i-1)
CalcAI(item, window_ms)
end
Undo_EndBlock( 'Generate AI from audio item', 0 )
end
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:33 AM.
|