Message Boards Message Boards

0
|
8770 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to make the note transition smooth?

Hi,
I am trying to generate notes/volume based on a slider2d control. Here is the code:
PlayNoteExample[{n_, v_}] := Module[{note, vol},
note = Floor[Rescale[n, {-1, 1}, {0, 11}]];
vol = Rescale[v, {-1, 1}, {0, 1}];
EmitSound[Sound[SoundNote[note, 0.1, "Flute", SoundVolume -> vol]]]];

Manipulate[PlayNoteExample[pt], {pt, {-1, -1}, {1, 1}}]

When I animate using the slider, the note transitions are jittery (I understand why). What should I do to make
the transitions smooth?

Regards,
Rangarajan
2 Replies
Hi Sean,
Thanks a lot. I see your point about EmitSound. I am starting to do some work on algorithmic music composition in Mathematica. It seems to me that SoundNote is the basic primitive to use for generating western music using pitches, scales, and instruments. The Play function (also ListPlay) appear to be fairly low level, and not that useful for generating music directly (I may be wrong). For example, how to model instruments such as Piano, Flute, etc. using Play? Compared to other music/sound composition programs such as SuperCollider, Mathematica appears a bit less powerful. I chose Mathematica because of its symbolic computation capabilities. It would be nice if there is a way to use Mathematica as a front end to Supercollider (or CSound).

Regards,
Rangarajan
Hi. Did you get this code from somewhere? This function is using SoundNote which creates sounds using Midi and discrete intervals. Frequencies between semi-tones are not accepted by the function, so you won't smooth transitions between frequencies with it. If you would like more control over the sound being made, you may want to use Play or ListPlay.

Additionally, what EmitSound does is cause a sound to be played. Once EmitSound starts to play a sound, changing something using a slider will not change the sound that EmitSound was asked to play. Instead, it will queue a new sound for EmitSound to play. To see this note the lag here:
Manipulate[EmitSound[Play[Sin[note*440 Pi t], {t, 0, 0.1}]], {note, 1, 2}]
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract