Consistently use ss and es identifiers for annotation emission to match
other decoders, as well as counting distances between sample points to
increase readability. This also dramatically reduces text line length.
raise SamplerateError('Cannot decode without samplerate.')
edge = self.options['edge']
avg_period = self.options['avg_period']
raise SamplerateError('Cannot decode without samplerate.')
edge = self.options['edge']
avg_period = self.options['avg_period']
last_n = deque()
last_t = None
while True:
last_n = deque()
last_t = None
while True:
else:
pin = self.wait({Pin.DATA: 'e'})
else:
pin = self.wait({Pin.DATA: 'e'})
- if not last_samplenum:
- last_samplenum = self.samplenum
+ if not ss:
+ ss = self.samplenum
- samples = self.samplenum - last_samplenum
+ es = self.samplenum
+ samples = es - ss
t = samples / self.samplerate
if t > 0:
t = samples / self.samplerate
if t > 0:
if len(last_n) > avg_period:
last_n.popleft()
if len(last_n) > avg_period:
last_n.popleft()
- self.put(last_samplenum, self.samplenum, self.out_ann,
+ self.put(ss, es, self.out_ann,
[Ann.TIME, [normalize_time(t)]])
if avg_period > 0:
[Ann.TIME, [normalize_time(t)]])
if avg_period > 0:
- self.put(last_samplenum, self.samplenum, self.out_ann,
+ self.put(ss, es, self.out_ann,
[Ann.AVG, [normalize_time(sum(last_n) / len(last_n))]])
if last_t and self.options['delta'] == 'yes':
[Ann.AVG, [normalize_time(sum(last_n) / len(last_n))]])
if last_t and self.options['delta'] == 'yes':
- self.put(last_samplenum, self.samplenum, self.out_ann,
+ self.put(ss, es, self.out_ann,
[Ann.DELTA, [normalize_time(t - last_t)]])
last_t = t
[Ann.DELTA, [normalize_time(t - last_t)]])
last_t = t
- last_samplenum = self.samplenum