def analyze(self, aiff_file=None, resolution_hz = 5.0): aiff_file = aiff_file or self.aiff_file self.analysis = analyze_aiff(self.aiff_file)#, resolution_hz) self.original_partials = self.analysis#store a copy of the original analysis data loris.exportSdif(aiff_file[:-4]+'.sdif', self.analysis)
# # analyze clarinet tone # print 'analyzing clarinet 4G# (%s)' % time.ctime(time.time()) a = loris.Analyzer( 390 ) a.setFreqDrift( 30 ) a.setAmpFloor( -80 ) cf = loris.AiffFile( os.path.join(path, 'clarinet.aiff') ) v = cf.samples() samplerate = cf.sampleRate() clar = a.analyze( v, samplerate ) print 'checking SDIF export/import' loris.exportSdif( 'clarinet.pytest.sdif', clar ) clar = loris.importSdif( 'clarinet.pytest.sdif' ) try: print 'making a bogus attempt at writing an Spc file' print 'WARNING: this will fail because the Partials are unchannelized' loris.exportSpc( 'bad_spc_file.pytest.spc', clar, 90 ) except: import sys print 'caught:', sys.exc_type, sys.exc_value loris.channelize( clar, loris.createFreqReference( clar, 415*.8, 415*1.2 ), 1 ) loris.distill( clar ) # just for fun, print out the average # frequency of the first partial in the
# # analyze clarinet tone # print 'analyzing clarinet 4G# (%s)' % time.ctime(time.time()) a = loris.Analyzer(390) a.setFreqDrift(30) a.setAmpFloor(-80) cf = loris.AiffFile(os.path.join(path, 'clarinet.aiff')) v = cf.samples() samplerate = cf.sampleRate() clar = a.analyze(v, samplerate) print 'checking SDIF export/import' loris.exportSdif('clarinet.pytest.sdif', clar) clar = loris.importSdif('clarinet.pytest.sdif') try: print 'making a bogus attempt at writing an Spc file --' print 'this will fail because the Partials are unchannelized' loris.exportSpc('bad_spc_file.pytest.spc', clar, 90) except: import sys print 'caught:', sys.exc_type print 'error is:', sys.exc_value print 'OK, moving on!' loris.channelize(clar, 415) loris.distill(clar)
loris.dilate( clar, clar_times, tgt_times ) print 'cello times:', cel_times loris.dilate( cel, cel_times, tgt_times ) # # synthesize and save dilated sources # # Save the synthesized samples files, and SDIF files # for each dilated source. # fname = 'flute.dilated.aiff' print 'synthesizing', fname, '(%s)' % time.ctime(time.time()) loris.exportAiff( fname, loris.synthesize( flut, samplerate ), samplerate, 16 ) fname = 'flute.dilated.sdif' print 'exporting sdif file:', fname, '(%s)' % time.ctime(time.time()) loris.exportSdif( fname, flut ) fname = 'clar.dilated.aiff' print 'synthesizing', fname, '(%s)' % time.ctime(time.time()) loris.exportAiff( fname, loris.synthesize( clar, samplerate ), samplerate, 16 ) fname = 'clarinet.dilated.sdif' print 'exporting sdif file:', fname, '(%s)' % time.ctime(time.time()) loris.exportSdif( fname, clar ) fname = 'cello.dilated.aiff' print 'synthesizing', fname, '(%s)' % time.ctime(time.time()) loris.exportAiff( fname, loris.synthesize( cel, samplerate ), samplerate, 16 ) fname = 'cello.dilated.sdif' print 'exporting sdif file:', fname, '(%s)' % time.ctime(time.time()) loris.exportSdif( fname, cel )
loris.dilate(clar, clar_times, tgt_times) print 'cello times:', cel_times loris.dilate(cel, cel_times, tgt_times) # # synthesize and save dilated sources # # Save the synthesized samples files, and SDIF files # for each dilated source. # fname = 'flute.dilated.aiff' print 'synthesizing', fname, '(%s)' % time.ctime(time.time()) loris.exportAiff(fname, loris.synthesize(flut, samplerate), samplerate, 16) fname = 'flute.dilated.sdif' print 'exporting sdif file:', fname, '(%s)' % time.ctime(time.time()) loris.exportSdif(fname, flut) fname = 'clar.dilated.aiff' print 'synthesizing', fname, '(%s)' % time.ctime(time.time()) loris.exportAiff(fname, loris.synthesize(clar, samplerate), samplerate, 16) fname = 'clarinet.dilated.sdif' print 'exporting sdif file:', fname, '(%s)' % time.ctime(time.time()) loris.exportSdif(fname, clar) fname = 'cello.dilated.aiff' print 'synthesizing', fname, '(%s)' % time.ctime(time.time()) loris.exportAiff(fname, loris.synthesize(cel, samplerate), samplerate, 16) fname = 'cello.dilated.sdif' print 'exporting sdif file:', fname, '(%s)' % time.ctime(time.time()) loris.exportSdif(fname, cel)