coastline 0.0.4
Loading...
Searching...
No Matches
audiomix.h File Reference

The hand-written routines of audiomix.s: copies of 64-bit words and the sample mixers, and the channel records they read. More...

#include "common/types.h"
Include dependency graph for audiomix.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MixerChannel
 A channel of a mixer. More...
struct  SdlMixerState
 Mixer channels and write position for one SDL audio context. More...

Macros

#define AUDIO_RING_BYTES   0x4000
 The bytes of the stereo ring buffer the mixers write.
#define MIXER_CHANNELS   16
 The channels of the music mixer.
#define SOUND_EFFECT_CHANNELS   6
 The channels of the sound effect mixer.
#define g_wAudioBufferWritePos   (GetSdlMixerState()->writePosition)
#define g_aMixerChannels   (GetSdlMixerState()->musicChannels)
#define g_qwSoundEffectSampleMask   (GetSdlMixerState()->soundEffectSampleMask)
#define g_aSoundEffectChannels   (GetSdlMixerState()->soundEffectChannels)
#define g_dwSoundEffectEchoOffset   (GetSdlMixerState()->soundEffectEchoOffset)

Functions

SdlMixerState * GetSdlMixerState (void)
void CopyVec4 (void *dst, const void *src)
 Copy 16 bytes between 8-byte aligned addresses.
void MemFill64Aligned (void *dst, u32 size, s32 value)
 Fill a byte count rounded up to 64 with a 32-bit value.
void MixAudioSamples (s16 *ring, u32 bytes)
 Mix six channels into the ring buffer, replacing what it held.
void MixAudioStereoSamples (s16 *ring, u32 bytes, u32 pairOffset)
 Add a pair of channels to the ring buffer.
void MixSoundEffectChannels (s16 *ring, u32 bytes, u32 offset)
 Add the sound effect channels to the ring buffer from an offset.

Detailed Description

The hand-written routines of audiomix.s: copies of 64-bit words and the sample mixers, and the channel records they read.

Macro Definition Documentation

◆ AUDIO_RING_BYTES

#define AUDIO_RING_BYTES   0x4000

The bytes of the stereo ring buffer the mixers write.

◆ MIXER_CHANNELS

#define MIXER_CHANNELS   16

The channels of the music mixer.

◆ SOUND_EFFECT_CHANNELS

#define SOUND_EFFECT_CHANNELS   6

The channels of the sound effect mixer.

◆ g_wAudioBufferWritePos

#define g_wAudioBufferWritePos   (GetSdlMixerState()->writePosition)

The byte offset of the next write within the stereo ring buffer.

◆ g_aMixerChannels

#define g_aMixerChannels   (GetSdlMixerState()->musicChannels)

The music mixer's sample channels.

◆ g_qwSoundEffectSampleMask

#define g_qwSoundEffectSampleMask   (GetSdlMixerState()->soundEffectSampleMask)

The mask that clears low bits during packed effect mixing.

◆ g_aSoundEffectChannels

#define g_aSoundEffectChannels   (GetSdlMixerState()->soundEffectChannels)

The sound effect channels.

◆ g_dwSoundEffectEchoOffset

#define g_dwSoundEffectEchoOffset   (GetSdlMixerState()->soundEffectEchoOffset)

The sample offset from channel zero to its echo, or zero.

Function Documentation

◆ GetSdlMixerState()

SdlMixerState * GetSdlMixerState ( void )
Precondition
An N64MixerContext is active.
Returns
The mixer storage, valid until the context is destroyed.

◆ CopyVec4()

void CopyVec4 ( void * dst,
const void * src )

Copy 16 bytes between 8-byte aligned addresses.

Parameters
dstThe destination.
srcThe source.
Ghidra address:
USA: 0x80256270
Ghidra address:
Asia: 0x80255DC0
Ghidra address:
EUR: 0x80257840
Ghidra address:
JPN: 0x802571d0

◆ MemFill64Aligned()

void MemFill64Aligned ( void * dst,
u32 size,
s32 value )

Fill a byte count rounded up to 64 with a 32-bit value.

The address must be 8-byte aligned.

Parameters
dstThe start of the memory to fill.
sizeThe count of bytes to fill.
valueThe value of each word. A value of -1 sets every bit, and a positive value leaves the upper halfword of each word clear.
Ghidra address:
USA: 0x80256290
Ghidra address:
Asia: 0x80255DE0
Ghidra address:
EUR: 0x80257860
Ghidra address:
JPN: 0x802571f0

◆ MixAudioSamples()

void MixAudioSamples ( s16 * ring,
u32 bytes )

Mix six channels into the ring buffer, replacing what it held.

Parameters
ringThe start of the ring buffer.
bytesThe count of bytes to mix from the write position.
Ghidra address:
USA: 0x802562f0
Ghidra address:
Asia: 0x80255E40
Ghidra address:
EUR: 0x802578c0
Ghidra address:
JPN: 0x80257250

◆ MixAudioStereoSamples()

void MixAudioStereoSamples ( s16 * ring,
u32 bytes,
u32 pairOffset )

Add a pair of channels to the ring buffer.

Parameters
ringThe start of the ring buffer.
bytesThe count of bytes to mix from the write position.
pairOffsetOffset of the pair's records from those of the first extra pair.
Ghidra address:
USA: 0x8025649c
Ghidra address:
Asia: 0x80255FEC
Ghidra address:
EUR: 0x80257a6c
Ghidra address:
JPN: 0x802573fc

◆ MixSoundEffectChannels()

void MixSoundEffectChannels ( s16 * ring,
u32 bytes,
u32 offset )

Add the sound effect channels to the ring buffer from an offset.

Parameters
ringThe start of the ring buffer.
bytesThe count of bytes to mix.
offsetThe offset in bytes into the ring buffer to start at.
Ghidra address:
USA: 0x8025658c
Ghidra address:
Asia: 0x802560DC
Ghidra address:
EUR: 0x80257b5c
Ghidra address:
JPN: 0x802574ec