MP3Player_PlayFile() - Parameter Definitions December 30, 2008 09:28PM | Admin Registered: 16 years ago Posts: 5,132 |
s32 MP3Player_PlayFile(void *cb_data,s32 (*reader)(void *,void *,s32),void (*filterfunc)(struct mad_stream *,struct mad_frame *));
Re: MP3Player_PlayFile() - Parameter Definitions December 30, 2008 09:49PM | Registered: 15 years ago Posts: 13 |
s32 MP3Player_PlayFile(void *cb_data,s32 (*reader)(void *,void *,s32),void (*filterfunc)(struct mad_stream *,struct mad_frame *)); that is 3 parameters, no?the first one is the mp3 data
Re: MP3Player_PlayFile() - Parameter Definitions December 30, 2008 10:27PM | Admin Registered: 16 years ago Posts: 5,132 |
Re: MP3Player_PlayFile() - Parameter Definitions January 01, 2009 12:20AM | Registered: 16 years ago Posts: 98 |
/* ASNDLIB Example2: Sound effects and play a MP3 file NOTE: libmad is released under GPL v2. if you release one executable, remember you to change the license to the GPL. Without libmad, you can use it as you want. If you prefer a MP3 lib under LGPL, looks my application 'Wiireader' to obtain a MP3/OGG player under LGP V2.1 terms If you prefer only a Oggplayer without GPL or LGPL license, looks the old sndlib and change the includes "snd.h" by "asnd.h" Copyright (c) 2008 HermesAll rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include "unistd.h" #include "asnd.h" // MOD Player #include "mp3player.h" // audio resources #include "audio_raw.h" // sound effects in RAW PCM 8 bits (signed) #include "audio2_raw.h" #include "organ8_smp.h" GXRModeObj *rmode; // Graphics Mode Object u32 *xfb = NULL; // Framebuffer int return_reset=2; int exit_by_reset=0; void reset_call() {exit_by_reset=return_reset;} void power_call() {exit_by_reset=3;} void fun_exit() { ASND_End(); fatUnmount(PI_INTERNAL_SD); VIDEO_WaitVSync(); VIDEO_WaitVSync(); if(exit_by_reset==2) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); if(exit_by_reset==3) SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0); } s32 my_reader(void *fp,void *dat, s32 size) { return fread(dat, 1, size, fp); } int main(int argc, char **argv) { FILE *fp; int counter; int voice1; return_reset=1; if(argc<1) return_reset=2; VIDEO_Init(); //Inicialización del Vídeo. rmode = VIDEO_GetPreferredMode(NULL); //mediante esta función rmode recibe el valor de tu modo de vídeo. xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); //inicialización del buffer. console_init(xfb,20,20,rmode->fbWidth,rmode-> //inicialización de la consola. xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ); VIDEO_Configure(rmode); //configuración del vídeo. VIDEO_SetNextFramebuffer(xfb); //Configura donde guardar el siguiente buffer . VIDEO_SetBlack(FALSE); //Hace visible el display . VIDEO_Flush(); VIDEO_WaitVSync(); if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync(); SYS_SetResetCallback(reset_call); SYS_SetPowerCallback(power_call); ASND_Init(); // Initialize the Accelerated Sound Lib (ASND) fatInit(8, false); fatSetDefaultInterface(PI_INTERNAL_SD); atexit(fun_exit); printf("\33[2J\n\n\n \33[42m Example2 of the ASNDLIB \33[40m \n\n"); printf("Press RESET to exit\n\n"); ASND_Pause(0); // Global pause=0 to start (note initially it is paused!!) // loading a mod file from the SD fp=fopen("fat:/test.mp3","r"); if(fp==NULL) { printf("can't open fat:/test.mp3\n\n"); voice1=SND_GetFirstUnusedVoice(); // sound for fail open ASND_SetVoice(voice1, VOICE_MONO_8BIT, 8000, 20, audio2_raw, size_audio2_raw, 255, 255, NULL); while(ASND_StatusVoice(voice1)==SND_WORKING) { if(exit_by_reset) break; VIDEO_WaitVSync(); } } printf("Test an Infinite Voice\n"); voice1=SND_GetFirstUnusedVoice(); ASND_SetInfiniteVoice(voice1, VOICE_MONO_8BIT, 8000, 0, organ8_smp, size_organ8_smp, 255, 255); // Infinite voices only can stop using ASND_PauseVoice() or ASND_StopVoice() // Normal voices stops with NULL callback, other case it wait to a ASND_AddVoice() to continue // remember you to use aligned voices and padded to 32 bytes to avoid strange cache problems!!! counter=0; while(1) { // pitch control 'alarm' if(counter>=120 && counter<300) { if(counter==120) printf(" Pitch control test...\n"); if((counter % 60)<60) { ASND_ChangePitchVoice(voice1, 16000+(counter % 30)*800); } } // pitch control and left to right if(counter>=300 && counter<480) { int left,right; if(counter==300) printf(" Volume control test...\n"); left=390-counter;if(left<0) left=0; right=counter-390;if(right<0) right=0; ASND_ChangePitchVoice(voice1, 8000+(480-counter)*400); ASND_ChangeVolumeVoice(voice1, 255*left/90, 255*right/90); } // pitch control and right to left if(counter>=480 && counter<660) { int left,right; right=570-counter;if(right<0) right=0; left=counter-570;if(left<0) left=0; ASND_ChangePitchVoice(voice1, 8000+(counter-480)*200); ASND_ChangeVolumeVoice(voice1, 255*left/90, 255*right/90); } // infinite voice paused if(counter==780) { printf(" Pause the Voice...\n"); ASND_PauseVoice(voice1,1); } // programa infinite multiples voices if(counter>=870 && counter<990) { if(counter==870)printf(" Arggghhhh!\n"); ASND_ChangeVolumeVoice(voice1, 255, 255); ASND_PauseVoice(voice1,0); if((counter % 10)==0) ASND_SetInfiniteVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000+100*(counter-870), 0, organ8_smp, size_organ8_smp, 255, 255); } if(counter>=990) { int n; // stops the crazy sounds if(counter==990) { for(n=0;n<16;n++) ASND_StopVoice(n); } // Multiple Delayed voices example if(counter==1020) { printf("\nMultiple Delayed Voices (16 voices)\n"); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 0, audio2_raw, size_audio2_raw, 255, 255, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 1000, audio2_raw, size_audio2_raw, 255, 0, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 1200, audio2_raw, size_audio2_raw, 0, 255, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 1800, audio2_raw, size_audio2_raw, 255, 0, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 2800, audio2_raw, size_audio2_raw, 25, 255, NULL); // BANG BANG ! ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 3800, audio_raw, size_audio_raw, 255, 255, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 3820, audio_raw, size_audio_raw, 255, 255, NULL); // reverb ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 4300, audio_raw, size_audio_raw, 255, 255, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 4320, audio_raw, size_audio_raw, 255, 255, NULL); // reverb ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 4420, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 4520, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 4620, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 4720, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 4820, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 5300, audio_raw, size_audio_raw, 64, 255, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 5600, audio_raw, size_audio_raw, 64, 255, NULL); } // wait to the multiple delayed voices to exit if(counter>1020) { int n; for(n=0;n<16;n++) if(ASND_StatusVoice(n)==SND_WORKING) break; if(n==16) break; } } if(exit_by_reset) break; VIDEO_WaitVSync(); counter++; } printf("\nExit\n"); if(fp) { MP3Player_Init(); MP3Player_Volume(127); // Medium volume (you can change also using SND_ChangeVolumeVoice(0, vol_l,vol_r) ) MP3Player_PlayFile(fp, my_reader, NULL); ASND_Pause(0); // Global pause=0 to start counter=0; printf("\33[2J\n\n\n \33[42m Example2 of the ASNDLIB\33[40m \n\n"); printf("Press RESET to exit\n\n"); printf("Playing the MP3 file (voice 0) and some effects\n\n"); while(1) { unsigned time; time=ASND_GetTimerVoice(0)/1000; printf("\33[9;0HVoice 0 time: %2.2u:%2.2u ", time/60, time % 60); if(MP3Player_IsPlaying()) { // bang bang if((counter % 600)==150) { ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 0, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 100, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 200, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 300, audio_raw, size_audio_raw, 255, 64, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 400, audio_raw, size_audio_raw, 255, 64, NULL); } // ^^ if((counter % 600)==450) { ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 0, audio2_raw, size_audio2_raw, 255, 255, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 1000, audio2_raw, size_audio2_raw, 255, 0, NULL); ASND_SetVoice(SND_GetFirstUnusedVoice(), VOICE_MONO_8BIT, 8000, 1200, audio2_raw, size_audio2_raw, 0, 255, NULL); } } counter++; if(exit_by_reset) break; VIDEO_WaitVSync(); } MP3Player_Stop(); fclose(fp); } else { while(1) { if(exit_by_reset) break; VIDEO_WaitVSync(); } } exit(0); }
Re: MP3Player_PlayFile() - Parameter Definitions January 02, 2009 12:58AM | Admin Registered: 16 years ago Posts: 5,132 |
Re: MP3Player_PlayFile() - Parameter Definitions January 03, 2009 12:00AM | Admin Registered: 16 years ago Posts: 5,132 |
s32 my_reader(void *fp,void *dat, s32 size){ return fread(dat, 1, size, fp); }
MP3Player_PlayFile(filepointer, my_reader, NULL);
filepointer=fopen("fat:/apps/Wiibreaker/data/sound1.mp3","r");
s32 my_reader(void *fp,void *dat, s32 size){ return fread(dat, 1, size, filepointer2); }
Re: MP3Player_PlayFile() - Parameter Definitions January 03, 2009 12:07AM | Registered: 16 years ago Posts: 77 |
Re: MP3Player_PlayFile() - Parameter Definitions January 03, 2009 12:11AM | Admin Registered: 16 years ago Posts: 5,132 |
Re: MP3Player_PlayFile() - Parameter Definitions January 06, 2009 05:33PM | Registered: 15 years ago Posts: 6 |
#include#include #include #include #include #include #include #include #include #include #include s32 my_reader(void *fp,void *dat, s32 size){ return fread(dat, 1, size, (FILE *) fp); } int main() { fatInitDefault(); // i/o MP3Player_Init(); //some stuff if (pressed & WPAD_BUTTON_A) { FILE *fp_actual=fopen("sd:/APPS/LASTFM/DATA/PROMISES.MP3","r"); MP3Player_PlayFile(fp_actual, my_reader, NULL); } }