[android-developers] Re: CPU cost of a semi-infinite loop

2011-01-04 Thread Slash4
Wonderful :) And you know what ? It's taking 1% of the CPU now... 3% @ 250 BPM with all quarter notes running. Absolutely amazing. Topic closed ! Thanks again. On 1 jan, 19:55, Dianne Hackborn hack...@android.com wrote: adb shell top will show CPU usage.  My favorite version is adb shell top

[android-developers] Re: CPU cost of a semi-infinite loop

2011-01-01 Thread Slash4
After several tests involving AudioTrack, both STATIC and STREAM mode, It was obvious I could not use this because of the specificity of my metronome, which can mix and play Notes, Half notes, quarter notes and triplets at the same time. Filling and reseting the AudioTracks buffers between each

Re: [android-developers] Re: CPU cost of a semi-infinite loop

2011-01-01 Thread Dianne Hackborn
adb shell top will show CPU usage. My favorite version is adb shell top -t -m 10. On Sat, Jan 1, 2011 at 7:49 AM, Slash4 alex.cen...@gmail.com wrote: After several tests involving AudioTrack, both STATIC and STREAM mode, It was obvious I could not use this because of the specificity of my

[android-developers] Re: CPU cost of a semi-infinite loop

2010-12-30 Thread Slash4
Thanks Kostya, Streaming seems to be a great solution. And it is very interesting because this way I can mix sounds... Let's do this :) Rgds, Alex On 29 déc, 21:23, Kostya Vasilyev kmans...@gmail.com wrote: To elaborate a bit:

[android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Slash4
Hello, thanks you so much for looking at my problem :) First, my application is using a SCREEN_DIM_WAKE_LOCK so the screen is always on, yet the backlight and the keyboard are dimmed. Did you say in this case, the battery would not be consumed ? So, about accuracy, the fastest callback that I

[android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Slash4
I answered you but I don't see my message.. I hope it's OK :s On 29 déc, 03:22, Dianne Hackborn hack...@android.com wrote: This will run the CPU at 100%.  With the screen off, this will tremendously impact battery life.  With it on, it will be at least noticeable. How accurate do you need to

Re: [android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Kostya Vasilyev
Perhaps it would be a better idea to a use pre-recorded sound for this. You are trying to solve a problem at the application level that's already been solved, but at lower levels within the system. By using a pre-recorded sound, you can leverage other people's work. For different metronome

[android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Bret Foreman
This is very similar to a problem I solved when I was testing disk I/O subsystems and needed to generate I/O requests at fixed intervals of a few hundred per second. What I did was to take a timestamp at the beginning of the test and set up a loop with a sleep in it. The initial sleep value was

Re: [android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Frank Weiss
I'd look into Kostya's suggestion. Ideally, you only need the click sample and you can program the audio player to play the sample at precise intervals. Trying to do precise timing with SDK programming is just frought with pitfalls, AFAIK. -- You received this message because you are subscribed

Re: [android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Dianne Hackborn
On Wed, Dec 29, 2010 at 10:54 AM, Slash4 alex.cen...@gmail.com wrote: First, my application is using a SCREEN_DIM_WAKE_LOCK so the screen is always on, yet the backlight and the keyboard are dimmed. Did you say in this case, the battery would not be consumed ? Absolutely not. The CPU

Re: [android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Kostya Vasilyev
To elaborate a bit: http://developer.android.com/reference/android/media/AudioTrack.html AudioTrack supports streaming mode of operation, where data can be fed into it on the fly. You'd still need to do some sort of scheduled periodic loop, for feeding data to AudioTrack in chunks, but this

Re: [android-developers] Re: CPU cost of a semi-infinite loop

2010-12-29 Thread Kristopher Micinski
How accurate is the looping setting on the MediaPlayer? Is it possible to synthesize the click track and then send it to a media player and set it to loop? I'm not sure how accurate that would be, perhaps someone else could offer some insight? kris On Wed, Dec 29, 2010 at 3:23 PM, Kostya