Audio Appending using RandomAccessFile

后端 未结 1 1170
夕颜
夕颜 2020-12-22 02:39

I use the following code to append as many wav files present in the sdcard to a single file. audFullPath is an arraylist containing the path of the audiofiles. Is it correct

相关标签:
1条回答
  • 2020-12-22 03:12

    You can't append WAV files the way you do. That's because each WAV has special format:

    The simplest possible WAV file looks like this:

    [RIFF HEADER]
    ...
    totalFileSize    
    
    [FMT CHUNK]
    ...
    audioFormat
    frequency
    bytesPerSample
    numberOfChannels
    ...
    
    [DATA CHUNK]
    dataSize
    <audio data>
    

    What you need to do is:

    1. Make sure that all WAV files are of compatible: same audioFormat, frequency, bits per sample, number of channels, etc.
    2. Create proper RIFF header with total file size
    3. Create proper FMT header
    4. Create proper DATA header with total audio data size

    This algorithm will definitely work for LPCM, ULAW, ALAW audio formats. Not sure about others.

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