kopia lustrzana https://github.com/corrscope/corrscope
Add amplification to WaveConfig
rodzic
81c19aff2e
commit
19c0909752
|
@ -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))
|
||||
|
|
|
@ -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]':
|
||||
|
|
Ładowanie…
Reference in New Issue