grabber = new SequenceGrabber();
System.out.println ("got grabber");
soundChannel = new SGSoundChannel (grabber);
System.out.println ("Got SGAudioChannel");
System.out.println ("SGChannelInfo = " +
soundChannel.getSoundInputParameters());
System.out.println ("SoundDescription = " +
soundChannel.getSoundDescription());
// create list of input devices
// getDeviceList flags: http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIII/sggetchanneldevicelist.htm
SGDeviceList devices = soundChannel.getDeviceList(StdQTConstants.sgDeviceListDontCheckAvailability);
int deviceCount = devices.getCount();
for (int i=0; i<deviceCount; i++) {
SGDeviceName deviceName = devices.getDeviceName(i);
// is it available?
if ((deviceName.getFlags() &
StdQTConstants.sgDeviceNameFlagDeviceUnavailable) == 0)
deviceChoice.add(deviceName.getName());
}
// prepare and start previewing
// note - second prepare arg should seemingly be false,
// but if it is, you get erroneous dskFulErr's
grabber.prepare(true, false);
soundChannel.setUsage (StdQTConstants.seqGrabPreview |
StdQTConstants.seqGrabRecord);
soundChannel.setVolume (0.0f);
// get settings
// yikes! this crashes java 1.4.2 on mac os x!
// soundChannel.settingsDialog();
final SGSoundChannel sc = soundChannel;
Thread t = new Thread() {
public void run() {
try {
sc.settingsDialog();
} catch (QTException qte) {
qte.printStackTrace();
}
}
};
t.start();
while (t.isAlive())
Thread.yield();
grabber.startPreview();
// create output file
grabFile = new QTFile (new java.io.File ("audiograb.mov"));
if (grabFile.exists())
grabFile.delete();
grabber.setDataOutput(grabFile,
StdQTConstants.seqGrabToDisk
//seqGrabDontAddMovieResource);
);
grabber.startRecord();
inputDriver = soundChannel.getInputDriver();
inputDriver.setLevelMeterOnOff (true);
int[] levelTest = inputDriver.getActiveLevels();
System.out.println (levelTest.length + " active levels");
// set up thread to update level meter
ActionListener timerCallback =
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (grabbing) {
try {
grabber.idle();
audioLevelMeter.repaint();
} catch (QTException qte) {
qte.printStackTrace();
}
}
}
};
Timer timer = new Timer (50, timerCallback);
timer.start();