Code: Select all
on bounce3
put 60 / field "bpm" into theTime
set the loc of image "sphere.png" to 50,285
if the label of button "cd1" is "X" then
play specialFolderPath ("engine") & "/Click.wav"
else
play specialFolderPath ("engine") & "/ClickSoft.wav"
end if
wait theTime sec with messages -- MUST have "with messages" in order to register a tap on this button to stop
set the loc of image "sphere.png" to (the width of this stack - 50)/2,285
if the label of button "cd2" is "X" then
play specialFolderPath ("engine") & "/Click.wav"
else
play specialFolderPath ("engine") & "/ClickSoft.wav"
end if
wait theTime sec with messages
set the loc of image "sphere.png" to (the width of this stack - 50),285
if the label of button "cd3" is "X" then
play specialFolderPath ("engine") & "/Click.wav"
else
play specialFolderPath ("engine") & "/ClickSoft.wav"
end if
wait theTime sec with messages
if the short name of me is "Stop" then send bounce3 to me
end bounce3
The problem I am encountering is that the speed of the clicks starts out at the user-specified beats per minute but, within a measure or two, begins to slow down maybe 20% or so. If I don't include the "with messages" then there's no way to stop the metronome. On my Mac, there is no apparent slowdown when running in the IDE or in a standalone OSX app.
I'm running the app directly on my Nexus 5 phone without tethering. The phone is running KitKat 4.4.4. The standalone app was made for Android 3.1 (the highest available given how I installed the SDK, I guess). I'm running LC7 on OSX 10.9.5 (Mavericks). The "click" and "clicksoft" .wav sounds are 9kb and 25KB and are .05 and .16 seconds, respectively; so these are tiny sounds that are quite short in length. (I may have some slight inaccuracy due to the addition of the audio files in the beats per minute but I can work these out mathematically. My issue here is the unexplained slowdown. It I stop the run and the start it again, it begins at the normal speed and slows down after a few measures. (Garbage collection?)
Suggestions are always welcomed.
Thanks,
Barry