@Override public void stop() { if (inputDevice != null) { ALC11.alcCaptureCloseDevice(inputDevice); inputDevice = null; } inputDeviceInitialized = false; captureBuffer = null; super.stop(); }
public int hleAudioInputBlocking(int maxSamples, int frequency, TPointer buffer) { if (!inputDeviceInitialized) { IntBuffer majorVersion = BufferUtils.createIntBuffer(1); IntBuffer minorVersion = BufferUtils.createIntBuffer(1); ALC10.alcGetInteger(null, ALC10.ALC_MAJOR_VERSION, majorVersion); ALC10.alcGetInteger(null, ALC10.ALC_MINOR_VERSION, minorVersion); log.info(String.format("OpenAL Version %d.%d, extensions %s", majorVersion.get(0), minorVersion.get(0), ALC10.alcGetString(null, ALC10.ALC_EXTENSIONS))); inputDevice = ALC11.alcCaptureOpenDevice(null, frequency, AL10.AL_FORMAT_MONO16, 10 * 1024); if (inputDevice != null) { ALC11.alcCaptureStart(inputDevice); } else { log.warn(String.format("No audio input device available, faking.")); } inputDeviceInitialized = true; } blockThreadInput(buffer.getAddress(), maxSamples, frequency); return 0; }
/** * Halts audio capturing without closing the capture device. * * <p>The implementation is encouraged to optimize for this case. The amount of audio samples available after restarting a stopped capture device is reset to * zero. The application does not need to stop the capture device to read from it.</p> * * @param device the capture device */ @NativeType("ALCvoid") public static void alcCaptureStop(@NativeType("ALCdevice *") long device) { ALC11.alcCaptureStop(device); }
/** Array version of: {@link #alcCaptureSamples CaptureSamples} */ @NativeType("ALCvoid") public static void alcCaptureSamples(@NativeType("ALCdevice *") long device, @NativeType("ALCvoid *") float[] buffer, @NativeType("ALCsizei") int samples) { ALC11.alcCaptureSamples(device, buffer, samples); }
/** * Allows the application to connect to a capture device. * * <p>The {@code deviceName} argument is a null terminated string that requests a certain device or device configuration. If {@code NULL} is specified, the implementation * will provide an implementation specific default.</p> * * @param deviceName the device or device configuration * @param frequency the audio frequency * @param format the audio format * @param samples the number of sample frames to buffer in the AL */ @NativeType("ALCdevice *") public static long alcCaptureOpenDevice(@Nullable @NativeType("ALCchar const *") ByteBuffer deviceName, @NativeType("ALCuint") int frequency, @NativeType("ALCenum") int format, @NativeType("ALCsizei") int samples) { return ALC11.alcCaptureOpenDevice(deviceName, frequency, format, samples); }
/** * Starts recording audio on the specific capture device. * * <p>Once started, the device will record audio to an internal ring buffer, the size of which was specified when opening the device. The application may * query the capture device to discover how much data is currently available via the alcGetInteger with the ALC_CAPTURE_SAMPLES token. This will report the * number of sample frames currently available.</p> * * @param device the capture device */ @NativeType("ALCvoid") public static void alcCaptureStart(@NativeType("ALCdevice *") long device) { ALC11.alcCaptureStart(device); }
/** Unsafe version of: {@link #alcCaptureSamples CaptureSamples} */ public static void nalcCaptureSamples(long device, long buffer, int samples) { ALC11.nalcCaptureSamples(device, buffer, samples); }
/** Unsafe version of: {@link #alcCaptureOpenDevice CaptureOpenDevice} */ public static long nalcCaptureOpenDevice(long deviceName, int frequency, int format, int samples) { return ALC11.nalcCaptureOpenDevice(deviceName, frequency, format, samples); }
OpenALC11 = ext.contains("OpenALC11") && checkExtension("OpenALC11", ALC11.isAvailable(this)); ALC_ENUMERATE_ALL_EXT = ext.contains("ALC_ENUMERATE_ALL_EXT"); ALC_ENUMERATION_EXT = ext.contains("ALC_ENUMERATION_EXT");
/** Array version of: {@link #alcCaptureSamples CaptureSamples} */ @NativeType("ALCvoid") public static void alcCaptureSamples(@NativeType("ALCdevice *") long device, @NativeType("ALCvoid *") short[] buffer, @NativeType("ALCsizei") int samples) { ALC11.alcCaptureSamples(device, buffer, samples); }
/** * Allows the application to connect to a capture device. * * <p>The {@code deviceName} argument is a null terminated string that requests a certain device or device configuration. If {@code NULL} is specified, the implementation * will provide an implementation specific default.</p> * * @param deviceName the device or device configuration * @param frequency the audio frequency * @param format the audio format * @param samples the number of sample frames to buffer in the AL */ @NativeType("ALCdevice *") public static long alcCaptureOpenDevice(@Nullable @NativeType("ALCchar const *") CharSequence deviceName, @NativeType("ALCuint") int frequency, @NativeType("ALCenum") int format, @NativeType("ALCsizei") int samples) { return ALC11.alcCaptureOpenDevice(deviceName, frequency, format, samples); }
/** * Obtains captured audio samples from the AL. * * <p>The implementation may defer conversion and resampling until this point. Requesting more sample frames than are currently available is an error.</p> * * @param device the capture device * @param buffer the buffer that will receive the samples. It must be big enough to contain at least {@code samples} sample frames. * @param samples the number of sample frames to obtain */ @NativeType("ALCvoid") public static void alcCaptureSamples(@NativeType("ALCdevice *") long device, @NativeType("ALCvoid *") ShortBuffer buffer, @NativeType("ALCsizei") int samples) { nalcCaptureSamples(device, memAddress(buffer), samples); }
/** * Allows the application to connect to a capture device. * * <p>The {@code deviceName} argument is a null terminated string that requests a certain device or device configuration. If {@code NULL} is specified, the implementation * will provide an implementation specific default.</p> * * @param deviceName the device or device configuration * @param frequency the audio frequency * @param format the audio format * @param samples the number of sample frames to buffer in the AL */ @NativeType("ALCdevice *") public static long alcCaptureOpenDevice(@Nullable @NativeType("ALCchar const *") ByteBuffer deviceName, @NativeType("ALCuint") int frequency, @NativeType("ALCenum") int format, @NativeType("ALCsizei") int samples) { if (CHECKS) { checkNT1Safe(deviceName); } return nalcCaptureOpenDevice(memAddressSafe(deviceName), frequency, format, samples); }
/** Array version of: {@link #alcCaptureSamples CaptureSamples} */ @NativeType("ALCvoid") public static void alcCaptureSamples(@NativeType("ALCdevice *") long device, @NativeType("ALCvoid *") int[] buffer, @NativeType("ALCsizei") int samples) { ALC11.alcCaptureSamples(device, buffer, samples); }
/** * Allows the application to disconnect from a capture device. * * @param device the capture device to close */ @NativeType("ALCboolean") public static boolean alcCaptureCloseDevice(@NativeType("ALCdevice *") long device) { return ALC11.alcCaptureCloseDevice(device); }
/** * Obtains captured audio samples from the AL. * * <p>The implementation may defer conversion and resampling until this point. Requesting more sample frames than are currently available is an error.</p> * * @param device the capture device * @param buffer the buffer that will receive the samples. It must be big enough to contain at least {@code samples} sample frames. * @param samples the number of sample frames to obtain */ @NativeType("ALCvoid") public static void alcCaptureSamples(@NativeType("ALCdevice *") long device, @NativeType("ALCvoid *") FloatBuffer buffer, @NativeType("ALCsizei") int samples) { nalcCaptureSamples(device, memAddress(buffer), samples); }
/** * Allows the application to connect to a capture device. * * <p>The {@code deviceName} argument is a null terminated string that requests a certain device or device configuration. If {@code NULL} is specified, the implementation * will provide an implementation specific default.</p> * * @param deviceName the device or device configuration * @param frequency the audio frequency * @param format the audio format * @param samples the number of sample frames to buffer in the AL */ @NativeType("ALCdevice *") public static long alcCaptureOpenDevice(@Nullable @NativeType("ALCchar const *") CharSequence deviceName, @NativeType("ALCuint") int frequency, @NativeType("ALCenum") int format, @NativeType("ALCsizei") int samples) { MemoryStack stack = stackGet(); int stackPointer = stack.getPointer(); try { stack.nUTF8Safe(deviceName, true); long deviceNameEncoded = deviceName == null ? NULL : stack.getPointerAddress(); return nalcCaptureOpenDevice(deviceNameEncoded, frequency, format, samples); } finally { stack.setPointer(stackPointer); } }
/** * Obtains captured audio samples from the AL. * * <p>The implementation may defer conversion and resampling until this point. Requesting more sample frames than are currently available is an error.</p> * * @param device the capture device * @param buffer the buffer that will receive the samples. It must be big enough to contain at least {@code samples} sample frames. * @param samples the number of sample frames to obtain */ @NativeType("ALCvoid") public static void alcCaptureSamples(@NativeType("ALCdevice *") long device, @NativeType("ALCvoid *") IntBuffer buffer, @NativeType("ALCsizei") int samples) { ALC11.alcCaptureSamples(device, buffer, samples); }
/** * Obtains captured audio samples from the AL. * * <p>The implementation may defer conversion and resampling until this point. Requesting more sample frames than are currently available is an error.</p> * * @param device the capture device * @param buffer the buffer that will receive the samples. It must be big enough to contain at least {@code samples} sample frames. * @param samples the number of sample frames to obtain */ @NativeType("ALCvoid") public static void alcCaptureSamples(@NativeType("ALCdevice *") long device, @NativeType("ALCvoid *") IntBuffer buffer, @NativeType("ALCsizei") int samples) { nalcCaptureSamples(device, memAddress(buffer), samples); }
ALC11.alcCaptureSamples(inputDevice, captureBuffer, samples);