1 /* Copyright (c) 2003-2021 James Daniels */
2 /* Distributed under the MIT License */
3 /* license terms: see LICENSE file in root or http://opensource.org/licenses/MIT */
5 /* Mixer-specific AAS include */
7 /* The functions and variables declared here should only be used if you need */
8 /* to directly access AAS_MixAudio(). This is not recommended and doing so */
9 /* will make it unsafe to use any other AAS functions except AAS_ShowLogo() */
10 /* and AAS_DoDMA3(). See the "Mixer" section of the documentation for more */
20 #define AAS_IN_IWRAM __attribute__ ((section (".iwram")))
21 #define AAS_IN_EWRAM __attribute__ ((section (".ewram")))
25 AAS_u8 effective_volume; /* 0 : effective_volume = (active&volume)?volume:0 */
26 AAS_BOOL active; /* 1 : 0 = Channel inactive, 1 = channel active */
27 AAS_u8 volume; /* 2 : Total vol of chan set must be <= 256, each vol usually in range 0-64 */
28 AAS_u8 pos_fraction; /* 3 : Fraction component of pos */
29 AAS_u16 frequency; /* 4 : Frequency (Hz) */
30 AAS_u16 delta; /* 6 : Delta */
31 const AAS_s8* pos; /* 8 : Current sample address, fraction component in pos_fraction */
32 const AAS_s8* end; /* 12 : Address of end of sample */
33 AAS_u32 loop_length; /* 16 : 0 = No repeat, Other value = Bytes from end back to restart point */
34 }; /* Length = 20 bytes */
36 extern struct AAS_Channel AAS_channels[16] AAS_IN_EWRAM;
37 extern AAS_u32 AAS_mix_buffer[640] AAS_IN_EWRAM;
39 #define AAS_INIT_BRANCH void (*ptr2Function)();
40 #define AAS_BRANCH(a,b...) ({ ptr2Function = a; ptr2Function(b); })
42 /* AAS_MixAudio() is in IWRAM, call from ROM as follows: (same for AAS_MixAudio_NoChange()) */
44 /* AAS_BRANCH( AAS_MixAudio, mix_buffer, chans, iterations ); */
46 void AAS_MixAudio( AAS_s8* mix_buffer, struct AAS_Channel chans[], int iterations );
47 void AAS_MixAudio_NoChange( AAS_s8* mix_buffer, struct AAS_Channel chans[], int iterations ); /* Only call if no changes to chans[] since previous call to AAS_MixAudio(). Do not call twice in a row. */
49 #define AAS_MIXAUDIO_MODE_NORMAL 0 /* Total vol must be <= 256, normal vol - default */
50 #define AAS_MIXAUDIO_MODE_BOOST 1 /* Total vol must be <= 128, double vol */
51 #define AAS_MIXAUDIO_MODE_BOOSTANDCLIP 2 /* Total vol must be <= 256, double vol */
53 void AAS_MixAudio_SetMode( int mode ); /* Set mixer mode, only call if 100% sure AAS_MixAudio won't interrupt */
55 /* Set maximum number of channels in set (lower=faster), only call if 100% sure AAS_MixAudio won't interrupt */
56 void AAS_MixAudio_SetMaxChans_2();
57 void AAS_MixAudio_SetMaxChans_4(); /* Default */
58 void AAS_MixAudio_SetMaxChans_8();