Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local root_dir = 'C:\\Users\\Stradith Rikink\\Desktop\\My New Projects\\FORMATED'
- local project_queue = {
- [1] = {
- key = "Folder Name",
- value = "track_name",
- 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"
- }
- }
- local voice_queue = {
- [1] = {
- key = "Hayley",
- value = "hayley"
- },
- [2] = {
- key = "Hazel",
- value = "hazel"
- },
- [3] = {
- key = "Heather",
- value = "heather"
- },
- [4] = {
- key = "Heera",
- value = "heera"
- },
- [5] = {
- key = "Helen",
- value = "helen"
- },
- [6] = {
- key = "ZiraPro",
- value = "zirapro"
- }
- }
- local effect_increment = 7
- local effect_border = 10
- local repeat_multiplier = 30
- function import(pk, vk)
- local file_name = project_queue[pk].value.."_"..voice_queue[vk].value.."_ "
- local file_path = root_dir..[[\]]..project_queue[pk].key..[[\]]..voice_queue[vk].key..[[\]]..file_name
- print('SaveProject2:AddToHistory="0" Filename="'..file_path..'draft.aup3"')
- for i = 1,24 do
- if (i < 10) then
- print('Import2: FileName="'..file_path..'0'..i..'.wav"')
- else
- print('Import2: FileName="'..file_path..i..'.wav"')
- end
- end
- print('Save:')
- end
- function merge(pk)
- for i = 1,6 do
- local file_name = project_queue[pk].value.."_"..voice_queue[i].value.."_finished.wav"
- local file_path = root_dir.."\\"..project_queue[pk].key.."\\"..file_name
- print('Import2: FileName="'..file_path..'"')
- end
- print('Export2: FileName="'..root_dir..'\\'..project_queue[pk].key..'\\'..project_queue[pk].value..'_merged.wav" NumChannels="1"')
- print('SelectAll:')
- print('RemoveTracks:')
- end
- function process(pk, vk)
- local file_name = project_queue[pk].value.."_"..voice_queue[vk].value.."_ "
- local file_path = root_dir.."\\"..project_queue[pk].key.."\\"..voice_queue[vk].key.."\\"..file_name
- local function repeat_effect()
- local length_tags,converted_tags = {},{}
- local hours,minutes,seconds = {},{},{}
- -- This chunk of code decrypts the string into length tags and stores them in a table
- for a = 1,string.len(project_queue[pk].tracks) do
- if (a%8 == 0) then
- length_tags[#length_tags + 1] = string.sub(project_queue[pk].tracks, a - 7, a)
- end
- end
- --[[
- 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',
- 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:
- (1*24+1) = 25; 25-24 = 1 THROUGH 24; (1*24) [1 = HAYLEY]
- (2*24+1) = 49; 49-24 = 25 THROUGH 48; (2*24) [2 = HAZEL]
- (3*24+1) = 73; 73-24 = 49 THROUGH 72; (3*24) [3 = HEATHER]
- (4*24+1) = 97; 97-24 = 73 THROUGH 96; (4*24) [4 = HEERA]
- (5*24+1) = 121; 121-24 = 97 THROUGH 120; (5*24) [5 = HELEN]
- (6*24+1) = 145; 145-24 = 121 THROUGH 144; (6*24) [6 = ZIRAPRO]
- In any scenario, we are still only processing 24 entries per function call.
- --]]
- for a = (vk*24+1)-24,(vk*24),1 do
- -- 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
- hours[#hours+1] = string.sub(length_tags[a], 1, 2)
- minutes[#minutes+1] = string.sub(length_tags[a], 4, 5)
- seconds[#seconds+1] = string.sub(length_tags[a], 7, 8)
- end
- for i = 1,24 do
- converted_tags[i] = (((hours[i]*60*60) + minutes[i]*60) + seconds[i])/repeat_multiplier
- end
- return converted_tags
- end
- local track_lengths = repeat_effect()
- -- 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;
- -- 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.
- local shitty_patch_int = 1
- print('SelectTracks:Mode="Set" Track="0" TrackCount="1"')
- print('SelTrackStartToEnd:')
- print('ChangeTempo:Percentage="3000" SBSMS="1"')
- print('Repeat:Count="'..math.floor(((10*60) + 59)/track_lengths[shitty_patch_int])..'"')
- print('Save:')
- shitty_patch_int = shitty_patch_int + 1
- for i = 1,23,1 do
- print('SelectTracks:Mode="Set" Track="'..i..'" TrackCount="1"')
- print('SelTrackStartToEnd:')
- if (i > effect_border) then
- print('SetTrackAudio:Pan="'..(i-effect_border) * -effect_increment..'" SBSMS="1"')
- print('ChangePitch:Percentage="'..(i-effect_border) * -5.613 ..'" SBSMS="1"')
- print('ChangeTempo:Percentage="3000" SBSMS="1"')
- print('Repeat:Count="'..math.floor(((10*60)+59)/track_lengths[shitty_patch_int])..'"')
- shitty_patch_int = shitty_patch_int+1
- else
- print('SetTrackAudio:Pan="'..i * effect_increment..'"')
- print('ChangePitch:Percentage="'..i * 5.946 ..'" SBSMS="1"')
- print('ChangeTempo:Percentage="3000" SBSMS="1"')
- print('Repeat:Count="'..math.floor(((10*60)+59)/track_lengths[shitty_patch_int])..'"')
- shitty_patch_int = shitty_patch_int+1
- end
- print('Save:')
- end
- print('SaveProject2:AddToHistory="0" Filename="'..file_path..'output.aup3"')
- print('SelectAll:')
- print('Export2:Filename="'..root_dir..'\\'..project_queue[pk].key..'\\'..project_queue[pk].value..'_'..voice_queue[vk].value..'_finished.wav" NumChannels = "1"')
- print('RemoveTracks:')
- end
- for pk,pv in ipairs(project_queue) do
- local voice_key = ""
- for vk,vv in ipairs(voice_queue) do
- import(pk, vk)
- process(pk, vk)
- end
- merge(pk)
- end
Advertisement
Add Comment
Please, Sign In to add comment