ddf.minim.ugens.* android alternative

edited January 2014 in Android Mode

Hi, I am using minim to create sounds in processing and now want to transfer this to an android device. All i require is a sound that lasts for a max of about 0.5 seconds. See the code snippet below:

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim       minim;
AudioOutput out;
Oscil       wave;

void setup()
{
  size(512, 200, P3D);

  minim = new Minim(this);

  // use the getLineOut method of the Minim object to get an AudioOutput object
  out = minim.getLineOut();

  // create a sine wave Oscil, set to 440 Hz, at 0.5 amplitude
  wave = new Oscil( 440, 0.5f, Waves.SINE );
  // patch the Oscil to the output
  wave.patch( out );
}

In fact all i really require is the android beep sound. What is the easiest way to do this in android.

Any help is much appreciated.

Cheers.

Answers

  • Perhaps your answer can be found on StackOverflow. A translated version of one answer would be as follows:

    //Imports
    import android.media.ToneGenerator;
    import android.media.AudioManager;
    
    //To play a beep anywhere in the sketch
    final ToneGenerator tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
    tg.startTone(ToneGenerator.TONE_PROP_BEEP);
    

    I haven't tested this code. I picked it because it was the shortest.

    If you want a Processing library that supports sound and works on Android, try APWidgets.

Sign In or Register to comment.