Sound Open Firmware
Loading...
Searching...
No Matches
auditory.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2022 Intel Corporation. All rights reserved.
4 *
5 * Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
6 */
7
8/* Psychoacoustics related functions */
9
10#ifndef __SOF_MATH_AUDITORY_H__
11#define __SOF_MATH_AUDITORY_H__
12
13#include <sof/math/fft.h>
14#include <sof/math/log.h>
15#include <stdint.h>
16
17#define AUDITORY_MAX_MEL_BANDS 256
18#define AUDITORY_EPS_Q31 1 /* Smallest nonzero Q1.31 value */
19#define AUDITORY_LOG2_2P25_Q16 Q_CONVERT_FLOAT(25.0, 16) /* log2(2^25) */
20
26
27/* Struct to define Mel filterback calculation. The filterbank data is compressed into
28 * a single vector from normal (half_fft_bins, mel_bins) size by storing only non-zero
29 * weights values.
30 *
31 * Triangles data Number triangles is mel_bins
32 * then for each triangle:
33 * index to next triangle 0, start fft_bin 1, length of this triangle 2,
34 * triangle weight values 3..N
35 */
54
60int16_t psy_hz_to_mel(int16_t hz);
61
70int16_t psy_mel_to_hz(int16_t mel);
71
80struct processing_module;
81int mod_psy_get_mel_filterbank(struct processing_module *mod, struct psy_mel_filterbank *mel_fb);
82int mod_psy_free_mel_filterbank(struct processing_module *mod, struct psy_mel_filterbank *mel_fb);
83
96void psy_apply_mel_filterbank_16(struct psy_mel_filterbank *mel_fb, struct icomplex16 *fft_out,
97 int32_t *power_spectra, int16_t *mel_log, int bitshift);
98
111void psy_apply_mel_filterbank_32(struct psy_mel_filterbank *mel_fb, struct icomplex32 *fft_out,
112 int32_t *power_spectra, int32_t *mel_log, int bitshift);
113
114#endif /* __SOF_MATH_AUDITORY_H__ */
int16_t psy_mel_to_hz(int16_t mel)
Convert Mel to Hz See Wikipedia https://en.wikipedia.org/wiki/Mel_scale hz = 700 * (exp(mel / 1126....
int mod_psy_get_mel_filterbank(struct processing_module *mod, struct psy_mel_filterbank *mel_fb)
void psy_apply_mel_filterbank_16(struct psy_mel_filterbank *mel_fb, struct icomplex16 *fft_out, int32_t *power_spectra, int16_t *mel_log, int bitshift)
Convert linear complex spectra from FFT into Mel band energies in desired logarithmic format.
psy_mel_log_scale
Definition auditory.h:21
@ MEL_LOG
Definition auditory.h:22
@ MEL_DB
Definition auditory.h:24
@ MEL_LOG10
Definition auditory.h:23
void psy_apply_mel_filterbank_32(struct psy_mel_filterbank *mel_fb, struct icomplex32 *fft_out, int32_t *power_spectra, int32_t *mel_log, int bitshift)
Convert linear complex spectra from FFT into Mel band energies in desired logarithmic format.
int16_t psy_hz_to_mel(int16_t hz)
Convert Hz to Mel.
int mod_psy_free_mel_filterbank(struct processing_module *mod, struct psy_mel_filterbank *mel_fb)
struct icomplex16 - Storage for a normal complex number.
Definition icomplex16.h:28
struct icomplex32 - Storage for a normal complex number.
Definition icomplex32.h:23
Definition auditory.h:36
int half_fft_bins
In, fft_bins / 2 + 1.
Definition auditory.h:48
enum psy_mel_log_scale mel_log_scale
In, LOG, LOG10 or DB to select Mel format.
Definition auditory.h:51
int16_t end_freq
In, Hz Q0.
Definition auditory.h:41
int16_t * data
Out, Packed triangles data.
Definition auditory.h:44
int mel_bins
In, Number of Mel frequency bins.
Definition auditory.h:49
int32_t log_mult
Out, QX.Y scale for log, log10, or dB format.
Definition auditory.h:37
int32_t scale_log2
Out, Scale as log2 Q16.16 to apply to Mel energies.
Definition auditory.h:38
int fft_bins
In, Number of FFT bins.
Definition auditory.h:47
int16_t start_freq
In, Hz Q0.
Definition auditory.h:40
int16_t * scratch_data2
Scratch, Packed triangles data.
Definition auditory.h:43
int scratch_length2
In, Length of second scratch.
Definition auditory.h:46
int data_length
Out, Number of int16_t words in triangles data.
Definition auditory.h:50
int16_t * scratch_data1
Scratch, At least half_fft_bins size.
Definition auditory.h:42
bool slaney_normalize
In, Apply Slaney type normalization for filterbank if true.
Definition auditory.h:52
int scratch_length1
In, Length of first scratch.
Definition auditory.h:45
int32_t samplerate
In, Hz Q0.
Definition auditory.h:39