I am trying to model microtonal music using Play
.
I have only partial success because it takes such a long time to make some sound.
Could you please have a look at my stackoverflow.com question?
The link is
=========== Original question linked above ===============
Do you have any suggestions how to write and play microtonal music?
My solution:
I tried to use Play
and Piecewise
but it takes a LONG time to take a sound!
Please read the details.
As you know there are many notes other than Do or Re or Mi of western music. So maybe I can not use SoundNote
for ancient music. Each note is represented as a fraction. Using middle Do as a base (i.e., base = 260.741 Hz
); the next notes are represented by re = 9/8 base
, mi = 5/4 base
, fa = 4/3 base
, di = 3/2 base
, etc. For example, to play fa for 2 seconds with SoundVolume = 1/3
, evaluate
Play[1/3 Sin[ fa 2 Pi x], {x,0,2}].
I model each such instance with a list of the form {time, note, soundvolume}
, for example {2, fa, 1/3}
. Consider a very short example of such a sequence of notes
voice1= {{1, 9/8, 1}, {1, 5/4, 2/3}, {1/2, 4/3, 1/3}, {1/2, 9/8, 1/3}, {1, 4/3, 1},
{1, 3/2, 2/3}, {1, 4/3, 1/3}}
How can voice1 be easily played using Play
?
I tried using Piecewise
, but with that I have to wait for a LONG TIME before I get any sound result. (Maybe the reason is the use Piecewise
in Play
, but I am not sure.)
Please, try the following example to see how slow you get the sound result for voice1.
Play[
Piecewise[{
{1, 0. < x <= 1},
{2/3, 1 < x <= 2},
{1/3, 2 < x <= 5/2 || 5/2 < x <= 3},
{1, 3 < x <= 4},
{2/3, 4 < x <= 5},
{1/3, 5 < x <= 6},
{0, True}}]
Sin[ base 2 Pi
Piecewise[{
{9/8, 0. < x <= 1},
{5/4, 1 < x <= 2},
{4/3, 2 < x <= 5/2},
{9/8, 5/2 < x <= 3},
{4/3, 3 < x <= 4},
{3/2, 4 < x <= 5},
{4/3, 5 < x <= 6},
{0, True}
}]],
{x,0, 6}]