Merging pcm audio files

后端 未结 1 1116
天命终不由人
天命终不由人 2020-12-10 09:08

I have recorded audio using AudioRecorder. I need to merge the recorded files into a single file. Any suggestion.

getAudioPath() -- the path of the audiofiles. getCo

相关标签:
1条回答
  • 2020-12-10 09:40

    If you're using AudioRecord.read(), I'm assuming you have the PCM data in a short or byte array. If that's the case, all you need to do is create a new array as large as both of the originals, and copy the data over, one after the other. Something like this:

    short[] newData = new short[dataOne.length + dataTwo.length];
    for(int i=0;i<dataOne.length;i++)
        newData[i] = dataOne[i];
    for(int i=0;i<dataTwo.length;i++)
        newData[i+dataOne.length] = dataTwo[i];
    

    Then you have one array with all the PCM data, and you can do with that what you will.

    0 讨论(0)
提交回复
热议问题