コード例 #1
0
ファイル: samples.py プロジェクト: musictheory/piano.js
    def get_partials(frames):
        analyzer = loris.Analyzer(0.8 * frequency, frequency)
        analyzer.setFreqDrift(0.48 * frequency)

        partials = analyzer.analyze(frames, SAMPLE_RATE)

        stretch = compute_stretch_factor(partials, frequency)
        if (stretch < 0): stretch = 0

        #        loris.resample(partials, 0.01)
        loris.Channelizer(frequency, stretch).channelize(partials)
        loris.distill(partials)

        return partials
コード例 #2
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()
	it = p.iterator()
コード例 #3
0
ファイル: morphtest.py プロジェクト: gesellkammer/loristrck
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()
    it = p.iterator()
コード例 #4
0
ファイル: lorisAnalysis.py プロジェクト: thanhmaikmt/pjl
  
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"

    
#path = os.getcwd()