Old 12-20-2019, 05:20 PM   #1
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,441
Default RubberBand Library Stretch Audio to Tempo Map

They have added a stretch marker method in ver 6 to fit audio automatically to a tempo map, but they are just doing it the same way as I made scripts for with stretch markers, but with stretch markers you get a glitch at the tempo marker over a held note/tone or vocal.
Though most other DAWs do it undetectably smooth:
https://www.dropbox.com/s/bdbl264r6t...o-Map.mp4?dl=0

I'm looking at using RubberBand command line to fit the audio as I've been using the standalone app for some years.
https://breakfastquay.com/rubberband/index.html
https://breakfastquay.com/rubberband/usage.txt

Quote:
-M<F>, --timemap <F> Use file F as the source for key frame map

A map file consists of a series of lines each having two numbers separated by a single space. These are source and target sample frame numbers for fixed time points within the audio data, defining a varying stretch factor through the audio. You must specify an overall stretch factor using e.g. -t as well.
Just not sure about all of that, getting the tempo map and sending from Lua using ExexcProcess CL to rubberband.exe to copy the wav then tempo map it and then change the source media ????
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 12-21-2019, 11:16 PM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,441
Default

Alright I got some more info.
In the pic below
Track 1 is stretch with Reaper to the tempo change and has a jerk where the tempo changes.
Track 2 is stretched with RubberBand is totally smooth at the tempo change with no jerk.
Track 3 is original 120bpm item

This is the command used:
Code:
rubberband -D 76.454 -M mapfile.txt Bass_bpm120.wav Bass_bpm120_output.wav
org duration 75.999
new duration 76.454
mapfile.txt
Code:
0 0
3131100 3131100
3351581 3371625
so in samples source > target
start 0 0 (120bpm)
marker 3131100 3131100 (110bpm)
end 3351581 3371625 (org length 3351581 to 3371625)

now a way needs to be worked out to calculate from the time,
sample rate and tempo changes a mapfile and command line for the
item that will fit the whole track or a smaller item to fit a
section of track.

Video Demo
https://www.dropbox.com/s/u9arbborrb...rBand.mp4?dl=0

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 12-24-2019, 02:26 AM   #3
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,120
Default

As far as I can tell, REAPER's current implementation of Rubberband is pretty unuseable -- at least for normal short-distance stretching.

Other algorithms such as Élastique work much better, but unfortunately all are glitchy and very sensitive to settings.

Here are some examples of different algorithms and modes stretching a plain sine wave. Stretch markers are at zero crossings, and all slopes are flat. Glitching can easily be seen by the blotches of different colors within the pure red pitch.

Élastique soloist:



Rubberband, standard window length



Rubberband, long window length



Rubberband, short window length

Last edited by juliansader; 12-24-2019 at 05:54 PM.
juliansader is offline   Reply With Quote
Old 12-24-2019, 05:18 AM   #4
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,441
Default

Thanks for that. Now we are getting somewhere, I can get a mono bass tone smooth at the tempo markers with it set to soloist and stretch marker fade set to 0.0 (without zero crossing)
for a stereo guitar strum I get get smooth with default or any elastique and stretch marker fade set to 0.0
but I'll have to do more testing with other files, and yea as you say they all are glitchy and very sensitive to settings.

So can I set that in SetMediaItemInfo_Value ?

Yea RubberBand is crap in there but if I command line the tempo changes it's fine. Reaper should be able to do automatically what RubberBand does with command line. Both mono and stereo are fine after command line.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Old 12-24-2019, 10:37 PM   #5
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 1,441
Default

MPL has a script to set the stretch mode
change the take pitch shift/time stretch mode of a selected item though reascript

Quote:
Originally Posted by mpl View Post
Code:
function MPL_SetTimeShiftPitchChange(item, pshift_mode0, timestr_mode0)
  if not item then return end
  local retval, str = reaper.GetItemStateChunk( item, '', false ) 
  local timestr_mode = tonumber(str:match('PLAYRATE [%d%-%.]+ [%d%-%.]+ [%d%-%.]+ [%d%-%.]+ ([%d%-%.]+)'))
  local timestr_mode_len = string.len(tonumber(timestr_mode))
  local timestr_mode_replace = str:match('(PLAYRATE [%d%-%.]+ [%d%-%.]+ [%d%-%.]+ [%d%-%.]+ [%d%-%.]+)') 
  local pshift_mode = tonumber(str:match('PLAYRATE [%d%-%.]+ [%d%-%.]+ [%d%-%.]+ ([%d%-%.]+)'))
  local pshift_mode_len = string.len(tonumber(pshift_mode))
  local pshift_mode_replace = str:match('(PLAYRATE [%d%-%.]+ [%d%-%.]+ [%d%-%.]+ [%d%-%.]+)') 
  if pshift_mode0 then pshift_mode= pshift_mode0 end
  if timestr_mode0 then timestr_mode = timestr_mode0 end 
  str =str:gsub(timestr_mode_replace:gsub("[%.%+%-]", function(c) return "%" .. c end), timestr_mode_replace:sub(0,-timestr_mode_len-1)..timestr_mode)
  str =str:gsub(pshift_mode_replace:gsub("[%.%+%-]", function(c) return "%" .. c end), pshift_mode_replace:sub(0,-pshift_mode_len-1)..pshift_mode)
  reaper.SetItemStateChunk( item, str, false )
end

------------------------------------------------------------------------------
  item = reaper.GetSelectedMediaItem(0,0)
  pshift_mode =   (6<<16) -- elastique 2.2.8 pro (val = 6 )
                  + (1<<4) -- syncronized (val = 1 )
  timestr_mode = 3 -- transient optimized (val = 3 )
  MPL_SetTimeShiftPitchChange(item, pshift_mode, timestr_mode)
  reaper.UpdateArrange()
this however works only for 1st take, you have to parse takes to make same thing for any take you want, there is a code for extracting take chunks from item written by me and placed somewhere in ReaTeam repo.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
MusoBob is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:36 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.