-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e75fd15
commit 4efa292
Showing
4 changed files
with
92,708 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
|
||
# set the project name | ||
project(ifft) | ||
set (CMAKE_CXX_STANDARD 11) | ||
set (DCMAKE_CXX_FLAGS "-Werror") | ||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ldl -lpthread -lm") | ||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ldl -lpthread -lm") | ||
|
||
# Emulator is not necessary for -DIS_MIN_DESKTOP | ||
set(ADD_ARDUINO_EMULATOR OFF CACHE BOOL "Add Arduino Emulator Library") | ||
set(ADD_PORTAUDIO OFF CACHE BOOL "No Portaudio") | ||
|
||
# Build with arduino-audio-tools | ||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) | ||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../.. ${CMAKE_CURRENT_BINARY_DIR}/arduino-audio-tools ) | ||
endif() | ||
|
||
# Download miniaudio.h | ||
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h) | ||
|
||
|
||
# build sketch as executable | ||
add_executable (ifft ifft.cpp) | ||
|
||
# set preprocessor defines | ||
target_compile_definitions(ifft PUBLIC -DIS_MIN_DESKTOP) | ||
|
||
# specify libraries | ||
target_link_libraries(ifft arduino-audio-tools) | ||
|
||
# access to miniaudio in sketch directory | ||
target_include_directories(ifft PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "AudioTools.h" | ||
#include "AudioTools/AudioLibs/AudioRealFFT.h" // using RealFFT | ||
#include "AudioTools/AudioLibs/MiniAudioStream.h" | ||
|
||
AudioInfo info(44100, 2, 16); | ||
AudioRealFFT afft; // or AudioKissFFT | ||
//CsvOutput<int16_t> out(Serial); | ||
MiniAudioStream out; | ||
StreamCopy copier(out, afft); | ||
int bin_idx = 0; | ||
|
||
// privide fft data | ||
void fftFillData(AudioFFTBase &fft) { | ||
fft.clearBins(); | ||
FFTBin bin{1,1}; | ||
fft.setBin(bin_idx, bin); | ||
|
||
// restart from first bin | ||
if (++bin_idx>=fft.size()) bin_idx = 0; | ||
} | ||
|
||
void setup() { | ||
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning); | ||
|
||
// Setup FFT | ||
auto tcfg = afft.defaultConfig(RX_MODE); | ||
tcfg.copyFrom(info); | ||
tcfg.length = 1024; | ||
tcfg.callback = fftFillData; | ||
afft.begin(tcfg); | ||
|
||
// setup output | ||
auto ocfg = out.defaultConfig(TX_MODE); | ||
ocfg.copyFrom(info); | ||
out.begin(ocfg); | ||
} | ||
|
||
void loop() { copier.copy(); } |
Oops, something went wrong.