second_analysis = analyze_aiff(second_aiff) length_of_first = get_length_of_aiff(first_aiff)[0] 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()
# flute analysis: fund = loris.copyLabeled( flut, 1 ); print "avg frequency of first distilled flute partial is", loris.weightedAvgFrequency( fund.first() ) # # perform temporal dilation # flute_times = [0.4, 1.] clar_times = [0.2, 1.] tgt_times = [0.3, 1.2] print 'dilating sounds to match', tgt_times, '(%s)' % time.ctime(time.time()) print 'flute times:', flute_times loris.dilate( flut, flute_times, tgt_times ) print 'clarinet times:', clar_times loris.dilate( clar, clar_times, tgt_times ) # # perform morph # print 'morphing flute and clarinet (%s)' % time.ctime(time.time()) mf = loris.BreakpointEnvelope() mf.insertBreakpoint( 0.6, 0 ) mf.insertBreakpoint( 2, 1 ) m = loris.morph( clar, flut, mf, mf, mf ) loris.exportAiff( 'morph.pytest.aiff', loris.synthesize( m, samplerate ), samplerate, 16 ) print 'done (%s)' % time.ctime(time.time())
# # perform morphs # # Morphs are from the first sound to the # second over the time 0.6 to 1.6 seconds. # mf = loris.LinearEnvelope() mf.insertBreakpoint( 0.6, 0 ) mf.insertBreakpoint( 1.6, 1 ) samplerate = 44100. print 'morphing flute and clarinet (%s)' % time.ctime(time.time()) m = loris.morph( clar, flut, mf, mf, mf ) # render samples, and export to AIFF samps = loris.synthesize( m, samplerate ) loris.exportAiff( 'clariflute.aiff', samps, samplerate, 16 ) print 'exporting sdif file clariflute.aiff', '(%s)' % time.ctime(time.time()) loris.exportSdif( 'clariflute.sdif', m ) # morph and render samples m = loris.morph( flut, clar, mf, mf, mf ) fout = loris.AiffFile( m, samplerate ) fout.write( 'flutinet.aiff' ) print 'morphing flute and cello (%s)' % time.ctime(time.time())
tgt_times = [0.3, 1.2] print 'dilating sounds to match', tgt_times, '(%s)' % time.ctime(time.time()) print 'flute times:', flute_times loris.dilate(flut, flute_times, tgt_times) print 'clarinet times:', clar_times loris.dilate(clar, clar_times, tgt_times) # # perform morph # print 'morphing flute and clarinet (%s)' % time.ctime(time.time()) mf = loris.LinearEnvelope() mf.insertBreakpoint(0.6, 0) mf.insertBreakpoint(2, 1) m = loris.morph(clar, flut, mf, mf, mf) loris.exportAiff('morph.pytest.aiff', loris.synthesize(m, samplerate), samplerate, 16) # # sanity check on the morph # # check the number and labeling of partials # (this will fail for very old versions of Python without sets I suppose) clarlabels = set() for p in clar: clarlabels.add(p.label()) flutlabels = set() for p in flut: flutlabels.add(p.label())
loris.exportSdif(fname, cel) # # perform morphs # # Morphs are from the first sound to the # second over the time 0.6 to 1.6 seconds. # mf = loris.LinearEnvelope() mf.insertBreakpoint(0.6, 0) mf.insertBreakpoint(1.6, 1) samplerate = 44100. print 'morphing flute and clarinet (%s)' % time.ctime(time.time()) m = loris.morph(clar, flut, mf, mf, mf) # render samples, and export to AIFF samps = loris.synthesize(m, samplerate) loris.exportAiff('clariflute.aiff', samps, samplerate, 16) print 'exporting sdif file clariflute.aiff', '(%s)' % time.ctime(time.time()) loris.exportSdif('clariflute.sdif', m) # morph and render samples m = loris.morph(flut, clar, mf, mf, mf) fout = loris.AiffFile(m, samplerate) fout.write('flutinet.aiff') print 'morphing flute and cello (%s)' % time.ctime(time.time()) print 'shifting flute pitch down by eleven half steps' flut_low = flut.copy()
# # perform morphs # # Morphs are from the first sound to the # second over the time 0.6 to 1.6 seconds. # mf = loris.BreakpointEnvelope() mf.insertBreakpoint( 0.6, 0 ) mf.insertBreakpoint( 1.6, 1 ) samplerate = 44100. print 'morphing flute and clarinet (%s)' % time.ctime(time.time()) m = loris.morph( clar, flut, mf, mf, mf ) loris.exportAiff( 'clariflute.aiff', loris.synthesize( m, samplerate ), samplerate, 1, 16 ) print 'exporting sdif file clariflute.aiff', '(%s)' % time.ctime(time.time()) loris.exportSdif( 'clariflute.sdif', m ) loris.exportAiff( 'flutinet.aiff', loris.synthesize( loris.morph( flut, clar, mf, mf, mf ), samplerate ), samplerate, 1, 16 ) print 'morphing flute and cello (%s)' % time.ctime(time.time()) print 'shifting flute pitch down by eleven half steps' flut_low = flut.copy() loris.shiftPitch( flut_low, loris.BreakpointEnvelopeWithValue( -1100 ) )