# 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 # clarinet analysis:
def analyze_if_needed(self, aiff_file = None): if aiff_file and os.path.isfile(aiff_file[:-4]+'.sdif'):#is there a twin sdif analysis self.analysis = loris.importSdif(aiff_file[:-4]+'.sdif')#if so, use it else: self.analyze(aiff_file) return self
# 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) # just for fun, print out the average