Hello,
I am making a new game for my 3DS. I am currently working on the menu for it. I thought that it would be nice to have some background to the menu, but I have not been able to find good code showing how to play a song. I am currently using this code to play the file:
I have made a loop from a royalty-free song, and I exported it to raw format with signed 16-bit PCM with Audacity. When it plays, I get static. What is wrong here?
I am making a new game for my 3DS. I am currently working on the menu for it. I thought that it would be nice to have some background to the menu, but I have not been able to find good code showing how to play a song. I am currently using this code to play the file:
Code:
u8* sndbuffer;
if (fexists("data/background.raw")) { //fexists(std::string) will check if a file exists.
FILE *file = fopen("data/background.raw", "rb");
debugPrint("Song loaded."); //debugPrint(const char *) prints to the bottom screen.
fseek(file, 0, SEEK_END);
off_t sndsize = ftell(file);
sndbuffer = (u8*)linearAlloc(sndsize);
fseek(file, 0, SEEK_SET);
debugPrint("Reading file...");
off_t bytesRead = fread(sndbuffer, 1, sndsize, file);
fclose(file);
debugPrint("File read.");
csndPlaySound(0x8, CSND_LOOPMODE_NORMAL, 32000, 1.0, 0.0, sndbuffer, sndbuffer, (u32)sndsize);