mirror of
https://github.com/KrisKennaway/ii-vision.git
synced 2024-06-17 12:29:31 +00:00
Start to flesh out function docstrings, add some more type annotations.
This commit is contained in:
parent
da2e2476e7
commit
ce078f493f
|
@ -25,6 +25,12 @@ class Audio:
|
||||||
normalization or self._normalization()) # type: float
|
normalization or self._normalization()) # type: float
|
||||||
|
|
||||||
def _decode(self, f, buf) -> np.array:
|
def _decode(self, f, buf) -> np.array:
|
||||||
|
"""
|
||||||
|
|
||||||
|
:param f:
|
||||||
|
:param buf:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
data = np.frombuffer(buf, dtype='int16').astype(
|
data = np.frombuffer(buf, dtype='int16').astype(
|
||||||
'float32').reshape((f.channels, -1), order='F')
|
'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
|
We compute the 2.5th and 97.5th percentiles i.e. only 2.5% of samples
|
||||||
will clip.
|
will clip.
|
||||||
|
|
||||||
|
:param read_bytes:
|
||||||
|
:return:
|
||||||
"""
|
"""
|
||||||
raw = bytearray()
|
raw = bytearray()
|
||||||
with audioread.audio_open(self.filename) as f:
|
with audioread.audio_open(self.filename) as f:
|
||||||
|
@ -52,6 +61,10 @@ class Audio:
|
||||||
return 16384. / norm
|
return 16384. / norm
|
||||||
|
|
||||||
def audio_stream(self) -> Iterator[int]:
|
def audio_stream(self) -> Iterator[int]:
|
||||||
|
"""
|
||||||
|
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
with audioread.audio_open(self.filename) as f:
|
with audioread.audio_open(self.filename) as f:
|
||||||
for buf in f.read_data(128 * 1024):
|
for buf in f.read_data(128 * 1024):
|
||||||
a = self._decode(f, buf)
|
a = self._decode(f, buf)
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
"""Parses the cc65 .dbg output to extract symbol addresses."""
|
"""Parses the cc65 .dbg output to extract symbol addresses."""
|
||||||
|
|
||||||
from typing import Dict
|
from typing import Dict, TextIO
|
||||||
|
|
||||||
|
|
||||||
class SymbolTable:
|
class SymbolTable:
|
||||||
"""Parse cc65 debug file to extract symbol table."""
|
"""Parse cc65 debug file to extract symbol table."""
|
||||||
|
|
||||||
def __init__(self, debugfile: str = None):
|
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 = {}
|
syms = {}
|
||||||
|
|
||||||
if not iostream:
|
if not iostream:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user