Skip to content

Commit

Permalink
Merge pull request #40 from lucianodato/development
Browse files Browse the repository at this point in the history
Remove inlines. Fixed some warnings
  • Loading branch information
lucianodato authored May 10, 2022
2 parents 3a92b61 + 095a6e1 commit b97be1f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/shared/pre_estimation/critical_bands.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <math.h>
#include <stdlib.h>

const static float bark_bands[24] = {
static const float bark_bands[24] = {
100.F, 200.F, 300.F, 400.F, 510.F, 630.F, 770.F, 920.F,
1080.F, 1270.F, 1480.F, 1720.F, 2000.F, 2320.F, 2700.F, 3150.F,
3700.F, 4400.F, 5300.F, 6400.F, 7700.F, 9500.F, 12000.F, 15500.F};
const static float opus_bands[20] = {200.F, 400.F, 600.F, 800.F, 1000.F,
static const float opus_bands[20] = {200.F, 400.F, 600.F, 800.F, 1000.F,
1200.F, 1400.F, 1600.F, 2000.F, 2400.F,
2800.F, 3200.F, 4000.F, 4800.F, 5600.F,
6800.F, 8000.F, 9600.F, 12000.F, 15600.F};
const static float mel_bands[33] = {
static const float mel_bands[33] = {
250.F, 500.F, 750.F, 1000.F, 1250.F, 1500.F, 1750.F, 2000.F,
2250.F, 2500.F, 2750.F, 3000.F, 3250.F, 3500.F, 3750.F, 4000.F,
4250.F, 4500.F, 4750.F, 5000.F, 5250.F, 5500.F, 5750.F, 6000.F,
6250.F, 6500.F, 6750.F, 7000.F, 7250.F, 7500.F, 7750.F, 8000.F};
const static float octave_bands[10] = {31.5F, 63.F, 125.F, 250.F, 500.F,
static const float octave_bands[10] = {31.5F, 63.F, 125.F, 250.F, 500.F,
1000.F, 2000.F, 4000.F, 8000.F, 16000.F};

static void compute_mapping_spectrum(CriticalBands *self);
Expand Down Expand Up @@ -78,7 +78,7 @@ CriticalBands *critical_bands_initialize(const uint32_t sample_rate,
compute_band_indexes(self);

return self;
};
}

void critical_bands_free(CriticalBands *self) {
free(self->band_delimiter_bins);
Expand Down
4 changes: 2 additions & 2 deletions src/shared/stft/fft_transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool fft_load_input_samples(FftTransform *self, const float *input) {
}

// Copy centered values only
for (int i = (int)self->copy_position;
for (uint32_t i = self->copy_position;
i < (self->frame_size + self->copy_position); i++) {
self->input_fft_buffer[i] = input[i - self->copy_position];
}
Expand All @@ -140,7 +140,7 @@ bool fft_get_output_samples(FftTransform *self, float *output) {
}

// Copy centered values only
for (int i = (int)self->copy_position;
for (uint32_t i = self->copy_position;
i < (self->frame_size + self->copy_position); i++) {
output[i - self->copy_position] = self->input_fft_buffer[i];
}
Expand Down
4 changes: 2 additions & 2 deletions src/shared/utils/general_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <math.h>
#include <stdlib.h>

inline float sanitize_denormal(float value) {
float sanitize_denormal(float value) {
if (!isnormal(value)) {
value = 0.F;
}
return value;
}

inline float from_db_to_coefficient(const float value_db) {
float from_db_to_coefficient(const float value_db) {
return expf(value_db / 10.F * logf(10.F));
}

Expand Down
18 changes: 8 additions & 10 deletions src/shared/utils/spectral_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <float.h>
#include <math.h>

static inline float blackman(const uint32_t bin_index,
const uint32_t fft_size) {
static float blackman(const uint32_t bin_index, const uint32_t fft_size) {
const float p = ((float)(bin_index)) / ((float)(fft_size));
return sanitize_denormal(0.42F - (0.5F * cosf(2.F * M_PI * p)) +
(0.08F * cosf(4.F * M_PI * p)));
}

static inline float hanning(const uint32_t bin_index, const uint32_t fft_size) {
static float hanning(const uint32_t bin_index, const uint32_t fft_size) {
const float p = ((float)(bin_index)) / ((float)(fft_size));
return sanitize_denormal(0.5F - (0.5F * cosf(2.F * M_PI * p)));
}

static inline float hamming(const uint32_t bin_index, const uint32_t fft_size) {
static float hamming(const uint32_t bin_index, const uint32_t fft_size) {
const float p = ((float)(bin_index)) / ((float)(fft_size));
return sanitize_denormal(0.54F - (0.46F * cosf(2.F * M_PI * p)));
}

static inline float vorbis(const uint32_t bin_index, const uint32_t fft_size) {
static float vorbis(const uint32_t bin_index, const uint32_t fft_size) {
const float p = ((float)(bin_index)) / ((float)(fft_size));
return sanitize_denormal(sinf(M_PI / 2.F * powf(sinf(M_PI * p), 2.F)));
}
Expand Down Expand Up @@ -144,14 +143,13 @@ bool direct_matrix_to_vector_spectral_convolution(const float *matrix_spectum,
return true;
}

inline float fft_bin_to_freq(const uint32_t bin_index,
const uint32_t sample_rate,
const uint32_t fft_size) {
float fft_bin_to_freq(const uint32_t bin_index, const uint32_t sample_rate,
const uint32_t fft_size) {
return (float)bin_index * ((float)sample_rate / (float)fft_size);
}

inline uint32_t freq_to_fft_bin(const float freq, const uint32_t sample_rate,
const uint32_t fft_size) {
uint32_t freq_to_fft_bin(const float freq, const uint32_t sample_rate,
const uint32_t fft_size) {
return (uint32_t)(freq / ((float)sample_rate / (float)fft_size / 2.F));
}

Expand Down

0 comments on commit b97be1f

Please sign in to comment.