summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-10-09 16:42:47 +0200
committerRobin Gareus <robin@gareus.org>2016-10-09 16:42:47 +0200
commit631c8afc668f8b57af21ca85332ac8f012a3f59e (patch)
tree4f78d1e01063e3e079ac5d8d3616c505e926dc35 /scripts
parentf58cf226e08dde72952f57a4015c92728f6f6537 (diff)
Audio->MIDI script: properly handle MIDI-region start-offset
Diffstat (limited to 'scripts')
-rw-r--r--scripts/_vamp_audio_to_midi.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/_vamp_audio_to_midi.lua b/scripts/_vamp_audio_to_midi.lua
index e74aac59eb..cf9b82c851 100644
--- a/scripts/_vamp_audio_to_midi.lua
+++ b/scripts/_vamp_audio_to_midi.lua
@@ -15,10 +15,9 @@ function factory () return function ()
end
end
assert (ar and mr)
- assert (mr:position () >= mr:start ())
local a_off = ar:position ()
- local m_off = tm:exact_beat_at_frame (mr:position () - mr:start (), 0)
+ local b_off = 4.0 * mr:pulse () - mr:start_beats ():to_double ()
vamp:analyze (ar:to_readable (), 0, nil)
local fl = vamp:plugin ():getRemainingFeatures ():at (0)
@@ -29,10 +28,11 @@ function factory () return function ()
local ft = Vamp.RealTime.realTime2Frame (f.timestamp, sr)
local fd = Vamp.RealTime.realTime2Frame (f.duration, sr)
local fn = f.values:at (0)
- local bs = tm:exact_beat_at_frame (a_off + ft, 0)
- local be = tm:exact_beat_at_frame (a_off + ft + fd, 0)
- local pos = Evoral.Beats (bs - m_off)
+ local bs = tm:exact_qn_at_frame (a_off + ft, 0)
+ local be = tm:exact_qn_at_frame (a_off + ft + fd, 0)
+
+ local pos = Evoral.Beats (bs - b_off)
local len = Evoral.Beats (be - bs)
local note = ARDOUR.LuaAPI.new_noteptr (1, pos, len, fn + 1, 0x7f)
midi_command:add (note)