Audio input from bluetooth mic
Vaibhav1587 opened this issue · 3 comments
Great plugin. Thanks for that!
Ionic_v4
Trying to record the audio using Bluetooth microphone and play through phone speaker.
I have turned on the Bluetooth SCO using https://github.com/gntikos/cordova-BluetoothSco
recoding :
startRecord() {
if (audioinput && !audioinput.isCapturing()) {
BluetoothSco.start(
function () {
console.log("Bluetooth SCO on");
},
function () {
console.log("Bluetooth SCO on error");
},
{ enablePlayback: false}
);
this.captureCfg = {
audioSourceType: 7,
};
audioinput.start(this.captureCfg);
}
}
Play:
playAudio(data) {
AudioToggle.setAudioMode(AudioToggle.SPEAKER);
var audioBuffer = this.audioContext.createBuffer(
audioinput.getCfg().channels,
data.length / audioinput.getCfg().channels,
audioinput.getCfg().sampleRate
);
if (this.captureCfg.channels > 1) {
for (var i = 0; i < audioinput.getCfg().channels; i++) {
var chdata = [],
index = 0;
while (index < data.length) {
chdata.push(data[index + i]);
index += parseInt(audioinput.getCfg().channels);
}
audioBuffer.getChannelData(i).set(chdata);
}
} else {
audioBuffer.getChannelData(0).set(data);
}
console.log("Playing audio..");
// Create a buffer source based on the audio buffer.
var source = this.audioContext.createBufferSource();
source.buffer = audioBuffer;
// Connect the buffer source before playing.
source.connect(filterNode);
// Play the audio immediately.
source.start(0);
....
}
I'm able to record through the Phone Mic and play on Bluetooth speaker. Just stuck on this on. Recording through Bluetooth mic and playing on the speaker.
Hi,
same problem here. I cannot record from the bluetooth mic. I tested on Android. Otherwise this plugin is great.
Any luck with this @touficzayed or @Vaibhav1587 ?
Hi @MumblesNZ.
I tried with the bluetoothSco plugin, and testing on one single device only it worked: I was able to record with the bluetooth microphone and listen in the bluetooth headset.
The only drawback is that the audio quality is not very good.