summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Glover <j@johnglover.net>2012-07-10 21:40:56 +0100
committerJohn Glover <j@johnglover.net>2012-07-10 21:40:56 +0100
commite539ccf6c01dc5f19f2aa34180f418e92da269b6 (patch)
tree5eb369cc06411a43d55c5f2a069606bce09f2acf
parent45501bc568d51ff17eeaffaf1eb7118d4c726fc8 (diff)
downloadsimpl-e539ccf6c01dc5f19f2aa34180f418e92da269b6.tar.gz
simpl-e539ccf6c01dc5f19f2aa34180f418e92da269b6.tar.bz2
simpl-e539ccf6c01dc5f19f2aa34180f418e92da269b6.zip
[sms] Some updates to old Python code to work with new C++ types.
-rw-r--r--simpl/pysms.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/simpl/pysms.py b/simpl/pysms.py
index e683ac2..79f9a69 100644
--- a/simpl/pysms.py
+++ b/simpl/pysms.py
@@ -7,14 +7,14 @@ class SMSPeakDetection(simpl.PeakDetection):
"Sinusoidal peak detection using SMS"
def __init__(self):
- simpl.PeakDetection.__init__(self)
+ super(SMSPeakDetection, self).__init__()
simplsms.sms_init()
# analysis parameters
self._analysis_params = simplsms.SMS_AnalParams()
simplsms.sms_initAnalParams(self._analysis_params)
- self._analysis_params.iSamplingRate = self._sampling_rate
+ self._analysis_params.iSamplingRate = self.sampling_rate
# set default hop and frame sizes to match those in the parent class
- self._analysis_params.iFrameRate = self.sampling_rate / self._hop_size
+ self._analysis_params.iFrameRate = self.sampling_rate / self.hop_size
self._analysis_params.iWindowType = simplsms.SMS_WIN_HAMMING
self._analysis_params.fHighestFreq = 20000
self._analysis_params.iMaxDelayFrames = 4
@@ -22,13 +22,13 @@ class SMSPeakDetection(simpl.PeakDetection):
self._analysis_params.minGoodFrames = 1
self._analysis_params.iCleanTracks = 0
self._analysis_params.iFormat = simplsms.SMS_FORMAT_HP
- self._analysis_params.nTracks = self._max_peaks
- self._analysis_params.maxPeaks = self._max_peaks
- self._analysis_params.nGuides = self._max_peaks
+ self._analysis_params.nTracks = self.max_peaks
+ self._analysis_params.maxPeaks = self.max_peaks
+ self._analysis_params.nGuides = self.max_peaks
self._analysis_params.preEmphasis = 0
if simplsms.sms_initAnalysis(self._analysis_params) != 0:
raise Exception("Error allocating memory for analysis_params")
- self._peaks = simplsms.SMS_SpectralPeaks(self._max_peaks)
+ self._peaks = simplsms.SMS_SpectralPeaks(self.max_peaks)
# By default, SMS will change the size of the frames being read
# depending on the detected fundamental frequency (if any) of the
# input sound. To prevent this behaviour (useful when comparing
@@ -142,10 +142,13 @@ class SMSPeakDetection(simpl.PeakDetection):
if simplsms.sms_initAnalysis(self._analysis_params) != 0:
raise Exception("Error allocating memory for analysis_params")
- def get_hop_size(self):
- return self._analysis_params.sizeHop
+ @property
+ def hop_size(self):
+ return super(SMSPeakDetection, self).hop_size
- def set_hop_size(self, hop_size):
+ @hop_size.setter
+ def hop_size(self, hop_size):
+ simpl.PeakDetection.hop_size(self, hop_size)
simplsms.sms_freeAnalysis(self._analysis_params)
self._analysis_params.iFrameRate = self.sampling_rate / hop_size
if simplsms.sms_initAnalysis(self._analysis_params) != 0:
@@ -173,9 +176,6 @@ class SMSPeakDetection(simpl.PeakDetection):
# set peaks list
self._peaks = simplsms.SMS_SpectralPeaks(max_peaks)
- def get_sampling_rate(self):
- return self._analysis_params.iSamplingRate
-
def set_sampling_rate(self, sampling_rate):
self._analysis_params.iSamplingRate = sampling_rate
simplsms.sms_freeAnalysis(self._analysis_params)