コード例 #1
0
ファイル: pymp_tutorial2.py プロジェクト: agramfort/PyMP
print (SNR, bitrate)

print "With Q=5"
SNR, bitrate, quantizedApprox = MPCoder.SimpleMDCTEncoding(mpApprox, 8000, Q=5);
print (SNR, bitrate)


SNR, bitrate, quantizedApprox = MPCoder.SimpleMDCTEncoding(mpApprox, 2000, Q=14);
print (SNR, bitrate)

pyLODico = pymp_MDCTDico.pymp_LODico(scales);
lompApprox , lompDecay = MP.MP(myPympSignal, pyLODico, 20, 2000,padSignal=False);  
SNRlo, bitratelo, quantizedApproxLO = MPCoder.SimpleMDCTEncoding(lompApprox, 2000, Q=14, TsPenalty=True);
print (SNRlo, bitratelo)

pyRSSDico = pymp_RandomDicos.pymp_RandomDico(scales);
rssApprox , rssDecay = MP.MP(myPympSignal, pyRSSDico, 20, 2000,padSignal=False);  
SNRrss, bitraterss, quantizedApproxRSS = MPCoder.SimpleMDCTEncoding(rssApprox, 2000, Q=14);
print (SNRrss, bitraterss)

print (quantizedApprox.atomNumber,  quantizedApproxLO.atomNumber , quantizedApproxRSS.atomNumber)

#quantizedApprox.plotTF()
#plt.show()


print " now at a much larger level : a SNR of nearly 50 dB and around 64 Kbps"
mpApprox , mpDecay = MP.MP(myPympSignal, pyDico, 50, 20000,padSignal=False); 
SNR, bitrate, quantizedApprox = MPCoder.SimpleMDCTEncoding(mpApprox, 64000, Q=16);
print (SNR, bitrate)
コード例 #2
0
ファイル: RSSMP_example.py プロジェクト: agramfort/PyMP
mpl.rcParams['image.interpolation'] = 'Nearest';
mpl.rcParams['text.usetex'] = True;

# Load glockenspiel signal
abPath = os.path.abspath('../../data/');
pySig = pymp_Signal.InitFromFile(abPath+'/glocs.wav',forceMono=True,doNormalize=True);

pySig.crop(0,3*pySig.samplingFrequency)

scales = [128,1024,8192];
nbAtom = 500;
srr = 30;

mpDico = pymp_MDCTDico.pymp_MDCTDico(scales)
lompDico = pymp_MDCTDico.pymp_LODico(scales)
rssMPDico = pymp_RandomDicos.pymp_RandomDico(scales)

approxMP , decayMP = MP.MP(pySig,mpDico,srr,nbAtom,padSignal=True);
approxLoMP, decayLoMP = MP.MP(pySig,lompDico,srr,nbAtom,padSignal=True);
approxRSSMP, decayRSSMP = MP.MP(pySig,rssMPDico,srr,nbAtom,padSignal=False);


plt.figure()
plt.plot(10*np.log10(decayMP) - 10*np.log10(decayMP[0]))
plt.plot(10*np.log10(decayLoMP) - 10*np.log10(decayLoMP[0]),'r:')
plt.plot(10*np.log10(decayRSSMP) - 10*np.log10(decayRSSMP[0]),'k--')
plt.ylabel('Normalized reconstruction error (dB)')
plt.xlabel('Iteration')
plt.legend(('Standard MP','Locally Optimized MP','RSS MP'))
plt.grid()
plt.show()