Repository navigation
First simple demo implementation of Spectrogram Wavelet analysis - #9510
Conversation
|
Purpose of this PR is mainly to share insight into extent of changes required to implement proposed functionality |
|
Good morning @kgramhans, thank you so much for this beautiful contribution! I am not sure that this is going to make it in Audacity 3, as it is being sunset, but we are interested in having it in Audacity 4. Unfortunately, the spectrum view has not yet been ported to Au4, so I can't just ask you to redirect to redirect this PR to the master branch. It's a matter of months till we have, so one option would be to just let this sit for a while and reactivate it in due time. We will discuss this in our daily today, but in the meantime I'll begin to review it, it won't be wasted time. |
saintmatthieu
left a comment
There was a problem hiding this comment.
Looks mostly okay. I see an opportunity to simplify by reusing existing code, as detailed in the comments. Also, we'll have to figure something out on how we present the settings for the wavelet, but for now let us try to finish this iteration.
|
Food for thoughts:
I would very much like to completely decouple the pixel grid from the spectrogram grid. It would allow us to make the spectrogram invertible, paving the way to spectral editing. |
|
Hi @kgramhans, thanks for having addressed these comments, I think the integration is a bit better now. We will want this feature for Audacity 4 (have you seen @Tantacrul 's video, btw?) but we haven't ported spectrograms yet. We don't want to merge it in Au3 either because it's now only in KTLO mode, and this feature would require advertisement and a little bit of design to give it the care it deserves in the spectrogram settings. My proposal would be to put a macro around the wavelet entry of const TranslatableStrings &SpectrogramSettings::GetAlgorithmNames()
{
static const TranslatableStrings results{
// Keep in correspondence with enum SpectrogramSettings::Algorithm:
XO("Frequencies") ,
/* i18n-hint: the Reassignment algorithm for spectrograms */
XO("Reassignment") ,
/* i18n-hint: EAC abbreviates "Enhanced Autocorrelation" */
XO("Pitch (EAC)") ,
#ifdef WAVELET
XO("Wavelet (1/6 Octave Hann)") ,
#endif
};
return results;
}Then the feature would not be available to production builds but you could still showcase this with local builds and the implementation would still get built, ensuring that it doesn't go stale until it's ported to Au4. Would you be okay with that? |
|
@saintmatthieu Hi Matt, |
|
Thanks for the offer, I'll keep it in mind. Right now I can't think of anything beside migrating more of the built-in effects from Au3 to Au4, and this is more standard software engineering, it does not involve real DSP. In the future other opportunities are likely to come forth, though. I've approved, feel free to merge, but before, please check the last comment I've added. Thanks! |
|
(I'm not sure you can merge, actually, let me know if it doesn't wrok.) |
|
@kgramhans another thing occurred to me that's of concern: the wavelet transform does not leverage FFT optimizations. AFAICS, this is the only algorithm of the four that doesn't. A quick test on my side also indeed shows that it's noticeably slower than the others. This could bother our Product guys (and me included, although I'm just an engineer), because we'd be exposing a feature that doesn't work smoothly. (I wonder if this might explain why this transform hasn't been implemented yet, maybe @SteveDaulton would know.) I expect the refresh rate during playback to be very, very slow (it's already slow for the spectrogram). I'll raise this during our daily again on Monday. I suppose we could add a "slow" mention to the algorithm's name in the dropdown, and if we still end up deciding against it, reverting the commit would be trivial. (Please squash your commits before you do the merge, thanks.) |
|
@saintmatthieu so true that the Wavelet transform is a different beast when it comes to optimisations As of now, the current implementation will calculate the inner product for each point of time with a number of wavelets that increase in length for lower frequencies. For example, with a sample frequency of 44kHz and analysis downto 20 Hz the a rough amount of calculations for each point in time on a linear frequency axis would be (Window length N, average wavelet length W) Octave 1: 11..22kHz WN/2 operations Totalling up to 5WN operations for 20-20kHz (10 octaves) audio range. The choice of window length, N, is selectable in current implementation (but naturally also limits lower frequency bound) There is a huge potential for optimisations here. In Practice, it would not be necessary to calculate more than a constant number of transform values in each octave in order to properly represent the signal Octave 1: W* max(N/2,12) operations Totalling up to 1024W12 = 0.4M operations plus the expense of a simple interpolation scheme These considerations are highly linked to the way Spectrograms are designed into Audacity: A full transform is calculated at all frequencies irrespective of what is being displayed. And the choice of Y axis also does not reflect what is being calculated This is in general a demanding design task. Adding also the complexity of real time behaviour does not make things simpler. With respect to the latter, it would be beneficial to implement wavelet analysis as a filter bank with downsampling a data for each octave being processed. The usage of causal filters could also prove useful. Such real time implementation and adequate interpolation schemes would according to my experience end up having twice the computational load of an FFT based algorithm like the conventional spectrogram But underlying all this would be a proper design, first of all. And understanding the different use cases The current proposal has not focussed on any optimisations. I think that would be premature |
|
Yes: at the moment, the implementation calculates a new value for each requested time/frequency coordinates, and these don't match the Wavelet transform, Even for the regular spectrogram, the time resolution Audacity asks of one spectrum per pixel column is often unnecessarily high. Normally, for a typical hop size of 1024 samples at 48kHz, only 46 analyses per second would be required. At my current zoom level, I have 681 pixels per second... The transition to Au4 may be a good opportunity to rectify this. Anyway, we've made good progress here for the Wavelet transform. Let's merge what we have. I probably should redirect your PR to the audacity3 branch. Thank you! |
790eac9 to
60797d6
Compare
|
@kgramhans looks like I've messed up: I rebased and squashed your commits into one but somehow this got rid of the amendments you made ( |
|
Hi Matt
I will do that end of this week since I am currently away on Vacation. I
will be back!
man. 13. okt. 2025, 03.19 skrev Matthieu Hodgkinson <
***@***.***>:
… *saintmatthieu* left a comment (audacity/audacity#9510)
<#9510 (comment)>
@kgramhans <https://github.com/kgramhans> looks like I've messed up: I
rebased and squashed your commits into one but somehow this got rid of the
amendments you made (XO("Wavelet (1/6 Octave Hann)") , isn't in the #ifdef
WAVELET, the comment still says // Do the convolution, etc.). Please
don't erase your local changes :) and open a new PR with them. Sorry about
that.
—
Reply to this email directly, view it on GitHub
<#9510 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BXF6WUPQQNEX4CKD7ZI6FCL3XL4YXAVCNFSM6AAAAACH5VP3R2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOJVGU4DMMBYGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@saintmatthieu |
Resolves: #9509
(short description of the changes and the motivation to make the changes)
Recommended:
QA: