PlayerCallback event are different between "DirectSound" and "WASAPI"

Started by Terry, December 05, 2019, 12:43:36 PM

Previous topic - Next topic

Terry

Hi

I load a same PDJ playlist file from the sample program; "VideoMixerWithFader" but different audio driver.
One is "DirectSound" and one is "WASAPI" ( I add some codes to initialize the "WASAPI" drivers).



        Private Sub frmFader_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Debug.Print(m_audioAPI.InitDriversType(enumDriverTypes.DRIVER_TYPE_WASAPI).ToString)

            ' verify presence of audio output devices
            Dim nOutputs As Int32 = m_audioAPI.GetOutputDevicesCount()
            If nOutputs = 0 Then
                MessageBox.Show("No output device detected and/or connected: the program will now close. If you are running under Windows Vista or higher, jack-sensing could disable an existing sound card if no speaker is physically connected so, if you are sure that a sound card is installed, try to plug a couple of speakers into the sound card before launching again this program.")
                Close()
            End If

            ' init the conmponent
            m_audioAPI.InitSoundSystem(2, 0, 0, 0, 0)

            If (Not m_audioAPI.WASAPI.DeviceIsStarted(0, enumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_RENDER)) Then
                ' start all of the WASAPI output devices in shared mode
                m_audioAPI.WASAPI.DeviceStartShared(0, enumWasapiDeviceTypes.WASAPI_DEVICE_TYPE_RENDER, enumWasapiChannelModes.WASAPI_CHANNEL_MODE_MULTI, 50, 10)
                Debug.Print(m_audioAPI.LastError.ToString)
            End If
....



The CallbackForPlayersEvents sequence are EV_PLAYLIST_SOUND_LOADED, EV_SOUND_PLAYING  and EV_SOUND_DONE step by step.
"DirectSound" logs are normal
"WASAPI" logs are weird

---------------------------------------------------------------------------------
"DirectSound"
EV_PLAYLIST_SOUND_LOADED 0 2019/12/05 18:46:46
EV_SOUND_PLAYING 2019/12/05 18:46:46
EV_SOUND_DONE 2019/12/05 18:46:56

EV_PLAYLIST_SOUND_LOADED 1 2019/12/05 18:46:56
EV_SOUND_PLAYING 2019/12/05 18:46:56
EV_SOUND_DONE 2019/12/05 18:47:10

EV_PLAYLIST_SOUND_LOADED 2 2019/12/05 18:47:10
EV_SOUND_PLAYING 2019/12/05 18:47:10
EV_SOUND_DONE 2019/12/05 18:47:29

EV_PLAYLIST_SOUND_LOADED 3 2019/12/05 18:47:29
EV_SOUND_PLAYING 2019/12/05 18:47:30
EV_SOUND_DONE 2019/12/05 18:47:35

----------------------------------------------------------------------------------

"WASAPI"
EV_PLAYLIST_SOUND_LOADED 0 2019/12/05 18:40:32
EV_SOUND_PLAYING 2019/12/05 18:40:32

EV_PLAYLIST_SOUND_LOADED 1 2019/12/05 18:40:42
EV_SOUND_PLAYING 2019/12/05 18:40:42
EV_SOUND_DONE 2019/12/05 18:40:43

EV_PLAYLIST_SOUND_LOADED 2 2019/12/05 18:40:57
EV_SOUND_PLAYING 2019/12/05 18:40:57
EV_SOUND_DONE 2019/12/05 18:40:57

EV_PLAYLIST_SOUND_LOADED 3 2019/12/05 18:41:16
EV_SOUND_PLAYING 2019/12/05 18:41:16
EV_SOUND_DONE 2019/12/05 18:41:16


As you can see, "EV_SOUND_DONE" always was fired immediately after "EV_SOUND_PLAYING", and the "EV_SOUND_DONE" to the firest song was never fired .

All song in the playlist can play smoothly to the end on both sides.


Best Regards
(Sorry for my English...)

Terry





Administrator

Hello,

could you be so kind to attach a sample of PDJ playlist file you are currently using for reproducing this issue?

Kind regards

Severino Delaurenti
MultiMedia Soft

Terry

Hi

<?xml version="1.0" ?>
<FaderPlayList>
    <PlayListItems>
        <Item pathname="C:\Users\yen\Music\廣告\10秒串場.mp3" Title="10秒串場" DurationSec="10.272" StartPosSec="0.100" MixPosSec="9.772" EndPosSec="10.272">
            <VolumePoints>
                <VolumePoint name="FadeInBegin" VolumeLevelLinear="0.000" PosSec="0.000" CurveType="1" />
                <VolumePoint name="FadeInEnd" VolumeLevelLinear="100.000" PosSec="0.000" CurveType="0" />
                <VolumePoint name="FadeOutBegin" VolumeLevelLinear="100.000" PosSec="11.296" CurveType="1" />
                <VolumePoint name="FadeOutEnd" VolumeLevelLinear="0.000" PosSec="10.296" CurveType="0" />
            </VolumePoints>
            <CuePoints />
        </Item>
        <Item pathname="C:\Users\yen\Music\廣告\15秒串場.mp3" Title="15秒串場" DurationSec="15.072" StartPosSec="0.100" MixPosSec="14.572" EndPosSec="15.072">
            <VolumePoints>
                <VolumePoint name="FadeInBegin" VolumeLevelLinear="0.000" PosSec="0.000" CurveType="1" />
                <VolumePoint name="FadeInEnd" VolumeLevelLinear="100.000" PosSec="0.000" CurveType="0" />
                <VolumePoint name="FadeOutBegin" VolumeLevelLinear="100.000" PosSec="16.096" CurveType="1" />
                <VolumePoint name="FadeOutEnd" VolumeLevelLinear="0.000" PosSec="15.096" CurveType="0" />
            </VolumePoints>
            <CuePoints />
        </Item>
        <Item pathname="C:\Users\yen\Music\廣告\20秒補充台呼.mp3" Title="20秒補充台呼" DurationSec="19.632" StartPosSec="0.100" MixPosSec="19.132" EndPosSec="19.632">
            <VolumePoints>
                <VolumePoint name="FadeInBegin" VolumeLevelLinear="0.000" PosSec="0.000" CurveType="1" />
                <VolumePoint name="FadeInEnd" VolumeLevelLinear="100.000" PosSec="0.000" CurveType="0" />
                <VolumePoint name="FadeOutBegin" VolumeLevelLinear="100.000" PosSec="20.656" CurveType="1" />
                <VolumePoint name="FadeOutEnd" VolumeLevelLinear="0.000" PosSec="19.656" CurveType="0" />
            </VolumePoints>
            <CuePoints />
        </Item>
        <Item pathname="C:\Users\yen\Music\廣告\5秒-音樂.MP3" Title="5秒-音樂" DurationSec="5.787" StartPosSec="0.100" MixPosSec="5.287" EndPosSec="5.787">
            <VolumePoints>
                <VolumePoint name="FadeInBegin" VolumeLevelLinear="0.000" PosSec="0.000" CurveType="1" />
                <VolumePoint name="FadeInEnd" VolumeLevelLinear="100.000" PosSec="0.000" CurveType="0" />
                <VolumePoint name="FadeOutBegin" VolumeLevelLinear="100.000" PosSec="6.799" CurveType="1" />
                <VolumePoint name="FadeOutEnd" VolumeLevelLinear="0.000" PosSec="5.799" CurveType="0" />
            </VolumePoints>
            <CuePoints />
        </Item>
    </PlayListItems>
</FaderPlayList>



Best Regards

Terry

Administrator

Hello,

unfortunately we were not able to replicate the issue: from our tests, after adding the following code to the PlayerCallback sub

         Select Case nEvent
            Case enumPlayerEvents.EV_SOUND_DONE
               Console.WriteLine("Sound done {0} for player {1}" & Constants.vbLf, nData1, nPlayer)
            Case enumPlayerEvents.EV_PLAYLIST_SOUND_LOADED
               ' this is the next player to fade-in so put it at the bottom of the Z-Order
               m_audioAPI.DisplayVideoMixer.PlayerZOrderSet(m_nMixerUniqueID, nPlayer, 100)

               Console.WriteLine("Loaded sound {0} for player {1}" & Constants.vbLf, nData1, nPlayer)
         ... etc.

the event is generated also for the first song when WASAPI driver is selected.

As a side note, which should in any case not impact the behaviour for your report, positions set into the FadeOutBegin and FadeOutEnd attributes are not coherent with themselves and with the song duration: FadeOutBegin should be smaller than FadeOutEnd and both should be set on a position smaller than the song's duration.

Kind Regards

Severino Delaurenti
MultiMedia Soft

Terry

Hi

I mail the program running video I recored.

and the PDJ playlist file, audio files…..

I find out that the firest sond "EV_SOUND_DONE" was shown at the end.

Please check it out.


Best Regards

Terry

Terry

Hello

Execute me!
I think I found the answer.

The second sond event "EV_SOUND_DONE" was the first sond fired .....

but, "DirectSound" is not in this state. ???

Best Regards

Terry

Administrator

Hello,

strange, from our tests they seem to behave the same, both DirectSound and Wasapi.

Kind regards

Severino Delaurenti
MultiMedia Soft

Terry

Hello

I am getting clear how volume automation for playlists going.

But, there are some points I can not catch.

put "m_audioAPI.PlayListCurrIndexGet(nPlayer, index)" in "EV_SOUND_DONE" or "EV_SOUND_PLAYING" session,
the index value seems always return 0 when "nPlayer" is not 0.

Therefore, how to know which song is done or playing when "nPlayer" is not 0 at "EV_SOUND_DONE" and "EV_SOUND_PLAYING" events, if playlist was very complicated?


Kind regards
Terry


Administrator

Hello,

if you look into the code of the VideoMixerWithFader sample, you will see that the fader is initialized to manage playlists through the following lines of code:

m_audioAPI.Fader.PlayListUseSingle(Player_1)
m_audioAPI.Fader.Init(enumFadeTypes.FADE_SINGLE_PLAYLIST, Player_1, Player_2)

this means that a single playlist will be loaded into Player_1 only BUT songs will be rendered by splitting them in both Player_1 and Player_2: this is the reason why the call to

m_audioAPI.PlayListCurrIndexGet(nPlayer, index)

will always return 0 for players different from Player_1, because other players don't have a playlist.

The PlayerCallback sub, which manages all of the players related events, receives the index of the player currently managing a song through its second parameter "nPlayer" and the index of the playlist's item through the third parameter nData1: as you will see inside the code, this parameter is used in order to highlight the item currently played inside the provided ListView control on the user interface.

Hope this clarifies a bit.

Kind regards

Severino Delaurenti
MultiMedia Soft





Terry

Hello

I can get the parameter nData1 at "EV_PLAYLIST_SOUND_LOADED" but "EV_SOUND_DONE" or "EV_SOUND_PLAYING".

It's Ok to check "EV_PLAYLIST_SOUND_LOADED" to get the time when a song starts playing.

But how to know when a song has been performed completely?

Kind regards
Terry

Administrator

Hello,

if you look into the documentation of the CallbackForPlayersEvents delegate, you will see that "EV_SOUND_DONE" and "EV_SOUND_PLAYING" will not pass any data: due to the fact that one single player cannot render 2 files at the same time, if you want to know when a specific playlist sound has ended, you may catch the EV_PLAYLIST_SOUND_LOADED event and check the value of the nPlayerIndex parameter: when the "EV_SOUND_DONE" event is fired for the same player (nPlayerIndex parameter would match the one passed with the EV_PLAYLIST_SOUND_LOADED event) this would mean that the song for that player has ended.

Kind regards

Severino Delaurenti
MultiMedia Soft