Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
290 views
in Technique[技术] by (71.8m points)

android - Adding silent pause between byte array of two audio

I have multiple audio files converted into byte array for each, and i have start time and end time of each audio file (these audio files are converted from video so i have its time stamps).

Now i want to merge these byte array of audio files to create one single audio mp3 file. I tried to simply merge these two array and it successfully creates a single mp3 file but it doesn't have any pause in between.

I want to add silent audio between each file based on the difference of start time and end time of each file. To achieve that, i added 0 bytes for each second difference between each array but it doesn't add sufficient pause.

Is there any way to determine how many bytes it will require to add for each second?

Every audio has 8000 sample Rate Hertz.

Following is the code i am using to add 0 bytes.

 ArrayList<Byte> buffer = previousTranslation.getAudioBuffer();   

// to get gape in seconds between two audio files from a video
int diff = (int)differenceBetweenTwoCalendar(
                previousTranslation.getSentenceEndTime(),
                translation.getSentenceStartTime());
// Add 0 bytes for each second between two audio buffers(bytes array)
for(int j = 0; j < diff; j++)
  buffer.add((byte) 0);

// Add seconds part of audio buffer byte array
buffer.addAll(translation.getAudioBuffer();
question from:https://stackoverflow.com/questions/65851553/adding-silent-pause-between-byte-array-of-two-audio

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...