react-native-voice-changer is a wrapper of un4seen Bass a native voice processing library
$ npm install react-native-voice-changer --save
For RN >=0.60
linking is automatic, else:
$ react-native link react-native-voice-changer
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
You may use react-native-permissions to grant permissions
import voiceChanger from 'react-native-voice-changer';
const effects = [
{
id: 1,
icon: require('./icons/default_fx.png'),
name: "helium",
pitch: 10,
rate: 0,
reverb: []
},
{
id: "3",
icon: require('./icons/default_fx.png'),
name: "Robot",
pitch: 3,
rate: 5,
amplify: 10,
echo: [100, 100, 40]
},
{
id: "4",
icon: require('./icons/default_fx.png'),
name: "Cave",
pitch: 0,
rate: 0,
reverb: [-3.25, 2000, 0.8]
},
];
class VoiceChangerExample extends Component {
componentDidMount() {
this.initMedia();
}
initMedia = () => {
voiceChanger.setPath(AudioUtils.DocumentDirectoryPath + '/record.wav');
voiceChanger.createDBMedia();
effects.forEach(e => voiceChanger.insertEffect(JSON.stringify(e)));
};
onPlay = (idx) => {
voiceChanger.playEffect(idx)
};
onSave = (idx) => {
voiceChanger
.saveEffect(idx)
.then(path => {
console.log('Saved to: ', path);
/* Do something with your saved file */
});
};
...
}
Method | Description |
---|---|
VoiceChanger.setPath(path) | Set current path of media to be processed |
VoiceChanger.createOutputDir | Create folder to save processed media |
VoiceChanger.createDBMedia | Prepare media player |
VoiceChanger.insertEffect(effect) | Add effect to effects list |
VoiceChanger.playEffect(effectIndex) | Play specified effect by index |
VoiceChanger.saveEffect(effectIdx) | Save processed media with a specific effect |
Effect object has the following properties
Property | Type | Decription |
---|---|---|
pitch: | Int | The pitch of a channel, [-60...0...+60] semitones. |
rate: | float | The tempo of a channel, [-95...0...+5000] percents. |
reverb: | [fReverbMix, fReverbTime, fHighFreqRTRatio] |
fReverbMix: Reverb mix, in dB, in the range from -96 through 0. The default value is 0 dB. fReverbTime: Reverb time, in milliseconds, in the range from 0.001 through 3000. The default value is 1000. fHighFreqRTRatio: High-frequency reverb time ratio, in the range from 0.001 through 0.999. The default value is 0.001. |
filter: | [lFilter, fCenter, fBandwidth] |
lFilter: Defines which BiQuad filter should be used. Filters list fCenter: Cut-off frequency (Center in PEAKINGEQ and Shelving filters) in Hz (1...info.freq/2). Default = 200Hz. fBandwidth: Bandwidth in octaves (0.1...4...n), Q is not in use (fBandwidth has priority over fQ). Default = 1 (0=not in use). |
flanger: | [fWetDryMix, fDepth, fFeedback, fDelay, lPhase, fFrequency] |
fWetDryMix: Ratio of wet (processed) signal to dry (unprocessed) signal. Must be in the range from 0 through 100 (all wet). The default value is 50. fDepth: Percentage by which the delay time is modulated by the low-frequency oscillator (LFO). Must be in the range from 0 through 100. The default value is 100. fFeedback: Percentage of output signal to feed back into the effect's input, in the range from -99 to 99. The default value is -50. fDelay: Number of milliseconds the input is delayed before it is played back, in the range from 0 to 4. The default value is 2 ms. lPhase: Phase differential between left and right LFOs, one of BASS_DX8_PHASE_NEG_180, BASS_DX8_PHASE_NEG_90, BASS_DX8_PHASE_ZERO, BASS_DX8_PHASE_90 and BASS_DX8_PHASE_180. The default value is BASS_DX8_PHASE_ZERO. fFrequency: Frequency of the LFO, in the range from 0 to 10. The default value is 0.25. |
chorus: | [fDryMix, fWetMix, fFeedback, fMinSweep, fMaxSweep, fRate] |
fDryMix: Dry (unaffected) signal mix (-2...+2). Default = 0. fWetMix: Wet (affected) signal mix (-2...+2). Default = 0. fFeedback: Feedback (-1...+1). Default = 0. fMinSweep: Minimum delay in ms (0<...6000). Default = 0. fMaxSweep: Maximum delay in ms (0<...6000). Default = 0. fRate: Rate in ms/s (0<...1000). Default = 0. |
distort: | [fEdge, fGain, fPostEQBandwidth, fPostEQCenterFrequency, fPreLowpassCutoff] |
fEdge: Percentage of distortion intensity, in the range in the range from 0 through 100. The default value is 15 percent. fGain: Amount of signal change after distortion, in the range from -60 through 0. The default value is -18 dB. fPostEQBandwidth: Width of frequency band that determines range of harmonic content addition, in the range from 100 through 8000. The default value is 2400 Hz. fPostEQCenterFrequency: Center frequency of harmonic content addition, in the range from 100 through 8000. The default value is 2400 Hz. fPreLowpassCutoff: Filter cutoff for high-frequency harmonics attenuation, in the range from 100 through 8000. The default value is 8000 Hz. |
reverse: | boolean | Reverse playback direction |
echo: | [fLeftDelay, fRightDelay, fFeedback, fWetDryMix] |
fLeftDelay: Delay for left channel, in milliseconds, in the range from 1 through 2000. The default value is 500 ms. fRightDelay: Delay for right channel, in milliseconds, in the range from 1 through 2000. The default value is 500 ms. fFeedback: Percentage of output fed back into input, in the range from 0 through 100. The default value is 50. fWetDryMix: Ratio of wet (processed) signal to dry (unprocessed) signal. Must be in the range from 0 through 100 (all wet). The default value is 50. |
echo4: | [fDryMix, fWetMix, fFeedback, fDelay] |
fDryMix: Dry (unaffected) signal mix (-2...+2). Default = 0. fWetMix: Wet (affected) signal mix (-2...+2). Default = 0. fFeedback: Percentage of output signal to feed back into the effect's input, in the range from -99 to 99. The default value is -50. fDelay: Delay in seconds (0<...6). Default = 0. |
eq1: | [fCenter, fBandwidth, fGain] |
fCenter: Center frequency, in hertz. fBandwidth: Bandwidth, in semitones, in the range from 1 to 36. The default value is 12. fGain: Gain, in the range from -15 to 15. The default value is 0 dB. |
eq2: | [fCenter, fBandwidth, fGain] |
Same as eq1 |
eq3: | [fCenter, fBandwidth, fGain] |
Same as eq1 |
amplify: | float | Amplification level (0...1...n, linear). Default = 0. |
rotate: | float | Rotation rate/speed in Hz (A negative rate can be used for reverse direction). |
phaser: | [fDryMix, fWetMix, fFeedback, fRate, fRange, fFreq] |
fDryMix: Dry (unaffected) signal mix (-2...+2). Default = 0. fWetMix: Wet (affected) signal mix (-2...+2). Default = 0. fFeedback: Feedback (-1...+1). Default = 0. fRate: Rate of sweep in cycles per second (0<...<10). Default = 0. fRange: Sweep range in octaves (0<...<10). Default = 0. fFreq: Base frequency of sweep range (0<...1000). Default = 0. |
autoWah: | [fDryMix, fWetMix, fFeedback, fRate, fRange, fFreq] |
Same as phaser |
compressor: | [fGain, fThreshold, fRatio, fAttack, fRelease] |
fGain: Output gain in dB of signal after compression, in the range from -60 to 60. The default value is 5 dB. fThreshold: Point in dB at which compression begins, in decibels, in the range from -60 to 0. The default value is -15 dB. fRatio: Compression ratio, in the range from 1 to 100. The default value is 3, which means 3:1 compression. fAttack: Time in ms before compression reaches its full value, in the range from 0.01 to 500. The default value is 20 ms. fRelease: Time (speed) in ms at which compression is stopped after input drops below fThreshold, in the range from 50 to 3000. The default value is 200 ms. |