|
|
Line 6: |
Line 6: |
| oiw4yE <a href="http://fjkcryucvbvi.com/">fjkcryucvbvi</a>, [url=http://trhbrchizxab.com/]trhbrchizxab[/url], [link=http://hkhgtokyzdpl.com/]hkhgtokyzdpl[/link], http://wamylnktrumd.com/ | | oiw4yE <a href="http://fjkcryucvbvi.com/">fjkcryucvbvi</a>, [url=http://trhbrchizxab.com/]trhbrchizxab[/url], [link=http://hkhgtokyzdpl.com/]hkhgtokyzdpl[/link], http://wamylnktrumd.com/ |
| | | |
− | ==ARM9 Functions==
| + | naxuMl <a href="http://nriellaiefev.com/">nriellaiefev</a>, [url=http://gljndqlmpvqo.com/]gljndqlmpvqo[/url], [link=http://apeuhpzoofxj.com/]apeuhpzoofxj[/link], http://tmxwhhtaueqm.com/ |
− | ===Mp3 Playback===
| + | |
− | '''mp3Init'''<br>
| + | |
− | Initalize mp3 player (on the ARM9 side). Will wait for arm7 to indicate its ready before continuing. Should be called once and only once at start of program.
| + | |
− | <source lang="c">
| + | |
− | void mp3Init(void);
| + | |
− | </source>
| + | |
− | '''mp3Play'''<br>
| + | |
− | Start playing the mp3 specified by the filesystem path. <br>
| + | |
− | (FAT and/or [[Nitrofs]] should be initialized prior to calling this or any other mp3/playlist functions!)
| + | |
− | * filename - pointer to string containing path to and the mp3 filename
| + | |
− | <source lang="c">
| + | |
− | bool mp3Play(char *filename);
| + | |
− | </source>
| + | |
− | '''mp3Update'''<br>
| + | |
− | This function should be placed in the game's idle loop. It is used to refill the input buffer from the stream as needed. The mp3 will not start, change, or much of anything untill this is called.
| + | |
− | | + | |
− | This along with mp3Init, and mp3Play represent the minimal requirements for playing an mp3. ^^
| + | |
− | <source lang="c">
| + | |
− | void mp3Update(void);
| + | |
− | </source>
| + | |
− | '''mp3Stop'''<br>
| + | |
− | Stops a playing an mp3
| + | |
− | <source lang="c">
| + | |
− | void mp3Stop(void);
| + | |
− | </source> | + | |
− | '''mp3Queue'''<br>
| + | |
− | Sets the next song to play when this one eof's.
| + | |
− | * filename - pointer to string containing path to and the mp3 filename
| + | |
− | <source lang="c">
| + | |
− | void mp3Queue(const char *filename);
| + | |
− | </source>
| + | |
− | '''mp3GetSongPos'''<br>
| + | |
− | Get the song's current playback position in minutes, seconds, and milliseconds. <br>
| + | |
− | All input variables should be of type int !!!
| + | |
− | * mins - pointer to mins variable
| + | |
− | * secs - pointer to seconds variable
| + | |
− | * ms - pointer to milliseconds variable
| + | |
− | Returns the elapsed time in ms*100.
| + | |
− | <source lang="c">
| + | |
− | int mp3GetSongPos(int *mins, int *secs, int *ms);
| + | |
− | </source>
| + | |
− | '''mp3SetPlayCb'''<br>
| + | |
− | Sets a callback thats called whenever the song changes (for displaying title)
| + | |
− | should be in the format of: void myMp3PlayCallback(char *filename, char *title). See example below..
| + | |
− | * func - address of a function to call each time song changes. Set as NULL to disable (default).
| + | |
− | <source lang="c">
| + | |
− | void mp3SetPlayCb(void *func)
| + | |
− | </source>
| + | |
− | | + | |
− | ===Mp3 Playback Macros===
| + | |
− | '''mp3SetOpts(o)'''<br>
| + | |
− | Sets various optons for mp3 playback, such as:
| + | |
− | * MP3_ADVANCE - advance to next song on playlist after this one finishes
| + | |
− | * MP3_REPEAT - return to beginning of playlist after last song
| + | |
− | * MP3_LOOP - loop currently playing song over and over and over and over till ya cant stand it no moar!! ;;
| + | |
− | <source lang="c">
| + | |
− | #define mp3SetOpts(o) (mp3Ipc->flags|=(o)) //set options
| + | |
− | </source>
| + | |
− | '''mp3ClearOpts'''<br>
| + | |
− | Same as above but instead will clear the given options
| + | |
− | <source lang="c">
| + | |
− | #define mp3ClearOpts(o) (mp3Ipc->flags=(mp3Ipc->flags&~(o)))
| + | |
− | </source>
| + | |
− | '''mp3PlaylistAdv'''
| + | |
− | Advance to the next song on the playlist.
| + | |
− | <source lang="c">
| + | |
− | #define mp3PlaylistAdv() (mp3PlaylistPlay(mp3Pl.nowplaying+1))
| + | |
− | </source>
| + | |
− | | + | |
− | | + | |
− | <source lang="c">
| + | |
− | //macros to get or set various things
| + | |
− | //set options
| + | |
− | #define mp3SetOpts(o) (mp3Ipc->flags|=(o))
| + | |
− | //same as above but clears instead
| + | |
− | #define mp3ClearOpts(o) (mp3Ipc->flags=(mp3Ipc->flags&~(o)))
| + | |
− | //move to next song on playlist
| + | |
− | #define mp3PlaylistAdv() (mp3PlaylistPlay(mp3Pl.nowplaying+1))
| + | |
− | //song position in samples
| + | |
− | #define mp3GetSongPosSamples() (mp3Ipc->mfram)
| + | |
− | //song position in milliseconds
| + | |
− | #define mp3GetSongPosms() ((mp3Ipc->mfram*100)/mp3Ipc->framenfo.samprate)
| + | |
− | //mp3 bitrate such as 96000 128000 192000,
| + | |
− | #define mp3GetBitrate() (mp3Ipc->framenfo.bitrate)
| + | |
− | //number of channels (1 = mono, 2 = stereo)
| + | |
− | #define mp3GetChans() (mp3Ipc->framenfo.nChans)
| + | |
− | //Sample rate. like: 44100,32000,19200 etc
| + | |
− | #define mp3GetRate() (mp3Ipc->framenfo.samprate)
| + | |
− | //bits per sample either 8, 16, 24 (we only support 16!!!!) | + | |
− | #define mp3GetBits() (mp3Ipc->framenfo.bitsPerSample)
| + | |
− | //mp3 layer | + | |
− | #define mp3GetLayer() (mp3Ipc->framenfo.layer)
| + | |
− | //mp3 layer version
| + | |
− | #define mp3GetVersion() (mp3Ipc->framenfo.version)
| + | |
− | //last error
| + | |
− | #define mp3GetError() (mp3Ipc->error)
| + | |
− | //How much data (in bytes) is in the pcm buffer
| + | |
− | #define mp3GetPCMUsed() (mp3Ipc->pcmbleft)
| + | |
− | //same as above but reports in percent instead ^^
| + | |
− | #define mp3GetPCMUsedPct() ((int)((mp3GetPCMUsed()*100)/PCMBUF_SAMPLES))
| + | |
− | //how much data (bytes) is in the stream buffer
| + | |
− | #define mp3GetDataUsed() (mp3Ipc->dleft)
| + | |
− | //same as above but reports in percent instead ^^
| + | |
− | #define mp3GetDataUsedPct() ((int)((mp3Ipc->dleft*100)/DECODEBUF_SIZE))
| + | |
− | //position of playback pointer within pcm buffer
| + | |
− | #define mp3GetPBPos() (mp3Ipc->pcmbpos) //useless except for debugging and even then should be removed mebbe? @_@
| + | |
− | //Number of frames decoded
| + | |
− | #define mp3GetDecoded() (mp3Ipc->fdec)
| + | |
− | //re/set the above variable
| + | |
− | #define mp3SetDecoded(d) (mp3Ipc->fdec=(d))
| + | |
− | //this value is incremented each idle loop of the arm7. should increment +60 each second.
| + | |
− | //starts moving slower as arm7 becomes saturated. used mostly for debugging
| + | |
− | #define mp3GetVBlnks() (mp3Ipc->vfram) //Number of
| + | |
− | //re/set the above variable
| + | |
− | #define mp3SetVBlnks(d) (mp3Ipc->vfram=(d)) //zero or whatever them
| + | |
− | #define mp3GetState() (mp3Ipc->state) //arm7's current operational state
| + | |
− | #define mp3GetCommand() (mp3Ipc->command) //for debug rly, reads contents of command buffer (fifo will prolly eliminate this)
| + | |
− | //fade out nicely in x amount of seconds (see thSound for exact seconds format!_!)
| + | |
− | #define mp3FadeOut(s) (thSndFade(HWSCHANNEL0, (s)),thSndFade(HWSCHANNEL1, (s)))
| + | |
− | </source>
| + | |
− | | + | |
− | ===Playlist===
| + | |
− | All functions here are for the arm9.
| + | |
− | | + | |
− | '''mp3ReadId3V1'''<br>
| + | |
− | Read IDv3 tag from mp3.
| + | |
− | * filename - pointer to string containing path to and the mp3 filename
| + | |
− | * id3 - pointer to structure of type ID3V1_T (see below)
| + | |
− | <source lang="c">
| + | |
− | bool mp3ReadId3V1(char *filename, ID3V1_T *id3);
| + | |
− | </source>
| + | |
− | | + | |
− | '''mp3GetId3FromFile'''<br>
| + | |
− | Same as above but uses an already open filehandle instead.
| + | |
− | * f - already opened filehandle (should be an mp3 ofc! :)
| + | |
− | * id3 - pointer to structure of type ID3V1_T
| + | |
− | <source lang="c">
| + | |
− | bool mp3GetId3FromFile(FILE *f, ID3V1_T *id3);
| + | |
− | </source>
| + | |
− | '''ID3V1_T structure'''
| + | |
− | The ID3V1_T structure type used by the two preceeding functions is defined as:
| + | |
− | <source lang="c">
| + | |
− | //This at last 128 (-3 for "TAG") bytes of file is the tag
| + | |
− | typedef struct _ID3V1_T {
| + | |
− | char title[30];
| + | |
− | char artist[30];
| + | |
− | char album[30];
| + | |
− | char year[4];
| + | |
− | char comment[30];
| + | |
− | char genre;
| + | |
− | } ID3V1_T __attribute__((packed));
| + | |
− | </source>
| + | |
− | '''mp3PlaylistClear'''<br>
| + | |
− | Clears all entries from the playlist.
| + | |
− | <source lang="c">
| + | |
− | void mp3PlaylistClear(void);
| + | |
− | </source>
| + | |
− | '''mp3PlaylistAdd'''<br>
| + | |
− | Add a single song to the playlist.
| + | |
− | * filename - pointer to string containing path to and the mp3 filename
| + | |
− | * title - ascii string containing title of song
| + | |
− | <source lang="c">
| + | |
− | void mp3PlaylistAdd(char *filename, char *title);
| + | |
− | </source>
| + | |
− | '''mp3FormatId3'''<br>
| + | |
− | This function determins is the default way id3 data is presented. Hard to explain this @_@. The user may override this to change how titles are created for the playlist by setting a different callback.
| + | |
− | * id3 - pointer to already populated id3 struct
| + | |
− | * titlestr - buffer to hold title string (should be 256 bytes at least)
| + | |
− | <source lang="c">
| + | |
− | void mp3FormatId3(ID3V1_T *id3, char *titlestr);
| + | |
− | </source>
| + | |
− | '''mp3PlaylistAddDir'''<br>
| + | |
− | Add all mp3s in directory to playlist.
| + | |
− | * dirpath - path/to/yourmp3s/
| + | |
− | <source lang="c">
| + | |
− | bool mp3PlaylistAddDir(char *dirpath);
| + | |
− | </source>
| + | |
− | '''mp3PlaylistAddM3u'''<br>
| + | |
− | Add all songs in .m3u file to playlist. M3u is the text based playlist format popular with most mp3 players.
| + | |
− | * filename - path/to/your.m3u
| + | |
− | <source lang="c">
| + | |
− | int mp3PlaylistAddM3u(char *filename);
| + | |
− | </source>
| + | |
− | '''mp3PlaylistPlay'''<br>
| + | |
− | Plays a song from the playlist
| + | |
− | * index - integer describing which song to play. 0 = first song, 1 = second song on list, 2 = third song, etc etc
| + | |
− | <source lang="c">
| + | |
− | bool mp3PlaylistPlay(int index);
| + | |
− | </source>
| + | |
− | | + | |
− | ===Playlist Macros===
| + | |
− | <source lang="c">
| + | |
− | //Get number of song in playlist
| + | |
− | #define mp3GetPlaylistCnt() (mp3Pl.numsongs)
| + | |
− | //Returns char * to entry 'i' on playlist's title
| + | |
− | #define mp3GetPlaylistTitle(i) (mp3Pl.entry[i]->title)
| + | |
− | //Returns char * to entry 'i' on playlist's filename | + | |
− | #define mp3GetPlaylistFilename(i) (mp3Pl.entry[i]->filename)
| + | |
− | //get currently playing song index | + | |
− | #define mp3GetPlaylistNowPlay() (mp3Pl.nowplaying)
| + | |
− | </source>
| + | |
| | | |
| ==ARM7== | | ==ARM7== |
Basic Mp3 Playing. Probably the simplest way to use this library.