How do I debug the following error?

In order to explain 'what is frequency of sound', I developed a small app. It works fine for 15 clicks, then show error 'play() called on uninitialized AudioTrack.' . Attaching image of blocks, pl tell what's an issue?

Perhaps introduce a clock timer (e.g. 100-250 ms) to generate a small delay between setting the frequency and calling the tone ?

But what's the meaning of error?

Well, it means that the audio track requested to be played (your frequency tone) has not been initialised, therefore it cannot be played.

Put the .aia file here.

1 Like

Sending .aia and extension file which I used.
SoundByFreq.aia (34.1 KB)
[mod edit] please do not provide direct download links to extensions that are not your own....

But it works 13 times exactly and then show error. How that?

I built an example based on you blocks and did not get the error. Does your error arise in companion or in a compiled app? Tested your aia in companion, no issues.

Its there in companion and app both, in both cases the error occurs at 14th click

In my opinion, the error occurs when we trigger a new sound before the previous one has finished. Therefore, to make another sound, wait for the previous one to finish.
It is simply an extension problem. You can use the timer to block buttons from being pressed while the sound is playing.

I tried as per your suggestion, but its same after giving sufficient time between 2 clicks

I'm waiting for further suggestion

1 Like

It's possibly a resource leak by the extension if it's consistently occurring after a certain number of calls and will likely be dependent on the device manufacturer and Android OS version. That could explain why different people are having different experiences when testing.