I asked about a Non-Linear Editor for sound that works from plain-text files. As it does not seem to exist, I programmed one with FFMPEG. The text input is:

## take_1.wav

-ss 3.32179
-to 7.57171
any notes on this

## take_1.wav

-ss 11.82790
-to 15.22180
some more notes

## take_2.wav

-ss 15.76000
-to 20.20920
more notes

and I extract those segments with FFMPEG:

ffmpeg -i take2.wav -ss 15.76000 -to 20.20920 -ac 1 temp3.wav

and then join them with Python's wave module, from this answer:

def join_audio(infiles, outfile):
    data = []
    for infile in infiles:
        w = wave.open(infile, 'rb')
        data.append( [w.getparams(), w.readframes(w.getnframes())] )

    output = wave.open(outfile, 'wb')
    for i in range(len(data)):

I notice some discrepancies at the joins between the segments. Since WAV is uncompressed, I assume that this slicing and joining is lossless. Is that correct or am I losing some information in the process?

  • 3
    Wav editing should always be lossless, but cutting at non-zero points is always going to click. How are you ensuring your edit points are going to be silent? Why do you need to do this programatically rather than audio-visually? I'm sure something like Audacity would be a simple-enough tool for this job. – Tetsujin Aug 2 '20 at 11:11
  • I was doing it programmatically to avoid the destructive editing of Audacity. Thanks for the tip on non-zero points. – miguelmorin Aug 3 '20 at 16:39

It will be lossless. You can avoid the popping sounds by doing very short fade ins/outs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.