Ejemplo n.º 1
0
	number_of_samples = sound_file.sampleFrames()
	sample_rate = sound_file.sampleRate()
	time_in_seconds = number_of_samples/sample_rate
	print 'file is '+str(time_in_seconds)+' seconds'
	return time_in_seconds,sample_rate
	
def simple_morph((first_aiff, second_aiff),(naked_start,naked_end)):
	first_analysis = analyze_aiff(first_aiff)
	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()
Ejemplo n.º 2
0
# frequency of the first partial in the
# 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.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)

#
Ejemplo n.º 3
0
# just for fun, print out the average 
# frequency of the first partial in the
# 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 )
Ejemplo n.º 4
0
#	perform temporal dilation
#
# Times are the beginning and end times 
# of the attack and the release. To change 
# the duration of the morph, change the 
# target times (tgt_times), as well as the
# morphing function, mf, defined below.
# 
flute_times = [0.175, 0.4, 2.15, 2.31]
clar_times = [0., 0.185, 1.9, 2.15]
cel_times = [0., 0.13, 2.55, 3.9]
tgt_times = [0., 0.19, 3., 3.25]

print 'dilating sounds to match', tgt_times, '(%s)' % time.ctime(time.time())
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'