0
0

Hello,
I am a newbie with FMod. Good Lib Good Job
I want to create a Windows MP3 Player and actived 4 output of my soundblaster live
I wrote a C++ Class it works but
but i have a Echo FX and less volume on 2 output than 2 others

How play a stream MP3 ((like Winamp or Windows mediaplayer ) on 4 “channels” of my soundcard ?

Thank you for your Help

And excuse me for my english

include “stdafx.h”

include “CSPlayer.h”

include “MP3FMOD.h”

ifdef _DEBUG

undef THIS_FILE

static char THIS_FILE[]=FILE;

define new DEBUG_NEW

endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

MP3FMOD::MP3FMOD(char *Fichier)
{
Mode_Flux=true; // Par défaut lecture d’un flux pour economiser de la memoire
StereoOutput=true;
// Initialisation Variables
memset(m_Fichier, 0, sizeof(char));
m_Sound_Obj = NULL;
MP3Stream = NULL;
m_soundChannel=-1;
Pas_de_Deplacement=5000; // 5 secondes

// Initialisation FMod 44100 Hz 32 Voix Soft DirectSound 6 Mini
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
FSOUND_SetDriver(FSOUND_CAPS_HARDWARE);

FSOUND_SetMixer(FSOUND_MIXER_AUTODETECT);
FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS);

LoadSong(Fichier);

}

MP3FMOD::~MP3FMOD()
{
if (Mode_Flux)
{
FSOUND_Stream_Stop(MP3Stream);
FSOUND_Stream_Close(MP3Stream);
}
else
{
// Free the sound in the current soundChannel
FSOUND_StopSound(m_soundChannel);

}
// Close and turn off the FMod Sound System.
FSOUND_Close();

}

bool MP3FMOD::LoadSong(char *Fichier)
{
// Teste si le fichier existe !!! A Completer !!!
if(!Fichier) return false;

// Charge le fichier et le stocke dans le pointeur

if (Mode_Flux)
{
    MP3Stream = FSOUND_Stream_OpenFile(Fichier,FSOUND_2D|FSOUND_HW3D , 0); 
    if (!MP3Stream ) return false;



}
else
{
    m_Sound_Obj = FSOUND_Sample_Load(FSOUND_FREE, Fichier, FSOUND_MPEGACCURATE, 1*1024*1024);
    if (!m_Sound_Obj ) return false;
}



strcpy(m_Fichier, Fichier);


return true;

}

void MP3FMOD::Play()
{
if ( FSOUND_GetPaused(m_soundChannel) && (m_soundChannel!=-1))
{

    Pause();
}
else
if ( FSOUND_IsPlaying(m_soundChannel) )
{
    if ( Mode_Flux )
    {
        FSOUND_Stream_SetPosition(MP3Stream,0);
    }
    else
    {
        FSOUND_SetCurrentPosition(m_soundChannel,0);
    }







}
else 
{
    if ( Mode_Flux )
    {
        m_soundChannel = FSOUND_Stream_Play(FSOUND_FREE, MP3Stream); 

    }
    else
    {
        m_soundChannel = FSOUND_PlaySound(FSOUND_FREE, m_Sound_Obj);
    }
}

}

void MP3FMOD::Pause()
{

FSOUND_SetPaused(m_soundChannel,!FSOUND_GetPaused(m_soundChannel));

}

void MP3FMOD::Rewind()
{
int NewPos=0;
int CurrentPos=0;
int MinPos=0;

if ( Mode_Flux )
{

    CurrentPos=FSOUND_Stream_GetTime(MP3Stream);;

    NewPos=CurrentPos-Pas_de_Deplacement;

    if ( NewPos < 0 )
    {
        NewPos=0;
    }
    FSOUND_Stream_SetTime(MP3Stream,NewPos);

}
else
{
    CurrentPos=FSOUND_GetCurrentPosition(m_soundChannel);

    NewPos=CurrentPos-(Pas_de_Deplacement*Constant_Deplacement_Sample);

    if ( NewPos < 0 )
    {
        NewPos=0;

    }

    FSOUND_SetCurrentPosition(m_soundChannel,NewPos);
}

}

void MP3FMOD::Forward()
{
int NewPos=0;
int CurrentPos=0;
int MaxPos=0;

if ( Mode_Flux )
{
    MaxPos=FSOUND_Stream_GetLengthMs(MP3Stream);

    CurrentPos=FSOUND_Stream_GetTime(MP3Stream);

    NewPos=CurrentPos+Pas_de_Deplacement;

    if ( NewPos > MaxPos )
    {
        NewPos=MaxPos;
    }
    FSOUND_Stream_SetTime(MP3Stream,NewPos);

}
else
{
    MaxPos=FSOUND_Sample_GetLength(m_Sound_Obj);

    CurrentPos=FSOUND_GetCurrentPosition(m_soundChannel);

    NewPos=CurrentPos+(Pas_de_Deplacement*Constant_Deplacement_Sample);

    if ( NewPos > MaxPos )
    {
        NewPos=MaxPos;

    }

    FSOUND_SetCurrentPosition(m_soundChannel,NewPos);
}

}

void MP3FMOD::SetVolume(int Volume)
{
if ( (Volume >= 0) && (Volume < 256) )
{

    if ( Mode_Flux )
    {
        FSOUND_SetVolume(m_soundChannel, Volume); 
    }
    else
    {
    }
}

}

void MP3FMOD::SetBalance(int Pos)
{
if ( (Pos >= 0) && (Pos < 256) )
{

    if ( Mode_Flux )
    {
        FSOUND_SetPan(m_soundChannel, Pos); 

    }
    else
    {
    }
}

}

int MP3FMOD::GetTime()
{
int Duree=10;

if ( Mode_Flux )
    {
        Duree=FSOUND_Stream_GetTime(MP3Stream);

    }
    else
    {
    }

return Duree;

}

void MP3FMOD::Stereo()
{
FSOUND_REVERB_PROPERTIES props = FSOUND_PRESET_OFF;
FSOUND_Reverb_SetProperties(&props);
FSOUND_Update();
StereoOutput=true;

}

void MP3FMOD::Quadriphonie()
{

FSOUND_REVERB_PROPERTIES props =FSOUND_PRESET_ROOM;
FSOUND_Reverb_SetProperties(&amp;props);
FSOUND_Update();
StereoOutput=false;

}

bool MP3FMOD::Is_Stereo()
{
return StereoOutput;
}

  • You must to post comments
0
0

What you’re trying to do won’t work unless you load 4 instances of the stream. Understand that FMOD only allows one channel per stream at a time. Brett has said himself that you can’t play a single stream object on multiple channels. To do this, you’d have to call FSOUND_Stream_OpenFile four times, once for each instance, then play each instance of the stream on its own channel.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.