Homebrew [DEV] Background Music in .cia?

Sono

cripple piss
Developer
Joined
Oct 16, 2015
Messages
2,821
Trophies
2
Location
home
XP
9,321
Country
Hungary
Well, a very cheapo and space-consuming method would be this:

  • Run `ffmpeg -i background_music.wav -f s16le -acodec pcm_s16le -ar 32728 -ac 1 bgm.bin`
  • Place bgm.bin into your project's "data" folder
  • Compile your project once
  • #include "bgm_bin.h"
And depending on what soundsystem you want to use, you can edit the below codes to fit in your code:
CSND
C:
csndInit();
csndPlaySound(0x8, SOUND_REPEAT | SOUND_FORMAT_16BIT, 32728, 1.0F, 0.0F, bgm_bin, NULL, bgm_bin_size);

while(aptMainLoop())
{
    // your program is in here
}

csndExit();

NDSP
C:
ndspWaveBuf bgmusic;
memset(&bgmusic, 0, sizeof(bgmusic));
bgmusic.data_vaddr = bgm_bin;
bgmusic.nsamples = bgm_bin_size / 2;
bgmusic.looping = 1;

if(ndspInit() >= 0)
{
    ndspSetOutputMode(NDSP_OUTPUT_STEREO);
    ndspSetOutputCount(2);
    ndspChnReset(2);
    ndspChnSetInterp(2, NDSP_INTERP_LINEAR);
    ndspChnSetRate(2, 32728.0F);
    ndspChnSetFormat(2, NDSP_FORMAT_MONO_PCM16);
    ndspChnWaveBufAdd(2, &bgmusic);
}

while(aptMainLoop())
{
    // your program is in here
}

ndspChnReset(2);
ndspExit();
 
Last edited by Sono, , Reason: fixed NDSP example

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Well start walking towards them +1