0
0

Hi guys(especially Andrew),
does FSOUND_CD_PLAYONCE work?

here the example:

include <stdio.h>

if defined(WIN32) || defined(_WIN64) || defined(WATCOMC)

#include <conio.h>
#include <windows.h>

elif defined(linux)

#include “../../api/inc/wincompat.h”

endif

include <stdlib.h>

include “../../api/inc/fmod.h”

include “../../api/inc/fmod_errors.h” /* optional */

int main()
{
/*
INITIALIZE
*/
if (!FSOUND_Init(44100, 32, FSOUND_INIT_USEDEFAULTMIDISYNTH))
{
printf(“Error!\n”);
printf(“%s\n”, FMOD_ErrorString(FSOUND_GetError()));
return 1;
}

/*
    LOAD SONG
*/
char cddevice_ = 0;
FSOUND_CD_SetPlayMode(cddevice_, FSOUND_CD_PLAYONCE);
FSOUND_CD_Play(cddevice_, 1);

return 0;

}

It plays the first track just fine.
But than the whoel cd.
I thought, it just has to play the track 1???.

Any guess?

platform: windows XP, fmod374

Cheers takomat fmod team

  • You must to post comments
0
0

[quote:3c0wm6ke] FSOUND_CD_Play(cddevice_, 1);

return 0; [/quote:3c0wm6ke]

You’re starting the CD and then exiting the app straight away. Because of the way CD playback (using MCI) works with Windows, the CD keeps playing through to the end even though the app is finished. Solution is to not exit your program straight away.

  • You must to post comments
0
0

Hi Andrew,
sorry, made that
example too simple.
Of course, the calls are performed in a
bigger application.

Please exchange the part
between load song and return(0) as follows:
/*
LOAD SONG
*/
char cddevice_ = 0;
FSOUND_CD_SetPlayMode(cddevice_, FSOUND_CD_PLAYONCE);
FSOUND_CD_Play(cddevice_, 4);

int pos_sample_ms__ = FSOUND_CD_GetTrackLength(cddevice_, 4);

while(pos_sample_ms__&gt;FSOUND_CD_GetTrackTime(cddevice_))
{
   Sleep(20000);
   std::cout &lt;&lt; " total(sec): " &lt;&lt; (pos_sample_ms__/60000);
   std::cout &lt;&lt; " act(sec): " &lt;&lt; (FSOUND_CD_GetTrackTime(cddevice_)/60000);
   std::cout &lt;&lt; std::endl;
}
Sleep(20000);

It plays the 5th song???? …

cheers lars

  • You must to post comments
0
0

any guesses?

In the meantime I tried the simple example above on
several computers with the same effect:
It does not stop after playing the selected song

Cheers Lars

  • You must to post comments
0
0

FMOD uses windows messages internally when it handles CD looping so you’re going to have to put a message pump in your app and link with user32.lib if you’re not already doing so. For example…

[code:189d80yd]
/*
LOAD SONG
*/
char cddevice_ = 0;
FSOUND_CD_SetPlayMode(cddevice_, FSOUND_CD_PLAYONCE);
FSOUND_CD_Play(cddevice_, 4);

int pos_sample_ms__ = FSOUND_CD_GetTrackLength(cddevice_, 4);

for (;;)
{
    MSG msg;
    if (PeekMessage(&amp;msg, NULL, 0, 0, PM_NOREMOVE))
    {
        if (GetMessage(&amp;msg, NULL, 0, 0) &gt; 0)
        {
            TranslateMessage(&amp;msg);
            DispatchMessage(&amp;msg);
        }
    }

    Sleep(14);

    static int display_time = 0;
    if ((display_time += 14) &gt;= 20000)
    {
        std::cout &lt;&lt; &quot; total(sec): &quot; &lt;&lt; (pos_sample_ms__/60000);
        std::cout &lt;&lt; &quot; act(sec): &quot; &lt;&lt; (FSOUND_CD_GetTrackTime(cddevice_)/60000);
        std::cout &lt;&lt; std::endl;
        display_time = 0;
    }
}

return 0;

[/code:189d80yd]

  • You must to post comments
0
0

Hi Andrew,

it is working on windows now. But:

Actually I do not work with windows messaging as
the application is platform independant.
That implies the next question:

what to do on linux or better what is the platform independent
code?

ifdef WIN32

   MSG msg;
    if (PeekMessage(&amp;msg, NULL, 0, 0, PM_NOREMOVE))
    {
        if (GetMessage(&amp;msg, NULL, 0, 0) &gt; 0)
        {
            TranslateMessage(&amp;msg);
            DispatchMessage(&amp;msg);
        }

endif

??
Thanx Lars
}

  • You must to post comments
0
0

The linux version doesn’t use any message stuff for CD looping so just ifdef out the windows message pump stuff and it should all work fine.

  • You must to post comments
0
0

ok. it works in general :-)

But I recognized the first time I tried it, that the next song
was played just for some 40 ms or so.
This short hearing of sound happened also similar,
when we set the stream or mod
with

channel_id__ = FSOUND_Stream_PlayEx(FSOUND_FREE,
stream, NULL, TRUE);
on pause and than
setting all the modes like
FSOUND_SetMute(channel_id__, TRUE);

and than
FSOUND_SetPaused(channel_id__, FALSE);

As this “errors” occurs none predictable,
we can not make you hear that effect,
but it is worse to mention it here.

I have not heared this small hearable error on linux.

Cheers Lars

  • You must to post comments
0
0

Make sure your message pump is running fast enough i.e. don’t put a huge sleep in there or bog down your frame rate doing other stuff. FMOD can only respond to the “CD track finished” message when it’s pumped in by your app.

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.