Playing Sounds March 29, 2009 07:04AM | Registered: 15 years ago Posts: 444 |
Re: Playing Sounds March 29, 2009 06:13PM | Registered: 16 years ago Posts: 265 |
Re: Playing Sounds March 29, 2009 07:06PM | Registered: 15 years ago Posts: 444 |
Re: Playing Sounds March 30, 2009 06:49AM | Registered: 15 years ago Posts: 703 |
void MP3Player_Init(); void MP3Player_Stop(); BOOL MP3Player_IsPlaying(); void MP3Player_Volume(u32 volume); s32 MP3Player_PlayBuffer(const void *buffer,s32 len,void (*filterfunc)(struct mad_stream *,struct mad_frame *)); s32 MP3Player_PlayFile(void *cb_data,s32 (*reader)(void *,void *,s32),void (*filterfunc)(struct mad_stream *,struct mad_frame *));
Re: Playing Sounds March 30, 2009 07:34AM | Registered: 15 years ago Posts: 83 |
Re: Playing Sounds March 30, 2009 07:48AM | Registered: 15 years ago Posts: 703 |
Re: Playing Sounds March 31, 2009 12:21AM | Registered: 15 years ago Posts: 444 |
Re: Playing Sounds March 31, 2009 01:13AM | Registered: 15 years ago Posts: 703 |
Re: Playing Sounds March 31, 2009 01:20AM | Registered: 15 years ago Posts: 83 |
I've seen many sources that include as binary, is this done with a raw2c type program, or by having the Makefile convert during build like you do with .jpg or .ogg? Just curious.Quote
scanff
The buffer is a pointer to your mp3 data. Which you could have loaded from a file or included as a binary header.
Re: Playing Sounds March 31, 2009 02:20AM | Registered: 15 years ago Posts: 703 |
#includeusing namespace std; int main() { FILE* in; in = fopen("yourfilename.whatever","rb"); FILE* out; out = fopen("data.h","wb"); unsigned char b = 0; fseek (in, 0, SEEK_END); unsigned long size = ftell(in); fseek (in, 0, SEEK_SET); // #define hdr ("static unsigned char bin_data[]={") #define data_size ("static unsigned long bin_data_size=") fwrite(hdr,strlen(hdr),1,out); char outchar[15] = {0}; for(int p=0;p<size;p++) { fread(&b,1,1,in); sprintf(outchar,"0x%0X",b); fwrite(outchar,strlen(outchar),1,out); if (p!=size-1) fwrite(",",1,1,out); if(!(p % 10)) fwrite("\n",1,1,out); // formatting } fwrite("\n};\n\n",5,1,out); fwrite(data_size,strlen(data_size),1,out); sprintf(outchar,"%d",size); fwrite(outchar,strlen(outchar),1,out); fwrite(";\n",2,1,out); fclose(in); fclose(out); return 0; }
Re: Playing Sounds March 31, 2009 02:34AM | Registered: 15 years ago Posts: 444 |
Re: Playing Sounds March 31, 2009 02:51AM | Registered: 16 years ago Posts: 175 |
Re: Playing Sounds March 31, 2009 03:28AM | Registered: 15 years ago Posts: 83 |
Nice, I'll try your program and see how it works out...thanks! Also, I haven't tried the bin2o command in the Makefile, but that was what I was originally referring to. I know it does images, and I've seen tutorials that used .OGG music files in Wii projects, that use the same bin2o command for .ogg files, so I would assume it would work for .mp3, but I could be wrong. I'll do some testing with it, and if it works, I'll post the info on it.Quote
scanff
I believe there's a make command bin2o that converts a binary file to be included in the output elf. I've only used the make command to include an image so I don't know if you can do it for any other binary files.
If you can't use a make file command then it's no big deal I have a C++ program I wrote in about 10mins that will convert a binary file into a hex array. It outputs the data as a hex array in a file called data.h. All you have to do is include data.h in your project and your buffer will be called bin_data,.Here it is if you want it.
Re: Playing Sounds March 31, 2009 03:33AM | Registered: 15 years ago Posts: 703 |
Re: Playing Sounds April 01, 2009 12:48AM | Registered: 15 years ago Posts: 444 |
Re: Playing Sounds April 01, 2009 01:39AM | Registered: 15 years ago Posts: 703 |
Re: Playing Sounds April 01, 2009 02:09AM | Registered: 15 years ago Posts: 444 |
Re: Playing Sounds April 01, 2009 02:57AM | Registered: 15 years ago Posts: 83 |
Re: Playing Sounds April 01, 2009 02:59AM | Registered: 15 years ago Posts: 4 |
Quote
#---------------------------------------------------------------------------------
%.mp3.o : %.mp3
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
-include $(DEPENDS)
Quote
#include "nameofthefile_mp3.h"
Quote
MP3Player_Init();
MP3Player_PlayBuffer(songname_mp3,songname_mp3_size,NULL);
Quote
DATA := data
Re: Playing Sounds April 01, 2009 03:37AM | Registered: 15 years ago Posts: 83 |
c:/projects/wii/game/source/game.cpp: In function 'void menu_loop()': c:/projects/wii/game/source/game.cpp:146: warning: statement is a reference, not call, to function 'MP3Player_Stop' c:/projects/wii/game/source/game.cpp:146: warning: statement has no effect GRRLIB.c pngu.c linking ... game.elf game.o: In function `menu_loop()': c:/projects/wii/game/source/game.cpp:136: undefined reference to `MP3Player_Init' c:/projects/wii/game/source/game.cpp:137: undefined reference to `MP3Player_PlayBuffer' collect2: ld returned 1 exit status(fixed)