usar new icon example codigo borderfactory java audio javasound mixer channels

new - ¿Cómo obtengo el diseño de los canales Mixer en Java?



new icon java (2)

Pensé que podía encontrar algo en este gran sitio, pero ahora parezco enfrentar el problema sin respuesta :) ¡Por favor ayuda!

La cosa es que necesito reproducir hasta 6 archivos wav diferentes con 1 canal cada uno en 6 canales compatibles con el mezclador de sistema (izquierda, derecha, envolvente izquierda, etc.).

Usar 6 DataDataLines diferentes parece lógico, pero por lo que veo, Mixer no puede hacer la sincronización por muestra para ellos, así que se me ocurrió entrelazarlos en un hilo separado y usar solo una SourceDataLine para reproducirlo. Funciona bien para dos canales, izquierdo y derecho, pero para más canales necesito saber el diseño preciso de los canales (puede ser diferente en el sistema de diferencias y en las tarjetas de sonido). Pensé que uno de los Mezcladores de sistema (tengo dos: "entrada lineal" y "mezclador de sistema de sonido Java") podría tener estos metadatos, pero no puedo encontrarlo.

¿Alguien sabe cómo obtener esta información?

Gracias.


Mi amigo y yo descubrimos que el sistema de sonido java7 admite 6 canales y todas las variantes de su uso con diferentes bits, etc.

Aquí está el código para enumerar lo que su Java puede hacer:

Mixer.Info[] mi = AudioSystem.getMixerInfo(); for (Mixer.Info info : mi) { System.out.println("info: " + info); Mixer m = AudioSystem.getMixer(info); System.out.println("mixer " + m); Line.Info[] sl = m.getSourceLineInfo(); for (Line.Info info2 : sl) { System.out.println(" info: " + info2); Line line = AudioSystem.getLine(info2); if (line instanceof SourceDataLine) { SourceDataLine source = (SourceDataLine) line; DataLine.Info i = (DataLine.Info) source.getLineInfo(); for (AudioFormat format : i.getFormats()) { System.out.println(" format: " + format); } } } }

Esto se reproduce desde mi macbook pro con tarjeta de sonido externa conectada por USB:

info: Default Audio Device, version Unknown Version mixer com.sun.media.sound.DirectAudioDevice@67310bf info: interface SourceDataLine supporting 14 audio formats, and buffers of at least 32 bytes format: PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, format: PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, big-endian format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, big-endian format: PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, format: PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, big-endian format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian info: interface Clip supporting 14 audio formats, and buffers of at least 32 bytes info: Built-in Input, version Unknown Version mixer com.sun.media.sound.DirectAudioDevice@2edf98c4 info: Built-in Output, version Unknown Version mixer com.sun.media.sound.DirectAudioDevice@59a683e6 info: interface SourceDataLine supporting 14 audio formats, and buffers of at least 32 bytes format: PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, format: PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, big-endian format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, big-endian format: PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, format: PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, big-endian format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian info: interface Clip supporting 14 audio formats, and buffers of at least 32 bytes info: SB X-Fi Surround 5.1 Pro, version Unknown Version mixer com.sun.media.sound.DirectAudioDevice@431d9f05 info: interface SourceDataLine supporting 20 audio formats, and buffers of at least 32 bytes format: PCM_UNSIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, format: PCM_SIGNED unknown sample rate, 8 bit, mono, 1 bytes/frame, format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 16 bit, mono, 2 bytes/frame, big-endian format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 24 bit, mono, 3 bytes/frame, big-endian format: PCM_UNSIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, format: PCM_SIGNED unknown sample rate, 8 bit, stereo, 2 bytes/frame, format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 16 bit, stereo, 4 bytes/frame, big-endian format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 24 bit, stereo, 6 bytes/frame, big-endian format: PCM_UNSIGNED unknown sample rate, 8 bit, 6 channels, 6 bytes/frame, format: PCM_SIGNED unknown sample rate, 8 bit, 6 channels, 6 bytes/frame, format: PCM_SIGNED unknown sample rate, 16 bit, 6 channels, 12 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 16 bit, 6 channels, 12 bytes/frame, big-endian format: PCM_SIGNED unknown sample rate, 24 bit, 6 channels, 18 bytes/frame, little-endian format: PCM_SIGNED unknown sample rate, 24 bit, 6 channels, 18 bytes/frame, big-endian format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian format: PCM_SIGNED 48000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian info: interface Clip supporting 20 audio formats, and buffers of at least 32 bytes info: SB X-Fi Surround 5.1 Pro, version Unknown Version mixer com.sun.media.sound.DirectAudioDevice@4db323af info: Port Built-in Input, version Unknown Version mixer com.sun.media.sound.PortMixer@4b743fba info: Built-in Input source port info: Port Built-in Output, version Unknown Version mixer com.sun.media.sound.PortMixer@45d1edcc info: Port SB X-Fi Surround 5.1 Pro, version Unknown Version mixer com.sun.media.sound.PortMixer@59530fe3 info: Port SB X-Fi Surround 5.1 Pro, version Unknown Version mixer com.sun.media.sound.PortMixer@5c382de5 info: SB X-Fi Surround 5.1 Pro source port


Sí, es una vieja pregunta, pero como estaba buscando todos los canales, profundidades, etc., decidí escribir un pequeño método de depuración que es útil si quieres ver más detalles y me gustaría usar 8 streams de Java :-)

Disfrutar:

//filter may be all if you want to include microphone public void getDeviceInfos(String filter) { Stream .of(AudioSystem.getMixerInfo()) .forEach(info -> { System.out.println("Mixer Name: " + info.getName()); System.out.println("Mixer Description: " + info.getDescription()); System.out.println("Mixer Vendor: " + info.getVendor()); Mixer m = AudioSystem.getMixer(info); Stream .of(Arrays.asList(m.getSourceLineInfo()), filter.equals("record") ? Arrays.asList(m.getTargetLineInfo()) : null) .flatMap(List::stream) .collect(Collectors.toList()) .forEach(lineInfo -> { System.out.println(" info: " + lineInfo); try { Line line = AudioSystem.getLine(lineInfo); if (line instanceof SourceDataLine || line instanceof TargetDataLine) { Arrays.asList(((DataLine.Info) line.getLineInfo()).getFormats()).forEach(format -> { System.out.println("Channels: " + format.getChannels()); System.out.println("Size in Bits: " + format.getSampleSizeInBits()); System.out.println("Frame Rate: " + format.getFrameRate()); System.out.println("Frame Size: " + format.getFrameSize()); System.out.println("Encoding: " + format.getEncoding()); System.out.println("Sample Rate: " + format.getSampleRate()); }); } } catch (Exception ex) { ex.printStackTrace(); } }); }); }