I'm using currently writing a mobile app on Expo that loads music files into a Webview and enables pitching their music key.
I'm utilizing this repo for that: https://github.com/olvb/phaze
, which works with AudioWorkletNodes and the waves-audio library.
AudioWorkletNodes play in IOS Webviews, however the quality sounds more like it's played from a radio in the 20s.
I tested with a HTMLAudioElements and it worked fine on the Webview, so now I'm thinking how I could convert my AudioWorklet into HTMLAudio to maintain a good quality for my playback.
What's the way to go here?
Some Code below to understand how the audio file is dealt with in the repo:
const wavesAudio = require('waves-audio');
const wavesLoaders = require('waves-loaders');
let audioContext = wavesAudio.audioContext;
let loader = new wavesLoaders.AudioBufferLoader();
const buffer = await loader.load('./track.mp3');
let [playerEngine, phaseVocoderNode] = await setupEngine(buffer);
let playControl = new wavesAudio.PlayControl(playerEngine);
// playControl enables us to play the AudioWorklet
// should we process our Audioworklet into a different format now?
async function setupEngine(buffer) {
let playerEngine = new wavesAudio.PlayerEngine(buffer);
playerEngine.buffer = buffer;
playerEngine.cyclic = true;
await audioContext.audioWorklet.addModule('phase-vocoder.js'); // processes file based on input
let phaseVocoderNode = new AudioWorkletNode(audioContext, 'phase-vocoder-processor');
playerEngine.connect(phaseVocoderNode);
phaseVocoderNode.connect(audioContext.destination);
return [playerEngine, phaseVocoderNode];
}
Trying to convert audio into a workable audio format for Webview