# HG changeset patch # User fazekasgy # Date 1250695277 0 # Node ID ba3686eb697c1da7e45b1db2a2c83376c29cdb79 # Parent 7648f3f2fa1470328e5c2d2e19ea804f4710edb9 examples now pass all tests diff -r 7648f3f2fa14 -r ba3686eb697c Example VamPy plugins/PySpectralFeatures.py --- a/Example VamPy plugins/PySpectralFeatures.py Tue Aug 18 08:32:45 2009 +0000 +++ b/Example VamPy plugins/PySpectralFeatures.py Wed Aug 19 15:21:17 2009 +0000 @@ -10,18 +10,23 @@ self.m_stepSize = 0 self.m_blockSize = 0 self.m_channels = 0 - self.threshold = 0.00 + self.threshold = 0.05 self.r = 2.0 + return None def initialise(self,channels,stepSize,blockSize): self.m_channels = channels self.m_stepSize = stepSize self.m_blockSize = blockSize - #self.prevMag = ones((blockSize/2)-1) / ((blockSize/2)-1) self.prevMag = zeros((blockSize/2)-1) self.prevMag[0] = 1 - return True + + def reset(self): + # reset any initial conditions + self.prevMag = zeros((self.m_blockSize/2)-1) + self.prevMag[0] = 1 + return None def getMaker(self): return 'VamPy Example Plugins' @@ -109,7 +114,7 @@ threshold={ 'identifier':'threshold', 'name':'Noise threshold: ', - 'description':'', + 'description':'Noise threshold', 'unit':'v', 'minValue':0.0, 'maxValue':0.5, @@ -120,11 +125,11 @@ renyicoeff={ 'identifier':'r', 'name':'Renyi entropy coeff: ', - 'description':'', + 'description':'Renyi entropy coeff', 'unit':'', 'minValue':0.0, 'maxValue':10.0, - 'defaultValue':2, + 'defaultValue':2.0, 'isQuantized':False } @@ -151,8 +156,10 @@ #for time domain plugins use the following line: #audioSamples = frombuffer(membuffer[0],float32) - #-1: do till the end, skip DC 2*32bit / 8bit = 8byte + #for frequency domain plugins use the following line: complexSpectrum = frombuffer(membuffer[0],complex64,-1,8) + #meaning of the parameters above: + #-1: do until the end, skip DC 2*32bit / 8bit = 8byte magnitudeSpectrum = abs(complexSpectrum) / (fftsize/2) tpower = sum(magnitudeSpectrum) #phaseSpectrum = angle(complexSpectrum) @@ -165,11 +172,8 @@ bw = 0.0 shannon = 0.0 renyi = 0.0 - r = self.r KLdiv = 0.0 - flatness = 0.0 exp=1.0 / (fftsize/2) - #print exp #declare outputs output0=[] @@ -184,11 +188,9 @@ centroid = sum(freq * magnitudeSpectrum) / tpower crest = max(magnitudeSpectrum) / tpower bw = sum( abs(freq - centroid) * magnitudeSpectrum ) / tpower - #flatness = prod(abs(complexSpectrum)) - #print flatness normMag = magnitudeSpectrum / tpower #make it sum to 1 shannon = - sum( normMag * log2(normMag) ) - renyi = (1/1-r) * log10( sum( power(normMag,r))) + renyi = (1/1-self.r) * log10( sum( power(normMag,self.r))) KLdiv = sum( normMag * log2(normMag / self.prevMag) ) self.prevMag = normMag @@ -230,3 +232,4 @@ #return a LIST of list of dictionaries return [output0,output1,output2,output3,output4,output5] + diff -r 7648f3f2fa14 -r ba3686eb697c Example VamPy plugins/PyZeroCrossing.py --- a/Example VamPy plugins/PyZeroCrossing.py Tue Aug 18 08:32:45 2009 +0000 +++ b/Example VamPy plugins/PyZeroCrossing.py Wed Aug 19 15:21:17 2009 +0000 @@ -74,7 +74,7 @@ paramlist1={ 'identifier':'threshold', 'name':'Noise threshold', - 'description':'', + 'description':'Noise threshold', 'unit':'v', 'minValue':0.0, 'maxValue':0.5, diff -r 7648f3f2fa14 -r ba3686eb697c pyvamp-main.cpp --- a/pyvamp-main.cpp Tue Aug 18 08:32:45 2009 +0000 +++ b/pyvamp-main.cpp Wed Aug 19 15:21:17 2009 +0000 @@ -181,7 +181,6 @@ // PyEval_InitThreads(); //not sure why this was needed } - vector pyPlugs; vector pyPath; vector pyClasses;