Skip to content

Commit de41719

Browse files
committed
vs1053 call setVolume on begin
1 parent 767409c commit de41719

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/AudioConfig.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,10 @@ typedef uint32_t eps32_i2s_sample_rate_type;
439439

440440
// use 0 for https://github.com/baldram/ESP_VS1053_Library
441441
// use 1 for https://github.com/pschatzmann/arduino-vs1053
442-
#define VS1053_EXT 1
442+
#define VS1053_EXT 0
443+
#define VS1053_DEFAULT_VOLUME 0.5
444+
445+
443446
//----------------
444447

445448
#ifdef IS_DESKTOP

src/AudioLibs/VS1053Stream.h

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class VS1053BaseStream : public AudioStreamX {
5656

5757
/// value from 0 to 1.0
5858
void setVolume(float vol){
59-
LOGD(LOG_METHOD);
59+
LOGD("setVolume: %f", vol);
6060
// make sure that value is between 0 and 1
6161
float volume = vol;
6262
if (volume>1.0) volume = 1.0;
@@ -76,7 +76,7 @@ class VS1053BaseStream : public AudioStreamX {
7676

7777
/// Adjusting the left and right volume balance, higher to enhance the right side, lower to enhance the left side.
7878
void setBalance(float bal){
79-
LOGD(LOG_METHOD);
79+
LOGD("setBalance: %f", vol);
8080
float balance = bal;
8181
if (balance<-1.0) balance = -1;
8282
if (balance>1.0) balance = 1;
@@ -115,7 +115,7 @@ class VS1053BaseStream : public AudioStreamX {
115115

116116
/// Sets the treble amplitude value (range 0 to 1.0)
117117
void setTreble(float val){
118-
LOGD(LOG_METHOD);
118+
LOGD("setTreble: %f", vol);
119119
float value = val;
120120
if (value<0.0) value = 0.0;
121121
if (value>1.0) value = 1.0;
@@ -133,22 +133,22 @@ class VS1053BaseStream : public AudioStreamX {
133133

134134
/// Sets the bass amplitude value (range 0 to 1.0)
135135
void setBass(float value){
136-
LOGD(LOG_METHOD);
136+
LOGD("setBass: %f", vol);
137137
if (p_vs1053!=nullptr){
138138
p_vs1053->setBass(value*100.0);
139139
}
140140
}
141141

142142
/// Sets the treble frequency limit in hz (range 0 to 15000)
143143
void setTrebleFrequencyLimit(uint16_t value){
144-
LOGD(LOG_METHOD);
144+
LOGD("setTrebleFrequencyLimit: %u", vol);
145145
if (p_vs1053!=nullptr){
146146
p_vs1053->setTrebleFrequencyLimit(value);
147147
}
148148
}
149149
/// Sets the bass frequency limit in hz (range 0 to 15000)
150150
void setBassFrequencyLimit(uint16_t value){
151-
LOGD(LOG_METHOD);
151+
LOGD("setBassFrequencyLimit: %u", vol);
152152
if (p_vs1053!=nullptr){
153153
p_vs1053->setBassFrequencyLimit(value);
154154
}
@@ -212,6 +212,7 @@ class VS1053Stream : public AudioStreamX {
212212
/// Starts with the indicated configuration
213213
bool begin(VS1053Config cfg) {
214214
LOGI(LOG_METHOD);
215+
bool result = true;
215216
// enfornce encoded data for midi mode
216217
if (cfg.is_midi_mode){
217218
cfg.is_encoded_data = true;
@@ -245,20 +246,27 @@ class VS1053Stream : public AudioStreamX {
245246
case TX_MODE:
246247
p_out->begin(cfg);
247248
p_driver->begin();
248-
return true;
249+
setVolume(VS1053_DEFAULT_VOLUME);
250+
result = true;
251+
break;
249252
#if VS1053_EXT
250253
case MIDI_MODE:
251254
getVS1053().beginMIDI();
252-
return true;
255+
setVolume(VS1053_DEFAULT_VOLUME);
256+
result = true;
257+
break;
253258

254259
case RX_MODE:
255260
getVS1053().beginInput(cfg.is_encoded_data);
256-
return true;
261+
result = true;
262+
break;
257263
#endif
258264
default:
259265
LOGE("Mode not supported");
260-
return false;
266+
result = false;
267+
break;
261268
}
269+
return result;
262270
}
263271

264272
/// Stops the processing and releases the memory

0 commit comments

Comments
 (0)