You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Audio cleanup checkpoint: Large portion of synthesis.c taken care of + occasional audio optimizations (#710)
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
#include "effects.h"
|
||||
#include "load.h"
|
||||
#include "data.h"
|
||||
#include "external.h"
|
||||
#include "seqplayer.h"
|
||||
#include "game/game_init.h"
|
||||
#include "game/main.h"
|
||||
#include "engine/math_util.h"
|
||||
|
||||
@@ -66,7 +68,7 @@ static void sequence_channel_process_sound(struct SequenceChannel *seqChannel) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
struct SequenceChannelLayer *layer = seqChannel->layers[i];
|
||||
if (layer != NULL && layer->enabled && layer->note != NULL) {
|
||||
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale * gConfig.audioFrequency;
|
||||
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
|
||||
layer->noteVelocity = layer->velocitySquare * channelVolume;
|
||||
layer->notePan = (layer->pan * panLayerWeight) + panFromChannel;
|
||||
}
|
||||
|
||||
@@ -1129,7 +1129,7 @@ static f32 get_sound_freq_scale(u8 bank, u8 item) {
|
||||
|
||||
// Goes from 1 at the camera to 1 + 1/15 at AUDIO_MAX_DISTANCE (and continues rising
|
||||
// farther than that)
|
||||
return amount / 15.0f + 1.0f;
|
||||
return (amount / 15.0f + 1.0f) * gConfig.audioFrequency;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1311,7 +1311,7 @@ static void update_game_sound(void) {
|
||||
#else
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = 1.0f;
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->pan = 0.5f;
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale = 1.0f;
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale = gConfig.audioFrequency;
|
||||
#endif
|
||||
break;
|
||||
case SOUND_BANK_ACTION:
|
||||
@@ -1477,7 +1477,7 @@ static void update_game_sound(void) {
|
||||
#else
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume = 1.0f;
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->pan = 0.5f;
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale = 1.0f;
|
||||
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale = gConfig.audioFrequency;
|
||||
#endif
|
||||
break;
|
||||
case SOUND_BANK_ACTION:
|
||||
|
||||
@@ -706,17 +706,14 @@ struct Note {
|
||||
/*0x8C*/ struct AudioListItem listItem;
|
||||
/*0x9C*/ s16 curVolLeft; // Q1.15, but will always be non-negative
|
||||
/*0x9E*/ s16 curVolRight; // Q1.15, but will always be non-negative
|
||||
/*0xA0*/ s16 reverbVolShifted; // Q1.15
|
||||
#ifdef ENABLE_STEREO_HEADSET_EFFECTS
|
||||
/*0xA2*/ u16 headsetPanRight;
|
||||
/*0xA4*/ u16 headsetPanLeft;
|
||||
/*0xA6*/ u16 prevHeadsetPanRight;
|
||||
/*0xA8*/ u16 prevHeadsetPanLeft;
|
||||
/* */ u8 align16Padding[0x06];
|
||||
#else
|
||||
/* */ u8 align16Padding[0x0E];
|
||||
/*0xA0*/ u16 headsetPanRight;
|
||||
/*0xA2*/ u16 headsetPanLeft;
|
||||
/*0xA4*/ u16 prevHeadsetPanRight;
|
||||
/*0xA6*/ u16 prevHeadsetPanLeft;
|
||||
/* */ u8 align16Padding[0x08];
|
||||
#endif
|
||||
}; // size = 0xB0
|
||||
}; // size = 0xA0, 0xB0
|
||||
#endif
|
||||
|
||||
struct NoteSynthesisBuffers {
|
||||
|
||||
@@ -359,7 +359,6 @@ void process_notes(void) {
|
||||
#endif
|
||||
u8 bookOffset;
|
||||
#endif
|
||||
struct NoteAttributes *attributes;
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
struct AudioListItem *it;
|
||||
#endif
|
||||
@@ -580,17 +579,18 @@ void process_notes(void) {
|
||||
|
||||
adsr_update(note);
|
||||
note_vibrato_update(note);
|
||||
attributes = ¬e->attributes;
|
||||
if (note->priority == NOTE_PRIORITY_STOPPING) {
|
||||
struct NoteAttributes *attributes = ¬e->attributes;
|
||||
frequency = attributes->freqScale;
|
||||
velocity = attributes->velocity;
|
||||
pan = attributes->pan;
|
||||
reverbVol = attributes->reverbVol;
|
||||
} else {
|
||||
frequency = note->parentLayer->noteFreqScale;
|
||||
velocity = note->parentLayer->noteVelocity;
|
||||
pan = note->parentLayer->notePan;
|
||||
reverbVol = note->parentLayer->seqChannel->reverbVol;
|
||||
struct SequenceChannelLayer *parentLayer = note->parentLayer;
|
||||
frequency = parentLayer->noteFreqScale;
|
||||
velocity = parentLayer->noteVelocity;
|
||||
pan = parentLayer->notePan;
|
||||
reverbVol = parentLayer->seqChannel->reverbVol;
|
||||
}
|
||||
|
||||
scale = note->adsrVolScale;
|
||||
@@ -875,14 +875,8 @@ void build_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLay
|
||||
// Repeat sample
|
||||
for (offset = note->sampleCount; offset < 0x40; offset += note->sampleCount) {
|
||||
lim = note->sampleCount;
|
||||
if (offset < 0 || offset > 0) {
|
||||
for (j = 0; j < lim; j++) {
|
||||
note->synthesisBuffers->samples[offset + j] = note->synthesisBuffers->samples[j];
|
||||
}
|
||||
} else {
|
||||
for (j = 0; j < lim; j++) {
|
||||
note->synthesisBuffers->samples[offset + j] = note->synthesisBuffers->samples[j];
|
||||
}
|
||||
for (j = 0; j < lim; j++) {
|
||||
note->synthesisBuffers->samples[offset + j] = note->synthesisBuffers->samples[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "heap.h"
|
||||
#include "load.h"
|
||||
#include "seqplayer.h"
|
||||
#include "game/main.h"
|
||||
|
||||
#ifdef VERSION_SH
|
||||
void seq_channel_layer_process_script_part1(struct SequenceChannelLayer *layer);
|
||||
@@ -44,7 +45,7 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) {
|
||||
seqChannel->scriptState.depth = 0;
|
||||
seqChannel->volume = 1.0f;
|
||||
seqChannel->volumeScale = 1.0f;
|
||||
seqChannel->freqScale = 1.0f;
|
||||
seqChannel->freqScale = gConfig.audioFrequency;
|
||||
seqChannel->pan = 0.5f;
|
||||
seqChannel->panChannelWeight = 1.0f;
|
||||
seqChannel->noteUnused = NULL;
|
||||
@@ -77,7 +78,7 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) {
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
seqChannel->volume = 1.0f;
|
||||
seqChannel->volumeScale = 1.0f;
|
||||
seqChannel->freqScale = 1.0f;
|
||||
seqChannel->freqScale = gConfig.audioFrequency;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
@@ -1684,7 +1685,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
|
||||
case 0xde: // chan_freqscale; pitch bend using raw frequency multiplier N/2^15 (N is u16)
|
||||
sp5A = m64_read_s16(state);
|
||||
seqChannel->freqScale = FLOAT_CAST(sp5A) / 32768.0f;
|
||||
seqChannel->freqScale = FLOAT_CAST(sp5A) / 32768.0f * gConfig.audioFrequency;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
seqChannel->changes.as_bitfields.freqScale = TRUE;
|
||||
#endif
|
||||
@@ -1697,7 +1698,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
#else
|
||||
cmd = m64_read_u8(state) + 127;
|
||||
#endif
|
||||
seqChannel->freqScale = gPitchBendFrequencyScale[cmd];
|
||||
seqChannel->freqScale = gPitchBendFrequencyScale[cmd] * gConfig.audioFrequency;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
seqChannel->changes.as_bitfields.freqScale = TRUE;
|
||||
#endif
|
||||
@@ -1706,7 +1707,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
#ifdef VERSION_SH
|
||||
case 0xee:
|
||||
cmd = m64_read_u8(state) + 0x80;
|
||||
seqChannel->freqScale = unk_sh_data_1[cmd];
|
||||
seqChannel->freqScale = unk_sh_data_1[cmd] * gConfig.audioFrequency;
|
||||
seqChannel->changes.as_bitfields.freqScale = TRUE;
|
||||
break;
|
||||
#endif
|
||||
@@ -1955,7 +1956,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
|
||||
seqChannel->vibratoRateTarget = 0;
|
||||
seqChannel->vibratoRateStart = 0;
|
||||
seqChannel->vibratoRateChangeDelay = 0;
|
||||
seqChannel->freqScale = 1.0f;
|
||||
seqChannel->freqScale = gConfig.audioFrequency;
|
||||
break;
|
||||
|
||||
case 0xe9: // chan_setnotepriority
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user