- Updated the `y-axis scale` based on the maximum value of the frequency spectrum, added logarithmic scaling to the x-axis labels, and improved interpolation logic for better display.
- 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.
- The code provided is a JavaScript application that visualizes frequency data from a WebSocket connection. It uses the Chart.js library to create an interactive graph that displays the spectrum of incoming audio. The chart includes annotations for specific frequencies and tooltips with detailed frequency information.
Here's a breakdown of the key components:
1. **Note Frequencies**:
- `noteFrequencies` is an object containing note names as keys and their corresponding frequencies in Hz.
2. **Chart Setup**:
- `chart` initializes a Chart.js chart with the specified type, dimensions, options, plugins, data, and animation.
- `chart.update()` updates the chart to reflect any changes in the dataset.
3. **WebSocket Connection**:
- A WebSocket connection (`ws`) is established to receive frequency data from a server running on the same hostname as the client.
- The `onmessage` event handler receives JSON-encoded data, which represents the frequency spectrum.
- The received spectrum data is interpolated using logarithmic scale to enhance the visual representation of the spectrum.
4. **Interpolation**:
- The `interpolateSpectrum` function converts the linear frequency bins of the spectrum to logarithmic scale and interpolates between the closest two bins for a smoother display.
- This interpolation helps in better handling of low-frequency components that may not be accurately represented by simple linear steps.
5. **Legend Disabling**:
- The `legend: { display: false }` option disables the legend in the chart, which is useful when multiple datasets are displayed.
This application provides a dynamic way to visualize audio frequency data, allowing users to interact with the spectrum and gain insights into the content of the incoming audio.
- The changes introduced in `src/main.cpp` are related to the calculation and formatting of bin ranges for frequency detection, specifically focusing on the FFT size from 60 Hz to 1100 Hz.
- New HTML file added to the `data` directory for a piano spectrum analyzer.
- Updated `Config.h` with WiFi settings and web configuration portal details.
- Update the Arduino sketch with WiFi and WebSocket support, enabling real-time spectrum data transmission over the web.
- 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.
- Updated `AudioLevelTracker.h` to scale the maximum range limit by a factor of 16.
- Updated the I2S sample rate from 8 kHz to 4 kHz, reduced DMA buffer count and length, adjusted gain for 16-bit range, increased task stack size and priority, and decreased debug interval.
- The `initI2S` function has been modified to use a smaller buffer size and adjust the data format to 16-bit, ensuring compatibility with existing code while reducing memory usage.
- Added a new header file `AudioLevelTracker.h` to track audio levels with a history of up to 3 seconds and a maximum range limit.
- `Config.h` has been added with new serial and I2S configurations. The aim is to configure these peripherals for audio processing.
- Added new header file `I2SConfig.h` with setup functions for initializing and reading from I2S interface.
- The `AudioLevelTracker.cpp` file has been updated to include functionality for tracking the maximum audio level over a specified duration.
- Initial setup for I2S communication with a microphone.
- Updated `Arduino` code with improved I2S configuration and dynamic range limiting.
- Added `.gitignore` file to exclude unnecessary build and system files.
- Summary: Added a README file for project headers, improving organization and management of header files in the source codebase.
- Added a README file in the lib directory for project-specific libraries.
- Added new partitions to `partitions.csv`.
- The `git diff` output updates the `platformio.ini` file to include new build and upload options, dependencies, and configuration for an ESP32-S3 development board using Arduino.
- The user has added a new `main.cpp` file, added I2S and FFT functionality to it, and defined a function to calculate the frequency and convert it to a MIDI note number.
- Added a new README file in the `test` directory for PlatformIO Unit Testing.