0

I need a little bit help and hope to find that here.

I am using sox for tagging some music with voice tags on my server while user is uploading the file. This is my command which I was using. Everything is working fine.

sox -m {voice_tag_loop} {source_file} {output_file}

Now I want to change something, but don't know how to do that and find no solution. So the {voice_tag_loop} will be uploaded by user and can have all length e.g. 30 seconds, 20s, 17s or 1 Minute. Don't know that before.

The {source_file} is the music file and can have also different length e.g. 3:13 Min, 4:20Min

How can I mix the {voice_tag_loop} with the {source_file} that the {output_file} has the length of {source_file} but has the {voice_tag_loop} is mixed and looped/ repeated into also with as long the length of the {source_file}

I hope I could explain that, that you can understand that.

Best regards

nopassport1
  • 1,821
  • 1
  • 25
  • 53

3 Answers3

1

Just repeat until the source file is exhausted, e.g.:

sox -m "| sox {voice_tag_loop} -p repeat -" {source_file} trim 0 $(soxi -d {source_file})

NB, don't forget the trim bit, otherwise the repeat part will generate an infinite file.

Thor
  • 45,082
  • 11
  • 119
  • 130
  • Thank you for your help but it is not working. I have found a command sox {short.mp3} -p repeat | sox - -m {long.mp3} output.mp3 Thats working but should now have the max repeat time of long.mp3 – grüne meile Feb 12 '20 at 19:57
1

OK I have now the answer for all you wants to mix short audio with long audio and the short one should repeated as long the long audio is.

In my case a small description. The short file will be changed to 44.1kHz and will be looped every 30 seconds. Max 100 times but as long as the long file is. And finally both files will be mixed. This all is one procedure.

sox {short_file} -r 44.1k -p pad 0 30 repeat 100 trim 0 $(sox --i -d {long_file}) | sox - -m {long_file} {output_file}

Regards

0

this did it for me

sox {short_file} -p repeat 100 trim 0 $(sox --i -d {long_file}) | sox - -m {long_file} {new_file}
  • 1
    Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Oct 11 '22 at 17:48