Click here to register.

Edit Message

Visitor Name
Subject
Message

Re: No sound

Hi Sergey,

>it looks like Java does not care about GNOME or KDE or ALSA or OSS

>defaults. Even worse, I don't think Java has a mechanism to assign the

>defaults at all. It leaves it up to the program.

The relevant code in the Speech Submission app is as follows: 

Declarations: 

public static final String fileType = "wav";    
public static final int samplingRate = 48000;// jre 1.4.2 only supports max of 44100
public static final int samplingRateFormat = 16;     
public static final int numberChannels = 1;     
   
AudioFormat format = new AudioFormat(samplingRate, samplingRateFormat, numberChannels, true, false);

From the Capture class:

public void run() {

... 

DataLine.Info info = new DataLine.Info(TargetDataLine.class,format); 

... 

line = (TargetDataLine) AudioSystem.getLine(info); 

line.open(format, line.getBufferSize()); 

... 

while (thread != null) {
    if((numBytesRead = line.read(data, 0, bufferLengthInBytes)) == -1) {
       break;
    }
    totalBytesWritten += numBytesRead;
    out.write(data, 0, numBytesRead);
    outbaos.write(data, 0, numBytesRead);
}

The getLine method from the AudioSystem class has this in its documentation:

Obtains a line that matches the description in the specified Line.Info object.  If a DataLine is requested, and info is an instance of DataLine.Info specifying at least one fully qualified audio format, the last one will be used as the default format of the returned DataLine. If system properties javax.sound.sampled.Clip, javax.sound.sampled.Port, javax.sound.sampled.SourceDataLine and javax.sound.sampled.TargetDataLine are defined or they are defined in the file "sound.properties", they are used to retrieve default lines. For details, refer to the class description. If the respective property is not set, or the mixer requested in the property is not installed or does not provide the requested line, all installed mixers are queried for the requested line type. A Line will be returned from the first mixer providing the requested line type. 

My sound.properties file is located in "/usr/java/jre1.6.0_03/lib" (Fedora FC6). 

To determine the device number for your USB card, execute the following (more info in this FAQ):

$ arecord --list-devices

You should get a listing similar to this:

[...]

card 1: default [Samson C01U ], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

This says that the USB microphone is is on card 1, device 0.   Based on this post (and this one)you might need to update your sound.properties file to something like this:

javax.sound.sampled.TargetDataLine=#AudioPCI [plughw:1,0] 

 

Other information: 

The sound.properties configuration file allows choice of default devices (RFE 4776511). For details, see MidiSystem and AudioSystem for details;

 

Another Approach:

From this document on Sun's web site (6.  Troubleshooting Java Sound): 

6.1 System Sound Configuration

Make sure that your audio system is correctly configured (sound card driver/DirectSound for Windows, ALSA or OSS for Linux, OSS or Audio Mixer for Solaris OS). In addition, ensure that your speakers are connected and that your sound card volume and mute state are adjusted to the appropriate value. To test your sound configuration, run any native sound application and play some sound through it.

On Solaris OS and Linux, you might be unable to play sounds because an application (or sound daemon, such as esd or artsd) opens the audio device exclusively, thereby denying Java Sound access to the device.

So killing your sound daemon before going to the SpeecSubmission app might help too.

Ken