Skip to content

Commit

Permalink
Fix broken tests. I'm starting to think I should just build docs and …
Browse files Browse the repository at this point in the history
…check them in
  • Loading branch information
JohnVinyard committed Aug 27, 2017
1 parent cdd992a commit 85d020c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
'numpy',
'scipy',
'scipy.fftpack',
'numpy.lib',
'numpy.lib.stride_tricks'
]

Expand Down
12 changes: 7 additions & 5 deletions zounds/timeseries/samplerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def resample(self, ratio):


class AudioSampleRate(SampleRate):

def __init__(self, samples_per_second, suggested_window, suggested_hop):
self.suggested_hop = suggested_hop
self.suggested_window = suggested_window
Expand Down Expand Up @@ -122,20 +123,21 @@ def __init__(self):
super(SR11025, self).__init__(11025, 512, 256)


_samplerates = (SR96000(), SR48000(), SR44100(), SR22050(), SR11025())


def audio_sample_rate(samples_per_second):
samplerates = (SR96000(), SR48000(), SR44100(), SR22050(), SR11025())
for sr in samplerates:
for sr in _samplerates:
if samples_per_second == sr.samples_per_second:
return sr
raise ValueError(
'{samples_per_second} is an invalid sample rate'.format(**locals()))


def nearest_audio_sample_rate(samples_per_second):
samplerates = (SR96000(), SR48000(), SR44100(), SR22050(), SR11025())
samplerates = np.array([s.samples_per_second for s in samplerates])
samplerates = np.array([s.samples_per_second for s in _samplerates])
diffs = np.abs(samples_per_second - samplerates)
return samplerates[np.argmin(diffs)]
return _samplerates[np.argmin(diffs)]


class HalfLapped(SampleRate):
Expand Down

0 comments on commit 85d020c

Please sign in to comment.