Skip to content

Commit

Permalink
Move general nyquist methods up into base SampleRate class
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnVinyard committed Feb 20, 2018
1 parent 6e34ce6 commit fb95e6a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions zounds/timeseries/samplerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ def overlap_ratio(self):
"""
return self.overlap / self.duration

@property
def samples_per_second(self):
return int(Picoseconds(int(1e12)) / self.frequency)

@property
def nyquist(self):
return self.samples_per_second // 2

def __mul__(self, other):
try:
if len(other) == 1:
Expand Down Expand Up @@ -125,14 +133,6 @@ def __init__(self, samples_per_second, suggested_window, suggested_hop):
def __int__(self):
return self.samples_per_second

@property
def samples_per_second(self):
return int(Picoseconds(int(1e12)) / self.frequency)

@property
def nyquist(self):
return self.samples_per_second // 2

def half_lapped(self):
return SampleRate(
self.one_sample * self.suggested_hop,
Expand Down Expand Up @@ -235,6 +235,7 @@ class SR16000(AudioSampleRate):
>>> sr.nyquist
8000
"""

def __init__(self):
super(SR16000, self).__init__(16000, 512, 256)

Expand Down

0 comments on commit fb95e6a

Please sign in to comment.