2

How can I add silence to the beginning and the end of a WAV file with Java?

the length of the silence should be variable.

clamp
  • 33,000
  • 75
  • 203
  • 299

1 Answers1

2

see this thread: Join two WAV files from Java?

If you have create a wav that is just a few seconds of silence you could combine your files together to get the required result, silence.wav + myfile.wav + silence.wav

The thread I linked to gives you the barebones code to combine wav file together. - be sure to vote up the answer in the other thread :)

Hope this helps, Eamonn

Community
  • 1
  • 1
Eamonn McEvoy
  • 8,876
  • 14
  • 53
  • 83
  • thanks! yes i have found this thread already. the problem is that in my case the length of the silence is dynamic. i.e. i want to define by code how much silence should be added. – clamp Apr 14 '11 at 10:13
  • @clamp what about having 1 second of silence in your file, then you can define how many 1 seconds of silence should be added to each end? – Eamonn McEvoy Apr 14 '11 at 10:24
  • or if 1 second is too long a shorter slience :) – Eamonn McEvoy Apr 14 '11 at 10:24
  • 1
    Upvote for the nice linke and mentioning upvoting other answer :-) – darioo Apr 14 '11 at 10:30
  • unfortunately no. the resolution is almost down to 1 millisecond. the final sounds will be used as soundeffects in a game and they should have the playback at very precise times. – clamp Apr 14 '11 at 10:45
  • I see combining file would be much too slow then, you could possibly think playing the sound on a new thread and simply putting in a delay before and after the file is played – Eamonn McEvoy Apr 14 '11 at 11:01