@@ -943,8 +943,17 @@ class VolumeStream : public AudioStreamX {
943
943
if (info.channels >max_channels){
944
944
max_channels = info.channels ;
945
945
}
946
+
947
+ // usually we use a exponential volume control - except if we allow values > 1.0
948
+ if (cfg.allow_boost ){
949
+ setVolumeControl (linear_vc);
950
+ } else {
951
+ setVolumeControl (pot_vc);
952
+ }
953
+
946
954
// set start volume
947
955
setVolume (cfg.volume );
956
+
948
957
return true ;
949
958
}
950
959
@@ -955,7 +964,7 @@ class VolumeStream : public AudioStreamX {
955
964
956
965
// / Resets the volume control to use the standard logic
957
966
void resetVolumeControl (){
958
- cached_volume.setVolumeControl (default_volume );
967
+ cached_volume.setVolumeControl (pot_vc );
959
968
}
960
969
961
970
// / Read raw PCM audio data, which will be the input for the volume control
@@ -1033,8 +1042,9 @@ class VolumeStream : public AudioStreamX {
1033
1042
Print *p_out=nullptr ;
1034
1043
Stream *p_in=nullptr ;
1035
1044
VolumeStreamConfig info;
1036
- SimulatedAudioPot default_volume;
1037
- CachedVolumeControl cached_volume = CachedVolumeControl(default_volume);
1045
+ LinearVolumeControl linear_vc{true };
1046
+ SimulatedAudioPot pot_vc;
1047
+ CachedVolumeControl cached_volume{pot_vc};
1038
1048
float *volume_values = nullptr ;
1039
1049
float *factor_for_channel = nullptr ;
1040
1050
bool is_active = false ;
@@ -1102,7 +1112,7 @@ class VolumeStream : public AudioStreamX {
1102
1112
void applyVolume16 (int16_t * data, size_t size){
1103
1113
for (size_t j=0 ;j<size;j++){
1104
1114
float result = factorForChannel (j%info.channels ) * data[j];
1105
- if (info.allow_boost ){
1115
+ if (! info.allow_boost ){
1106
1116
if (result>max_value) result = max_value;
1107
1117
if (result<-max_value) result = -max_value;
1108
1118
}
@@ -1113,7 +1123,7 @@ class VolumeStream : public AudioStreamX {
1113
1123
void applyVolume24 (int24_t * data, size_t size) {
1114
1124
for (size_t j=0 ;j<size;j++){
1115
1125
float result = factorForChannel (j%info.channels ) * data[j];
1116
- if (info.allow_boost ){
1126
+ if (! info.allow_boost ){
1117
1127
if (result>max_value) result = max_value;
1118
1128
if (result<-max_value) result = -max_value;
1119
1129
}
@@ -1125,7 +1135,7 @@ class VolumeStream : public AudioStreamX {
1125
1135
void applyVolume32 (int32_t * data, size_t size) {
1126
1136
for (size_t j=0 ;j<size;j++){
1127
1137
float result = factorForChannel (j%info.channels ) * data[j];
1128
- if (info.allow_boost ){
1138
+ if (! info.allow_boost ){
1129
1139
if (result>max_value) result = max_value;
1130
1140
if (result<-max_value) result = -max_value;
1131
1141
}
0 commit comments