This commit is contained in:
Phil Schatzmann 2022-08-10 15:07:10 +02:00
parent c84cd8af7c
commit dc66a07010
3 changed files with 17 additions and 6 deletions

View File

@ -68,7 +68,7 @@ class int24_t {
/// Standard Conversion to Int
int toInt() const {
int newInt = (((0xFF & value[0]) << 16) | ((0xFF & value[1]) << 8) | (0xFF & value[2]));
int newInt = ((((int32_t)0xFF & value[0]) << 16) | (((int32_t)0xFF & value[1]) << 8) | ((int32_t)0xFF & value[2]));
if ((newInt & 0x00800000) > 0) {
newInt |= 0xFF000000;
} else {

View File

@ -381,7 +381,9 @@ typedef uint32_t eps32_i2s_sample_rate_type;
#define USE_PWM
#define USE_TIMER
#ifndef assert
#define assert(T)
#endif
#define rintf(F) static_cast<int>(F)
#define PIN_PWM_START 6
#define PIN_CS CS
@ -394,7 +396,7 @@ typedef uint32_t eps32_i2s_sample_rate_type;
// logging is using too much memory
#undef LOG_PRINTF_BUFFER_SIZE
#define LOG_PRINTF_BUFFER_SIZE 80
#define LOG_PRINTF_BUFFER_SIZE 40
#undef USE_AUDIO_LOGGING
#define USE_AUDIO_LOGGING false

View File

@ -19,8 +19,16 @@ public:
bool begin() {
p_vs1053 = new VS1053(_cs_pin,_dcs_pin,_dreq_pin );
// initialize SPI
SPI.begin();
p_vs1053->begin();
p_vs1053->startSong();
p_vs1053->switchToMp3Mode(); // optional, some boards require this
if (p_vs1053->getChipVersion() == 4) { // Only perform an update if we really are using a VS1053, not. eg. VS1003
p_vs1053->loadDefaultVs1053Patches();
}
setVolume(vol);
return true;
}
@ -32,11 +40,11 @@ public:
/// value from 0 to 1.0
void setVolume(float volume){
// make sure that value is between 0 and 1
float v = volume;
if (v>1.0) v = 1.0;
if (v<0) v = 0.0;
vol = volume;
if (vol>1.0) vol = 1.0;
if (vol<0) vol = 0.0;
// Set the player volume.Level from 0-100, higher is louder
p_vs1053->setVolume(v*100);
p_vs1053->setVolume(vol*100);
}
virtual size_t write(const uint8_t *buffer, size_t size) override{
@ -53,6 +61,7 @@ public:
protected:
VS1053 *p_vs1053 = nullptr;
uint8_t _cs_pin, _dcs_pin, _dreq_pin;
float vol=1.0;
};