Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
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 3944 times)
0 Members and 1 Guest are viewing this topic.
Offline Tramboturbiener

Junior Newbie





« Posted 2007-08-18 00:58:40 »

I have tried to use capturing with this code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
        ALut.alutInit();
        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 Member




That's what she said


« Reply #1 - Posted 2007-08-18 04: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 23: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 Member




That's what she said


« Reply #3 - Posted 2007-08-20 03: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (22 views)
2014-04-15 18:08:23

BurntPizza (17 views)
2014-04-15 03:46:01

UprightPath (31 views)
2014-04-14 17:39:50

UprightPath (15 views)
2014-04-14 17:35:47

Porlus (31 views)
2014-04-14 15:48:38

tom_mai78101 (57 views)
2014-04-10 04:04:31

BurntPizza (115 views)
2014-04-08 23:06:04

tom_mai78101 (214 views)
2014-04-05 13:34:39

trollwarrior1 (182 views)
2014-04-04 12:06:45

CJLetsGame (189 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!