Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setting audio devices (long)



see apart from
spbDevice.getInputSourceNames();
if there's some
spbDevice.getInputSources();

if there's a
mAudio.setDevice(String)
indeed, that String might mean something else than a name

you could do
mAudio.setDevice(getInputSources()[index])
once the user selected some name from the
getInputSourceNames() array result (you get index of user
selection)

just a guess,
George

> Hi there,
>
> I am writing a multi-track audio recording application in
Javausing
> QTJava (OS X 10.2.3, Java 1.4.1 DP 9 installed, but I'm
using 1.3.1 for
> QT to work) - until now with limited success. I have come
across
> problems I cannot solve (this is only one of them...):
>
> * how can I set the audio device with which to record from
the
> application?
>
> I have included a code fragment of a MyRecorder class that
does nothing
> else but list and try to set the audio input drivers.
>
> Here's an example:
>
> Whenever I try to set a device corresponding to a driver,
QT throws an
> exception although it lists the devices as present in the
preceding
> code.
> On my PowerBook, the "Built-in audio controller" has four
devices, and
> the "iMic USB audio system" only one, as can be seen in
the following
> printout:
>
> --- 0 ----------
> Input Driver : Built-in audio controller
> Sound Input Parameters: 16, 2, 1918990112
> Sound Input Rate : 44100.0
> Input device[0] : External microphone/Line In
> Input device[1] : Sound Input
> Input device[2] : Zoomed Video
> Input device[3] : Internal microphone
> Selected device : 1, Sound Input
> Channels avail, in use: 2, 2
>
> --- 1 ----------
> Input Driver : iMic USB audio system
> Sound Input Parameters: 16, 2, 1918990112
> Sound Input Rate : 44100.0
> Input device[0] : iMic USB audio system
> Selected device : 0, iMic USB audio system
> Channels avail, in use: 2, 2
>
> Now, if I try to change the device to e.g. "Internal
microphone" using
> the setDevice() method with a device name, I get
"BadSoundInDevice" and
> "badComponentInstance" exceptions. Using the setDevice()
method with a
> driver name, e.g. "Built-in..." or "iMic..." does not
cause an
> exception, but it also does not allow me to change my
settings!
>
> *** What am I doing wrong here? **********
>
> Any help is greatly appreciated!
>
> Christoph
>
> ---------- Here's the code (MyRecorder.java)
> --------------------------------------------------
>
> import quicktime.*;
> import quicktime.std.sg.*;
> import quicktime.sound.*;
> import quicktime.std.StdQTConstants;
>
> public class MyRecorder implements StdQTConstants {
>
> private SGSoundChannel audio;
> private SequenceGrabber grabber;
>
> private Grabber grab_1;
> private Grabber grab_2;
>
> MyRecorder(String driver0, String driver1) {
> try {
> QTSession.open();
>
> grabber = new SequenceGrabber();
>
> grab_1 = new Grabber (driver0, 0, grabber);
> grab_2 = new Grabber (driver1, 1, grabber);
>
> } catch (QTException e) {
> System.out.println(e);
> e.printStackTrace();
> QTSession.close();
> }
> }
>
> public static void main (String [] args) {
> new MyRecorder(args[0], args[1]);
> }
> }
>
>
> class Grabber implements StdQTConstants {
>
> private SGSoundChannel mAudio;
> private SequenceGrabber mGrabber;
> private SPBDevice spbDevice;
>
> private String driver;
> private int devIndex;
>
> public Grabber(String drv, int index, SequenceGrabber
grab) {
> mGrabber = grab;
> driver = drv;
> devIndex = index;
> try {
> createSGObject();
> } catch (Exception ee){
> ee.printStackTrace();
> QTSession.close();
> }
> }
>
> public void createSGObject() throws QTException {
>
> mAudio = new SGSoundChannel (mGrabber);
> mAudio.setUsage (seqGrabRecord);
> mAudio.setInputDriver(driver);
>
> spbDevice = mAudio.getInputDriver();
> String [] inputSourceNames =
spbDevice.getInputSourceNames();
>
> System.out.println ("\n--- " + devIndex + " ----------");
> System.out.println ("Input Driver : " +
> mAudio.getInputDriver().getName());
> System.out.println ("Sound Input Parameters: " +
> mAudio.getSoundInputParameters().mSampleSize + ", " +
> mAudio.getSoundInputParameters().mNumChannels + ", " +
> mAudio.getSoundInputParameters().mCompressionType);
> System.out.println ("Sound Input Rate : " +
> mAudio.getSoundInputRate());
> for(int i = 0; i < inputSourceNames.length; i++) {
> System.out.println("Input device[" + i + "] : " +
> inputSourceNames[i]);
> }
> System.out.println ("Selected device : " +
> (spbDevice.getInputSource() - 1) + ", " +
> inputSourceNames[spbDevice.getInputSource() - 1]);
> System.out.println ("Channels avail, in use: " +
> spbDevice.getChannelAvailable() + ", " +
spbDevice.getNumberChannels());
>
> // does not work
>
//mAudio.setInputDriver(inputSourceNames[spbDevice.getInputS
ource() -
> 1]);
> // works
> //mAudio.setDevice(driver);
> // does not work
>
mAudio.setDevice(inputSourceNames[spbDevice.getInputSource()
- 1]);
> }
> }
_______________________________________________
quicktime-java mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/quicktime-java
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.