Hi Severino,
Could you help me out with the following issue.
I am trying to create a playlist with crossfade functionality using the AudioDJStudioApiF4 control. (version 10.1.0.0 / Engine 13.6.0.17)
The playlist is created from scratch using the PlayListCreateEx and PlayListAddItem procedure.
When I create the playlist without crossfade functionality, the second track is automatically started when the first raises a Done event (both on DeckA).
But when I add the Fader object, the second track is started and directly raises a done event.
Could you hint me what I am doing wrong?
Please find below the debug logging and VB.Net code.
=== start debug logging ===
=================
Control Version = 10.1.0.0
Engine Version = 13.6.0.17
=================
[date/time] [deck] [event]
10:58:05.057 - 0 - EV_PLAYLIST_SOUND_LOADED
10:58:05.890 - 0 - EV_BPM_AVAILABLE
10:58:05.906 - 0 - EV_FADEIN_STARTED
10:58:05.908 - 0 - EV_SOUND_PLAYING
10:58:06.704 - 0 - EV_FADEIN_COMPLETED
10:58:06.705 - 0 - EV_VOLUME_SLIDE_COMPLETED
11:00:25.125 - 0 - EV_FADING_POINT_REACHED <--fade point first track
11:00:25.175 - 1 - EV_PLAYLIST_SOUND_LOADED <--load 2nd track in deckB
11:00:26.058 - 1 - EV_BPM_AVAILABLE
11:00:26.060 - 1 - EV_SOUND_DONE
11:00:26.063 - 1 - EV_SOUND_PLAYING <--start 2nd track in deckB
11:00:26.114 - 1 - EV_SOUND_DONE <--done 2nd track in deckB
11:00:40.084 - 0 - EV_SOUND_DONE
=== end debug logging ===
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
InitAudioEngine()
Timer1.Start()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim AudioFiles As String() = Directory.GetFiles("C:\Audio Files", "*.mp3")
CreatePlaylist(AudioFiles.ToList)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
PlaylistStart()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
PlaylistStop()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.Text = $"{GetCurrentTrackPositionString()} / {GetTotalTrackDurationString()}"
End Sub
End Class
Imports AudioDjStudioApi
Imports System.IO
Module mAudioEngine
Public AudioApiEngine As New AudioDjStudioApiObj()
Public Const Deck_A As Short = 0
Public Const Deck_B As Short = 1
Private Delegate Sub CallbackForPlayersEventsDelegate(ByVal nEvent As enumPlayerEvents,
ByVal nPlayer As Int16,
ByVal nData1 As Int32,
ByVal nData2 As Int32,
ByVal fData3 As Single,
ByVal pBufferUnicode As IntPtr,
ByVal nBufferLength As Int32)
Private addrCallbackForPlayersEvents As CallbackForPlayersEvents
Public Sub InitAudioEngine()
Debug.WriteLine("=================")
Debug.WriteLine($"Control Version = {AudioApiEngine.GetControlVersion()}")
Debug.WriteLine($"Engine Version = {AudioApiEngine.GetEngineVersion()}")
Debug.WriteLine("=================")
AudioApiEngine.InitSoundSystem(2, 0, 0, 0, 0)
' set the player's callback
addrCallbackForPlayersEvents = New CallbackForPlayersEvents(AddressOf PlayerCallback)
AudioApiEngine.CallbackForPlayersEventsSet(addrCallbackForPlayersEvents)
AudioApiEngine.Fader.Init(enumFadeTypes.FADE_SINGLE_PLAYLIST, Deck_A, Deck_B)
AudioApiEngine.Fader.PlayListUseSingle(Deck_A)
AudioApiEngine.Fader.FadeInEnabled = True
AudioApiEngine.Fader.FadeInLength = 350
AudioApiEngine.Fader.FadeOutEnabled = True
AudioApiEngine.Fader.FadeOutLength = 3500
End Sub
Public Sub DisposeAudioEngine()
AudioApiEngine.StopSound(Deck_A)
AudioApiEngine.StopSound(Deck_B)
AudioApiEngine.Dispose()
End Sub
Private Sub PlayerCallback(ByVal nEvent As enumPlayerEvents,
ByVal nPlayer As Int16,
ByVal nData1 As Int32,
ByVal nData2 As Int32,
ByVal fData3 As Single,
ByVal pBufferUnicode As IntPtr,
ByVal nBufferLength As Int32)
Select Case nEvent
Case enumPlayerEvents.EV_WAVEFORM_CHANGE
Case enumPlayerEvents.EV_FADING_VOLUME_CHANGED
Case enumPlayerEvents.EV_VUMETER
Case Else
Debug.WriteLine($"{Date.Now:HH:mm:ss.fff} - {nPlayer} - {nEvent}")
End Select
End Sub
Public Sub CreatePlaylist(AudioFiles As List(Of String))
AudioApiEngine.PlayListSetLoop(Deck_A, bLoop:=False)
AudioApiEngine.PlayListSetShuffle(Deck_A, bShuffle:=False)
AudioApiEngine.PlayListCreateEx(Deck_A, enumPlayListModes.PLAYLIST_AUTOMATION_MODE)
Dim Index As Integer = 0
For Each f As String In AudioFiles
If Not File.Exists(f) Then Continue For
AudioApiEngine.PlayListAddItem(nPlayerIndex:=Deck_A,
strPathname:=f,
nIndex:=Index)
Index += 1
Next
End Sub
Public Sub PlaylistStart()
Debug.WriteLine(AudioApiEngine.PlayListExecute(Deck_A, bFromBegin:=True).ToString())
End Sub
Public Sub PlaylistStop(Optional ByVal Deck As Short = -1)
If Deck = -1 Then
AudioApiEngine.StopSound(Deck)
Return
End If
AudioApiEngine.StopSound(GetPlayingDeck())
End Sub
Public Function GetTotalTrackDurationString() As String
Return AudioApiEngine.GetFormattedSoundDuration(GetPlayingDeck)
End Function
Public Function GetTotalTrackDurationInt() As Integer
Return AudioApiEngine.GetSoundDuration(GetPlayingDeck)
End Function
Public Function GetCurrentTrackPositionString() As String
Return AudioApiEngine.GetCurrentPosString(GetPlayingDeck, False, False)
End Function
Public Function GetCurrentTrackPositionInt() As Integer
Return AudioApiEngine.GetCurrentPos(GetPlayingDeck)
End Function
Public Function GetPlayingDeck() As Short
If AudioApiEngine.GetPlayerStatus(Deck_B) = enumPlayerStatus.SOUND_PLAYING Then
Return Deck_B
End If
Return Deck_A
End Function
End Module
Hello Patrick,
the problem should be due to the fact that you are setting the playlist to work in automation mode but without entering any kind of volume automation for the items: the volume automation is mainly intended for usage with PDJ playlist files or by entering full volume automation with an XML string passed to the strPathname parameter of the PlayListAddItem method (see its documentation for an example).
Your code should work by changing the line:
AudioApiEngine.PlayListCreateEx(Deck_A, enumPlayListModes.PLAYLIST_AUTOMATION_MODE)
with
AudioApiEngine.PlayListCreateEx(Deck_A, enumPlayListModes.PLAYLIST_FULL_MODE)
Hope this helps
Kind regards
Severino Delaurenti
MultiMedia Soft
Hi Severino,
Thank for the explanation.
I assumed that, because the fade volume points where automatically applied for the first track, that this would apply for all the tracks.
Best regards
Patrick Vossen