Nintendo 3DS >> C/C++ >> SDL v1.2

Load Music


參考資訊:
1. libctru doc
2. 3ds-examples

說明:

API
int Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize)
Mix_Music* Mix_LoadMUS(const char *file)
int Mix_PlayMusic(Mix_Music *music, int loops)
int Mix_HaltMusic(void)
void Mix_FreeMusic(Mix_Music *music)
void Mix_CloseAudio(void)

main.c

#include <stdio.h>
#include <stdlib.h>
#include <3ds.h>
#include <SDL.h>
#include <SDL_mixer.h>

int main(void)
{
    SDL_Init(SDL_INIT_AUDIO);
    Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096);

    Mix_Music *music = Mix_LoadMUS("sdmc:/3ds/main.wav");
    Mix_PlayMusic(music, 1);
    SDL_Delay(3000);

    Mix_HaltMusic();
    Mix_FreeMusic(music);
    Mix_CloseAudio();
    SDL_Quit();
    return 0;
}


返回上一頁