length_of_second = get_length_of_aiff(second_aiff)[0] longest = max(length_of_first,length_of_second) if longest == length_of_first: loris.dilate(second_analysis,[0.,length_of_second],[0,length_of_first]) elif longest == length_of_second: loris.dilate(first_analysis,[0.,length_of_first],[0,length_of_second]) #loris.distill(first_analysis) #loris.distill(second_analysis) envelope_create = loris.BreakpointEnvelope() envelope_create.insertBreakpoint(naked_start,0) envelope_create.insertBreakpoint(longest-naked_end,1) morph = loris.morph(first_analysis,second_analysis,envelope_create,envelope_create, envelope_create) loris.crop(morph,0,longest) synth = loris.synthesize(morph, 44100) loris.exportAiff( first_aiff+'morph.aiff',synth,44100, 1, 16 ) def thin_by_duration(partialList,minimum_duration):#stolen--- iter = partialList.begin() end = partialList.end() tempList = loris.PartialList() tempIter = tempList.begin() while not iter.equals(end): part = iter.partial() dur = part.duration() if dur >= minimum_duration: tempIter = tempList.insert(tempIter, part) tempIter = tempIter.next() #print tempIter iter = iter.next() print tempList.size(),'partials'
def resynthesize(partials,path, samplerate = 44100, nchannels = 1, bitsPerSamp = 16): resynthesis_vector = loris.synthesize(partials,samplerate) loris.exportAiff(path,resynthesis_vector,samplerate,nchannels,bitsPerSamp)
f = f + pos.frequency() n = n + 1 else: p = clar.iterator().next() it = p.iterator() while not it.atEnd(): f = f + it.next().frequency() n = n + 1 print "avg frequency of first distilled clarinet partial is", f/n print 'shifting pitch of clarinet' loris.shiftPitch( clar, loris.BreakpointEnvelope( -600 ) ) # check clarinet synthesis: loris.exportAiff( 'clarOK.pytest.aiff', loris.synthesize( clar, samplerate ), samplerate, 16 ) # # analyze flute tone (reuse Analyzer) # print 'analyzing flute 4D (%s)' % time.ctime(time.time()) a = loris.Analyzer( 270 ) # reconfigure Analyzer a.setFreqDrift( 30 ) v = loris.AiffFile( os.path.join(path, 'flute.aiff') ).samples() flut = a.analyze( v, samplerate ) loris.channelize( flut, loris.createFreqReference( flut, 291*.8, 291*1.2, 50 ), 1 ) loris.distill( flut ) # check flute synthesis: loris.exportAiff( 'flutOK.pytest.aiff', loris.synthesize( flut, samplerate ), samplerate, 16 )
print 'flute times:', flute_times loris.dilate( flut, flute_times, tgt_times ) print 'clarinet times:', clar_times 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'
f = f + pos.frequency() n = n + 1 else: p = clar.iterator().next() it = p.iterator() while not it.atEnd(): f = f + it.next().frequency() n = n + 1 print "avg frequency of first distilled clarinet partial is", f / n print 'shifting pitch of clarinet' loris.shiftPitch(clar, loris.LinearEnvelope(-600)) # check clarinet synthesis: loris.exportAiff('clarOK.pytest.aiff', loris.synthesize(clar, samplerate), samplerate, 16) # # analyze flute tone # print 'analyzing flute 4D (%s)' % time.ctime(time.time()) a = loris.Analyzer(270) # reconfigure Analyzer a.setFreqDrift(30) v = loris.AiffFile(os.path.join(path, 'flute.aiff')).samples() flut = a.analyze(v, samplerate) # loris.channelize( flut, loris.createFreqReference( flut, 291*.8, 291*1.2, 50 ), 1 ) refenv = a.fundamentalEnv() loris.channelize(flut, refenv, 1) loris.distill(flut)
print 'flute times:', flute_times loris.dilate(flut, flute_times, tgt_times) print 'clarinet times:', clar_times 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 'flute times:', flute_times loris.dilate( flut, str(flute_times), str(tgt_times) ) print 'clarinet times:', clar_times loris.dilate( clar, str(clar_times), str(tgt_times) ) print 'cello times:', cel_times loris.dilate( cel, str(cel_times), str(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, 1, 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, 1, 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, 1, 16 ) fname = 'cello.dilated.sdif'