On Jan 13 20:07:12, sox-users@xxxxxxxxxxxxxxxxxxxxx wrote: > I use sox for converting and merging vox-files in a shell script. But the > vox files often have different duration in seconds and I want to make sure > that the shorter file always has the duration of the longer file before > merging. Why? You are not telling the whole story. Is that always two files, both mono, being merged into stereo? What is the use case, why are you doing the stretching? Also, why are you using 'stretch' and not 'tempo'? According to the manual, "its results are comparatively poor"; I'd say it's comparatively horrendous: sox -r 8k -n file.vox synth 10 sin 440 gain -6 sox -r 8k file.vox stretch.vox stretch 2.0 sox -r 8k file.vox tempo.vox tempo 0.5 soxi file.vox stretch.vox tempo.vox play file.vox stretch.vox tempo.vox > With soxi -D <file.vox> I get the length in seconds. If the differences > between the two files are greater than 2 seconds, Why 2 seconds? Why are you doing the stretching at all, and why not if the lenght difference is 1.95s? > I calculate the stretch factor. The “problem” now is that > the stretched file is often longer than > the longer file itself, e.g. > soxi -D fileA.vox = 870.408000 > soxi -D fileB.vox = 868.360000 > > stretch factor = 1.00235846883780920355 > > The used command for stretching is: > > sox -r 8000 -t vox “$fileB” -r 8000 -t vox “${work_dir}/fileB_stretched.vox” > stretch “$factor” > > But the unexpected result of stretching this file is > > soxi -D ${work_dir}/fileB_stretched.vox = 875.197500 This seems to be more precise: sox -r 8k -n fileA.vox synth 870.408 sin 440 gain -6 sox -r 8k -n fileB.vox synth 868.360 sin 440 gain -6 bc -e 'scale = 8 ; 868.360 / 870.408' sox -r 8k fileB.vox stretched.vox tempo .99764708 soxi fileA.vox fileB.vox stretched.vox Also, is this error specific to vox files? Have you tried with wavs? (I don't think it would make a difference, as I believe the stretch effect itself is the culprit.) > chatgpt says Srsly, stop right here. Jan _______________________________________________ Sox-users mailing list Sox-users@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/sox-users