MultiMedia Soft forum

MultiMedia Soft products => Audio playback and audio management components => Topic started by: vbfan on April 07, 2015, 12:25:10 PM

Title: Driving custom VUMeters from Players
Post by: vbfan on April 07, 2015, 12:25:10 PM
Hi,
using VB.Net 2008. I'm intended to use two custom VUMeters for two different players, say VUmeter1 for Player1 and VUMeter2 for Player2. 
Embedded VUMeters are working fine but I want to use customized VUMeters that have the property

VUMeter1.Level  'can handle a value from 0 to 40000

I've the following VUMeter related code:
In the Form Load I've:
     AudioDjStudio1.DisplayVUMeter.Create(Player1, VuMeter1.Handle)
     AudioDjStudio1.DisplayVUMeter.Create(Player2, VuMeter2.Handle)


For event Handling:
Private Sub audioDjStudio1_VUMeterValueChange(ByVal Sander As Object, ByVal e As AudioDjStudio.VUMeterValueChangeEventArgs) _ HandlesudioDjStudio1.VUMeterValueChange
        VUMeter1.Value = e.nPeakLeft   'Works fine only for Player1
End Sub


I don't know how to drive my VUMeter2 from Player2. I admit that I'm missing some extremely basic concept (especially with event handling). :-\ I've studied documentation but could not figure it even after spending a whole day. Can you please reveal the correct syntax and concept that can drive two VUMeters (VUMeter1 and VUMeter2) from two different Players(Player1 and Player2)?  :)
Best regards.
Title: Re: Driving custom VUMeters from Players
Post by: Administrator on April 07, 2015, 04:22:07 PM
Hello,

the VUMeterValueChangeEventArgs class, represented by the "e" parameter of the VUMeterValueChange event, is made of 3 elements and the first element is nPlayerIndex: this number represents the zero-based index of the player that fired the event so, during playback of the 2 streams loaded into Player1 and Player2, it will be fired once for Player1 and once for Player2: usually, as seen inside our samples, Player1 has value 0 while Player2 has value 1 so the parameter nPlayerIndex will come once with value 0 and once with value 1.

The pseudo-code for driving the 2 custom vu-meters will be something similar:


Private Sub audioDjStudio1_VUMeterValueChange(ByVal Sander As Object, ByVal e As AudioDjStudio.VUMeterValueChangeEventArgs) _ HandlesudioDjStudio1.VUMeterValueChange
    If e.nPlayerIndex = Player1 Then
        VUMeter1.Value = e.nPeakLeft
    ElseIf e.nPlayerIndex = Player2 Then
        VUMeter2.Value = e.nPeakLeft
    End If
End Sub


Hope this better explains the usage of the e.nPlayerIndex which is identical for any player-related event.

Kind Regards

Severino Delaurenti
MultiMedia Soft
Title: Re: Driving custom VUMeters from Players
Post by: vbfan on April 07, 2015, 05:47:02 PM
Thanks. I got the idea and managed it with success.  :D Actually I was confused with the concept of e.
It's working fine now.You helped me a lot (as usual :) ). Thanks again.