diff options
author | John Glover <j@johnglover.net> | 2021-07-23 09:53:44 +0100 |
---|---|---|
committer | John Glover <j@johnglover.net> | 2021-07-23 09:53:44 +0100 |
commit | 19a2fa34b8b253fa5bfd7c8cbb7b51287d30cbbe (patch) | |
tree | 23f0f29b2c0137621986ad112e8ca9d225e1207a | |
parent | 5c63899cbffacb9a0506eb79f9b5d7c6398bd031 (diff) | |
download | simpl-19a2fa34b8b253fa5bfd7c8cbb7b51287d30cbbe.tar.gz simpl-19a2fa34b8b253fa5bfd7c8cbb7b51287d30cbbe.tar.bz2 simpl-19a2fa34b8b253fa5bfd7c8cbb7b51287d30cbbe.zip |
More Python 3 fixes
-rw-r--r-- | examples/plotpeaks.py | 2 | ||||
-rw-r--r-- | simpl/mq.py | 2 | ||||
-rw-r--r-- | simpl/plot/__init__.py | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/examples/plotpeaks.py b/examples/plotpeaks.py index ea9ff4c..adf9110 100644 --- a/examples/plotpeaks.py +++ b/examples/plotpeaks.py @@ -10,7 +10,7 @@ if len(sys.argv) != 2: audio = simpl.read_wav(sys.argv[1])[0] # take just a few frames -audio = audio[len(audio) / 2:(len(audio) / 2) + 4096] +audio = audio[len(audio) // 2:(len(audio) // 2) + 4096] # peak detection using the SndObj library pd = simpl.SndObjPeakDetection() diff --git a/simpl/mq.py b/simpl/mq.py index d8a701d..ef5acdd 100644 --- a/simpl/mq.py +++ b/simpl/mq.py @@ -186,7 +186,7 @@ class MQPartialTracking(simpl.PartialTracking): free_peaks = [p for p in free_peaks if p.amplitude > 0] distances = [abs(peak.frequency - p.frequency) for p in free_peaks] if len(distances): - min_distance_position = min(xrange(len(distances)), + min_distance_position = min(range(len(distances)), key=distances.__getitem__) if min(distances) < self._matching_interval: return free_peaks[min_distance_position] diff --git a/simpl/plot/__init__.py b/simpl/plot/__init__.py index 75441c6..65d45e9 100644 --- a/simpl/plot/__init__.py +++ b/simpl/plot/__init__.py @@ -6,7 +6,7 @@ def plot_peaks(frames): "Plot peaks found by a peak detection algorithm" # Get the maximum peak amplitude, used to select an appropriate # colour for each peak. - max_amp = None + max_amp = 0 for frame in frames: if frame.peaks: max_amp = max(max_amp, max([p.amplitude for p in frame.peaks])) @@ -26,7 +26,7 @@ def plot_partials(frames, show_peaks=False): "Plot partials created by a partial tracking algorithm" # Get the maximum peak amplitude, used to select an appropriate # colour for each peak. - max_amp = None + max_amp = 0 for frame in frames: if frame.partials: max_amp = max(max_amp, max([p.amplitude for p in frame.partials])) |