NDART
http://ndart.ca
RNSaveAudio Module
Home Useful Links Custom Module Tutorial
React-NativePurpose
The purpose of this module is to take an array of int16 data from javascript, and create a .wav file from that data, on Android and iOS devices natively. This module is essentially suppose to provide a sink when working with the react-native-recording
module (https://www.npmjs.com/package/react-native-recording). More information can be found on the projects respective github homepage page -> https://github.com/qiuxiang/react-native-recording#readme...
Installation
Android
- To install, run
npm install rnsaveaudio
- Edit
/android/settings.gradle
and add the following lines...
include ':rnsaveaudio'.projectDir = new File(rootProject.projectDir, '../node_modules/rnsaveaudio/android')
- Edit
/android/app/build.gradle
and add the following line inside ofdependencies
...
compile
- Edit
/android/app/src/main/java/.../MainApplication.java
with the follow lines...
- Import the module at the top of the file
- Instantiate the package inside of the
getPackages()
method
new RNSaveAudioPackage()
- run the command
cd android && gradlew clean && cd ../
for windows, orcd android && ./gradlew clean && cd ../
for OSX, inside the root directory of your react-native project
iOS
- Open your xCode project and add the
RNSaveAudio.xcodeproj
file to your project - Go to your project's build phases, and add the
libRNSaveAudio.a
file to the list labeledLink Binary With Libraries
, using the+
under the list
- If you get an error saying xCode cannot find
<RCTEventEmitter.h>
, openRNSaveAudio.h
inside of theios
project folder, and change the the header to<React/RCTEventEmitter.h>
- For more information, look at https://github.com/maxs15/react-native-spinkit/wiki/Manual-linking---IOS
Notes
- Version 1.0.6 is current
- Works on Android and iOS (Tested)
- Sends a promise when complete
- Creates a .wav file based on an array of signed short (SInt16) values at a frequency of 44.1kHz
- Meant to work with react-native-recording node package and react-native-fs package
Useage
- Import the module using
import RNSaveAudio from 'rnsaveaudio';
- Export audio using
RNsaveAudio.saveWav(PATH+'/filename.wav',dataArray);
- Make sure to include the keywords
await
andasync
if used inside of a function, eg.async func(prop){ const variable = await RNsaveAudio.saveWav(PATH+'/filename.wav',dataArray); }
Contact Information
- My email is
nkambo1@my.bcit.ca
, use the module name in the subject line. - Submit an issue to the github page. http://github.com/navrajkambo/RNSaveAudio/issues
Other Information
- If you feel like contributing, send me a message or open an issue! Any help is appriciated :)
- For more information on bridging native modules to react-native, have a look at https://gist.github.com/chourobin/f83f3b3a6fd2053fad29fff69524f91c, https://eastcodes.com/packaging-and-sharing-react-native-modules, and http://matthewsessions.com/2017/10/27/developing-rn-module.html. They are very informative!