e92d5490894645d92955279c66d8dfe7671fa7e2
[gbajam21] / libs / aas / AAS.h
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 */
4
5 /* Main AAS include */
6 /* */
7 /* See API documentation for more information. */
8
9 #ifndef __AAS__
10 #define __AAS__
11
12 #ifdef __cplusplus
13 #define AAS_BEGIN_DECLS extern "C" {
14 #define AAS_END_DECLS }
15 #else
16 #define AAS_BEGIN_DECLS
17 #define AAS_END_DECLS
18 #endif
19
20 AAS_BEGIN_DECLS
21
22 #define AAS_VERSION 0x111  /* v1.11 */
23
24 /* Types */
25 #define AAS_u32 unsigned int
26 #define AAS_s32 signed int
27 #define AAS_u16 unsigned short
28 #define AAS_s16 signed short
29 #define AAS_u8 unsigned char
30 #define AAS_s8 signed char
31 #define AAS_BOOL unsigned char
32 #define AAS_TRUE 1
33 #define AAS_FALSE 0
34 #define AAS_NULL 0
35
36 /* Return values */
37 #define AAS_OK                             0
38 #define AAS_ERROR_VOLUME_OUT_OF_RANGE     -1
39 #define AAS_ERROR_CHANNEL_NOT_AVAILABLE   -2
40 #define AAS_ERROR_FREQUENCY_OUT_OF_RANGE  -3
41 #define AAS_ERROR_MOD_DOES_NOT_EXIST      -4
42 #define AAS_ERROR_CALL_SET_CONFIG_FIRST   -5
43 #define AAS_ERROR_INVALID_CONFIG          -6
44 #define AAS_ERROR_INVALID_SAMPLE_ADDRESS  -7
45 #define AAS_ERROR_NO_MOD_PLAYING          -8
46 #define AAS_ERROR_NOT_ENOUGH_CHANNELS     -9
47 #define AAS_ERROR_CHANNEL_ACTIVE          -10
48 #define AAS_ERROR_CHANNEL_UNRESUMEABLE    -11
49 #define AAS_ERROR_INVALID_SONG_POS        -12
50
51 /* AAS_SetConfig() mix settings */
52 #define AAS_CONFIG_MIX_32KHZ       1
53 #define AAS_CONFIG_MIX_28KHZ       2
54 #define AAS_CONFIG_MIX_24KHZ       3
55 #define AAS_CONFIG_MIX_20KHZ       4
56 #define AAS_CONFIG_MIX_16KHZ       5
57 #define AAS_CONFIG_MIX_12KHZ       6
58 #define AAS_CONFIG_MIX_8KHZ        7
59
60 /* AAS_SetConfig() channel settings */
61 #define AAS_CONFIG_CHANS_16_LOUD   6
62 #define AAS_CONFIG_CHANS_8_LOUD    5
63 #define AAS_CONFIG_CHANS_4_LOUD    4
64 #define AAS_CONFIG_CHANS_16        3
65 #define AAS_CONFIG_CHANS_8         2
66 #define AAS_CONFIG_CHANS_4         1
67
68 /* AAS_SetConfig() spatial settings */
69 #define AAS_CONFIG_SPATIAL_STEREO  2
70 #define AAS_CONFIG_SPATIAL_MONO    1
71
72 /* AAS_SetConfig() dynamic mixing settings */
73 #define AAS_CONFIG_DYNAMIC_OFF     0
74 #define AAS_CONFIG_DYNAMIC_ON      1
75
76 /* General commands */
77 int AAS_SetConfig( int config_mix, int config_chans, int config_spatial, int config_dynamic );  /* Must call at least once before doing anything else */
78 void AAS_DoDMA3( void* source, void* dest, AAS_u32 flags_and_length );
79 void AAS_ShowLogo();
80
81 /* Interrupt handling commands */
82 void AAS_Timer1InterruptHandler(); /* Use when there are no other CPU-intensive interrupts */
83 void AAS_FastTimer1InterruptHandler(); /* Use when there are other CPU-intensive interrupts */
84 void AAS_DoWork(); /* Must be called at least 50 times/sec if using AAS_FastTimer1InterruptHandler() */
85
86 /* Sample playing commands */
87 int AAS_SFX_Play( int channel, int sample_volume, int sample_frequency, const AAS_s8* sample_start, const AAS_s8* sample_end, const AAS_s8* sample_restart );
88 AAS_BOOL AAS_SFX_ChannelExists( int channel ); /* returns AAS_TRUE only if AAS_SFX_Play will succeed for this channel */
89 AAS_BOOL AAS_SFX_IsActive( int channel ); /* returns AAS_TRUE if channel is valid and active, AAS_FALSE otherwise */
90 int AAS_SFX_EndLoop( int channel ); /* If sample was looping, will stop at end of current iteration */
91 int AAS_SFX_SetFrequency( int channel, int sample_frequency );
92 int AAS_SFX_SetVolume( int channel, int sample_volume );
93 int AAS_SFX_Stop( int channel );
94 int AAS_SFX_Resume( int channel );
95 int AAS_SFX_GetNumChannels(); /* returns number of SFX channels */
96
97 /* MOD commands */
98 int AAS_MOD_Play( int song_num ); /* loops by default */
99 int AAS_MOD_SetLoop( AAS_BOOL loop ); /* specify whether current song will loop */
100 void AAS_MOD_Stop();
101 AAS_BOOL AAS_MOD_IsPlaying(); /* is a song playing? */
102 AAS_BOOL AAS_MOD_HasLooped(); /* has the current song looped? */
103 int AAS_MOD_GetVolume(); /* 0: silent, 256 = max */
104 int AAS_MOD_SetVolume( int vol ); /* 0: silent, 256 = max (do not set above 256 or below 0!) */
105 int AAS_MOD_GetSongPos();
106 int AAS_MOD_SetSongPos( int song_pos ); /* Immediately jumps to the specified song position. */
107 int AAS_MOD_QueueSongPos( int song_pos ); /* Jumps to the specified song position when the current pattern finishes. */
108 int AAS_MOD_GetLineNum();
109 int AAS_MOD_GetLastFilterValue(); /* Returns the value specified by the most recent "E0: Set Filter" effect */
110 void AAS_MOD_Pause(); /* Stops the MOD in a way that allows it to be safely resumed */
111 void AAS_MOD_Resume(); /* Should only be used after AAS_MOD_Pause() */
112 int AAS_MOD_GetNumChannels(); /* Returns number of channels currently being reserved by the MOD */
113
114 /* Misc commands */
115 const AAS_s8* AAS_GetOutputBufferAddress( int buffer ); /* buffer should be 0 or 1, otherwise will return AAS_NULL */
116 int AAS_GetOutputBufferLength();
117 int AAS_GetActualMixRate();
118
119 AAS_END_DECLS
120
121 #endif