I'm trying to play the musical notes. I use soundpool and timer. However, sometimes distorted because the period of time. Phone ram and it's elongation and contraction depending on the processor state. Is there another method would you recommend? I can give a priority to the CPU and RAM to their application? Is there a way to do that?
I can play MusicXML files. I get all the data from the MySQL database.
The problem is:
For example, there are 10 notes.
Each time 1 second.
I sometimes use the timer each time going 1 second. Sometimes they go shortening occurs.
B4X:
Sub tmrPlay1_Tick
Dim mp As Map
mp.Initialize
mp=lstTmr1.Get(nIndex1)
pGitar = SP.Play(sGitar, 1, 1, 1, 1,mp.Get("notarate"))
nIndex1=nIndex1+1
mp=lstTmr1.Get(nIndex1)
tmrPlay1.Initialize("tmrPlay1",mp.Get("notaduration"))
tmrPlay1.Enabled=True
End Sub
I define the duration of the timer in the next note Ticker.
Your code is wrong.
1. You are creating a new timer every tick event. You shouldn't initialize the timer again.
2. You are creating a new map every tick_event (remove the mp.Initialize line). Though this is not the real problem.
Not sure that I understand the question. Do you want to find the sound duration? It is not available from SoundPool. You can use MediaPlayer to find it.
A-B-C-D-E-F-G music notes.
I am using Playback rate properties of soundpool. This way I can find all the notes in one voice.
p = SP.Play(s, 1, 1,1, 1,0.5) ----- 0.5 note voice.
p = SP.Play(s, 1, 1,1, 1,0.4)------ 0.4 note voice.
Also note that the length of the (duration) required.
For example 1.notes last 1 second.
The second half-second notes.
Third note ........ 1.5 seconds
If few notes of a song ....
That's my only problem now.
That note lengths. (DURATIONs)
Let's say there are 200 notes, each at different times.
I want to play them repeatedly.
(I explain difficult because of Google translate. Sorry...)