Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: java sound error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: java sound error



HM wrote:

>java.lang.IllegalArgumentException: No line matching
>interface TargetDataLine supporting format PCM_SIGNED, 8000.0 Hz, 8 bit,
>mono, audio data is supported.

Your code blindly assumes a specific format will always be supported by
JavaSound.  That's not true.

JavaSound allows a platform or implementation to support only a limited
number of formats, and to support different ones on input or output.
That's why you should always ask for what's available, and then attempt to
match your request to that, rather than just failing when a specific format
isn't available.

The format limitations can be in any or all of the parameters: sample rate,
sample size, numeric representation, mono/stereo, etc.

On Mac OS X, the input lines support only 44.1KHz sample rate.  On Windows
and Linux, it's otherwise.  The information you need is available from
JavaSound, but you have to write your code to ask for it.

Here's the output from a little describer I wrote in Java.  This is a
pretty simple program, and only makes normal JavaSound references, yet all
the information is visible.

#####
  ..OS: Mac OS X, 10.3.5
  Java: 1.4.2_05-141.3
#####
Supported conversions:
  PCM_SIGNED to: ULAW PCM_SIGNED ALAW PCM_UNSIGNED
  PCM_UNSIGNED to: PCM_SIGNED PCM_UNSIGNED
  ALAW to: ALAW PCM_SIGNED
  ULAW to: ULAW PCM_SIGNED
#####
Mixer #1: com.sun.media.sound.HeadspaceMixer
  Java Sound Audio Engine, version 1.0
  supported Lines:
    interface SourceDataLine: 32 at once
    interface Clip: 32 at once
  ctrls: 1
    EnumControl: com.sun.media.sound.HeadspaceMixer$MixerReverbControl
      Reverb with current value: Acoustic Lab, early reflection delay 2000
ns, early reflection intensity -2.0 dB, late deflection delay 8000 ns, late
reflection intensity -3.0 dB, decay time 280000
  source lines: 2
    class: com.sun.media.sound.MixerSourceLine
     kind: SourceDataLine
     info: interface SourceDataLine supporting 8 audio formats
    formats: 8
      PCM_SIGNED, -1.0 Hz, 8 bit, mono, audio data
      PCM_UNSIGNED, -1.0 Hz, 8 bit, mono, audio data
      PCM_SIGNED, -1.0 Hz, 8 bit, stereo, audio data
      PCM_UNSIGNED, -1.0 Hz, 8 bit, stereo, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, mono, little-endian, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, mono, big-endian, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, stereo, little-endian, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, stereo, big-endian, audio data
    ctrls: 4
      FloatControl:
com.sun.media.sound.MixerSourceLine$MixerSourceLineGainControl
        Master Gain with current value: 0.0 dB (range: -80.0 - 13.9794)
      BooleanControl:
com.sun.media.sound.MixerSourceLine$MixerSourceLineMuteControl
        Mute Control with current value: False
      FloatControl:
com.sun.media.sound.MixerSourceLine$MixerSourceLinePanControl
        Pan with current value: 0.0  (range: -1.0 - 1.0)
      FloatControl:
com.sun.media.sound.MixerSourceLine$MixerSourceLineSampleRateControl
        Sample Rate with current value: 44100.0 FPS (range: 0.0 - 48000.0)
    ---
    class: com.sun.media.sound.MixerClip
     kind: Clip
     info: interface Clip supporting 8 audio formats, and buffers of 0 to
4194304 bytes
    formats: 8
      PCM_SIGNED, -1.0 Hz, 8 bit, mono, audio data
      PCM_UNSIGNED, -1.0 Hz, 8 bit, mono, audio data
      PCM_SIGNED, -1.0 Hz, 8 bit, stereo, audio data
      PCM_UNSIGNED, -1.0 Hz, 8 bit, stereo, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, mono, little-endian, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, mono, big-endian, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, stereo, little-endian, audio data
      PCM_SIGNED, -1.0 Hz, 16 bit, stereo, big-endian, audio data
    ctrls: 4
      FloatControl: com.sun.media.sound.MixerClip$MixerClipGainControl
        Master Gain with current value: 0.0 dB (range: -80.0 - 13.9794)
      BooleanControl: com.sun.media.sound.MixerClip$MixerClipMuteControl
        Mute Control with current value: Not Mute
      FloatControl: com.sun.media.sound.MixerClip$MixerClipPanControl
        Pan with current value: 0.0  (range: -1.0 - 1.0)
      FloatControl: com.sun.media.sound.MixerClip$MixerClipSampleRateControl
        Sample Rate with current value: 44100.0 FPS (range: 0.0 - 48000.0)
    ---
  target lines: 0
#####
Mixer #2: com.sun.media.sound.SimpleInputDevice
  Mac OS X,CoreAudio,Audio hardware, version Unknown Version
  supported Lines:
    interface TargetDataLine: -1 at once
  ctrls: 0
  source lines: 0
  target lines: 1
    class: com.sun.media.sound.SimpleInputDevice$InputDeviceDataLine
     kind: TargetDataLine
     info: interface TargetDataLine supporting 8 audio formats
    formats: 8
      PCM_SIGNED, 44100.0 Hz, 8 bit, mono, audio data
      PCM_UNSIGNED, 44100.0 Hz, 8 bit, mono, audio data
      PCM_SIGNED, 44100.0 Hz, 16 bit, mono, big-endian, audio data
      PCM_SIGNED, 44100.0 Hz, 16 bit, mono, little-endian, audio data
      PCM_SIGNED, 44100.0 Hz, 8 bit, stereo, audio data
      PCM_UNSIGNED, 44100.0 Hz, 8 bit, stereo, audio data
      PCM_SIGNED, 44100.0 Hz, 16 bit, stereo, big-endian, audio data
      PCM_SIGNED, 44100.0 Hz, 16 bit, stereo, little-endian, audio data
    ctrls: 0
    ---

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.