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
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