Advertisement
dialga512

audacity macro generator

May 22nd, 2022 (edited)
1,008
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local root_dir = 'C:\\Users\\Stradith Rikink\\Desktop\\My New Projects\\FORMATED'
  2. local project_queue = {
  3.   [1] = {
  4.     key = "Folder Name",
  5.     value = "track_name",
  6.     tracks = "00:00:5700:00:5700:01:3000:00:5000:01:0100:01:1100:01:1100:01:1100:01:1000:01:1300:01:3200:01:1200:01:2200:01:2200:01:2200:01:2600:01:4500:01:4100:01:1000:01:1800:00:5300:01:3000:01:5200:01:1200:01:0300:01:0400:01:4100:00:5700:01:0800:01:1900:01:1900:01:1900:01:1800:01:2000:01:4100:01:1900:01:3100:01:3100:01:3000:01:3400:01:5200:01:4900:01:2000:01:2900:01:0100:01:3900:02:0100:01:2000:00:5700:00:5700:01:3000:00:5100:01:0000:01:1100:01:1100:01:1100:01:1100:01:1500:01:3300:01:1100:01:2100:01:2100:01:2000:01:2500:01:4400:01:4300:01:1100:01:2000:00:5400:01:3100:01:5200:01:1500:01:1100:01:1100:01:5300:01:0300:01:1600:01:2900:01:2900:01:2900:01:2800:01:3200:01:5300:01:2700:01:4000:01:4000:01:3900:01:4400:02:0500:02:0400:01:2800:01:3900:01:0800:01:5300:02:1800:01:3000:00:5800:00:5800:01:3000:00:5200:01:0000:01:1300:01:1300:01:1400:01:1200:01:1300:01:3000:01:1400:01:2400:01:2400:01:2300:01:2700:01:4000:01:3700:01:1200:01:2100:00:5700:01:2800:01:4600:01:1600:00:5700:00:5400:01:2700:00:5000:00:5700:01:0700:01:0800:01:0800:01:0700:01:1000:01:2600:01:0900:01:1800:01:1800:01:1700:01:2100:01:3500:01:3200:01:0800:01:1600:00:5300:01:2500:01:4400:01:12"
  7.   }
  8. }
  9. local voice_queue = {
  10.     [1] = {
  11.         key = "Hayley",
  12.         value = "hayley"
  13.     },
  14.     [2] = {
  15.         key = "Hazel",
  16.         value = "hazel"
  17.     },
  18.     [3] = {
  19.         key = "Heather",
  20.         value = "heather"
  21.     },
  22.     [4] = {
  23.         key = "Heera",
  24.         value = "heera"
  25.     },
  26.     [5] = {
  27.         key = "Helen",
  28.         value = "helen"
  29.     },
  30.     [6] = {
  31.         key = "ZiraPro",
  32.         value = "zirapro"
  33.     }
  34. }
  35.  
  36. local effect_increment = 7
  37. local effect_border = 10
  38. local repeat_multiplier = 30
  39.  
  40.  
  41. function import(pk, vk)
  42.     local file_name = project_queue[pk].value.."_"..voice_queue[vk].value.."_ "
  43.     local file_path = root_dir..[[\]]..project_queue[pk].key..[[\]]..voice_queue[vk].key..[[\]]..file_name
  44.  
  45.     print('SaveProject2:AddToHistory="0" Filename="'..file_path..'draft.aup3"')
  46.  
  47.     for i = 1,24 do
  48.         if (i < 10) then
  49.             print('Import2: FileName="'..file_path..'0'..i..'.wav"')
  50.         else
  51.             print('Import2: FileName="'..file_path..i..'.wav"')
  52.     end
  53.     end
  54.     print('Save:')
  55. end
  56.  
  57. function merge(pk)
  58.     for i = 1,6 do
  59.         local file_name = project_queue[pk].value.."_"..voice_queue[i].value.."_finished.wav"
  60.         local file_path = root_dir.."\\"..project_queue[pk].key.."\\"..file_name
  61.         print('Import2: FileName="'..file_path..'"')
  62.     end
  63.     print('Export2: FileName="'..root_dir..'\\'..project_queue[pk].key..'\\'..project_queue[pk].value..'_merged.wav" NumChannels="1"')
  64.     print('SelectAll:')
  65.     print('RemoveTracks:')
  66. end
  67.  
  68.  
  69. function process(pk, vk)
  70.     local file_name = project_queue[pk].value.."_"..voice_queue[vk].value.."_ "
  71.     local file_path = root_dir.."\\"..project_queue[pk].key.."\\"..voice_queue[vk].key.."\\"..file_name
  72.  
  73.     local function repeat_effect()
  74.         local length_tags,converted_tags = {},{}
  75.         local hours,minutes,seconds = {},{},{}
  76.  
  77.         -- This chunk of code decrypts the string into length tags and stores them in a table
  78.         for a = 1,string.len(project_queue[pk].tracks) do
  79.             if (a%8 == 0) then
  80.                 length_tags[#length_tags + 1] = string.sub(project_queue[pk].tracks, a - 7, a)
  81.             end
  82.         end
  83.            
  84.         --[[
  85.                 This loop declaration looks confusing as hell, but it is necessary because, since the hours, minutes, and seconds are each stored within their own table and are not seperated like 'project_queue' and 'voice_queue',
  86.             we cannot keep track of our position in the conventional way. In essence, we are using 'vk' (the voice key) to start the loop from where it ended the last time the function was called; it is easier to comprehend when you write out the math:
  87.    
  88.                 (1*24+1) = 25; 25-24 = 1 THROUGH 24; (1*24) [1 = HAYLEY]
  89.                 (2*24+1) = 49; 49-24 = 25 THROUGH 48; (2*24) [2 = HAZEL]
  90.                 (3*24+1) = 73; 73-24 = 49 THROUGH 72; (3*24) [3 = HEATHER]
  91.                 (4*24+1) = 97; 97-24 = 73 THROUGH 96; (4*24) [4 = HEERA]
  92.                 (5*24+1) = 121; 121-24 = 97 THROUGH 120; (5*24) [5 = HELEN]
  93.                 (6*24+1) = 145; 145-24 = 121 THROUGH 144; (6*24) [6 = ZIRAPRO]
  94.  
  95.             In any scenario, we are still only processing 24 entries per function call.
  96.  
  97.         --]]
  98.         for a = (vk*24+1)-24,(vk*24),1 do
  99.             -- This chunk of code seperates the length tags into hours, minutes, and seconds, storing each section in its own table to ensure it is easily accessible
  100.             hours[#hours+1] = string.sub(length_tags[a], 1, 2)
  101.             minutes[#minutes+1] = string.sub(length_tags[a], 4, 5)
  102.             seconds[#seconds+1] = string.sub(length_tags[a], 7, 8)
  103.         end
  104.        
  105.         for i = 1,24 do
  106.             converted_tags[i] = (((hours[i]*60*60) + minutes[i]*60) + seconds[i])/repeat_multiplier
  107.         end
  108.         return converted_tags
  109.     end
  110.     local track_lengths = repeat_effect()
  111.   -- this exists because, while the tracks in audacity start from  and end at 23, the tables in lua start from 1 and end at 24;
  112.   -- it doesn't look pretty, but, in all honestly, I can't be bothered to give a shit; it works perfect and that is good enough.
  113.     local shitty_patch_int = 1
  114.  
  115.     print('SelectTracks:Mode="Set" Track="0" TrackCount="1"')
  116.     print('SelTrackStartToEnd:')
  117.     print('ChangeTempo:Percentage="3000" SBSMS="1"')
  118.     print('Repeat:Count="'..math.floor(((10*60) + 59)/track_lengths[shitty_patch_int])..'"')
  119.     print('Save:')
  120.     shitty_patch_int = shitty_patch_int + 1
  121.  
  122.     for i = 1,23,1 do
  123.         print('SelectTracks:Mode="Set" Track="'..i..'" TrackCount="1"')
  124.         print('SelTrackStartToEnd:')
  125.        
  126.         if (i > effect_border) then
  127.             print('SetTrackAudio:Pan="'..(i-effect_border) * -effect_increment..'" SBSMS="1"')
  128.             print('ChangePitch:Percentage="'..(i-effect_border) * -5.613 ..'" SBSMS="1"')
  129.             print('ChangeTempo:Percentage="3000" SBSMS="1"')
  130.             print('Repeat:Count="'..math.floor(((10*60)+59)/track_lengths[shitty_patch_int])..'"')
  131.         shitty_patch_int = shitty_patch_int+1
  132.         else
  133.             print('SetTrackAudio:Pan="'..i * effect_increment..'"')
  134.             print('ChangePitch:Percentage="'..i * 5.946 ..'" SBSMS="1"')
  135.             print('ChangeTempo:Percentage="3000" SBSMS="1"')
  136.             print('Repeat:Count="'..math.floor(((10*60)+59)/track_lengths[shitty_patch_int])..'"')
  137.             shitty_patch_int = shitty_patch_int+1
  138.         end
  139.         print('Save:')
  140.     end
  141.     print('SaveProject2:AddToHistory="0" Filename="'..file_path..'output.aup3"')
  142.     print('SelectAll:')
  143.     print('Export2:Filename="'..root_dir..'\\'..project_queue[pk].key..'\\'..project_queue[pk].value..'_'..voice_queue[vk].value..'_finished.wav" NumChannels = "1"')
  144.     print('RemoveTracks:')
  145. end
  146.  
  147. for pk,pv in ipairs(project_queue) do
  148.     local voice_key = ""
  149.  
  150.     for vk,vv in ipairs(voice_queue) do
  151.         import(pk, vk)
  152.         process(pk, vk)    
  153.     end
  154.     merge(pk)
  155. end
Advertisement
RAW Paste Data Copied
Advertisement