How to sox sequence of synth commands [closed]
Asked Answered
Q

1

5

I have created, at the moment, a simple script that generates several beeps with synusoids and that after concatenates them, to have more complex sounds. I used a bash script to do that, as I could not understand how to do this using simply sox... My script with play is something like

count=0
while [ 1 ]
do
play -n synth 1 sine C
play -n synth 0.2 sine E
play -n synth 0.2 sine C
play -n synth 0.2 sine E
if [ $count -eq 5 ]
then
sleep 1
count=0
fi
count=$(($count+1))
done

Which produces something like an italian ambulance. That's not the aim of course, but the idea is... How can I produce with one command several consecutive sines without needing of different commands?

Quattlebaum answered 5/9, 2017 at 14:10 Comment(4)
Did you read the manual? It explains quite clearly in it.Earful
While interesting, this Q is not about programming as defined for StackOverflow. It may be more appropriate on superuser.com or another StackExchange site. Use the flag link at the bottom of your Q and ask the moderator to move it. Please don't post the same Q on 2 different sites. Please read stackoverflow.com/help/how-to-ask stackoverflow.com/help/dont-ask and stackoverflow.com/help/mcve before posting more Qs here. Good luck.Houseline
shellter, thanks, but I think it is not a sysadmin problem, it is some kind of development problem. It is not a very commonly used tool, but ok. I think that the topic is ok. Dealing with 123's RTFM suggestion I can tell that if that's clear for you, you may suggest where to look if you have a solution, as it is pretty clear that, even reading that several times, it is absolutely not clear how to do this...Quattlebaum
BTW, for the kind of work you're doing here, I personally would reach for Overtone.Tedman
E
7

This answer is by Deltaray.

There is a way to do this although it's not very clear or discoverable in the documentation despite claims to the contrary. I came across this method by accident while looking for something else in the man page. You can use the ':' character to separate effects chains like this:

play -n synth 1 sin C : synth .5 sin D

That plays C, D on a sine waveform at two different lengths. You can also create separate effects chains for each note:

play -n synth .5 sin C3 : synth 1 tri D3 chorus .7 .5 20 1 1 2 -t : synth 2 pl E3

This will play C3 D3 and E3 using different lengths for the notes, waveforms and effects.

Apparently you can also use newline separators, but that's for if you're using the --effects-file option, which is how I found out about the ':' character. This is described in the "Multiple Effects Chains" in the man page, which is about 25% into a rather long man page.

Another method of doing this which combines the notes into a single sample is to use the delay and remix effects like this:

play -n synth 1 pl C pl D pl E delay 0 1 2 remix -

The issue with this though is that the notes are all the same length.

When you need notes of variable length and with silent spaces around, say in Morse codes, then you can use these commands:

Without saving a temporal file:

play -n synth 0.3 sin E6 : trim 0.0 .1 : synth 0.1 sin E6 : trim 0.0 .1 : synth 0.3 sin E6;

With saving a temporal file:

sox -n morse_text.ogg synth 0.1 sin E6 : trim 0.0 .1 : synth 0.3 sin E6 : trim 0.0 .1 : synth 0.1 sin E6; 
play morse_text.ogg; 

A faster solution is to use the temporal file in shared memory, if it is possible in your system:

/dev/shm/morse_text.ogg 
Epos answered 11/9, 2018 at 3:4 Comment(2)
you saved my day, thanks!Inefficacy
Say, if you play Morse codes, you must add silence: play -n synth 0.3 sin E6 : trim 0.0 .1 : synth 0.1 sin E6 : trim 0.0 .1 : synth 0.3 sin E6; sox -n morse_text.ogg synth 0.1 sin E6 : trim 0.0 .1 : synth 0.3 sin E6 : trim 0.0 .1 : synth 0.1 sin E6; play morse_text.ogg;Informal

© 2022 - 2024 — McMap. All rights reserved.