1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
[main.c]
#include "constantes.h"
int main(int argc, char *argv[])
{
char* toto = "intro.ogg";
musique* test = new musique(toto);
test->play();
system("pause");
return 0;
}
-------------------------------------------------------
[constantes.h]
#ifndef CONSTANTES_H_
# define CONSTANTES_H_
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <FMOD/fmod.h>
#include "sons.h"
# endif /* CONSTANTES_H_ */
-------------------------------------------------------
[sons.h]
#ifndef SONS_H_
# define SONS_H_
class musique
{
public:
char* fichier;
FSOUND_STREAM * load;
musique(char* nomfichier);
~musique();
void play();
void stop();
};
# endif /* SONS_H_ */
-------------------------------------------------------
[sons.c]
#include "constantes.h"
musique::musique(char* nomfichier)
{
this->fichier = nomfichier;
FSOUND_Init(44100, 32, 0);
}
void musique::play()
{
this->load = FSOUND_Stream_Open(this->fichier, FSOUND_LOOP_NORMAL, 0, 0);
FSOUND_Stream_Play(FSOUND_FREE, this->load);
}
void musique::stop()
{
FSOUND_Stream_Stop(this->load);
}
musique::~musique()
{
FSOUND_Close();
} |
Partager