Mario Kart 64
Loading...
Searching...
No Matches
mixer.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <align_asset_macro.h>
#include "mixer.h"
Include dependency graph for mixer.c:

Macros

#define aUnkCmd19(pkt, a1, a2, a3, a4)
 
#define ROUND_UP_64(v)
 
#define ROUND_UP_32(v)
 
#define ROUND_UP_16(v)
 
#define ROUND_UP_8(v)
 
#define ROUND_DOWN_16(v)
 
#define DMEM_BUF_SIZE   0x17D0
 
#define BUF_U8(a)
 
#define BUF_S16(a)
 

Functions

static int16_t clamp16 (int32_t v)
 
static int32_t clamp32 (int64_t v)
 
void aClearBufferImpl (uint16_t addr, int nbytes)
 
void aLoadBufferImpl (const void *source_addr, uint16_t dest_addr, uint16_t nbytes)
 
void aSaveBufferImpl (uint16_t source_addr, int16_t *dest_addr, uint16_t nbytes)
 
void aLoadADPCMImpl (int num_entries_times_16, const int16_t *book_source_addr)
 
void aSetBufferImpl (uint8_t flags, uint16_t in, uint16_t out, uint16_t nbytes)
 
void aInterleaveImpl (uint16_t left, uint16_t right)
 
void aDMEMMoveImpl (uint16_t in_addr, uint16_t out_addr, int nbytes)
 
void aSetLoopImpl (ADPCM_STATE *adpcm_loop_state)
 
void aADPCMdecImpl (uint8_t flags, ADPCM_STATE state)
 
void aResampleImpl (uint8_t flags, uint16_t pitch, RESAMPLE_STATE state)
 
void aEnvSetup1Impl (uint8_t initial_vol_wet, uint16_t rate_wet, uint16_t rate_left, uint16_t rate_right)
 
void aEnvSetup2Impl (uint16_t initial_vol_left, uint16_t initial_vol_right)
 
void aEnvMixerImpl (uint16_t in_addr, uint16_t n_samples, bool swap_reverb, bool neg_left, bool neg_right, uint16_t dry_left_addr, uint16_t dry_right_addr, uint16_t wet_left_addr, uint16_t wet_right_addr)
 
void aMixImpl (int16_t gain, uint16_t in_addr, uint16_t out_addr, uint16_t count)
 
void aS8DecImpl (uint8_t flags, ADPCM_STATE state)
 
void aAddMixerImpl (uint16_t count, uint16_t in_addr, uint16_t out_addr)
 
void aDuplicateImpl (uint16_t count, uint16_t in_addr, uint16_t out_addr)
 
void aDMEMMove2Impl (uint8_t t, uint16_t in_addr, uint16_t out_addr, uint16_t count)
 
void aResampleZohImpl (uint16_t pitch, uint16_t start_fract)
 
void aDownsampleHalfImpl (uint16_t n_samples, uint16_t in_addr, uint16_t out_addr)
 
void aInterlImpl (uint16_t in_addr, uint16_t out_addr, uint16_t n_samples)
 
void aFilterImpl (uint8_t flags, uint16_t count_or_buf, int16_t *state_or_filter)
 
void aHiLoGainImpl (uint8_t g, uint16_t count, uint16_t addr)
 
void aUnkCmd3Impl (uint16_t a, uint16_t b, uint16_t c)
 
void aUnkCmd19Impl (uint8_t f, uint16_t count, uint16_t out_addr, uint16_t in_addr)
 

Variables

struct { 
 
   uint16_t   in 
 
   uint16_t   out 
 
   uint16_t   nbytes 
 
   uint16_t   vol [2] 
 
   uint16_t   rate [2] 
 
   uint16_t   vol_wet 
 
   uint16_t   rate_wet 
 
   ADPCM_STATE *   adpcm_loop_state 
 
   int16_t   adpcm_table [8][2][8] 
 
   uint16_t   filter_count 
 
   int16_t   filter [8] 
 
   union { 
 
      int16_t   as_s16 [DMEM_BUF_SIZE/sizeof(int16_t)] 
 
      uint8_t   as_u8 [DMEM_BUF_SIZE
 
   }   buf 
 
rspa 
 
static int16_t resample_table [64][4]
 

Macro Definition Documentation

◆ aUnkCmd19

#define aUnkCmd19 ( pkt,
a1,
a2,
a3,
a4 )
Value:
aUnkCmd19Impl(a1, a2, a3, a4)
void aUnkCmd19Impl(uint8_t f, uint16_t count, uint16_t out_addr, uint16_t in_addr)
Definition mixer.c:1047

◆ BUF_S16

#define BUF_S16 ( a)
Value:
(rspa.buf.as_s16 + (a) / sizeof(int16_t))
static struct @111115220225173102313045065244126153342261214353 rspa

◆ BUF_U8

#define BUF_U8 ( a)
Value:
(rspa.buf.as_u8 + (a))

◆ DMEM_BUF_SIZE

#define DMEM_BUF_SIZE   0x17D0

◆ ROUND_DOWN_16

#define ROUND_DOWN_16 ( v)
Value:
((v) & ~0xf)

◆ ROUND_UP_16

#define ROUND_UP_16 ( v)
Value:
(((v) + 15) & ~15)

◆ ROUND_UP_32

#define ROUND_UP_32 ( v)
Value:
(((v) + 31) & ~31)

◆ ROUND_UP_64

#define ROUND_UP_64 ( v)
Value:
(((v) + 63) & ~63)

◆ ROUND_UP_8

#define ROUND_UP_8 ( v)
Value:
(((v) + 7) & ~7)

Function Documentation

◆ aAddMixerImpl()

void aAddMixerImpl ( uint16_t count,
uint16_t in_addr,
uint16_t out_addr )
Here is the call graph for this function:

◆ aADPCMdecImpl()

void aADPCMdecImpl ( uint8_t flags,
ADPCM_STATE state )
Here is the call graph for this function:

◆ aClearBufferImpl()

void aClearBufferImpl ( uint16_t addr,
int nbytes )

◆ aDMEMMove2Impl()

void aDMEMMove2Impl ( uint8_t t,
uint16_t in_addr,
uint16_t out_addr,
uint16_t count )

◆ aDMEMMoveImpl()

void aDMEMMoveImpl ( uint16_t in_addr,
uint16_t out_addr,
int nbytes )

◆ aDownsampleHalfImpl()

void aDownsampleHalfImpl ( uint16_t n_samples,
uint16_t in_addr,
uint16_t out_addr )

◆ aDuplicateImpl()

void aDuplicateImpl ( uint16_t count,
uint16_t in_addr,
uint16_t out_addr )
Here is the call graph for this function:

◆ aEnvMixerImpl()

void aEnvMixerImpl ( uint16_t in_addr,
uint16_t n_samples,
bool swap_reverb,
bool neg_left,
bool neg_right,
uint16_t dry_left_addr,
uint16_t dry_right_addr,
uint16_t wet_left_addr,
uint16_t wet_right_addr )
Here is the call graph for this function:

◆ aEnvSetup1Impl()

void aEnvSetup1Impl ( uint8_t initial_vol_wet,
uint16_t rate_wet,
uint16_t rate_left,
uint16_t rate_right )

◆ aEnvSetup2Impl()

void aEnvSetup2Impl ( uint16_t initial_vol_left,
uint16_t initial_vol_right )

◆ aFilterImpl()

void aFilterImpl ( uint8_t flags,
uint16_t count_or_buf,
int16_t * state_or_filter )
Here is the call graph for this function:

◆ aHiLoGainImpl()

void aHiLoGainImpl ( uint8_t g,
uint16_t count,
uint16_t addr )
Here is the call graph for this function:

◆ aInterleaveImpl()

void aInterleaveImpl ( uint16_t left,
uint16_t right )

◆ aInterlImpl()

void aInterlImpl ( uint16_t in_addr,
uint16_t out_addr,
uint16_t n_samples )

◆ aLoadADPCMImpl()

void aLoadADPCMImpl ( int num_entries_times_16,
const int16_t * book_source_addr )
Here is the call graph for this function:

◆ aLoadBufferImpl()

void aLoadBufferImpl ( const void * source_addr,
uint16_t dest_addr,
uint16_t nbytes )
Here is the call graph for this function:

◆ aMixImpl()

void aMixImpl ( int16_t gain,
uint16_t in_addr,
uint16_t out_addr,
uint16_t count )
Here is the call graph for this function:

◆ aResampleImpl()

void aResampleImpl ( uint8_t flags,
uint16_t pitch,
RESAMPLE_STATE state )
Here is the call graph for this function:

◆ aResampleZohImpl()

void aResampleZohImpl ( uint16_t pitch,
uint16_t start_fract )

◆ aS8DecImpl()

void aS8DecImpl ( uint8_t flags,
ADPCM_STATE state )
Here is the call graph for this function:

◆ aSaveBufferImpl()

void aSaveBufferImpl ( uint16_t source_addr,
int16_t * dest_addr,
uint16_t nbytes )
Here is the call graph for this function:

◆ aSetBufferImpl()

void aSetBufferImpl ( uint8_t flags,
uint16_t in,
uint16_t out,
uint16_t nbytes )

◆ aSetLoopImpl()

void aSetLoopImpl ( ADPCM_STATE * adpcm_loop_state)

◆ aUnkCmd19Impl()

void aUnkCmd19Impl ( uint8_t f,
uint16_t count,
uint16_t out_addr,
uint16_t in_addr )
Here is the call graph for this function:

◆ aUnkCmd3Impl()

void aUnkCmd3Impl ( uint16_t a,
uint16_t b,
uint16_t c )

◆ clamp16()

static int16_t clamp16 ( int32_t v)
inlinestatic
Here is the caller graph for this function:

◆ clamp32()

static int32_t clamp32 ( int64_t v)
inlinestatic

Variable Documentation

◆ adpcm_loop_state

ADPCM_STATE* adpcm_loop_state

◆ adpcm_table

int16_t adpcm_table[8][2][8]

◆ as_s16

int16_t as_s16[DMEM_BUF_SIZE/sizeof(int16_t)]

◆ as_u8

uint8_t as_u8[DMEM_BUF_SIZE]

◆ [union]

union { ... } buf

◆ filter

int16_t filter[8]

◆ filter_count

uint16_t filter_count

◆ in

uint16_t in

◆ nbytes

uint16_t nbytes

◆ out

uint16_t out

◆ rate

uint16_t rate[2]

◆ rate_wet

uint16_t rate_wet

◆ resample_table

int16_t resample_table[64][4]
static
Initial value:
= {
{ 0x0c39, 0x66ad, 0x0d46, 0xffdf }, { 0x0b39, 0x6696, 0x0e5f, 0xffd8 }, { 0x0a44, 0x6669, 0x0f83, 0xffd0 },
{ 0x095a, 0x6626, 0x10b4, 0xffc8 }, { 0x087d, 0x65cd, 0x11f0, 0xffbf }, { 0x07ab, 0x655e, 0x1338, 0xffb6 },
{ 0x06e4, 0x64d9, 0x148c, 0xffac }, { 0x0628, 0x643f, 0x15eb, 0xffa1 }, { 0x0577, 0x638f, 0x1756, 0xff96 },
{ 0x04d1, 0x62cb, 0x18cb, 0xff8a }, { 0x0435, 0x61f3, 0x1a4c, 0xff7e }, { 0x03a4, 0x6106, 0x1bd7, 0xff71 },
{ 0x031c, 0x6007, 0x1d6c, 0xff64 }, { 0x029f, 0x5ef5, 0x1f0b, 0xff56 }, { 0x022a, 0x5dd0, 0x20b3, 0xff48 },
{ 0x01be, 0x5c9a, 0x2264, 0xff3a }, { 0x015b, 0x5b53, 0x241e, 0xff2c }, { 0x0101, 0x59fc, 0x25e0, 0xff1e },
{ 0x00ae, 0x5896, 0x27a9, 0xff10 }, { 0x0063, 0x5720, 0x297a, 0xff02 }, { 0x001f, 0x559d, 0x2b50, 0xfef4 },
{ 0xffe2, 0x540d, 0x2d2c, 0xfee8 }, { 0xffac, 0x5270, 0x2f0d, 0xfedb }, { 0xff7c, 0x50c7, 0x30f3, 0xfed0 },
{ 0xff53, 0x4f14, 0x32dc, 0xfec6 }, { 0xff2e, 0x4d57, 0x34c8, 0xfebd }, { 0xff0f, 0x4b91, 0x36b6, 0xfeb6 },
{ 0xfef5, 0x49c2, 0x38a5, 0xfeb0 }, { 0xfedf, 0x47ed, 0x3a95, 0xfeac }, { 0xfece, 0x4611, 0x3c85, 0xfeab },
{ 0xfec0, 0x4430, 0x3e74, 0xfeac }, { 0xfeb6, 0x424a, 0x4060, 0xfeaf }, { 0xfeaf, 0x4060, 0x424a, 0xfeb6 },
{ 0xfeac, 0x3e74, 0x4430, 0xfec0 }, { 0xfeab, 0x3c85, 0x4611, 0xfece }, { 0xfeac, 0x3a95, 0x47ed, 0xfedf },
{ 0xfeb0, 0x38a5, 0x49c2, 0xfef5 }, { 0xfeb6, 0x36b6, 0x4b91, 0xff0f }, { 0xfebd, 0x34c8, 0x4d57, 0xff2e },
{ 0xfec6, 0x32dc, 0x4f14, 0xff53 }, { 0xfed0, 0x30f3, 0x50c7, 0xff7c }, { 0xfedb, 0x2f0d, 0x5270, 0xffac },
{ 0xfee8, 0x2d2c, 0x540d, 0xffe2 }, { 0xfef4, 0x2b50, 0x559d, 0x001f }, { 0xff02, 0x297a, 0x5720, 0x0063 },
{ 0xff10, 0x27a9, 0x5896, 0x00ae }, { 0xff1e, 0x25e0, 0x59fc, 0x0101 }, { 0xff2c, 0x241e, 0x5b53, 0x015b },
{ 0xff3a, 0x2264, 0x5c9a, 0x01be }, { 0xff48, 0x20b3, 0x5dd0, 0x022a }, { 0xff56, 0x1f0b, 0x5ef5, 0x029f },
{ 0xff64, 0x1d6c, 0x6007, 0x031c }, { 0xff71, 0x1bd7, 0x6106, 0x03a4 }, { 0xff7e, 0x1a4c, 0x61f3, 0x0435 },
{ 0xff8a, 0x18cb, 0x62cb, 0x04d1 }, { 0xff96, 0x1756, 0x638f, 0x0577 }, { 0xffa1, 0x15eb, 0x643f, 0x0628 },
{ 0xffac, 0x148c, 0x64d9, 0x06e4 }, { 0xffb6, 0x1338, 0x655e, 0x07ab }, { 0xffbf, 0x11f0, 0x65cd, 0x087d },
{ 0xffc8, 0x10b4, 0x6626, 0x095a }, { 0xffd0, 0x0f83, 0x6669, 0x0a44 }, { 0xffd8, 0x0e5f, 0x6696, 0x0b39 },
{ 0xffdf, 0x0d46, 0x66ad, 0x0c39 }
}

◆ [struct]

struct { ... } rspa

◆ vol

uint16_t vol[2]

◆ vol_wet

uint16_t vol_wet