This is an new version of the jAudioRecord library (but not a direct plugin replacement) provided as a b4xlib and uses current B4x practices and classes.
It allows selection of audio inputs and capturing directly to file or to a byte array so you can process the data further.
The library no longer relies on the threading library.
The CaptureRaw class uses B4xBytesBuilder from theB4xCollections library.
Demo
CaptureRaw vs CaptureToFile
The method GetBuffer is only relevant to the CaptureRaw class, a zero length byte array is returned from the CaptureToFile class as it does not buffer the data and is therefore more memory efficient.
B4xlib
The jAudioRecord2 b4xlib contains the code and some necessary utilities. Feel free to unzip and inspect or change it as you wish.
Dependencies
Updates
V0.11
Comments
There are as many device configurations as there are PC's. It does work with mine and I have an external sound card as well as an internal sound card, Whether java supports all devices will remain to be seen.
Please bear in mind that the demo and B4xlib provides all of the capabilities for the library. For your code, you can pick which classes you want to use. If you don't want to use the threaded classes you can copy only the classes you want to your project (or build a b4xlib) and remove the dependency on the threading library.
Please try it and let me know how you get on and report any issues.
It allows selection of audio inputs and capturing directly to file or to a byte array so you can process the data further.
The CaptureRaw class uses B4xBytesBuilder from theB4xCollections library.
Demo
- jAudioRecord2-Demo
- Demonstrates the full functionality of the library and enumerates and allows selecting the input device and capturing directly to a file or to a byte array (which is subsequently written to a file in the demo, but doesn't have to be).
- Contains CaptureMethod class which is a parent class to the CaptureRaw, CaptureToFile, CaptureRaw_TH and CaptureToFile_TH classes and uses duck typing to enable switching between the classes within the app. If you only want to use one method, you can just use the class you want directly.
- For an example of recording and playing see the jAudioRecAndPlay demo in jAudioTrack2 library.
- jAudiorecordNonUI
- An example for a non-ui app. Just records for 10 seconds and then exits the application. You will need to provide the start/stop recording controls as appropriate to your app.
CaptureRaw vs CaptureToFile
The method GetBuffer is only relevant to the CaptureRaw class, a zero length byte array is returned from the CaptureToFile class as it does not buffer the data and is therefore more memory efficient.
B4xlib
The jAudioRecord2 b4xlib contains the code and some necessary utilities. Feel free to unzip and inspect or change it as you wish.
Dependencies
Updates
V0.11
- Added sub GetDevices and related Constants to JAudioRecordUtils
Added Threaded classes (now depends on the Threading library. The threaded classes cannot be used in debug mode)
Demo contains the source code
Removed dependency on Xui for use in Non-ui apps.
Comments
There are as many device configurations as there are PC's. It does work with mine and I have an external sound card as well as an internal sound card, Whether java supports all devices will remain to be seen.
Please bear in mind that the demo and B4xlib provides all of the capabilities for the library. For your code, you can pick which classes you want to use. If you don't want to use the threaded classes you can copy only the classes you want to your project (or build a b4xlib) and remove the dependency on the threading library.
Please try it and let me know how you get on and report any issues.
Attachments
Last edited: