def estimate_pitches(self, audio_url): input_audio_path = os.path.join(settings.MEDIA_ROOT, self.fk_audio.audio_file.name) # get filename and change extension to mei filename, _ = os.path.splitext(os.path.split(input_audio_path)[1]) filename += '.mei' # perform the pitch estimation on the audio input file pt = PolyphonicTranscription() mei_str = pt(audio_url, input_audio_path) # save the mei to the output file file_contents = ContentFile(mei_str) pmei = MeiPitch(fk_mid=self.fk_audio.fk_mid) pmei.mei_file.save(filename, file_contents, save=True) # sanitize pitches to conform with the guitar model if self.fk_guitar is not None: guitarify = Guitarify(self.fk_guitar.num_frets, self.fk_guitar.tuning, self.fk_guitar.capo) # write in place guitarify.sanitize_mei_file(pmei.get_abs_path(), pmei.get_abs_path(), prune=self.pitch_sanitize_prune) pmei.mei_append_metamusic() # attach the tab to the Tabulate object self.fk_pmei = pmei # Note that saving also updates self.output_ts to clock out the # analysis time self.save()
def gen_tab(self): input_mei_path = os.path.join(settings.MEDIA_ROOT, self.fk_pmei.mei_file.name) filename = os.path.split(input_mei_path)[1] # sanitize pitches to conform with the guitar model # don't clobber original pmei file, since the tablature should be able to be arranged # with different guitar models guitarify = Guitarify(self.fk_guitar.num_frets, self.fk_guitar.tuning, self.fk_guitar.capo) sanitized_mei_str = guitarify.sanitize_mei_file(self.fk_pmei.get_abs_path(), None, prune=self.pitch_sanitize_prune) # perform the tablature arrangement of the input mei ta = TablatureArrangement() mei_str = ta(self.fk_guitar.num_frets, self.fk_guitar.tuning, self.fk_guitar.capo, sanitized_mei_str) file_contents = ContentFile(mei_str) tab = MeiTab(fk_mid=self.fk_pmei.fk_mid) tab.mei_file.save(filename, file_contents, save=True) # append data about the guitar to the MEI document tab.append_guitar_data(self.fk_guitar.tuning, self.fk_guitar.capo) # attach the tab to the Tabulate object self.fk_tmei = tab # Note that saving also updates self.output_ts to clock out the # analysis time self.save()
def gen_tab(self): input_mei_path = os.path.join(settings.MEDIA_ROOT, self.fk_pmei.mei_file.name) filename = os.path.split(input_mei_path)[1] # sanitize pitches to conform with the guitar model # don't clobber original pmei file, since the tablature should be able to be arranged # with different guitar models guitarify = Guitarify(self.fk_guitar.num_frets, self.fk_guitar.tuning, self.fk_guitar.capo) sanitized_mei_str = guitarify.sanitize_mei_file( self.fk_pmei.get_abs_path(), None, prune=self.pitch_sanitize_prune) # perform the tablature arrangement of the input mei ta = TablatureArrangement() mei_str = ta(self.fk_guitar.num_frets, self.fk_guitar.tuning, self.fk_guitar.capo, sanitized_mei_str) file_contents = ContentFile(mei_str) tab = MeiTab(fk_mid=self.fk_pmei.fk_mid) tab.mei_file.save(filename, file_contents, save=True) # append data about the guitar to the MEI document tab.append_guitar_data(self.fk_guitar.tuning, self.fk_guitar.capo) # attach the tab to the Tabulate object self.fk_tmei = tab # Note that saving also updates self.output_ts to clock out the # analysis time self.save()