Start to flesh out function docstrings, add some more type annotations.

This commit is contained in:
kris 2019-03-21 22:41:05 +00:00
parent da2e2476e7
commit ce078f493f
2 changed files with 21 additions and 3 deletions

View File

@ -25,6 +25,12 @@ class Audio:
normalization or self._normalization()) # type: float
def _decode(self, f, buf) -> np.array:
"""
:param f:
:param buf:
:return:
"""
data = np.frombuffer(buf, dtype='int16').astype(
'float32').reshape((f.channels, -1), order='F')
@ -39,6 +45,9 @@ class Audio:
We compute the 2.5th and 97.5th percentiles i.e. only 2.5% of samples
will clip.
:param read_bytes:
:return:
"""
raw = bytearray()
with audioread.audio_open(self.filename) as f:
@ -52,6 +61,10 @@ class Audio:
return 16384. / norm
def audio_stream(self) -> Iterator[int]:
"""
:return:
"""
with audioread.audio_open(self.filename) as f:
for buf in f.read_data(128 * 1024):
a = self._decode(f, buf)

View File

@ -1,15 +1,20 @@
"""Parses the cc65 .dbg output to extract symbol addresses."""
from typing import Dict
from typing import Dict, TextIO
class SymbolTable:
"""Parse cc65 debug file to extract symbol table."""
def __init__(self, debugfile: str = None):
self.debugfile = debugfile
self.debugfile = debugfile # type: str
def parse(self, iostream=None) -> Dict:
def parse(self, iostream: TextIO = None) -> Dict:
"""
:param iostream:
:return:
"""
syms = {}
if not iostream: