Using AudioTrack in Android to play a WAV file

后端 未结 7 966
别跟我提以往
别跟我提以往 2020-12-01 05:50

I\'m working with Android, trying to make my AudioTrack application play a Windows .wav file (Tada.wav). Frankly, it shouldn\'t be this hard, but I\'m hearing a lot of stra

7条回答
  •  渐次进展
    2020-12-01 06:12

    Are you skipping the first 44 bytes of the file before you dump the rest of the file's data into the buffer? The first 44 bytes are the WAVE header and they would sound like random noise if you tried to play them.

    Also, are you sure you are creating the AudioTrack with the same properties as the WAVE you are trying to play (sample rate, bit rate, number of channels, etc)? Windows actually does a good job of giving this information to you in the File Properties page: alt text

提交回复
热议问题