Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How playback audio data with several audio card's simultaneously uses LWJGL  (Read 19842 times)
0 Members and 1 Guest are viewing this topic.
Offline aurusd

Junior Newbie





« Posted 2016-03-29 09:14:17 »

I need to play audio data with several audio card's simultaneously. For begin I don't know how change audio device with method

AL.create("DirectSound3D", 44100, 15, false);

for use another audio card in PC. Maybe someone know how can realize this issue Angry
Offline ziozio
« Reply #1 - Posted 2016-03-29 13:49:32 »

Using lwjgl3 I use this method to create a context

device=ALDevice.create(...);
context=ALContext.create(device);

You can therefore create multiple contexts on multiple devices
Offline aurusd

Junior Newbie





« Reply #2 - Posted 2016-03-30 08:03:34 »

Thanks's for answer.
You can show sample code how create multiple contexts on multiple devices and play audio data on 2 soundcard's?
context=ALContext.create(device); device where i can see name of my device (for example second sound card)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ziozio
« Reply #3 - Posted 2016-03-30 18:23:33 »

Hi

looks like there is a bit more work!

1  
2  
3  
4  
5  
6  
7  
8  
9  
            String deviceList = ALC10.alcGetString(sound.ALC_DEVICE_SPECIFIER);
            System.out.println("Device["+deviceList+"]");
            String captureDeviceList = sound.alcGetString(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER);
            System.out.println("Capture Device["+captureDeviceList+"]");
           
            long device  = ALC10.alcOpenDevice(deviceList);
            long context = ALC10.alcCreateContext(device, null);          
            boolean success =  ALC10.alcMakeContextCurrent(context);
            System.out.println(success);


The device list and captureList are a null separated list, I only have 1 sound card so can't test. Tell me how it goes.

This is my output

Device[OpenAL Soft]
Capture Device[Built-in Audio Analogue Stereo]
true
Offline aurusd

Junior Newbie





« Reply #4 - Posted 2016-03-31 05:57:51 »

Ok, thank's for help, will try today at work, with usb sound card Smiley and reply to you
Offline aurusd

Junior Newbie





« Reply #5 - Posted 2016-04-04 13:15:09 »

Sorry for long answer.
I have use'd some same code before, but have error. Your code i use like

        String deviceList = ALC10.alcGetString(null, ALC10.ALC_ALL_ATTRIBUTES);
        System.out.println("Device["+deviceList+"]");
        String captureDeviceList = ALC10.alcGetString(null, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER);
        System.out.println("Capture Device["+captureDeviceList+"]");
        
        ALCdevice device  = ALC10.alcOpenDevice(deviceList);
        ALCcontext context = ALC10.alcCreateContext(device, null);          
        int success =  ALC10.alcMakeContextCurrent(context);
        System.out.println(success);

Have exception in thread "JavaFX Application Thread"  WARN 2016-04-04 16:05:17,979    SystemErr - Exception in thread "JavaFX Application Thread"
 WARN 2016-04-04 16:05:17,979    SystemErr - org.lwjgl.openal.OpenALException: Invalid Enum
 WARN 2016-04-04 16:05:17,979    SystemErr -    at org.lwjgl.openal.Util.checkALCError(Util.java:55)
 WARN 2016-04-04 16:05:17,979    SystemErr -    at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:156)
in this line String deviceList = ALC10.alcGetString(null, ALC10.ALC_ALL_ATTRIBUTES);
what is sound variable in your code? (ALDevice sound = ALDevice.create()Wink
And ALC10.alcGetString() has two parameter's, in your code only one, how it could be?
Offline ziozio
« Reply #6 - Posted 2016-04-04 17:59:44 »

I believe I missed off a static reference when I posted my code, you can use

1  
ALC10.ALC_DEVICE_SPECIFIER


instead of

1  
sound.ALC_DEVICE_SPECIFIER


where as you use

1  
ALC10.ALC_ALL_ATTRIBUTES


I beleive your code doesn't work with getString.
Offline aurusd

Junior Newbie





« Reply #7 - Posted 2016-04-05 13:51:02 »

I believe you are right.
Use your code like
1  
2  
3  
4  
String deviceList = ALC10.alcGetString(null,ALC10.ALC_DEVICE_SPECIFIER);
System.out.println("Device["+deviceList+"]");
String captureDeviceList = ALC10.alcGetString(null,ALC11.ALC_CAPTURE_DEVICE_SPECIFIER);
System.out.println("Capture Device["+captureDeviceList+"]");

but have Exception in thread "main" java.lang.UnsatisfiedLinkError: org.lwjgl.openal.ALC10.nalcGetString(JI)Ljava/nio/ByteBuffer;
Problem with alcGetString, as you said before
Try to enumerate audio device
1  
2  
3  
4  
5  
6  
7  
8  
System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER));
      if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
           String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
      System.out.println("Available devices: ");
           for(int i=0; i<devices.length; i++) {
              System.out.println(i +": " + devices[i]);
           }
        }

result is:
1  
2  
3  
Available devices:  INFO 2016-04-05 16:45:58,309    SystemOut - Available devices: 

0: OpenAL Soft INFO 2016-04-05 16:45:58,309    SystemOut - 0: OpenAL Soft

If use System.out.println("Default device: " + ALC10.alcGetString(null, ALC11.ALC_ALL_DEVICES_SPECIFIER)); insted System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER));
result is
1  
2  
3  
4  
5  
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.nio.charset.MalformedInputException: Input length = 1
   at org.lwjgl.MemoryUtil.decodeImpl(MemoryUtil.java:336)
   at org.lwjgl.MemoryUtil.decode(MemoryUtil.java:305)
   at org.lwjgl.MemoryUtil.decodeUTF8(MemoryUtil.java:294)
   at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:157)

Test in condition when used 2 card's (one sound usb). How to resolve this issue... Huh
Offline aurusd

Junior Newbie





« Reply #8 - Posted 2016-04-07 05:59:17 »

This code have exception too..
1  
2  
3  
4  
5  
      String[] devices = ALC10.alcGetString(AL.getDevice(), ALC11.ALC_ALL_DEVICES_SPECIFIER).split("\0"); // -- in this line
      System.out.println("Available devices: ");
      for(int i=0; i<devices.length; i++) {
         System.out.println(i +": " + devices[i]);
      }

1  
2  
3  
4  
5  
Exception in thread "main" java.lang.RuntimeException: java.nio.charset.MalformedInputException: Input length = 1
   at org.lwjgl.MemoryUtil.decodeImpl(MemoryUtil.java:336)
   at org.lwjgl.MemoryUtil.decode(MemoryUtil.java:305)
   at org.lwjgl.MemoryUtil.decodeUTF8(MemoryUtil.java:294)
   at org.lwjgl.openal.ALC10.alcGetString(ALC10.java:157)
Offline ziozio
« Reply #9 - Posted 2016-04-07 17:56:32 »

@spasi

Is this exception caused by something LWJGL is doing?

@aurusd

If you don't hear from spasi here you might want to post the exceptions in the LWJGL forums or on the github issues list.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Spasi
« Reply #10 - Posted 2016-04-07 22:14:04 »

The ALC_ALL_DEVICES_SPECIFIER query returns a null-terminated list of null-terminated strings, but the normal alcGetString can only handle a normal string. LWJGL provides the ALUtil.getStringList() method for this special case. The alcGetString javadoc mentions this.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
Ecumene (56 views)
2017-09-30 02:57:34

theagentd (79 views)
2017-09-26 18:23:31

cybrmynd (187 views)
2017-08-02 12:28:51

cybrmynd (185 views)
2017-08-02 12:19:43

cybrmynd (192 views)
2017-08-02 12:18:09

Sralse (202 views)
2017-07-25 17:13:48

Archive (758 views)
2017-04-27 17:45:51

buddyBro (892 views)
2017-04-05 03:38:00

CopyableCougar4 (1441 views)
2017-03-24 15:39:42

theagentd (1324 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!