Using the synth effect for something like this:
play -n -c1 synth sin %-7 sin %0 fade q 0.1 3 0.1
generates a chord of D + A (interval of a fifth).
But is it a perfect fifth (just intonation; factor of 1.5 in frequency), or an equal tempered (chromatic) fifth (factor of 2^(7/12) i.e. 1.498 in frequency) or something else?
1. Presuming that sox currently uses equal temperament, please do actually state this in the soxeffect -> synth manpage.
2. It would be rather neat if sox supported various different tunings. See http://en.wikipedia.org/wiki/Just_intonation for some more details.
Here is an audible demo:
5ths (first in equal-temperament, then in just-intonation)
play -n -c1 synth sin 440 sin 659.255 fade q 0.1 3 0.1 ; play -n -c1 synth sin 440 sin 660 fade q 0.1 3 0.1
3rds (first in equal-temperament, then in just-intonation)
play -n -c1 synth sin 440 sin 544.599 fade q 0.1 3 0.1 ; play -n -c1 synth sin 440 sin 550 fade q 0.1 3 0.1
The difference in 5ths is very hard to hear; the difference in 3rds is dramatic!
Hello Richard,
I've updated the man page to explain the current situation.
Yes, this would be nice to have. Can you suggest a notation that should be used to achieve this?
Cheers,
Rob
Hi Rob - thanks for such a quick response.
I've thought about this a bit more, and I think that a reasonably generic implementation will require 3 optional parameters:
tuning, key, and a440.
Tuning specifies which system the semitones should be calculated in. The default (if not specified) would be "equal", while the options should include (at least) equal, just, pythagorean, and as many others as you want to implement. An overview of the calculations required is here:
http://en.wikipedia.org/wiki/Musical_tuning#Systems_for_the_twelve-note_chromatic_scale
Key would be the note of the fundamental scale (eg "C" or "A" or F# or Bb). For sanity's sake you should probably model this on a piano where there are exactly 12 keys per octave (and you drop the distinction between F# and Gb). For equal-temperament, KEY doesn't matter, but for other schemes it does. Eg in J.I. we can tune the piano to have C-major sound "perfect" and result is that nearby keys (F major, G major etc) are close to right, and distant keys (C# major) will sound hideous. But one might want to have the perfect scale be another key such as A major. (If omitted, this value should default to C, I think). In all cases, the tuning must keep concert A at 440 Hz.
Lastly we may in fact want to globally change the tuning, so I suggest a parameter "a440" which defaults to 440Hz, but may be a different number, such as 436.
----
While you're at it (if this complexity hasn't put you off!), I might suggest this requires some careful documenting of exactly how the implementation works. It might also be nice to add a different way of specifying semitones: as well as "%+3", could you support the standard way lilypond does it eg "c2" or "g4" (see http://lilypond.org/web/switch/howto ). [If necessary to make the syntax more regular, maybe %c2 ]
Thanks for taking the time to give such a detailed and considered reply. We're currently going through release candidates for SoX 14.3.0, but I couldn't resist hacking in a very basic JI implementation (now in CVS). To do it properly will take a bit more time and will have to wait for 14.4.0.
In the mean time, this is how it looks:
synth [-j KEY] [-n] [len] {[type] [combine]
[[%]freq[k][:|+|/|-[%]freq2[k]]] [off] [ph] [p1] [p2] [p3]}
freq/freq2 are the frequencies at the beginning/end of synthesis
in Hz or, if preceded with ‘%’, semitones relative to A
(440 Hz); for both, default=%0. By default, the tuning used for
the semitone notation is equal temperament; the -j KEY option
selects just intonation, where KEY is an integer number of semi‐
tones relative to A. So for example, -8 or 4 selects the key of
C. If freq2 is given, then len must also have been given and
Note that with this quick-and-dirty, the key tonic is at its equal temperament freq w.r.t. A440, so concert A may not be 440. You can see what freqs are being used by using sox (or play) -V4.
Cheers,
Rob
Thanks - I tested that, and it's really neat. It's quite interesting to compare the following:
Major 3rd (A,C#), in J.I. tuned in A major:
/usr/local/bin/play -V4 -n -c1 synth -j 0 sin %0 sin %+4 fade q 0.1 2 0.1;
Major 3rd (A,C#) in J.I., tuned in A# major: (ouch!)
/usr/local/bin/play -V4 -n -c1 synth -j 1 sin %0 sin %+4 fade q 0.1 2 0.1