Commit Graph

3 Commits

Author SHA1 Message Date
f500937067 refactor ♻️: Refactored the audio processing and visualization tasks into separate cores, improved CPU usage monitoring, optimized memory usage, managed inter-core communication, and enhanced network functionality.
- Refactor the audio processing and visualization tasks into separate cores, improve CPU usage monitoring, optimize memory usage, manage inter-core communication, and enhance network functionality.
- This code snippet provides a basic implementation of a piano note detection system using an Arduino. The system includes a setup phase where calibration and initialization are performed, along with serial communication for user interaction. The main loop is empty, as all the work is handled by separate tasks created on different cores.

The `setup()` function sets up the serial connection, initializes the piano note detector, and creates two separate tasks: `audioProcessingTask` and `visualizationTask`. These tasks handle the audio processing and visualization of the detected notes, respectively. The main loop runs in a paused state to allow for task execution on different cores.

The audio processing task (`audioProcessingTask`) reads analog signals from an I2S microphone (C2-C6), processes them using Fourier Transform, and detects note frequencies. It then updates a spectrum visualization and sends the results over the serial interface to the host PC for further analysis.

The visualization task (`visualizationTask`) receives the processed data from the audio processing task, visualizes the spectrum, and sends updates over the serial interface. The main loop in the `loop()` function is empty, as all the work is handled by these tasks.
2025-04-25 21:13:59 +02:00
c83d04eb23 plaintext feat undefined: Updated Arduino project with new features for audio processing. fix: Updated I2SConfig.h to include additional parameter for reading I2S samples. refactor: Improved performance by rounding integer samples to
- This code snippet is a C++ program that utilizes the Arduino framework to implement audio processing for a microphone. The program includes several classes and functions to handle various aspects of audio analysis, such as note detection, frequency analysis, and spectrum visualization.

The key components of this program include:

1. **AudioLevelTracker**: This class provides real-time audio level monitoring by tracking the maximum amplitude of an input signal. It uses a simple peak detection algorithm to determine when the input signal reaches a certain threshold.

2. **NoteDetector**: This class performs frequency analysis on the input audio signal and identifies specific notes based on their frequencies. The note detector utilizes a pre-defined list of known frequencies and compares them against the detected frequencies to identify matches.

3. **SpectrumVisualizer**: This class provides real-time spectrum visualization by displaying the magnitude of the input audio signal in the form of an ASCII graph. The magnitude scaling is done dynamically based on the signal power to ensure that all frequencies are visible.

4. **Main Loop**: The main loop handles all the other components and processes them sequentially. It initializes the audio level tracker, note detector, and spectrum visualizer, and then enters a loop where it continuously processes the input audio signal.

The program also includes error handling mechanisms, such as automatic I2S reset on communication errors and dynamic threshold adjustment to ensure that the audio processing remains stable and accurate. The project is structured with clear class definitions and proper documentation for each component.
- The updateMaxLevel and getMaxLevel methods in AudioLevelTracker have been modified to accept and return int16_t values instead of int32_t, which improves range handling.
- The `Config.h` file has been updated to enhance audio processing by increasing gain, adjusting noise threshold for 16-bit samples, and changing the FFT size from a power of 2. The main goal is to optimize performance while maintaining good noise detection and note detection capabilities for better accuracy in music analysis tasks.
- The `git diff` output shows a change to the I2SConfig.h file. Specifically, it adds a line to define an additional parameter for reading I2S samples: int16_t*.
- This commit introduces a new header file `NoteDetector.h` for detecting musical notes in an Arduino project, enhancing the detection process with FFT analysis and dynamic threshold adjustments.
- The `SpectrumVisualizer.h` file has been added to the project with new definitions and functions to visualize audio spectrum and detected notes.
- The main goal of these changes is to update the `lib_deps` in the `platformio.ini` file to include a specific library named `kosme/arduinoFFT` which is version 1.6.
- The changes improve the audio level tracking by rounding the integer samples to 16 bits before storing them, ensuring that the range remains within a feasible limit for processing.
- The main goal of the changes is to optimize the `readI2SSamples` function by removing unnecessary conversion from 16-bit to 32-bit samples, which was previously done in an existing code section that could be reused for other purposes. This change improves performance and reduces complexity while maintaining compatibility with existing code.
- A new `NoteDetector` class has been created in the `src/NoteDetector.cpp` file, implementing various calibration and note detection functionalities.
- The user has added new functions `magnitudeToDb`, `mapToDisplay`, `printBarGraph`, `drawFFTMagnitudes`, `visualizeSpectrum`, and `visualizeNotes` to the `SpectrumVisualizer.cpp` file. The changes are related to visualizing spectrum data and note detection results in a serial monitor format for debugging.
- The main goal is to enhance the piano note detection system by adding support for a NoteDetector and updating SpectrumVisualizer when notes are detected, as well as handling serial commands for calibration, threshold adjustments, and toggling spectrum display.
2025-04-25 12:14:06 +02:00
9af74aa4bc Initial commit 2025-04-18 17:24:16 +02:00