![]() |
|
This thread is locked; no one can reply to it.
![]() ![]() |
1
2
|
AllegroMP3 == chaos in my mind. |
Albin Engström
Member #8,110
December 2006
![]() |
I have never seen something more confusing than the AllegroMP3 example file.. yes, i don't have enough knowledge but still, an example file should only include the things necessary and related to the subject, in this case to play an mp3 file. This might sound a little lazy but.. could someone please post a piece of code of AllegroMP3 that only includes the very minimum required code to play an mp3 file?. thanks! |
Kibiz0r
Member #6,203
September 2005
![]() |
It's been a long time since I used it, but I thought it was something like ALMP3_load(), ALMP3_play()... I'll go check it out, though. Heh, okay... maybe not. Quote: Server not found
--- |
CGamesPlay
Member #2,559
July 2002
![]() |
You have to open a file, seek to the end of it, find the offset of that position, seek to the beginning, create a buffer of the same size as the file, read the file into the buffer, than pass that to AlMP3, IIRC. -- Ryan Patterson - <http://cgamesplay.com/> |
Archon
Member #4,195
January 2004
![]() |
Quote: create a buffer of the same size as the file Does 'seeking' actually give you purely PCM data (as it has VBR and probably metadata in each frame)? OP: Basically, MP3 and all other codecs should decode to a common format (like .wav files - which is why they're so big), but each codec does it differently. Unless you want to stream it, you'll need to create a normal SAMPLE and then uncompress the PCM data of the MP3 file into the data attribute, as well as give it the metadata (bits[rate], stereo, freq[uency], len[gth]) so the SAMPLE knows how much data data describes. Then you should be able to just play it like you play a normal .wav file. |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote: Unless you want to stream it, you'll need to create a normal SAMPLE and then uncompress the PCM data of the MP3 file into the data attribute, as well as give it the metadata (bits[rate], stereo, freq[uency], len[gth]) so the SAMPLE knows how much data data describes. Then you should be able to just play it like you play a normal .wav file. And why would anyone use AlMP3 if they had to do this? Quote: Does 'seeking' actually give you purely PCM data (as it has VBR and probably metadata in each frame)? No, it gives you the size of the MP3 file. AlMP3 doesn't know how to read files, so you can for instance pass in an MP3 stored in a datafile. -- Ryan Patterson - <http://cgamesplay.com/> |
Albin Engström
Member #8,110
December 2006
![]() |
OK.. maybe all that 'crap' wasn't unnecessary.. thanks for your help!! If you have a more detailed version on how to make it work then don't hesitate to post it. I thank thee! |
Archon
Member #4,195
January 2004
![]() |
Quote:
And why would anyone use AlMP3 if they had to do this?
I don't know! I can't think straight (it was 2:10am) I'm just recalling what I'm trying to do with libvorbisfile and libFLAC for OpenAL... Not so fun if I can't test it in the middle of programming it. |
Kibiz0r
Member #6,203
September 2005
![]() |
Wow, how is ALMP3 a billion times more complicated than I remember it? I was able to use it while I was still working on my first game, which was pure C with ridiculously awful practices and an endearingly noob-ish lack of skill/knowledge... I got through by the skin of my teeth. I wonder how I was able to contend with ALMP3. --- |
Thomas Fjellstrom
Member #476
June 2000
![]() |
You can't stream the mp3s directly of the disk by just sending chunks of data instead of it all? Loading up a 3-5MB mp3 just to send to almp3 seems a bit silly when libmad lets you load and decode on the fly. -- |
Albin Engström
Member #8,110
December 2006
![]() |
Thomas Fjellstrom said: You can't stream the mp3s directly of the disk by just sending chunks of data instead of it all? Loading up a 3-5MB mp3 just to send to almp3 seems a bit silly when libmad lets you load and decode on the fly.
I think you can. Anyway: i'm accepting the AllegroMP3 challenge and now i'm facing my first opponent. PACKFILES! i'm having a huge problem understanding these fellas. |
Thomas Fjellstrom
Member #476
June 2000
![]() |
A normal allegro packfile is just a regular file that can optionally be moderately compressed. pack_fopen pack_fread pack_fclose etc. The api is very similar to the libc standard file io routines. Now if you mean datafiles, theres dat.exe and grabber.exe -- |
Albin Engström
Member #8,110
December 2006
![]() |
nono! not datafiles, i have those under control.. gah, something like this would have made my day: packfile.write("iman.mp3"); - -. |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Ah, the packfile stuff is very similar to "stdio". PACKFILE *pf = pack_fopen("w", "filename"); pack_fwrite(data, sizeof_data, pf); pack_fclose(pf);
-- |
Albin Engström
Member #8,110
December 2006
![]() |
"PACKFILE *pf = pack_fopen("w", "filename");" pack_fwrite(data, sizeof_data, pf); |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Quote: This loads a packfile right? It just opens it, for "w"riting in this case. Quote: Is this where you write to the opened datafile? Packfile, and yes. char data[256]; PACKFILE *pf = pack_fopen("r", "filename"); pack_fread(data, 256, pf); pack_fclose(pf); And that will read the first 256 bytes of whatever is in "filename", and place it in data. -- |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote: You can't stream the mp3s directly of the disk by just sending chunks of data instead of it all? No, you can. That's why AlMP3 doesn't provide filename-based functions and lets you do the dirty work. If it did, it would cut out a lot of the features. -- Ryan Patterson - <http://cgamesplay.com/> |
Albin Engström
Member #8,110
December 2006
![]() |
char data[256]; PACKFILE *pf = pack_fopen("r", "filename"); pack_fread(data, 256, pf); pack_fclose(pf); ok, so thats how i read.. to write however: pack_fwrite(data, sizeof_data, pf); manual said: from memory location pointed to by `p'. memory means? can i replace data with the path to the mp3? (hopes for an easy solution).. why: char data[256]?? |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Quote: memory means? Any memory address. like a pointer to something. Generally an array of some kind is used (since using it without the []s it acts like a pointer, and thus works in functions like these). Quote: can i replace data with the path to the mp3? (hopes for an easy solution).. If you want to read the mp3, you just place the filename in the "filename" bit in pack_fopen, and then use pack_fread to read it in. Quote: why: char data[256]?? Because. No reason, just some random number I picked. Quote: why does it read the first 256bytes? Because a file "read" position starts at 0 by default, and I put "256" in the size bit in pack_fread, its also the size of the array (you never want to read more data than can fit in your memory variable). Quote: can't i have more than one information in one packfile? IIRC its limited to about 2-4GB Quote: can i nest packfiles? Yes. Though thats a little more complex than just normal packfiles. -- |
Albin Engström
Member #8,110
December 2006
![]() |
Quote: Though thats a little more complex than just normal packfiles. Aka nothing i should bother with.. Well, below is my pathetic attempt to make a simple function to load and play mp3 files.. this didn't work, it doesn't crash either, which should have been preferred..
|
Thomas Fjellstrom
Member #476
June 2000
![]() |
DATAZ is only 256kb in size, with a 128kb/s mp3, thats about 2 seconds of mp3 data. Also, I think the MP3STREAM/mp3stream stuff is for streaming off the disk, so you read X bytes every so often and send into the stream, where as it looks like you want to just load it all and send, in which case, you need to dynamically allocate "data" with "malloc" or "new" the size of the file, and then send it using the non stream functions. -- |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote: DATAZ is only 256kb in size, with a 128kb/s mp3, thats about 2 seconds of mp3 data. No, it's 32 KB. -- Ryan Patterson - <http://cgamesplay.com/> |
Thomas Fjellstrom
Member #476
June 2000
![]() |
Yeah, somehow I got the math wrong, its 1024kb, which is 8 seconds of playtime with a 128kb/s mp3. -- |
CGamesPlay
Member #2,559
July 2002
![]() |
Quote: #define DATASZ (1<<15) It's 32,768 bytes long. 32 kilobytes. -- Ryan Patterson - <http://cgamesplay.com/> |
Thomas Fjellstrom
Member #476
June 2000
![]() |
OOps, I'm really fuzzy this morning. I was right to begin with. I'm talking BITS here not bytes. To match with the way mp3s are labeled (in kbits/s). 32KB * 8bits is a whole 256kbits. Do you see now what I'm talking about? -- |
Albin Engström
Member #8,110
December 2006
![]() |
I think my muscles was just replaced by lead.. Ok, the goal is to load and play a mp3 non-streamed.. trying to get a grip on >what i have to do to get it to work< is important.
It's not easy being a newbie, |
|
1
2
|