espressif / esp-adf-libs

61 stars 41 forks source link

esp_codec: use fabs instead of abs #27

Open stintel opened 1 year ago

stintel commented 1 year ago

This fixes the following warnings when building with IDF 5:

Building C object esp-idf/esp-adf-libs/CMakeFiles/__idf_esp-adf-libs.dir/esp_codec/audio_forge.c.obj/willow/deps/esp-adf/components/esp-adf-libs/esp_codec/audio_forge.c: In function 'audio_forge_downmix_set_gain': /willow/deps/esp-adf/components/esp-adf-libs/esp_codec/audio_forge.c:847:15: warning: using integer absolute value function 'abs' when argument is of floating-point type 'float' [-Wabsolute-value]
  847 |     if ((int)(abs((gain[0] - audio_forge->downmix.source_info[index].gain[0]) * 100)) <= 5 //100 and 5 is to determine if two double numbers are equal.
      |               ^~~
/willow/deps/esp-adf/components/esp-adf-libs/esp_codec/audio_forge.c:848:18: warning: using integer absolute value function 'abs' when argument is of floating-point type 'float' [-Wabsolute-value]
  848 |         && (int)(abs((gain[1] - audio_forge->downmix.source_info[index].gain[0]) * 100)) <= 5) {
      |                  ^~~
/willow/deps/esp-adf/components/esp-adf-libs/esp_codec/audio_forge.c: In function 'audio_forge_sonic_set_speed':
/willow/deps/esp-adf/components/esp-adf-libs/esp_codec/audio_forge.c:986:15: warning: using integer absolute value function 'abs' when argument is of floating-point type 'float' [-Wabsolute-value]
  986 |     if ((int)(abs((sonic_speed - audio_forge->sonic_speed) * 100)) <= 5) {
      |               ^~~
/willow/deps/esp-adf/components/esp-adf-libs/esp_codec/audio_forge.c: In function 'audio_forge_sonic_set_pitch':
/willow/deps/esp-adf/components/esp-adf-libs/esp_codec/audio_forge.c:1011:15: warning: using integer absolute value function 'abs' when argument is of floating-point type 'float' [-Wabsolute-value]
 1011 |     if ((int)(abs((sonic_pitch - audio_forge->sonic_pitch) * 100)) <= 5) {
      |               ^~~