- 
                Notifications
    You must be signed in to change notification settings 
- Fork 347
Audio: STFT Process: Add new SOF module #10306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|  | ||
| # C & ASM flags | ||
| target_compile_options(sof_options INTERFACE -g -O3 -fPIC -DPIC -std=c99 -std=gnu99 -fgnu89-inline | ||
| target_compile_options(sof_options INTERFACE -g -fPIC -DPIC -std=c99 -std=gnu99 -fgnu89-inline | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-Og?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't planning to keep this to not slow down our CI. I've never used -Og, I wonder if would be a a good compromise between speed and debug-ability on x86,
But then, the xtensa build should have all optimization to know the MCPS performance of modules.
| struct module_data *md = &mod->priv; | ||
| struct comp_dev *dev = mod->dev; | ||
| struct stft_comp_data *cd; | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_can_be_cold()
| static void debug_print_to_file_complex(FILE *fh, struct icomplex32 *c, int n) | ||
| { | ||
| for (int i = 0; i < n; i++) | ||
| fprintf(fh, "%d %d\n", c[i].real, c[i].imag); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%d+i%d?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data is not for humans to read. An Octave script reads it with raw ascii numbers load(), so I don't want to include formatting.
| y += samples_without_wrap; | ||
|  | ||
| /* Check for wrap */ | ||
| y = (y >= y_end) ? y - y_size : y; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, this keeps hitting me as if (y < y_end) y = y;...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.. I liked the one line look for wraps but this relies on a smart compiler that is not ensured. I'll change those.
|  | ||
| /* Allocate buffers for FFT input and output data */ | ||
| fft->fft_buffer_size = fft->fft_padded_size * sizeof(struct icomplex32); | ||
| fft->fft_buf = rzalloc(SOF_MEM_FLAG_USER, fft->fft_buffer_size); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not rballoc()? same below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'll fix these after the component works well. I should also increse the max size of FFT Liam's vmalloc is the way to go?
Also if I increase the max size of FFT there would be quite large twiddle factors data to be moved to DRAM like SRC coefficients.
|  | ||
| # C & ASM flags | ||
| target_compile_options(sof_options INTERFACE -g -O3 -fPIC -DPIC -std=c99 -std=gnu99 -fgnu89-inline | ||
| target_compile_options(sof_options INTERFACE -g -fPIC -DPIC -std=c99 -std=gnu99 -fgnu89-inline | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't planning to keep this to not slow down our CI. I've never used -Og, I wonder if would be a a good compromise between speed and debug-ability on x86,
But then, the xtensa build should have all optimization to know the MCPS performance of modules.
| static void debug_print_to_file_complex(FILE *fh, struct icomplex32 *c, int n) | ||
| { | ||
| for (int i = 0; i < n; i++) | ||
| fprintf(fh, "%d %d\n", c[i].real, c[i].imag); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data is not for humans to read. An Octave script reads it with raw ascii numbers load(), so I don't want to include formatting.
| y += samples_without_wrap; | ||
|  | ||
| /* Check for wrap */ | ||
| y = (y >= y_end) ? y - y_size : y; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.. I liked the one line look for wraps but this relies on a smart compiler that is not ensured. I'll change those.
|  | ||
| /* Allocate buffers for FFT input and output data */ | ||
| fft->fft_buffer_size = fft->fft_padded_size * sizeof(struct icomplex32); | ||
| fft->fft_buf = rzalloc(SOF_MEM_FLAG_USER, fft->fft_buffer_size); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'll fix these after the component works well. I should also increse the max size of FFT Liam's vmalloc is the way to go?
Also if I increase the max size of FFT there would be quite large twiddle factors data to be moved to DRAM like SRC coefficients.
| * | 16 bits, e.g. x23 -> 46 bytes | 16 bits, e.g. 13x -> 26 bytes | | ||
| * +----------------------------------+----------------------------------+ | ||
| * | ||
| */ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, these are not updated from how it was in MFCC. Need to figure out these and document.
ca9f11b    to
    ae6f2f9      
    Compare
  
    This patch adds error check to not silently accept too large FFT configuration request. Traced error messages are also added to quickly see what is wrong. Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch updates the headers document style to preferred style in SOF. The similar partial documentation comments are removed from window.c. Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch adds 32 bit Q1.31 format window functions for better precision in audio processing. The constant define for Blackman is suffixed with Q15 to help avoid using it with new 32 bit window and it's similar constant. Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch adds the Hann window. It provides higher attenuation of side lobes vs. similar family Hamming window. Hann window is suitable for use in STFT overlap-add procedure. Signed-off-by: Seppo Ingalsuo <[email protected]>
Signed-off-by: Seppo Ingalsuo <[email protected]>
This patch adds build of topology sof-hda-benchmark-stft_process16.tplg for first tests with the new module. Signed-off-by: Seppo Ingalsuo <[email protected]>
WIP - currently this is the same as with MFCC. Should remove unsupported features and add more options for STFT transform domain audio format. Signed-off-by: Seppo Ingalsuo <[email protected]>
This module provides analysis and synthesis filters for frequency domain processing. The used technique is short term Fourier transform (STFT) and inverse STFT. The FFT length, hop, and window type are configured with the bytes control configuration blob. WIP - the audio quality is not yet good enough Signed-off-by: Seppo Ingalsuo <[email protected]>
ae6f2f9    to
    1b25adc      
    Compare
  
    | Improved audio quality with 32 bit window functions and switch to Hann window type. | 
| @singalsu can you also add a Readme.md to the module directory describing usage/tuning. Thanks ! | 
WIP, not yet good quality audio