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  
  Capturing and alcCaptureOpenDevice  (Read 5911 times)
0 Members and 1 Guest are viewing this topic.
Offline Tramboturbiener

Junior Newbie

« Posted 2007-08-17 22:58:40 »

I have tried to use capturing with this code:

        AL al = ALFactory.getAL();
        ALC alc = ALFactory.getALC();

        int size = 4010;
        byte[] buffer = new byte[size];

        ALCdevice device =
                alc.alcCaptureOpenDevice(buffer, 22050, AL.AL_FORMAT_MONO16, size, 0);

        int error = alc.alcGetError(device);

        System.out.println("Error ?:  " + alc.alcGetString(null, alc.alcGetError(device)));


But I got a Invalid Device Error. The question is whether the parameters for the mehtod alcCaptureOpenDevice are correct. There is no way to define a device in this method. In the OpenAL 1.1 Spec parameters looks like this:

ALCdevice* alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint freq, ALCenum fmt, ALCsizei bufsize);

and in JOAL:

alcCaptureOpenDevice(byte[], int0, int1, int2, int3) (a parameter for deviceName is missing)

What should I do to get this work? I hope its not a bug...
Offline Ultraq

Junior Devvie

That's what she said

« Reply #1 - Posted 2007-08-18 02:49:57 »

The first parameter of alcCaptureOpenDevice, is the device name.  JOAL provides 2 variants:

ALCdevice alcCaptureOpenDevice(byte[] devicename, int devicename_offset, int frequency, int format, int buffersize)
ALCdevice alcCaptureOpenDevice(ByteBuffer devicename, int frequency, int format, int buffersize)

According to the OpenAL 1.1 programmers guide, the byte[] or ByteBuffer is actually a device name String. (it's normally ALCchar*, but char* gets converted to byte[] and ByteBuffer).  I think you'll have to get the device name, convert it to the character bytes, but be sure that you convert to 8-bit characters, not the default 16-bit unicode characters of Java (there are methods in the Java API to do this).

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Offline Tramboturbiener

Junior Newbie

« Reply #2 - Posted 2007-08-18 21:00:16 »

Thx Ultraq for your reply. Well, I have changed my code:
        int size = 10000;
        byte[] buffer = new byte[size];
        ByteBuffer b = ByteBuffer.wrap(alc.alcGetString(null, ALC.ALC_CAPTURE_DEVICE_SPECIFIER);  // SB Audigy Adio [FF80]

        ALCdevice device = alc.alcCaptureOpenDevice(b, 22050, al.AL_FORMAT_MONO16, size);


But it does not work. I get the same error: "Invalid Device". Do I anything wrong? Any ideas?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ultraq

Junior Devvie

That's what she said

« Reply #3 - Posted 2007-08-20 01:50:44 »

The bytes in the ByteBuffer, are they representing 16-bit character strings (can check by looking at every alternating byte and seeing if it's 0x00)?  Since the OpenAL function requires an ALCchar (8-bit characters), you'll need to do some conversion.  Unfortunately, I don't have an IDE set up where I am right now, but my guess is you'll have to do something like this:

String deviceString16 = alc.alcGetString(null, ALC_CAPTURE_DEVICE_SPECIFIER);
byte[] deviceChars8 = device16.getBytes("US_ASCII");

ALCdevice device = alc.alcCaptureOpenDevice(deviceChars8, 22050, AL_FORMAT_MONO16, size);

[EDIT]: Looking at the public API of JOAL, there's also an ALC.alcgetStringImpl() which returns a ByteBuffer.  Maybe that retains the 8-bit characters for you, which you can feed into alcCaptureOpenDevice(ByteBuffer, ...) ?

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

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

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

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

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

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

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

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

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

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

theagentd (1316 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 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‑
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!