pcm_utils: added inline function pcm_float_to_volume()
This commit is contained in:
parent
5ddde0aac7
commit
ad77a3e0ac
@ -36,6 +36,16 @@ struct pcm_convert_state {
|
|||||||
int error;
|
int error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a float value (0.0 = silence, 1.0 = 100% volume) to an
|
||||||
|
* integer volume value (1000 = 100%).
|
||||||
|
*/
|
||||||
|
static inline int
|
||||||
|
pcm_float_to_volume(float volume)
|
||||||
|
{
|
||||||
|
return volume * 1000.0 + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
void pcm_volume(char *buffer, int bufferSize,
|
void pcm_volume(char *buffer, int bufferSize,
|
||||||
const struct audio_format *format,
|
const struct audio_format *format,
|
||||||
int volume);
|
int volume);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "player_control.h"
|
#include "player_control.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "idle.h"
|
#include "idle.h"
|
||||||
|
#include "pcm_utils.h"
|
||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
@ -483,8 +484,8 @@ static int changeSoftwareVolume(int change, int rel)
|
|||||||
else if (new <= 0)
|
else if (new <= 0)
|
||||||
new = 0;
|
new = 0;
|
||||||
else
|
else
|
||||||
new =
|
new = pcm_float_to_volume((exp(new / 25.0) - 1) /
|
||||||
1000.0 * (exp(new / 25.0) - 1) / (54.5981500331F - 1) + 0.5;
|
(54.5981500331F - 1));
|
||||||
|
|
||||||
setPlayerSoftwareVolume(new);
|
setPlayerSoftwareVolume(new);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user