/* Hallo. Ich habe Gegoogled wie ein verrückten aber keine Antwort darauf gefunden, wie man diese Mp3-bibliothek zum laufen bekommt.
Die Readme habe ich auch gelesen und auch alles so umgesetzt wie beschrieben. Wahrscheinlich habe ich einen kleinen Fehler gemacht der mir jetzt grade nicht auffällt.
Nun bitte ich doch recht herzlich um Hilfe wie ich diese Mp3 von mir (3.2 MB) mit ALLEGRO zum laufen kriege. */
Alles anzeigen
Hier ein Auszug aus der readme Datei.
Using AllegroMP3
----------------
To be able to use AllegroMP3 with your program, you just need (once
compiled the library) to link the generated lib with your program
(remember that since this lib relies on allegro, you need to add
almp3 *before* alleg) and include the header "almp3.h", available in
the lib and include directories respectively.
Reference
---------
Note parameters are marked between ' ' markers.
Differences between ALMP3_MP3 and ALMP3_MP3STREAM:
With ALMP3_MP3 you will be able to know the mp3 length, seek in the
file (directly), and multiple other things, BUT you'll need to load
the whole file in memory and keep it there until you stop playing it.
With ALMP3_MP3STREAMs you won't be able to do that (well, you will be
able to do seeking but in a special way), BUT you'll be able to load
just small chunks of data, very alike Allegro's AUDIOSTREAMs do, saving
memory and loading time.
ALMP3_MP3 *almp3_create_mp3(void *data, int data_len);
Creates an ALMP3_MP3 which you'll have to pass to all the other
functions, where 'data' will be a pointer to the buffer containing
the mp3 data and 'data_len' the size of this buffer. Note you aren't
supposed to free this buffer until you have destroyed the ALMP3_MP3.
return values:
NULL if there ocurred an error (mostly an invalid mp3 data was passed).
Other value ( != NULL ) otherwise.
void almp3_destroy_mp3(ALMP3_MP3 *mp3);
Destroys the ALMP3_MP3 automatically stopping it. Note this function
check if the 'mp3' pointer is pointing to NULL, so for example this:
ALMP3_MP3 *mp3 = NULL;
destroy_mp3(mp3);
won't crash the program.
int almp3_play_mp3(ALMP3_MP3 *mp3, int buffer_len, int vol, int pan);
Plays the 'mp3' ALMP3_MP3 with the given volume 'vol' (from 0 to 255)
and panning 'pan' (from 0 to 255, where 0 is full left and 255 is
full right). 'buffer_len' is the desired size in bytes of the
buffer where the decoded data will be stored. The bigger, the less
you'll have to poll the MP3, but the more time you will have to wait
in order to hear the song start playing. Note that due to some
mp3 format limitations, the internal (and real) buffer will be
an aproximation to the 'buffer_len' given. A 'buffer_len' size between
16384 and 32768 bytes (16kb and 32kb) will do in most cases.
return values:
ALMP3_OK if no problems.
ALMP3_PLAY_BUFFERTOOSMALL if the given 'buffer_len' was not big enough.
special note:
This function also works like a "resume" function, since it
won't rewind the ALMP3_MP3 automatically. Note that once the ALMP3_MP3
has reached the end when playing, it will rewind though, stoping the
ALMP3_MP3 if the loop flag was set at FALSE (see almp3_play_ex_mp3())
or continuing playing it if it was set at TRUE. Also note that this
automatically stops decoding.
Danke für Hilfe und frohes neues.
Die Readme habe ich auch gelesen und auch alles so umgesetzt wie beschrieben. Wahrscheinlich habe ich einen kleinen Fehler gemacht der mir jetzt grade nicht auffällt.
Nun bitte ich doch recht herzlich um Hilfe wie ich diese Mp3 von mir (3.2 MB) mit ALLEGRO zum laufen kriege. */
Quellcode
- /*Ich arbeite mit den Dev-C++ 4.9 Compiler für Windows.
- Allegro ist richtig installiert und nutzbar.
- Mit den Linker sind die Bibliotheksdateien
- libalmp3.a(für mp3) und liballeg.a(für Allegro)
- in dieser Reihenfolge verbunden.*/
- #include <almp3.h>
- #include <allegro.h>
- int main(void){
- allegro_init() ;
- char *puffer = "6.mp3" ;
- install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) ;
- ALMP3_MP3 *musik = almp3_create_mp3(puffer,4000) ;
- // Ich glaube hier müsste irgendwo der Fehler sein,
- // weil wenn ich diese Zeile lösche läuft das Programm
- // normal, zeigt aber nur die Nachricht an.
- almp3_play_mp3(musik,4000,255,255) ;
- allegro_message("MUSIK TEST") ;
- }END_OF_MAIN() ;
Hier ein Auszug aus der readme Datei.
Using AllegroMP3
----------------
To be able to use AllegroMP3 with your program, you just need (once
compiled the library) to link the generated lib with your program
(remember that since this lib relies on allegro, you need to add
almp3 *before* alleg) and include the header "almp3.h", available in
the lib and include directories respectively.
Reference
---------
Note parameters are marked between ' ' markers.
Differences between ALMP3_MP3 and ALMP3_MP3STREAM:
With ALMP3_MP3 you will be able to know the mp3 length, seek in the
file (directly), and multiple other things, BUT you'll need to load
the whole file in memory and keep it there until you stop playing it.
With ALMP3_MP3STREAMs you won't be able to do that (well, you will be
able to do seeking but in a special way), BUT you'll be able to load
just small chunks of data, very alike Allegro's AUDIOSTREAMs do, saving
memory and loading time.
ALMP3_MP3 *almp3_create_mp3(void *data, int data_len);
Creates an ALMP3_MP3 which you'll have to pass to all the other
functions, where 'data' will be a pointer to the buffer containing
the mp3 data and 'data_len' the size of this buffer. Note you aren't
supposed to free this buffer until you have destroyed the ALMP3_MP3.
return values:
NULL if there ocurred an error (mostly an invalid mp3 data was passed).
Other value ( != NULL ) otherwise.
void almp3_destroy_mp3(ALMP3_MP3 *mp3);
Destroys the ALMP3_MP3 automatically stopping it. Note this function
check if the 'mp3' pointer is pointing to NULL, so for example this:
ALMP3_MP3 *mp3 = NULL;
destroy_mp3(mp3);
won't crash the program.
int almp3_play_mp3(ALMP3_MP3 *mp3, int buffer_len, int vol, int pan);
Plays the 'mp3' ALMP3_MP3 with the given volume 'vol' (from 0 to 255)
and panning 'pan' (from 0 to 255, where 0 is full left and 255 is
full right). 'buffer_len' is the desired size in bytes of the
buffer where the decoded data will be stored. The bigger, the less
you'll have to poll the MP3, but the more time you will have to wait
in order to hear the song start playing. Note that due to some
mp3 format limitations, the internal (and real) buffer will be
an aproximation to the 'buffer_len' given. A 'buffer_len' size between
16384 and 32768 bytes (16kb and 32kb) will do in most cases.
return values:
ALMP3_OK if no problems.
ALMP3_PLAY_BUFFERTOOSMALL if the given 'buffer_len' was not big enough.
special note:
This function also works like a "resume" function, since it
won't rewind the ALMP3_MP3 automatically. Note that once the ALMP3_MP3
has reached the end when playing, it will rewind though, stoping the
ALMP3_MP3 if the loop flag was set at FALSE (see almp3_play_ex_mp3())
or continuing playing it if it was set at TRUE. Also note that this
automatically stops decoding.
Danke für Hilfe und frohes neues.
