|
PVSnesLib
4.4.0
Documentation to code in C or ASM for the Nintendo SNES
|
snes sound support. More...
Go to the source code of this file.
Data Structures | |
| struct | brrsamples |
| brr sample sound header(8 bytes) More... | |
Macros | |
| #define | REG_APU00 (*(vuint8 *)0x2140) |
| Main CPU to Sound CPU Communication Port 0 (R/W) 7-0 APU I/O Data (Write: Data to APU, Read: Data from APU) Caution: These registers should be written only in 8bit mode (there is a hardware glitch that can cause a 16bit write to [2140h..2141h] to destroy [2143h], this might happen only in some situations, like when the cartridge contains too many ROM chips which apply too much load on the bus). | |
Functions | |
| void | spcAllocateSoundRegion (u8 size) |
| Set the size of the sound region. | |
| void | spcBoot (void) |
| boots the spc700 with sm-spc. call once at startup disable time consuing interrupts during this function | |
| void | spcEffect (u16 pitch, u16 sfxIndex, u8 volpan) |
| Play sound effect (load with spcLoadEffect) | |
| void | spcFadeModuleVolume (u16 vol, u16 fadespeed) |
| fade the module volume towards the target | |
| void | spcFlush (void) |
| Flush message queue (force sync) | |
| void | spcLoad (u16 musIndex) |
| load module into sm-spc. this function may take some time to execute | |
| void | spcLoadEffect (u16 sfxIndex) |
| load sound effect into sm-spc. this function may take some time to execute | |
| void | spcPauseMusic (void) |
| pause playing the current module and save the music position. | |
| void | spcPlay (u8 startPos) |
| play module. note: this simply queues a message, use spcFlush if you want to wait until the message is processed | |
| void | spcPlaySound (u8 sndIndex) |
| Play sound from memory (using default arguments) | |
| void | spcPlaySoundV (u8 sndIndex, u16 volume) |
| Play sound from memory (using default arguments) | |
| void | spcProcess (void) |
| Process messages This function will try to give messages to the spc until a few scanlines pass. | |
| void | spcResumeMusic (void) |
| Resume playing of current module at music position. | |
| void | spcSetBank (u8 *bank) |
| set soundbank origin. soundbank must have dedicated bank(s) | |
| void | spcSetModuleVolume (u8 vol) |
| set the module playback volume | |
| void | spcSetSoundDataEntry (u8 vol, u8 panning, u8 pitch, u16 length, u8 *sampleaddr, brrsamples *ptr) |
| set the values of a sound entry | |
| 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 | spcSetSoundTable (u16 sndTableAddr, u8 sndTableBank) |
| set the address of the SOUND TABLE | |
| void | spcStop (void) |
| stop playing the current module. | |
snes sound support.
Really great thanks to shiru for sound engine and tools used in his Christmas Craze homebrew http://shiru.untergrund.net/
Also great thanks for mukunda for snesmod sound engine http://snes.mukunda.com/
And special thanks to Kung Fu Furby for help debugging snesmod port with C interface
| #define REG_APU00 (*(vuint8 *)0x2140) |
Main CPU to Sound CPU Communication Port 0 (R/W) 7-0 APU I/O Data (Write: Data to APU, Read: Data from APU) Caution: These registers should be written only in 8bit mode (there is a hardware glitch that can cause a 16bit write to [2140h..2141h] to destroy [2143h], this might happen only in some situations, like when the cartridge contains too many ROM chips which apply too much load on the bus).
Same thing for REG_APU01, REG_APU02 and REG_APU03 for addr 2141h..2143h REG_APU0001 and REG_APU0203 for 16 bits read/write access
| spcAllocateSoundRegion | ( | u8 | size | ) |
Set the size of the sound region.
Use it only if you are playing effects with BRR files. If not, just allocate the value 0 by calling spcAllocateSoundRegion(0);
The value must be big enough to hold your longest/largest sound. This function will STOP module playback too.
| size | size of sound region (size*256 bytes) |
| spcEffect | ( | u16 | pitch, |
| u16 | sfxIndex, | ||
| u8 | volpan | ||
| ) |
Play sound effect (load with spcLoadEffect)
| pitch | pitch (0-15, 1=4Khz , 2=8khz, 4=16Khz, 8=32Khz) |
| sfxIndex | effect index (0-15) |
| volpan | volume(0..15) AND panning(0..15) (volume*16+pan) |
| spcFadeModuleVolume | ( | u16 | vol, |
| u16 | fadespeed | ||
| ) |
fade the module volume towards the target
| vol | volume (0..255) |
| fadespeed | fade speed (volume(0..255) += y every 32ms) |
| spcLoad | ( | u16 | musIndex | ) |
load module into sm-spc. this function may take some time to execute
| musIndex | module_id |
| spcLoadEffect | ( | u16 | sfxIndex | ) |
load sound effect into sm-spc. this function may take some time to execute
| sfxIndex | sfx_id |
| spcPlay | ( | u8 | startPos | ) |
play module. note: this simply queues a message, use spcFlush if you want to wait until the message is processed
another note: there may be a significant startup time from after the message is processed to when the song starts playing... to sync the program with the song start use spcFlush and then wait until SPC_P of the status register is set.
| startPos | starting position |
| spcPlaySound | ( | u8 | sndIndex | ) |
Play sound from memory (using default arguments)
| sndIndex | index in sound table. Be careful: the index 0 corresponds to the LAST sound loaded. The index 1 is the penultimate sound loaded and so on... |
| spcPlaySoundV | ( | u8 | sndIndex, |
| u16 | volume | ||
| ) |
Play sound from memory (using default arguments)
| sndIndex | index in sound table. Be careful: the index 0 corresponds to the LAST sound loaded. The index 1 is the penultimate sound loaded and so on... |
| volume | volume (0..15) |
| spcProcess | ( | void | ) |
Process messages This function will try to give messages to the spc until a few scanlines pass.
this function MUST be called every frame if you are using streamed sounds
| spcResumeMusic | ( | void | ) |
Resume playing of current module at music position.
spcPauseMusic has to be call before to restore correct position.
| spcSetBank | ( | u8 * | bank | ) |
set soundbank origin. soundbank must have dedicated bank(s)
| bank | bank address |
| spcSetModuleVolume | ( | u8 | vol | ) |
| spcSetSoundDataEntry | ( | u8 | vol, |
| u8 | panning, | ||
| u8 | pitch, | ||
| u16 | length, | ||
| u8 * | sampleaddr, | ||
| brrsamples * | ptr | ||
| ) |
set the values of a sound entry
set the address of the SOUND TABLE for a sound entry
| vol | volume (0..15) |
| panning | panning (0..15) |
| pitch | PITCH (1..6) (hz = PITCH * 2000) |
| length | length of brr sample |
| sampleaddr | address of brr sample |
| ptr | address of variable where sounds values will be stored |
| 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
| vol | volume (0..15) |
| panning | panning (0..15) |
| pitch | PITCH (1..6) (hz = PITCH * 2000) |
| length | length of brr sample |
| sampleaddr | address of brr sample |
| ptr | address of variable where sounds values will be stored |
| spcSetSoundTable | ( | u16 | sndTableAddr, |
| u8 | sndTableBank | ||
| ) |
set the address of the SOUND TABLE
| sndTableAddr | address of sound table |
| sndTableBank | bank of sound table |