Improve Audio Data Processing and Spectrum Analyzer#745
Merged
kblaschke merged 6 commits intoprojectM-visualizer:masterfrom Nov 25, 2023
Merged
Improve Audio Data Processing and Spectrum Analyzer#745kblaschke merged 6 commits intoprojectM-visualizer:masterfrom
kblaschke merged 6 commits intoprojectM-visualizer:masterfrom
Conversation
89fbe8e to
9f411fe
Compare
revmischa
reviewed
Nov 24, 2023
Comment on lines
+94
to
+96
| * You might want to slightly damp (blur) the input if your signal isn't | ||
| * of a very high quality, to reduce high-frequency noise that would | ||
| * otherwise show up in the output. |
Member
There was a problem hiding this comment.
is there any audio we expect people to feed in that will not be of "a very high quality"?
Member
Author
There was a problem hiding this comment.
Don't know, probably not relevant anymore today. Most of the Doxygen text in this class is just a 1:1 copy of the comments in Milkdrop's code, I didn't change it for "historical reasons". 😁
revmischa
reviewed
Nov 24, 2023
| @@ -0,0 +1,55 @@ | |||
| /** | |||
| * @file WaveformAligner.hpp | |||
| * @brief Mip-based waveform alignment algorithm | |||
Member
Author
There was a problem hiding this comment.
Yeah... Will just keep the class doc, and only add a "brief" description for the file.
revmischa
reviewed
Nov 24, 2023
| /** | ||
| * @brief Calculates equalization factors for each frequency domain. | ||
| * | ||
| * @param equalize If false, all factors will be set to 1, otherwise will calculate a frequency-based multiplier. |
Member
There was a problem hiding this comment.
what's the purpose of the equalizer?
Member
Author
There was a problem hiding this comment.
Member
Author
Removed the previous FFT algorithm, now using a modernized version of the original Milkdrop FFT transform which also has both an equalizer and frequency envelope, making it slightly more sophisticated. Modernization mainly included replacing raw pointer arrays with std::vector and using STL types/functions for the calculation, specifically std::complex as the FFT heavily uses these numbers. This makes the code more compact and readable. Manually tested both original and modernized versions of the class to test if the algorithm still returns the exact same results, which is the case.
Consolidated audio processing code into the PCM class, removing the BeatDetect class in the process. Beat detection now uses the same algorithm as Milkdrop, passing the proper relative bass/mid/treb values to presets. Makes many presets look less jumpy/flickering, as the values are now (smoothly) alternating around 1.0. Updating frame audio is now done in a function that must specifically be called. Any subsequent calls to GetFrameAudioData() will then return the exact same copy of the audio data. As of now with the exception that new waveform data may be passed in via a separate thread, which will then be returned and might not match the spectrum data. Will fix that in a later commit.
Also consolidated the waveform sample count constant to keep it aligned over all classes.
The "+1" somehow disappeared at some point...
Directly passing references to the affected members is easier to read in the main UpdateFrameAudioData() method.
dd4053b to
9c68339
Compare
blaquewithaq
approved these changes
Nov 24, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Reimplemented audio data processing to closely match Milkdrop's algorithms and resulting sample/spectrum values.
proejctM's previous implementation was very simplistic, and thus resulted in sample/beat detection values which weren't even close to what Milkdrop passes to presets. This PR changes/fixes the following audio-related issues:
FFTclass. It also smoothes and equalized the spectrum a bit to remove noise. Now spectrum-based custom waveforms draw properly.Fixes issue #708.