Dim NuovoVolume As Double = Value
Dim T As MidiTrack = Main.Seq.GetTracks(oo)
Dim canale As Int
Canale = GetTrackChannel(t)
Dim mm As MidiShortMessage
mm.Initialize
mm.Create4(MidiStatus.CONTROL_CHANGE,canale,7,127)
Dim PCEvt As MidiEvent
PCEvt.Initialize
PCEvt.CreateShort(mm,SalvaTick)
T.Add(PCEvt)
If LblTrack0.Text ="" Then
Return
End If
canale = canale -1
Dim tx As MidiTrack = Main.Seq.GetTracks(LblTrack0.text)
For o = 0 To tx.Size - 1
Dim Mevt As MidiEvent = tx.Get(o)
If Mevt.GetMessage.IsShortMessage Then
If canale = Mevt.GetMessage.AsShortMessage.GetChannel Then
Dim sm As MidiShortMessage = Mevt.GetMessage.AsShortMessage
If sm.GetCommand = MidiStatus.CONTROL_CHANGE Then
If sm.GetData1 = 7 Then
LblVol0.Text = sm.GetData2
SliderCh0.Value = sm.GetData2
End If
End If
End If
End If
Next
It just calls the getController method in the JavaxSound library.But your library's GetController function returns an incorrect value. Can you please check it?
'Obtains the current value of the specified controller.
Public Sub GetController(Controller As Int) As Int
Return TJO.RunMethod("getController",Array As Object(Controller))
End Sub
'Obtains
I made a quick program and put you a foundation to test it. This base must be placed in c: \It just calls the getController method in the JavaxSound library.
B4X:'Obtains the current value of the specified controller. Public Sub GetController(Controller As Int) As Int Return TJO.RunMethod("getController",Array As Object(Controller)) End Sub 'Obtains
I don't have a an app set up that I can test it on. If you have one I'll look at it.
Thanks.OK, that is the expected result. Channel.getController method is a realtime method, which means that it will only return a meaningful value when the track is being played with a sequencer. It gets the current value of the controller at the current time in the track.
Controllers are continuous, there could be many thousands of messages for a given controller in a midi track. Consider a crescendo in the music. The controller will start a small value, and rise, maybe every 50th of a second until the highest value is achieved.
To monitor this correctly you would normally use the event llistener, but Channel.GetController gets a snapshot of the value when it is called.