mirror of
https://github.com/Llennpie/Saturn.git
synced 2025-01-22 23:52:09 -05:00
premultiply volume scales by master volume
instead of scaling the output
This commit is contained in:
parent
94db04aaf0
commit
34af21bad4
2 changed files with 7 additions and 13 deletions
|
@ -5,9 +5,8 @@
|
||||||
|
|
||||||
#define CONFIGFILE_DEFAULT "sm64config.txt"
|
#define CONFIGFILE_DEFAULT "sm64config.txt"
|
||||||
|
|
||||||
#define MAX_BINDS 3
|
#define MAX_BINDS 3
|
||||||
#define MAX_VOLUME 127
|
#define MAX_VOLUME 127
|
||||||
#define VOLUME_SHIFT 7
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int x, y, w, h;
|
unsigned int x, y, w, h;
|
||||||
|
|
|
@ -75,12 +75,12 @@ void send_display_list(struct SPTask *spTask) {
|
||||||
#define printf
|
#define printf
|
||||||
|
|
||||||
void produce_one_frame(void) {
|
void produce_one_frame(void) {
|
||||||
|
|
||||||
gfx_start_frame();
|
gfx_start_frame();
|
||||||
|
|
||||||
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f);
|
const f32 master_mod = (f32)configMasterVolume / 127.0f;
|
||||||
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f);
|
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * master_mod);
|
||||||
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f);
|
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
|
||||||
|
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);
|
||||||
|
|
||||||
game_loop_one_iteration();
|
game_loop_one_iteration();
|
||||||
thread6_rumble_loop(NULL);
|
thread6_rumble_loop(NULL);
|
||||||
|
@ -98,13 +98,8 @@ void produce_one_frame(void) {
|
||||||
}
|
}
|
||||||
//printf("Audio samples before submitting: %d\n", audio_api->buffered());
|
//printf("Audio samples before submitting: %d\n", audio_api->buffered());
|
||||||
|
|
||||||
// scale by master volume (0-127)
|
|
||||||
const s32 mod = (s32)configMasterVolume;
|
|
||||||
for (u32 i = 0; i < num_audio_samples * 4; ++i)
|
|
||||||
audio_buffer[i] = ((s32)audio_buffer[i] * mod) >> VOLUME_SHIFT;
|
|
||||||
|
|
||||||
audio_api->play((u8*)audio_buffer, 2 * num_audio_samples * 4);
|
audio_api->play((u8*)audio_buffer, 2 * num_audio_samples * 4);
|
||||||
|
|
||||||
gfx_end_frame();
|
gfx_end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue