java - Metronome android app AudioTrack releaseBuffer() error -


i trying create sounding metronome app android. right have audiotrack create , press play initialize. write pcm bytes buffer , use audiotrack.writesound() write buffer. first write buffer

        for(int i=0;i<this.tick;i++) {             soundtickarray[i] = tick[i];         }         for(int i=0;i<silence;i++)             silencesoundarray[i] = 0;     } 

then, write audiotrack after been converted pcm sequentially in loop.

        {             audiogenerator.writesound(soundtickarray);             audiogenerator.writesound(silencesoundarray);         } while(running); 

in while loop until terminated in thread.

the problem keep getting error.

releasebuffer() track 0xb491b280 disabled due previous underrun, restarting

and metronome won't stop.

does have suggestions why happening or how solve it.

or other suggestions run consistent metronome beats doesn't lag , precise? tried use soundpool ran lag.

thanks!

this refers accuracy of metronome.

when you're doing sort of thing, have make sure beats being controlled consistent pulse matching sampling rate. is, true accurate timing rhythm, need control metronome clicks control rate matches sampling rate.

a common solution problem create square wave runs @ sampling rate of audio. frequency of square wave adjusted user match bpm of metronome. then, whenever squarewave produces 1 or -1, use trigger audio samples.

the best solution though, access audio clock on computers sound card. take @ webpage explains in more detail;

http://www.javaperformancetuning.com/articles/soundtimer.shtml


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -