Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using an Asynctask is along the lines of what you want to do. However, I would suggest using a thread-pool. You can then put your animation in as a task, add your audio recording as a task, the FFT as another task, and your additional analysis as a task.</p> <p>The brief stutter is likely the result of allocating resources for the recording in the animation thread. Using a pool means you won't have to pause while creating the thread to run your audio tasks. Obviously, some code would be handy to fully understand your problem.</p> <p>Take a look at:</p> <p>ScheduledThreadPoolExecutor <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html</a></p> <p>or</p> <p>ThreadPoolExecutor <a href="http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html</a></p> <p>A very simple example of what you might want to do:</p> <p>In your activity you can define this to start up the tasks</p> <pre><code>ExecutorService threadPool = new ScheduledThreadPoolExecutor(2); Recording record = new Recording(); Ball ball = new Ball(threadPool, record); threadPool.submit(ball); </code></pre> <p>Ball.java</p> <pre><code>import java.util.concurrent.ExecutorService; public class Ball implements Runnable { private final Recording record; private final ExecutorService threadPool; private boolean condition; private boolean active; public Ball(ExecutorService threadPool, Recording record) { this.record = record; this.threadPool = threadPool; this.active = true; } @Override public void run() { while (this.active) { moveBall(); if (isBallHalfway()) { threadPool.submit(record); } } } private boolean isBallHalfway() { return condition; // Condition for determining when ball is halfway } private void moveBall() { // Code to move the ball } } </code></pre> <p>Recording.java</p> <pre><code>public class Recording implements Runnable { @Override public void run() { // Do recording tasks here } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload