|
libMusicForge
|
Analyze normalized mono PCM using a Hann-windowed real FFT. More...
Public Member Functions | |
| None | __init__ (self, *, int fft_size=2048, int band_count=24) |
| Initialize the configured instance. | |
| bool | is_zeroized (self) |
| Report whether ambient calibration is active. | |
| None | start_zeroize (self) |
| Begin collecting ambient noise frames. | |
| None | finish_zeroize (self) |
| Commit collected ambient noise calibration; requires at least one frame. | |
| None | clear_zeroize (self) |
| Discard calibration and reset adaptive state. | |
| MusicAnalysisState | analyze (self, Sequence[float] samples, int sample_rate_hz) |
| Analyze normalized mono PCM into spectrum and activity estimates. | |
Public Attributes | |
| fft_size = fft_size | |
| band_count = band_count | |
Protected Member Functions | |
| float | _beat (self, np.ndarray magnitude, float duration_s) |
| np.ndarray | _gate_ambient (self, np.ndarray magnitude) |
| np.ndarray | _gate_spectral_leakage (self, np.ndarray magnitude) |
| None | _reset_adaptive_state (self) |
| float | _normalized_band (self, np.ndarray magnitude, np.ndarray frequencies, float low_hz, float high_hz, str key) |
| tuple[float,...] | _spectrum (self, np.ndarray magnitude, np.ndarray frequencies, int sample_rate_hz) |
| float | _activity (self, str name, float raw, float transient_weight) |
| PercussionActivity | _percussion (self, np.ndarray magnitude, np.ndarray frequencies) |
Static Protected Member Functions | |
| float | _band_rms (np.ndarray magnitude, np.ndarray frequencies, float low_hz, float high_hz) |
Protected Attributes | |
| _window = np.hanning(fft_size).astype(np.float32) | |
| _band_peaks = np.full(band_count, 1e-6, dtype=np.float32) | |
| dict | _summary_peaks = {"bass": 1e-6, "mid": 1e-6, "treble": 1e-6} |
| dict | _activity_peaks = {name: 1e-6 for name in activity_names} |
| dict | _previous_activity = {name: 0.0 for name in activity_names} |
| np.ndarray|None | _previous_magnitude = None |
| float | _beat_envelope = 0.0 |
| float | _flux_average = 0.0 |
| float | _beat_age = 1.0 |
| bool | _zeroize_collecting = False |
| list | _zeroize_frames = [] |
| np.ndarray|None | _noise_floor = None |
Static Protected Attributes | |
| float | _ZEROIZE_PERCENTILE = 75.0 |
| float | _ZEROIZE_MARGIN_DB = 3.0 |
| float | _SPECTRAL_RELATIVE_FLOOR_DB = -42.0 |
Analyze normalized mono PCM using a Hann-windowed real FFT.
| None musicforge.analysis.analyzer.MusicAnalyzer.__init__ | ( | self, | |
| * | , | ||
| int | fft_size = 2048, | ||
| int | band_count = 24 ) |
Initialize the configured instance.
| self | Current instance. |
| fft_size | FFT length, a power of two of at least 256. |
| band_count | Number of spectrum bands, at least three. |
|
protected |
|
staticprotected |
|
protected |
Estimate onsets via positive spectral flux, not tempo or instrument identity.
|
protected |
|
protected |
Suppress bins far below the strongest spectral component. A Hann window greatly reduces FFT leakage, but it does not eliminate it. Without a floor, adaptive per-band normalization can promote tiny leakage in an otherwise empty band to full-scale activity on the first frame.
|
protected |
|
protected |
|
protected |
|
protected |
| MusicAnalysisState musicforge.analysis.analyzer.MusicAnalyzer.analyze | ( | self, | |
| Sequence[float] | samples, | ||
| int | sample_rate_hz ) |
Analyze normalized mono PCM into spectrum and activity estimates.
| self | Current instance. |
| samples | Normalized mono PCM samples. |
| sample_rate_hz | Sample rate in hertz. |
Reimplemented from musicforge.analysis.interfaces.MusicAnalyzerIf.
| None musicforge.analysis.analyzer.MusicAnalyzer.clear_zeroize | ( | self | ) |
Discard calibration and reset adaptive state.
| self | Current instance. |
Reimplemented from musicforge.analysis.interfaces.MusicAnalyzerIf.
| None musicforge.analysis.analyzer.MusicAnalyzer.finish_zeroize | ( | self | ) |
Commit collected ambient noise calibration; requires at least one frame.
| self | Current instance. |
Reimplemented from musicforge.analysis.interfaces.MusicAnalyzerIf.
| bool musicforge.analysis.analyzer.MusicAnalyzer.is_zeroized | ( | self | ) |
Report whether ambient calibration is active.
| self | Current instance. |
Reimplemented from musicforge.analysis.interfaces.MusicAnalyzerIf.
| None musicforge.analysis.analyzer.MusicAnalyzer.start_zeroize | ( | self | ) |
Begin collecting ambient noise frames.
| self | Current instance. |
Reimplemented from musicforge.analysis.interfaces.MusicAnalyzerIf.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
| musicforge.analysis.analyzer.MusicAnalyzer.band_count = band_count |
| musicforge.analysis.analyzer.MusicAnalyzer.fft_size = fft_size |