Comments (6)
Below a test program and output when no USB sound cards are connected. Then both index 0 (default_ and 1 (plughw:0,0) will work. Maybe with internal sound card both work and with USB sound cards only default when that is set? Can test by plugging USB sound card and changing back default output.
Maybe use this pseudo code:
- find right plughw
a. if works, fine
b. if not works, try default instead
Test program:
public static void main(String[] args) throws Exception {
for (int i = 0; i < AudioSystem.getMixerInfo().length; i++) {
System.out.println(AudioSystem.getMixerInfo()[i].getName());
for (int k : new int[] { 8, 11, 22, 32, 44, 48 }) {
File url = new File("/home/emulder/Downloads/game-music-mono-" + k + "k.wav");
final AudioInputStream stream = AudioSystem.getAudioInputStream(url);
AudioFormat inputFormat = stream.getFormat();
// Explicitly set to stereo to control each speaker individually.
AudioFormat outputFormat = new AudioFormat(inputFormat.getEncoding(), inputFormat.getSampleRate(), inputFormat.getSampleSizeInBits(),
2, 4, inputFormat.getFrameRate(), inputFormat.isBigEndian());
try {
Mixer.Info[] q = AudioSystem.getMixerInfo();
SourceDataLine line = AudioSystem.getSourceDataLine(outputFormat, AudioSystem.getMixerInfo()[i]);
// SourceDataLine line = (SourceDataLine) mixer.getLine(new DataLine.Info(SourceDataLine.class, format));
line.open();
line.close();
System.out.println(" OK : [" + i + "] - " + k);
} catch (IllegalArgumentException e) {
System.out.println("FAIL: [" + i + "] - " + k);
}
}
}
}
Output:
default [default]
OK : [0] - 8
OK : [0] - 11
OK : [0] - 22
OK : [0] - 32
OK : [0] - 44
OK : [0] - 48
PCH [plughw:0,0]
OK : [1] - 8
OK : [1] - 11
OK : [1] - 22
OK : [1] - 32
OK : [1] - 44
OK : [1] - 48
PCH [plughw:0,3]
OK : [2] - 8
OK : [2] - 11
OK : [2] - 22
OK : [2] - 32
OK : [2] - 44
OK : [2] - 48
PCH [plughw:0,7]
OK : [3] - 8
OK : [3] - 11
OK : [3] - 22
OK : [3] - 32
OK : [3] - 44
OK : [3] - 48
PCH [plughw:0,8]
OK : [4] - 8
OK : [4] - 11
OK : [4] - 22
OK : [4] - 32
OK : [4] - 44
OK : [4] - 48
Port PCH [hw:0]
FAIL: [5] - 8
FAIL: [5] - 11
FAIL: [5] - 22
FAIL: [5] - 32
FAIL: [5] - 44
FAIL: [5] - 48
from immerse.
Actually without the USB sound cards it was the case. It seemed not, but that was because the default was not the internal sound card, but some 'Dummy device' that popped up somewhere during testing. So the behavior is consistent.
from immerse.
New output when running without dummy device (plughw:0,0 is default others are HDMI devices):
default [default]
OK : [0] - 8
OK : [0] - 11
OK : [0] - 22
OK : [0] - 32
OK : [0] - 44
OK : [0] - 48
PCH [plughw:0,0]
FAIL: [1] - 8
FAIL: [1] - 11
FAIL: [1] - 22
FAIL: [1] - 32
FAIL: [1] - 44
FAIL: [1] - 48
PCH [plughw:0,3]
OK : [2] - 8
OK : [2] - 11
OK : [2] - 22
OK : [2] - 32
OK : [2] - 44
OK : [2] - 48
PCH [plughw:0,7]
OK : [3] - 8
OK : [3] - 11
OK : [3] - 22
OK : [3] - 32
OK : [3] - 44
OK : [3] - 48
PCH [plughw:0,8]
OK : [4] - 8
OK : [4] - 11
OK : [4] - 22
OK : [4] - 32
OK : [4] - 44
OK : [4] - 48
Port PCH [hw:0]
FAIL: [5] - 8
FAIL: [5] - 11
FAIL: [5] - 22
FAIL: [5] - 32
FAIL: [5] - 44
FAIL: [5] - 48
from immerse.
Hmm, after a few trial runs it seems like when opening the default internal audio device sometimes it throws an exception and sometimes is doesn't. But with the current code that is ok, since it will work both ways.
from immerse.
Could it be related to the order in which lines are opened? Cause the sound cards are in a set it can vary. With the index 0 not being first it works (one test):
NOT an exception for systemMixerInfo: Set [plughw:2,0], version 4.8.0-040800-generic
NOT an exception for systemMixerInfo: PCH [plughw:0,0], version 4.8.0-040800-generic
NOT an exception for systemMixerInfo: Device [plughw:1,0], version 4.8.0-040800-generic
Another:
NOT an exception for systemMixerInfo: Device [plughw:1,0], version 4.8.0-040800-generic
NOT an exception for systemMixerInfo: PCH [plughw:0,0], version 4.8.0-040800-generic
NOT an exception for systemMixerInfo: Set [plughw:2,0], version 4.8.0-040800-generic
Hmm no, wrong again:
NOT an exception for systemMixerInfo: PCH [plughw:0,0], version 4.8.0-040800-generic
NOT an exception for systemMixerInfo: Set [plughw:2,0], version 4.8.0-040800-generic
NOT an exception for systemMixerInfo: Device [plughw:1,0], version 4.8.0-040800-generic
from immerse.
Newer testing shows very consistent behavior: the device that is set to be the OS default will always throw an exception and work when using 'null' for the default. So taking that as a 'known issue' for now in the code and documentation. If any future tests show otherwise, a new issue (bug) can be created for that.
from immerse.
Related Issues (20)
- AudioInputBuffer should actively keep live streams in sync HOT 1
- Support all audio formats for live streams HOT 3
- Refactor out input/output flag in ImmerseAudioFormat
- Can Url and Supplied Audio Resources still be live? HOT 1
- Research Java Sound API behaviour of different microphones HOT 3
- Research detailed behaviour of SourceDataLine HOT 8
- Refactor UdpAudioResource to better handle the many parameters
- Implement own audio format converters that use minimal amount of buffering
- General volume feature for every playback HOT 1
- Now that we have DynamicData for all ScenarioSettings with time state, can we get rid of the Factory stuff?
- Generify some DynamicData stuff in ActiveScenario?
- Measure delay in DynamicData start time and real audio start time and consider refactor
- Re-research right internal OS buffer size for all systems HOT 1
- Bug: playback randomly stops after heavy stuttering HOT 2
- Is dynamic volume setting linear?
- Does dragon wings file cause ticks in plackback because of overflow in Audacity? HOT 2
- Research and fix weird indexoutofbounds bug
- Is stopping playback a source of hickups?
- Bug: AudioInputBuffer ArrayIndexOutOfBounds
- Performance issue: playing through adventure service is much heavier on CPU than local HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immerse.