PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
sound.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------------
2 
3  Sound functions.
4 
5  Copyright (C) 2012-2023
6  Alekmaul
7 
8  This software is provided 'as-is', without any express or implied
9  warranty. In no event will the authors be held liable for any
10  damages arising from the use of this software.
11 
12  Permission is granted to anyone to use this software for any
13  purpose, including commercial applications, and to alter it and
14  redistribute it freely, subject to the following restrictions:
15 
16  1. The origin of this software must not be misrepresented; you
17  must not claim that you wrote the original software. If you use
18  this software in a product, an acknowledgment in the product
19  documentation would be appreciated but is not required.
20  2. Altered source versions must be plainly marked as such, and
21  must not be misrepresented as being the original software.
22  3. This notice may not be removed or altered from any source
23  distribution.
24 
25 
26 ---------------------------------------------------------------------------------*/
27 
41 #ifndef SNES_SOUND_INCLUDE
42 #define SNES_SOUND_INCLUDE
43 
44 #include <snes/snestypes.h>
45 #include <snes/interrupt.h>
46 
50 typedef struct
51 {
52  u8 pitch;
53  u8 panning;
54  u8 volume;
55  u8 length1;
56  u8 length2;
57  u8 addr1;
58  u8 addr2;
59  u8 bank;
60 } brrsamples;
61 
73 #define REG_APU00 (*(vuint8 *)0x2140)
74 #define REG_APU01 (*(vuint8 *)0x2141)
75 #define REG_APU02 (*(vuint8 *)0x2142)
76 #define REG_APU03 (*(vuint8 *)0x2143)
77 #define REG_APU0001 (*(vuint16 *)0x2140)
78 #define REG_APU0203 (*(vuint16 *)0x2142)
79 
83 void spcBoot(void);
84 
89 void spcSetBank(u8 *bank);
90 
95 void spcLoad(u16 musIndex);
96 
101 void spcLoadEffect(u16 sfxIndex);
102 
114 void spcPlay(u8 startPos);
115 
119 void spcStop(void);
120 
125 void spcSetModuleVolume(u8 vol);
126 
132 void spcFadeModuleVolume(u16 vol, u16 fadespeed);
133 
137 void spcFlush(void);
138 
147 void spcProcess(void);
148 
155 void spcEffect(u16 pitch, u16 sfxIndex, u8 volpan);
156 
162 void spcSetSoundTable(u16 sndTableAddr, u8 sndTableBank);
163 
173 void spcSetSoundEntry(u8 vol, u8 panning, u8 pitch, u16 length, u8 *sampleaddr, brrsamples *ptr);
174 
184 void spcSetSoundDataEntry(u8 vol, u8 panning, u8 pitch, u16 length, u8 *sampleaddr, brrsamples *ptr);
185 
186 //---------------------------------------------------------------------------------
196 void spcSetSoundTableEntry(brrsamples *ptr);
197 
205 
212 void spcPlaySound(u8 sndIndex);
213 
221 void spcPlaySoundV(u8 sndIndex, u16 volume);
222 
223 #endif // SNES_SOUND_INCLUDE
snes interrupt support.
Custom types used by libsnes.
void spcAllocateSoundRegion(u8 size)
set the size of the sound region (this must be big enough to hold your longest/largest sound) this fu...
void spcLoad(u16 musIndex)
load module into sm-spc. this function may take some time to execute
void spcFlush(void)
Flush message queue (force sync)
void spcSetSoundEntry(u8 vol, u8 panning, u8 pitch, u16 length, u8 *sampleaddr, brrsamples *ptr)
set the values and address of the SOUND TABLE for a sound entry
void spcFadeModuleVolume(u16 vol, u16 fadespeed)
fade the module volume towards the target
void spcLoadEffect(u16 sfxIndex)
load sound effect into sm-spc. this function may take some time to execute
void spcPlaySoundV(u8 sndIndex, u16 volume)
Play sound from memory (using default arguments)
void spcSetSoundDataEntry(u8 vol, u8 panning, u8 pitch, u16 length, u8 *sampleaddr, brrsamples *ptr)
set the values of a sound entry
void spcPlaySound(u8 sndIndex)
Play sound from memory (using default arguments)
void spcEffect(u16 pitch, u16 sfxIndex, u8 volpan)
Play sound effect (load with spcLoadEffect)
void spcSetBank(u8 *bank)
set soundbank origin. soundbank must have dedicated bank(s)
void spcProcess(void)
Process messages This function will try to give messages to the spc until a few scanlines pass.
void spcSetSoundTable(u16 sndTableAddr, u8 sndTableBank)
set the address of the SOUND TABLE
void spcBoot(void)
boots the spc700 with sm-spc. call once at startup
void spcSetModuleVolume(u8 vol)
set the module playback volume
void spcPlay(u8 startPos)
play module. note: this simply queues a message, use spcFlush if you want to wait until the message i...
void spcStop(void)
stop playing the current module.
brr sample sound header(8 bytes)
Definition: sound.h:51
u8 pitch
Definition: sound.h:52
u8 volume
Definition: sound.h:54
u8 length2
Definition: sound.h:56
u8 addr2
Definition: sound.h:58
u8 addr1
Definition: sound.h:57
u8 length1
Definition: sound.h:55
u8 panning
Definition: sound.h:53
u8 bank
Definition: sound.h:59