Phonegap mixing audio files

后端 未结 2 2040
既然无缘
既然无缘 2020-12-30 12:06

I\'m building a karaoke app using Phonegap for Ios.

I have audio files in the www/assets folder that I am able to play using the media.play()function

This al

2条回答
  •  难免孤独
    2020-12-30 12:28

    The solution was to use the offlineAudioContext

    The steps were: 1. Load the two files as buffers using the BufferLoader 2. Create an OfflineAudioContext 3. connect the two buffers to the OfflineAudioContext 4. start the two buffers 5. use the offline startRendering function 6. Set the offfline.oncomplete function to get a handle on the renderedBuffer.

    Here's the code:

    offline = new webkitOfflineAudioContext(2, voice.buffer.length, 44100);
    vocalSource = offline.createBufferSource();
    vocalSource.buffer = bufferList[0];
    vocalSource.connect(offline.destination);
    
    backing = offline.createBufferSource();
    backing.buffer = bufferList[1];
    backing.connect(offline.destination);
    
    vocalSource.start(0);
    backing.start(0);
    
    offline.oncomplete = function(ev){
        alert(bufferList);
        playBackMix(ev);
        console.log(ev.renderedBuffer);
        sendWaveToPost(ev);
    }
    offline.startRendering();
    

提交回复
热议问题