Skip to content

Commit 73fc083

Browse files
committed
AudioFFTBase: add frequencyToBin()
1 parent 4efa292 commit 73fc083

File tree

4 files changed

+8
-92622
lines changed

4 files changed

+8
-92622
lines changed

src/AudioTools/AudioLibs/AudioFFT.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,12 @@ class AudioFFTBase : public AudioStream {
357357
return static_cast<float>(bin) * cfg.sample_rate / cfg.length;
358358
}
359359

360+
/// Determine the bin number from the frequency
361+
int frequencyToBin(int freq){
362+
int max_freq = cfg.sample_rate / 2;
363+
return map(freq, 0, max_freq, 0, size());
364+
}
365+
360366
/// Determines the result values in the max magnitude bin
361367
AudioFFTResult result() {
362368
AudioFFTResult ret_value;

tests-cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/resample ${CMAKE_CURRENT_BINARY_DIR
2424
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/generator ${CMAKE_CURRENT_BINARY_DIR}/generator)
2525
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/effects ${CMAKE_CURRENT_BINARY_DIR}/effects)
2626
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fft ${CMAKE_CURRENT_BINARY_DIR}/fft)
27+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ifft ${CMAKE_CURRENT_BINARY_DIR}/ifft)
2728
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/filter ${CMAKE_CURRENT_BINARY_DIR}/filter)
2829
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/filter-wav ${CMAKE_CURRENT_BINARY_DIR}/filter-wav)
2930
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/url-test ${CMAKE_CURRENT_BINARY_DIR}/url-test)

0 commit comments

Comments
 (0)