MSoundCapture and MSoundPlayback

Some of my students (and myself) were having trouble with the Mary Jane Soft MSound library so I put together very quick and dirty style libraries: MSoundCapture and MSoundPlayback

Download them: MSoundCapture, MSoundPlayback

Here is some example code:

import processing.core.*;
import com.mobvcasting.msoundcapture.*;
import com.mobvcasting.msoundplayback.*;

public class MSoundCaptureTest extends PMIDlet
{
MSoundPlayback sndplay;
MSoundCapture sndcap;
byte[] soundData;

String mimeType;

String captureKey = "Capture";
String stopCaptureKey = "Stop Capture";
String playKey = "Play Sound";

public void setup()
{
softkey(captureKey);

sndcap = new MSoundCapture((PMIDlet)this);
}

public void draw()
{
}

public void softkeyPressed(String label)
{
if (label.equals(captureKey))
{
sndcap.startCapture();
softkey(stopCaptureKey);
}
else if (label.equals(stopCaptureKey))
{
mimeType = sndcap.getCapturedType();
sndcap.stopCapture();
}
else if (label.equals(playKey))
{
sndplay = new MSoundPlayback(this,soundData,mimeType);
sndplay.playSound();
}
redraw();
}

public void libraryEvent(Object library, int event, Object data)
{
if (library.getClass().isInstance(sndcap) && event ==
MSoundCapture.CAPTURE_COMPLETE)
{
soundData = (byte[])data;
mimeType = sndcap.getCapturedType();
softkey(playKey);
redraw();
}
}
}

Leave a comment

Your email address will not be published. Required fields are marked *