def run(self): at = AudioTrack() duration = StructDuration() #print("start .... ") while True: #Aquire the next free job self.lock_j.acquire() if self.jobs_free[0] >= len(self.jobs): self.lock_j.release() return curr_job = self.jobs_free[0] file_name = self.jobs[curr_job] self.jobs_free[0] = self.jobs_free[0] + 1 self.lock_j.release() full_file = os.path.join( self.dir_name , file_name ) if at.open( full_file ): ( dr14, dB_peak, dB_rms ) = compute_dr14( at.Y , at.Fs , duration ) self.lock_res_list.acquire() print( file_name + ": \t DR " + str( int(dr14) ) ) self.res_list[curr_job] = { 'file_name': file_name , 'dr14': dr14 , 'dB_peak': dB_peak , 'dB_rms': dB_rms , 'duration':duration.to_str() } self.lock_res_list.release() else: print( "- fail - " + full_file )
def __compute_and_append( self , at , file_name ): duration = StructDuration() #( dr14, dB_peak, dB_rms ) = self.compute_dr.compute( at.Y , at.Fs ) ( dr14, dB_peak, dB_rms ) = compute_dr14( at.Y , at.Fs , duration ) self.dr14 = self.dr14 + dr14 res = { 'file_name': file_name , 'dr14': dr14 , 'dB_peak': dB_peak , 'dB_rms': dB_rms , 'duration':duration.to_str() } self.res_list.append(res) print( file_name + ": \t DR " + str( int(dr14) ) )
def __compute_and_append( self , at , file_name ): duration = StructDuration() #( dr14, dB_peak, dB_rms ) = self.compute_dr.compute( at.Y , at.Fs ) ( dr14, dB_peak, dB_rms ) = compute_dr14( at.Y , at.Fs , duration ) sha1 = sha1_track_v1( at.Y , at.get_file_ext_code() ) self.dr14 = self.dr14 + dr14 res = { 'file_name': file_name , 'dr14': dr14 , 'dB_peak': dB_peak , 'dB_rms': dB_rms , 'duration': duration.to_str() , 'sha1': sha1 } self.res_list.append(res) print_msg( file_name + ": \t DR " + str( int(dr14) ) )
def __compute_and_append(self, at, file_name): duration = StructDuration() #( dr14, dB_peak, dB_rms ) = self.compute_dr.compute( at.Y , at.Fs ) (dr14, dB_peak, dB_rms) = compute_dr14(at.Y, at.Fs, duration) sha1 = sha1_track_v1(at.Y, at.get_file_ext_code()) self.dr14 = self.dr14 + dr14 res = {'file_name': file_name, 'dr14': dr14, 'dB_peak': dB_peak, 'dB_rms': dB_rms, 'duration': duration.to_str(), 'sha1': sha1} self.res_list.append(res) print_msg(file_name + ": \t DR " + str(int(dr14)))
def run_mp( self , dir_name , lock_j , lock_res_list , job_free , res_array_sh ): at = AudioTrack() duration = StructDuration() #print_msg("start .... ") while True: #Aquire the next free job lock_j.acquire() if job_free.value >= len(res_array_sh): lock_j.release() return curr_job = job_free.value file_name = res_array_sh[curr_job].file_name job_free.value = job_free.value + 1 lock_j.release() full_file = os.path.join( dir_name , file_name ) #print ( full_file ) if at.open( full_file ): ( dr14, dB_peak, dB_rms ) = compute_dr14( at.Y , at.Fs , duration ) lock_res_list.acquire() print_msg( file_name + ": \t DR " + str( int(dr14) ) ) #res_list[curr_job] = { 'file_name': file_name , 'dr14': dr14 , 'dB_peak': dB_peak , 'dB_rms': dB_rms , 'duration':duration.to_str() } res_array_sh[curr_job].dr14 = dr14 res_array_sh[curr_job].dB_peak = dB_peak res_array_sh[curr_job].dB_rms = dB_rms res_array_sh[curr_job].duration = duration.to_float() lock_res_list.release() else: print_msg( "- fail - " + full_file )
def run_mp( self , job_queue_sh , res_queue_sh ): at = AudioTrack() duration = StructDuration() #print_msg("start .... ") while True: if job_queue_sh.empty() : return job = job_queue_sh.get() full_file = os.path.join( job.dir_name , job.file_name ) #print ( full_file ) if at.open( full_file ): ( dr14, dB_peak, dB_rms ) = compute_dr14( at.Y , at.Fs , duration ) sha1 = sha1_track_v1( at.Y , at.get_file_ext_code() ) print_msg( job.file_name + ": \t DR " + str( int(dr14) ) ) flush_msg() job.dr14 = dr14 job.dB_peak = dB_peak job.dB_rms = dB_rms job.duration = duration.to_float() job.sha1 = sha1 else: job.fail = True print_msg( "- fail - " + full_file ) res_queue_sh.put( job ) job_queue_sh.task_done()
def run_mp(self, job_queue_sh, res_queue_sh): at = AudioTrack() duration = StructDuration() #print_msg("start .... ") while True: if job_queue_sh.empty(): return job = job_queue_sh.get() full_file = os.path.join(job.dir_name, job.file_name) #print ( full_file ) if at.open(full_file): (dr14, dB_peak, dB_rms) = compute_dr14(at.Y, at.Fs, duration) sha1 = sha1_track_v1(at.Y, at.get_file_ext_code()) print_msg(job.file_name + ": \t DR " + str(int(dr14))) flush_msg() job.dr14 = dr14 job.dB_peak = dB_peak job.dB_rms = dB_rms job.duration = duration.to_float() job.sha1 = sha1 else: job.fail = True print_msg("- fail - " + full_file) res_queue_sh.put(job) job_queue_sh.task_done()
def compute( self , Y , Fs ): return compute_dr14( Y , Fs , self.duration , self.Dr_lr )