mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
vamp_audio_to_midi script now operates on a list of regions, calling qm-transcription for each region. The MIDI region holding the output is resized to the extents of the audio region list. This is because qm-transcription is a memory hog and barfs if you try to process too big a region.
This commit is contained in:
parent
259f049adc
commit
4ab80e16e9
1 changed files with 38 additions and 22 deletions
|
|
@ -6,23 +6,38 @@ function factory () return function ()
|
||||||
local sr = Session:nominal_frame_rate ()
|
local sr = Session:nominal_frame_rate ()
|
||||||
local tm = Session:tempo_map ()
|
local tm = Session:tempo_map ()
|
||||||
local vamp = ARDOUR.LuaAPI.Vamp ("libardourvampplugins:qm-transcription", sr)
|
local vamp = ARDOUR.LuaAPI.Vamp ("libardourvampplugins:qm-transcription", sr)
|
||||||
local ar, mr
|
local midi_region
|
||||||
|
local audio_regions = {}
|
||||||
|
local start_time = Session:current_end_frame ()
|
||||||
|
local end_time = Session:current_start_frame ()
|
||||||
for r in sel.regions:regionlist ():iter () do
|
for r in sel.regions:regionlist ():iter () do
|
||||||
if r:to_midiregion():isnil() then
|
if r:to_midiregion():isnil() then
|
||||||
ar = r
|
local st = r:position()
|
||||||
|
local ln = r:length()
|
||||||
|
local et = st + ln
|
||||||
|
if st < start_time then
|
||||||
|
start_time = st
|
||||||
|
end
|
||||||
|
if et > end_time then
|
||||||
|
end_time = et
|
||||||
|
end
|
||||||
|
table.insert(audio_regions, r)
|
||||||
else
|
else
|
||||||
mr = r:to_midiregion()
|
midi_region = r:to_midiregion()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert (ar and mr)
|
assert (audio_regions and midi_region)
|
||||||
|
midi_region:set_initial_position(start_time)
|
||||||
|
midi_region:set_length(end_time - start_time, 0)
|
||||||
|
|
||||||
|
for i,ar in pairs(audio_regions) do
|
||||||
local a_off = ar:position ()
|
local a_off = ar:position ()
|
||||||
local b_off = 4.0 * mr:pulse () - mr:start_beats ()
|
local b_off = 4.0 * midi_region:pulse () - midi_region:start_beats ()
|
||||||
|
|
||||||
vamp:analyze (ar:to_readable (), 0, nil)
|
vamp:analyze (ar:to_readable (), 0, nil)
|
||||||
local fl = vamp:plugin ():getRemainingFeatures ():at (0)
|
local fl = vamp:plugin ():getRemainingFeatures ():at (0)
|
||||||
if fl and fl:size() > 0 then
|
if fl and fl:size() > 0 then
|
||||||
local mm = mr:midi_source(0):model()
|
local mm = midi_region:midi_source(0):model()
|
||||||
local midi_command = mm:new_note_diff_command ("Audio2Midi")
|
local midi_command = mm:new_note_diff_command ("Audio2Midi")
|
||||||
for f in fl:iter () do
|
for f in fl:iter () do
|
||||||
local ft = Vamp.RealTime.realTime2Frame (f.timestamp, sr)
|
local ft = Vamp.RealTime.realTime2Frame (f.timestamp, sr)
|
||||||
|
|
@ -39,4 +54,5 @@ function factory () return function ()
|
||||||
end
|
end
|
||||||
mm:apply_command (Session, midi_command)
|
mm:apply_command (Session, midi_command)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end end
|
end end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue