Skip to content

Implement Audio::GetVolumeFromTo (was a stub returning 0.0) - #106

Open
vjandrea wants to merge 1 commit into
resolume:masterfrom
vjandrea:fix/issue-84-get-volume-from-to
Open

Implement Audio::GetVolumeFromTo (was a stub returning 0.0)#106
vjandrea wants to merge 1 commit into
resolume:masterfrom
vjandrea:fix/issue-84-get-volume-from-to

Conversation

@vjandrea

Copy link
Copy Markdown

Maps the requested Hz range to FFT bin indices using freqMax/fft.size() and reduces them the same way Update() already does for the bass/med/high bands (square, apply gain, mean, sqrt). Range args are order-independent and clamped to the valid bin range, with the range always covering at least one bin.

Also stops caching freqBinStep from SetSampleRate, since that could run before the first Update() call while fft was still empty (freqMax / 0), and nothing recomputed it afterward if fft's size changed. The equivalent bin step is now computed on demand from the always-current fft.size().

Fixes #84

Maps the requested Hz range to FFT bin indices using `freqMax/fft.size()`
and reduces them the same way `Update()` already does for the bass/med/high
bands (square, apply gain, mean, sqrt). Range args are order-independent
and clamped to the valid bin range, with the range always covering at
least one bin.

Also stops caching `freqBinStep` from `SetSampleRate`, since that could run
before the first `Update()` call while `fft` was still empty `(freqMax / 0)`,
and nothing recomputed it afterward if `fft`'s size changed. The equivalent
bin step is now computed on demand from the always-current `fft.size()`.

Fixes resolume#84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why does Audio::GetVolumeFromTo( int fromFreq, int toFreq ) return 0.0?

1 participant