baldram / ESP_VS1053_Library

A library for VS1053 MP3 Codec Breakout adapted for Espressif ESP8266 and ESP32 boards.
https://platformio.org/lib/show/1744/ESP_VS1053_Library
GNU General Public License v3.0
114 stars 36 forks source link

setVolume values / question #85

Closed h1aji closed 2 years ago

h1aji commented 2 years ago

I was comparing setVolume

https://github.com/baldram/ESP_VS1053_Library/blob/f501eb734f0517f2c079369024201667c6471fee/src/VS1053.cpp#L189-L218

with the code from Adafruit

void Adafruit_VS1053::setVolume(uint8_t left, uint8_t right) {
  // accepts values between 0 and 255 for left and right.
  uint16_t v;
  v = left;
  v <<= 8;
  v |= right;

  noInterrupts(); // cli();
  sciWrite(VS1053_REG_VOLUME, v);
  interrupts(); // sei();
}

And found that maximum value for setVolume is 254. So, which value would be correct in this case?

Dr-Dawg commented 2 years ago

The map function maps the values from 0-100 to 0-254 (= 0xFE ), see https://www.arduino.cc/reference/de/language/functions/math/map/ So basically both funtions do the same. Using a range from 0-100 is of course coarser, but imho is more intuitive and does not really make a difference.