0
0

hi i am trying to play a mp3 with fmod stream
here is my code what have i missed for it work?

thanks
malo

ps :Ihave don’t use errors for the moment i just want to play a sound


include<stdio.h>

include”./inc/fmod.h”

int main (){
FSOUND_STREAM *stream;

FSOUND_Init(44100,32,0);
sream=FSOUND_Stream_OpenFile(“./jules.mp3”,FSOUND_NORMAL,0);
FSOUND_Stream_Play(FSOUND_FREE,stream);

}

  • You must to post comments
0
0

Your program exits before FMOD can play the first chunk of sound.

For a similar problem, see http://52.88.2.202/forum/viewtopic.php?t=1341 and my reply.

  • You must to post comments
0
0

Thanks for your help
i am starting to programming and code with fmod
so sorry
it does’nt work

i have a new code it give me it ‘s ok but it does’nt play anysound
so here is my code

[/code][code:2sy3coml]

include<stdio.h>

include<string.h>

include "./inc/fmod.h"

int track(char * file, FSOUND_STREAM * stream,int * channel)
{
int position=1;

stream=FSOUND_Stream_OpenFile(file,FSOUND_NORMAL| FSOUND_MPEGACCURATE | FSOUND_LOOP_OFF,0);

do
{
if(channel<0)
{
///le channel est libre on peut jouer:)))
channel=FSOUND_Stream_Playex(FSOUND_FREE,stream,NULL,1);
FSOUND_Setpaused(
channel,0);
}

    position ++;
  sleep(10);
   } while ((FSOUND_Stream_GetLength(stream))!=(FSOUND_Stream_SetPosition(stream , position)));

return 1;
}

int son (const char * file ){

FSOUND_STREAM * stream;
int channel=-1;

FSOUND_SetOutput(FSOUND_OUTPUT_OSS);

// FSOUND_SetDriver(0);// par defaut

///////////// initialisation //////////////

if (! FSOUND_Init(44100,32,0))
{
FSOUND_Close();
return 0;
}

//jouer

return( track(file,stream,&amp; channel));

}

int main()
{
char * file;

file=(char) malloc(sizeof(char)20);
*file="./jules.mp3";
printf("%i\n", (son(file)));

}
[/code:2sy3coml]

  • You must to post comments
0
0

[code:12czi8db]
{
if(channel<0)
{
[/code:12czi8db]

What you’re testing for there is not the value of the channel handle, but the pointer. You meant
if(*channel<0)

[code:12czi8db]
position ++;
sleep(10);
} while ((FSOUND_Stream_GetLength(stream))!=(FSOUND_Stream_SetPosition(stream , position)));
[/code:12czi8db]

What did you intend there ?
If you wanted the loop to stop when the sound has finished playing, change it to

[code:12czi8db]
} while((unsigned)FSOUND_Stream_GetLenght(stream)>FSOUND_Stream_GetPosition(stream));
[/code:12czi8db]

[code:12czi8db]
file=(char) malloc(sizeof(char)20);
*file=”./jules.mp3″;
[/code:12czi8db]

Huh ? How about
char *file = “./jules.mp3”;

For this to work you’ll have to change the first parameter of your track(…) func to “const char *”.

  • You must to post comments
0
0

thanks it works

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.