Need Help Inserting Delay Between Sound Effect Playback
<p>I'm still new to Android dev and am stuck.  I have an onTouchEvent that powers a rotating graphic and increases a background int [counter] which triggers a short sound effect (beep) to be played.  Currently, if [counter] > 10 a the sound is played (using the soundpool) and is summarily looped as long as the onTouchEvent keeps counter > 10.  Is it possible to insert a delay between playbacks of the beep sound effect so that the delay decreases the larger the value of [counter] gets?</p>

<p>Example:
if (counter == 10) { delay = 80 // in MS }
if (counter == 90) { delay = 10 // in MS }</p>

<p>My Code:</p>

<pre><code>sm = new SoundManager();
    sm.initSounds(getBaseContext());
    sm.addSound(1, R.raw.beep);

...

@Override
public boolean onTouchEvent(MotionEvent event) {

    if (buttonClicked) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            counter++;
            startRotating();
            break;
        case MotionEvent.ACTION_UP:
            counter--;
            stopRotating();
            break;
        }
    }

    return super.onTouchEvent(event);
}

public void startRotating() {
    returnRotating = false;

    if (!keepRotating) {
        keepRotating = true;

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (keepRotating) {
                    degrees = (degrees + 10) % 360;
                    make(degrees);
                    counter = counter + 1;

                    if (counter &gt; 10)
                        sm.playSound(1);  // plays beep

                    handler.postDelayed(this, INTERVAL);
                }
            }
        }, INTERVAL);
    }
}
</code></pre>

<p>EDIT: Added code</p>

<pre><code>public void stopRotating() {
    keepRotating = false;

    if (!returnRotating) {
        returnRotating = true;

        final Handler handler = new Handler();

        handler.postDelayed(new Runnable() {

            @Override
            public void run() {

                if (returnRotating) {
                    degrees = (degrees - 10) % 360;
                    make(degrees);
                    counter = counter - 1;

                    if (counter &gt; 10) {
                    sm.playSound(1); // plays beep

                    handler.postDelayed(this, INTERVAL);
                }
            }
        }, INTERVAL);
    }
}
</code></pre>
