diff --git a/ovgenpy/ovgenpy.py b/ovgenpy/ovgenpy.py index 908b445..ba2e476 100644 --- a/ovgenpy/ovgenpy.py +++ b/ovgenpy/ovgenpy.py @@ -19,6 +19,8 @@ class Config(NamedTuple): wave_dir: str audio_path: Optional[str] fps: int + amplification: float + time_visible_ms: int scan_ratio: float @@ -48,6 +50,7 @@ def main(wave_dir: str, audio_path: Optional[str], fps: int, output: str): wave_dir=wave_dir, audio_path=audio_path, fps=fps, + amplification=5, time_visible_ms=25, scan_ratio=1, @@ -91,7 +94,7 @@ class Ovgen: waves = sorted(wave_dir.glob('*.wav')) for idx, path in enumerate(waves): wcfg = WaveConfig( - wave_path=str(path) + amplification=self.cfg.amplification ) wave = Wave(wcfg, str(path)) diff --git a/ovgenpy/wave.py b/ovgenpy/wave.py index ac4b5aa..6dc55ef 100644 --- a/ovgenpy/wave.py +++ b/ovgenpy/wave.py @@ -8,10 +8,7 @@ if TYPE_CHECKING: class WaveConfig(NamedTuple): - wave_path: str - # TODO color - - # TODO wave-specific trigger options? + amplification: float = 1 FLOAT = np.single @@ -19,7 +16,7 @@ FLOAT = np.single class Wave: def __init__(self, wcfg: Optional[WaveConfig], wave_path: str): - self.cfg = wcfg + self.cfg = wcfg or WaveConfig() self.smp_s, self.data = wavfile.read(wave_path, mmap=True) # type: int, np.ndarray dtype = self.data.dtype @@ -59,7 +56,7 @@ class Wave: """ Copies self.data[item], converted to a FLOAT within range [-1, 1). """ data = self.data[index].astype(FLOAT) data -= self.center - data /= self.max_val + data *= self.cfg.amplification / self.max_val return data def get(self, begin: int, end: int) -> 'np.ndarray[FLOAT]':