Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
Java in General
Java Sound (GNU/Linux & alsa): can't get a line
Edmundo Carmona
Greenhorn
Posts: 3
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How can I get a line on GNU/linux with alsa?
Here's the
testing
code I'm using:
// audio format AudioFormat format = new AudioFormat(44100f, 16, 2, true, false); System.out.println("Sound Format: " + format); DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); SourceDataLine line = null; Mixer.Info [] mixerInfo = AudioSystem.getMixerInfo(); // Let's look for a line that supports our DataLine.Info Mixer mixer; for (int i = 0; line == null && i < mixerInfo.length; i++) { mixer = AudioSystem.getMixer(mixerInfo[i]); System.out.println("Mixer: " + mixerInfo[i].getName() + ": " + mixerInfo[i].getDescription()); try { line = (SourceDataLine) mixer.getLine(info); if (!line.getLineInfo().matches(info)) { System.out.println("The line doesn't match the format!"); line = null; } } catch (LineUnavailableException e) { System.out.println("Line Unavailable!"); line = null; } catch (IllegalArgumentException e) { System.out.println("Illegal Argument!"); line = null; } System.out.println(); } if (line == null) { System.out.println("No line was found"); System.exit(1); } else { System.out.println("Line found!"); }
Here's the output when I run it:
Sound Format: PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian Mixer: ICH5 [plughw:0,0]: Direct Audio Device: Intel ICH5, Intel ICH, Intel ICH5 Illegal Argument! Mixer: ICH5 [plughw:0,1]: Direct Audio Device: Intel ICH5, Intel ICH - MIC ADC, Intel ICH5 - MIC ADC Illegal Argument! Mixer: ICH5 [plughw:0,2]: Direct Audio Device: Intel ICH5, Intel ICH - MIC2 ADC, Intel ICH5 - MIC2 ADC Illegal Argument! Mixer: ICH5 [plughw:0,3]: Direct Audio Device: Intel ICH5, Intel ICH - ADC2, Intel ICH5 - ADC2 Illegal Argument! Mixer: ICH5 [plughw:0,4]: Direct Audio Device: Intel ICH5, Intel ICH - IEC958, Intel ICH5 - IEC958 The line doesn't match the format! Mixer: Java Sound Audio Engine: Software mixer and synthesizer The line doesn't match the format! Mixer: Port ICH5 [hw:0]: Intel ICH5, Realtek ALC202 rev 0 Illegal Argument! Couldn't find a line
It fails with little-endian and big-endian formats. How can I solve this?
Bring out your dead! Or a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Digital Signal Processing (DSP, FFT, Spectrum)
Question about inheritance
Baffled with IllegalArgumentException
Play a .wav file
Java Sound API
More...