def __init__(self, track_info_dict, id): self.length = float(track_info_dict['end']) self.id = id if self.id == '0': self.name = set_a_names[file_number] else: self.name = set_b_names[file_number] pipe.do_command(f'SelectTracks: Mode=Set Track={self.id} TrackCount=1') pipe.do_command(f'SetTrackStatus: Name={self.name}') self.data = [self.name, self.id, self.length]
def add_white_noise(): # Needs cleaing up if track1.length < track2.length: l_track = track2 else: l_track = track1 import_track(white_noise_path) white_noise = Track(get_track_data(2), '2') trim = white_noise.length - (l_track.length + 2) pipe.do_command( f'Select: Start="0" End="{trim}" Track={white_noise.id} Mode="Set" RelativeTo="ProjectEnd"' ) pipe.do_command('Delete:')
def get_track_data(track_number): track_info = json.loads( pipe.do_command("GetInfo: Type=Tracks").replace( "BatchCommand finished: OK", '')) try: t_info = track_info.pop(track_number) except IndexError(): print("ERROR: That track does not exist.") return t_info
def export_files(): pipe.do_command( f'SaveProject2: Filename="{cwd}\\exported_projects\\{track1.name}_&_{track2.name}_project.aup"' ) pipe.do_command('SelectAll:') pipe.do_command( f'Export2: Filename="{cwd}\\exported_files\\{track1.name}_&_{track2.name}.wav"' ) print(f"File {track1.name}_&_{track2.name} exported successfully.")
def cleanup(): pipe.do_command('SelectAll:') pipe.do_command('RemoveTracks')
def add_silence(seconds, tracks_list): for track in tracks_list: # Adds silence at start and end by copy/repeat/silence a slice of audio. pipe.do_command( f'Select: Start="0" End="{seconds}" Track={track.id} Mode="Set" RelativeTo="ProjectStart"' ) pipe.do_command('Repeat:Count="1"') pipe.do_command( f'SelectTime: Start="0" End="{seconds}" RelativeTo="SelectionStart"' ) pipe.do_command('Silence:') pipe.do_command( f'Select: Start="0" End="{seconds}" Track={track.id} Mode="Set" RelativeTo="ProjectEnd"' ) pipe.do_command('Repeat:Count="1"') pipe.do_command( f'SelectTime: Start="0" End="{seconds}" RelativeTo="ProjectEnd"') pipe.do_command('Silence:')
def trunc_silence(): pipe.do_command('SelectAll:') pipe.do_command( 'TruncateSilence: Minimum=0.2 Truncate=0.0 Independent=True')
def import_track(file): pipe.do_command(f'Import2: Filename="{file}"')