Exemple #1
0
def channelize(partials, refFreqEnvelope, refLabel):
    """
	Label Partials in a PartialList with the integer nearest to
	the amplitude-weighted average ratio of their frequency envelope
	to a reference frequency envelope. The frequency spectrum is 
	partitioned into non-overlapping channels whose time-varying 
	center frequencies track the reference frequency envelope. 
	The reference label indicates which channel's center frequency
	is exactly equal to the reference envelope frequency, and other
	channels' center frequencies are multiples of the reference 
	envelope frequency divided by the reference label. Each Partial 
	in the PartialList is labeled with the number of the channel
	that best fits its frequency envelope. The quality of the fit
	is evaluated at the breakpoints in the Partial envelope and
	weighted by the amplitude at each breakpoint, so that high-
	amplitude breakpoints contribute more to the channel decision.
	Partials are labeled, but otherwise unmodified. In particular, 
	their frequencies are not modified in any way.
 	"""
    loris.channelize(partials, refFreqEnvelope, refLabel)
Exemple #2
0
def channelize( partials, refFreqEnvelope, refLabel ):	
	"""
	Label Partials in a PartialList with the integer nearest to
	the amplitude-weighted average ratio of their frequency envelope
	to a reference frequency envelope. The frequency spectrum is 
	partitioned into non-overlapping channels whose time-varying 
	center frequencies track the reference frequency envelope. 
	The reference label indicates which channel's center frequency
	is exactly equal to the reference envelope frequency, and other
	channels' center frequencies are multiples of the reference 
	envelope frequency divided by the reference label. Each Partial 
	in the PartialList is labeled with the number of the channel
	that best fits its frequency envelope. The quality of the fit
	is evaluated at the breakpoints in the Partial envelope and
	weighted by the amplitude at each breakpoint, so that high-
	amplitude breakpoints contribute more to the channel decision.
	Partials are labeled, but otherwise unmodified. In particular, 
	their frequencies are not modified in any way.
 	"""
 	loris.channelize( partials, refFreqEnvelope, refLabel )
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()
Exemple #4
0
# 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 291 Hz as reference frequency for channelization'
flut_ref = loris.LinearEnvelope( 291 )
loris.channelize( flut, flut_ref, 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 estimated fundamental as reference'
env = a.fundamentalEnv()
loris.channelize( clar, env, 1 )
loris.distill( clar )
Exemple #5
0
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
# 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()
Exemple #6
0
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 
# 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()
Exemple #7
0
# 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 291 Hz as reference frequency for channelization'
flut_ref = loris.LinearEnvelope(291)
loris.channelize(flut, flut_ref, 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 estimated fundamental as reference'
env = a.fundamentalEnv()
loris.channelize(clar, env, 1)
loris.distill(clar)
Exemple #8
0
  
a = loris.Analyzer( 270 )       # reconfigure Analyzer
a.setFreqDrift( 30 )

file=loris.AiffFile( name+'.aiff' )
v = file.samples()
samplerate=file.sampleRate()

parts = a.analyze( v, samplerate )
    

# loris.channelize( flut, loris.createFreqReference( flut, 291*.8, 291*1.2, 50 ), 1 )

refenv = a.fundamentalEnv()
loris.channelize( parts, refenv, 1 )
loris.distill( parts )
 
     

for part in parts:
    print "*****************************************"
    it=part.iterator()
    while not it.atEnd():
        bp=it.next()
        print "t:",bp.time(), " a:",bp.amplitude()," bw:",bp.bandwidth()," f:",bp.frequency()," p:",bp.phase()
    
loris.exportSpc(name+".spc",parts,60)
print "Done"

    
# 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 )
loris.distill( clar )