[DEV] Background Music in .cia?

Discussion in '3DS - Homebrew Development and Emulators' started by ShinyMK, Jul 12, 2016.

  1. ShinyMK
    OP

    ShinyMK known as @PRAGMA

    Member
    6
    Dec 29, 2015
    Ireland
    127.0.0.1
    Is there any Devkit library with Looping Background Music support?
     
  2. Deck of Noobs
    This message by Deck of Noobs has been removed from public view by raulpica, Jul 12, 2016, Reason: Useless -rp.
    Jul 12, 2016
  3. ShinyMK
    This message by ShinyMK has been removed from public view by raulpica, Jul 12, 2016, Reason: Reply to trashed post -rp.
    Jul 12, 2016
  4. Deck of Noobs

    Deck of Noobs Politically Incorrect

    Member
    5
    Apr 9, 2016
    United States
    3ds.guide
    CONTEXT: There probably is, but I don't know where to find it.
     
  5. ShinyMK
    OP

    ShinyMK known as @PRAGMA

    Member
    6
    Dec 29, 2015
    Ireland
    127.0.0.1
    Yeah I couldnt either its why im asking here :/
     
  6. MarcusD

    MarcusD WOODMILLS!

    Member
    9
    Oct 16, 2015
    Austria
    Europe
    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
    Code:
    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
    Code:
    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 MarcusD, Jul 12, 2016 - Reason: fixed NDSP example
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice