Author Topic: looking for help to : play the same playlist sound on the mutliple output  (Read 439 times)

Fabien

  • Posts: 17
Hello,

I don't find solution to play the same playlist on the multiple output like i do with a simple stream.

Below the code i use to manage playlist. I create a mixer (that's the playlist), i define channel sync function (callback), i creat a stream , i add stream into the mixer

Code: [Select]
// FUNCTION DE CALLBACK SPECIFIQUE BASS
//-------------------------------------
void CALLBACK Play_list::SyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
Play_list *self=(Play_list*)user;

HSTREAM l_next_stream=0;
BOOL l_return;
 
//Modif 26/11/15 std::string l_fic_audio = self->new_file_audio();
std::wstring l_fic_audio = self->new_file_audio();

l_next_stream = BASS_StreamCreateFile(false,l_fic_audio.c_str(),0,0,BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT);
l_return = BASS_Mixer_StreamAddChannel(self->m_mixer, l_next_stream, BASS_STREAM_AUTOFREE|BASS_MIXER_NORAMPIN);
l_return = BASS_ChannelSetPosition(self->m_mixer,0,BASS_POS_BYTE);
}

WD_BASS_PLAYLIST* Play_list::Creer()
//void Play_list::Creer(DWORD P_HDMixer, DWORD P_Nb_File_audio, const char *P_PlayList, DWORD P_len_char, BOOL P_Lect_alea)
// Paramètres à passer :
//---------------------
//  P_HDMixer est le steam mixer créé pour lire la playlist
// P_Flags paramètres pour (voir doc bass)
//  P_Param paramètres pour (voir doc bass)
//  P_Nb_File_audio est le nombre de morceaux (fichiers audio) contenu dans la playlist
//  *P_PlayList est le pointeur sur P_PlayList qui est la chaine qui contient la liste des fichiers son séparés par un ;
//  P_len_char est la longuer de P_PlayList en nombre d'octets
//  P_Lect_alea est l'information de lecture aléatoire de la playlist True=1=Lecture aléatoire / False=0=Lecture séquentielle
// Valeur de retour :
//-------------------
//  Hstream est le N° Stream créé pour la lecture des fichiers audio
{

m_liste_fichier_audio = m_PlayList;
m_tab_playlist=init_tableau(1,m_nombre_fichier_audio);

// On mélange si lecture aléatoire demandée
//-----------------------------------------
//m_lect_alea = false;
    if (this->m_lect_alea) this->melanger(this->m_tab_playlist,this->m_nombre_fichier_audio-1);

//Modif 26/11/15 std::string First_Fic_Audio = this->new_file_audio();
std::wstring First_Fic_Audio = this->new_file_audio();

this->m_mixer = BASS_Mixer_StreamCreate(44100,2,BASS_MIXER_END);

BASS_ChannelSetSync(this->m_mixer,BASS_SYNC_END|BASS_SYNC_MIXTIME,0,this->SyncProc,this);
   
this->m_source = BASS_StreamCreateFile(false,First_Fic_Audio.c_str(),0,0,BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT);  //1st file open
BASS_Mixer_StreamAddChannel(m_mixer,this->m_source,BASS_STREAM_AUTOFREE);

this->m_str_playlist.G_Mixer = this->m_mixer;
this->m_str_playlist.G_Source = this->m_source;
Play_list *const lc_Objet = this;
    this->m_str_playlist.G_Objet = static_cast<HANDLE>(lc_Objet);

return &this->m_str_playlist;
}

Then i try to split the mixer to send the sound on multiple output (1 split / 1 ouput) but it doesn't work.
I proced like that :

   - Loop (for all ouput required)
      - Bass_SetDevice(output id)
      - Bass_Split_StreamCreate(stream id) to create stream on each output device
      - Bass_ChannelSetLink to link all splitted mixer
   - End loop
   - Bass_ChannelPlay(mixer id) to play sound on all output.

In fact, the playlist is played only on the first output


For more information, with "single" stream i use these functions and it's work very well
   - Bass_streamCreate with DECODE flag to create the stream (master)
   - Loop (for all ouput required)
       - Bass_setDevice (output id)
       - Bass_Split_StreamCreate (stream id) to create stream on each output device
       - Bass_ChannelSetLink to link all splitted stream
   - End loop
   - Bass_ChannelPlay(stream id) to play sound on all output.

If you have comment or idea i'll be happy and interested
Maybe the way i am to manage playlist is completly wrong....

Thanks for your help
Fabien

Ian @ un4seen

  • Administrator
  • Posts: 20437
When using splitters to send the mixer output to multiple devices, are you adding the BASS_STREAM_DECODE flag to the BASS_Mixer_StreamCreate call? If not, the BASS_Split_StreamCreate calls will be failing, ie. returning 0. Also, when using splitters on a source, all playback of that source needs to go through a splitter, ie. you can't play the mixer directly. The splitter setup could look something like this:

Code: [Select]
for (int n=0; n<outputs; n++) {
BASS_SetDevice(device[n]); // set device to create splitter on
split[n]=BASS_Split_StreamCreate(mixer, 0, 0); // create the splitter
if (n>0) BASS_ChannelSetLink(split[0], split[n]); // link it with the 1st splitter
}
BASS_ChannelPlay(split[0], 0); // start the splitters

Fabien

  • Posts: 17
Ian,

You were right, BASS_STREAM_DECODE flag was missing to the BASS_Mixer_StreamCreate call. But when i add this flag there is an error. BASS_StreamCreateFile return 0.

Can i add a decode stream into decode mixer ?
Do i use incompatible mixer's and stream's flag ?

For more informations, when DECODE flag was missing  to the BASS_Mixer_StreamCreate call, the split function wasn't working but i was abke to read playlist on the first output.If i add DECODE flag, i have problem before use Split function.

When code is :

Code: [Select]
// FUNCTION DE CALLBACK SPECIFIQUE BASS

WD_BASS_PLAYLIST* Play_list::Creer()
{
        ........
        ........
        ........

        // I added DECODE FLAG IN THE LINE BELOW
        //----------------------------------------------
this->m_mixer = BASS_Mixer_StreamCreate(44100,2,BASS_STREAM_DECODE|BASS_MIXER_END);

BASS_ChannelSetSync(this->m_mixer,BASS_SYNC_END|BASS_SYNC_MIXTIME,0,this->SyncProc,this);
   
this->m_source = BASS_StreamCreateFile(false,First_Fic_Audio.c_str(),0,0,BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT);  //1st file open
BASS_Mixer_StreamAddChannel(m_mixer,this->m_source,BASS_STREAM_AUTOFREE);

.........
        .........
}

For more information see below code of the callback function i use to manage playlist and create new channel in the same mixer.

Code: [Select]
// FUNCTION DE CALLBACK SPECIFIQUE BASS
//-------------------------------------
void CALLBACK Play_list::SyncProc(HSYNC handle, DWORD channel, DWORD data, void *user)
{
Play_list *self=(Play_list*)user;

HSTREAM l_next_stream=0;
BOOL l_return;
 
//Modif 26/11/15 std::string l_fic_audio = self->new_file_audio();
std::wstring l_fic_audio = self->new_file_audio();

l_next_stream = BASS_StreamCreateFile(false,l_fic_audio.c_str(),0,0,BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT);
l_return = BASS_Mixer_StreamAddChannel(self->m_mixer, l_next_stream, BASS_STREAM_AUTOFREE|BASS_MIXER_NORAMPIN);
l_return = BASS_ChannelSetPosition(self->m_mixer,0,BASS_POS_BYTE);
}

}

I'm turning around this problem for many months. I'm close to reath MY limits (not Bass's limit )
So, help and support will be appreciated. Thanks
Fabien

Ian @ un4seen

  • Administrator
  • Posts: 20437
That code looks fine. To find out why the BASS_StreamCreateFile call is failing, please call BASS_ErrorGetCode straight after it to get the error code.

Fabien

  • Posts: 17
Once again you're right the problem was on splitter function and on Channel play. In fact you must create split and setlink with the mixer id and after play the stream id (and not the mixer id).

Thanks
Solved