comparison Example VamPy plugins/PyZeroCrossing.py @ 1:dc88002ce687

some typos corrected
author fazekasgy
date Tue, 11 Mar 2008 20:24:58 +0000
parents e20e214bdfb5
children e1b508f2f914
comparison
equal deleted inserted replaced
0:e20e214bdfb5 1:dc88002ce687
1 '''PyZeroCrossing.py - Example plugin designed to demonstrate''' 1 '''PyZeroCrossing.py - Example plugin demonstrates'''
2 '''how to call a python class using the VamPy VAMP plugin''' 2 '''how to call a python class using the VamPy VAMP plugin'''
3 3
4 #from time import * 4 #from time import *
5 #import sys 5 #import sys
6 6
36 def getInputDomain(self): 36 def getInputDomain(self):
37 return 'TimeDomain' 37 return 'TimeDomain'
38 38
39 def getOutputDescriptors(self): 39 def getOutputDescriptors(self):
40 40
41 #python dictionary 41 #descriptors are python dictionary
42 output0={ 42 output0={
43 'identifier':'vampy-counts', 43 'identifier':'vampy-counts',
44 'name':'Number of Zero Crossings', 44 'name':'Number of Zero Crossings',
45 'description':'Number of zero crossings per audio frame', 45 'description':'Number of zero crossings per audio frame',
46 'unit':' ', 46 'unit':' ',
117 if prev <= 0.0 : crossing = True 117 if prev <= 0.0 : crossing = True
118 118
119 if crossing == True : 119 if crossing == True :
120 count = count + 1 120 count = count + 1
121 feature1={ 121 feature1={
122 'hasTimestamp':True, #bool 122 'hasTimestamp':True,
123 #for now return sample position and convert to RealTime in C code 123 #for now return sample position and convert to RealTime in C code
124 'timeStamp':x 124 'timeStamp':x
125 #'values':[count] 125 #'values':[count]
126 #'label':label 126 #'label':label
127 } 127 }
133 count = 0.0 133 count = 0.0
134 self.previousSample = inbuf[len(inbuf)-2] 134 self.previousSample = inbuf[len(inbuf)-2]
135 135
136 feature0={ 136 feature0={
137 'hasTimestamp':False, 137 'hasTimestamp':False,
138 'values':[count], #strictly must be a list 138 'values':[count], #strictly must be a list
139 'label':str(count) 139 'label':str(count)
140 } 140 }
141 output0.append(feature0) 141 output0.append(feature0)
142 142
143 #return a LIST of list of dictionaries 143 #return a LIST of list of dictionaries