コード例 #1
0
ファイル: lorisdoc.py プロジェクト: gesellkammer/loristrck
def createFreqReference( partials, minFreq, maxFreq, numSamps = 0 ):
	"""
	Return a newly-constructed BreakpointEnvelope by sampling the 
	frequency envelope of the longest Partial in a PartialList. 
	Only Partials whose frequency at the Partial's loudest (highest 
	amplitude) breakpoint is within the given frequency range are 
	considered. 
	
	If the number of sample points is not specified, then the
	longest Partial's frequency envelope is sampled every 30 ms
	(No fewer than 10 samples are used, so the sampling maybe more
	dense for very short Partials.) 
	
	For very simple sounds, this frequency reference may be a 
	good first approximation to a reference envelope for
	channelization (see channelize()).
 	"""
 	return loris.createFreqReference( partials, minFreq, maxFreq, numSamps )
コード例 #2
0
ファイル: lorisdoc.py プロジェクト: CaishunChen/loristrck
def createFreqReference(partials, minFreq, maxFreq, numSamps=0):
    """
	Return a newly-constructed BreakpointEnvelope by sampling the 
	frequency envelope of the longest Partial in a PartialList. 
	Only Partials whose frequency at the Partial's loudest (highest 
	amplitude) breakpoint is within the given frequency range are 
	considered. 
	
	If the number of sample points is not specified, then the
	longest Partial's frequency envelope is sampled every 30 ms
	(No fewer than 10 samples are used, so the sampling maybe more
	dense for very short Partials.) 
	
	For very simple sounds, this frequency reference may be a 
	good first approximation to a reference envelope for
	channelization (see channelize()).
 	"""
    return loris.createFreqReference(partials, minFreq, maxFreq, numSamps)
コード例 #3
0
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:
f = 0
n = 0
import sys
if float(sys.version[:3]) >= 2.2:
	p = clar.first()
	for pos in p:
		f = f + pos.frequency()
		n = n + 1
else:
	p = clar.iterator().next()
コード例 #4
0
# (this reduces the number of partials considerably by 
# connecting and condensing related partials; for example, 
# in quasi-harmonic sounds, the distillation process yields
# one partial per harmonic)
# - a test synthesis of the distilled partials is performed,
# just as a sanity check, and to verify the suitability of the
# analysis configuration and distillation parameters
#
print 'analyzing flute 3D (%s)' % time.ctime(time.time())
a = loris.Analyzer(.8*291, 1.0*291)
ff = loris.AiffFile( os.path.join(srcdir, 'flute.source.aiff') )
v = ff.samples()
samplerate = ff.sampleRate()
flut = a.analyze( v, samplerate )
print 'using fundamental as reference'
flut_env = loris.createFreqReference( flut, 250, 500, 20 )
loris.channelize( flut, flut_env, 1 )
loris.distill( flut )

#
#	analyze clarinet tone
#
print 'analyzing clarinet 3G# (%s)' % time.ctime(time.time())
a = loris.Analyzer(.8*415, 1.0*415)
cf = loris.AiffFile( os.path.join(srcdir, 'clarinet.source.aiff') )
v = cf.samples()
samplerate = cf.sampleRate()
clar = a.analyze( v, samplerate )
print 'using fundamental as reference'
env = loris.createFreqReference( clar, 350, 500, 20 )
loris.channelize( clar, env, 1 )