I am trying to play a musical note using the accelerometer to trigger the note.
The issue I’m having is the note retriggers super quickly and glitches out. I just want it to play once for each movement. I’ve tried experimenting with ‘wait’ and restricting the range without much luck.
You’re right that the error block isn’t going to help here. Have you already tried placing a wait block inside the when Play is done block? What is the duration of the sound file you’re using?
Yep I have tried the wait block however it still has the issue of playing ~100 times per second. I’ve tried with the wait before and after play, same problem though unfortunately!
If I Live Test these blocks in Thunkable Live on an iPhone 11 and tap the button repeatedly, it only plays the sound once until completion and then repeats.
So that tells me that Thunkable is firing the when Play is done section only after the sound completes playing. But you didn’t mention… what is the duration of your sound file?
I’ve been testing on Android (Oppo something something).
Just tested on my iPhone 6S which seems a slightly less glitchy. Since I restricted the range (between 2-3) its not tooooo bad. The problem is when the phone is held at the angle that triggers the note, it plays (super fast) repeatedly.
I’m also a bit confused because the accelerometer seems to be functioning as a gyroscope (as far as my limited understanding goes). That is, the values are changing based on the angle I hold the phone, rather than how fast I move the phone.
For the code here, did you say before I should run something as a JSON? I’m not exactly sure what you’re asking me to do? If you could block it out that might enlighten me a bit
varies by your software. download the app and test it on your mobile device.
you’ll need to run the latest version. if you updated your computer. if not, try going to setting and acess to unknown appand then <Thunkable live/your downloaded app> and then sound to true.
hmmm. I experienced the same problem. and for the app same as you! set sencivity to high.
now test it on your mobile device
@domhnallohanlon I wonder if you could help me out here?
Is there a block that will let me just play a sound once, when the accelerometer changes?
At the moment because the accelerometer is changing 1000 times a second, the sound is restarted many times per second and sounds glitchy.
One option would be to check for the accelerometer changing and then check to see if enough time has passed by comparing the “seconds since 1970” block to a variable storing that value when the accelerometer changed. If the difference is greater than some amount (say, 0.1 seconds or 0.5 seconds), then play a sound. So you’re essentially adding a timer to the accelerometer event.