5
$\begingroup$

How do I make this sound like a violin instead of a beep?

EmitSound[ Play[   Sin[600 π t], {t, 0, 1}]]
$\endgroup$
5
$\begingroup$

Use Sound[SoundNote[...]] to create the violin sound and EmitSound will play it on evaluation:

EmitSound[Sound[SoundNote["D4", 1, "Violin"]]]

Sin[600\[Pi]] corresponds to 300Hz. If you want the same pitch as your question, you need to start with a note close to 300Hz and shift the pitch up. By using a close note we minimize distortions.

From here https://pages.mtu.edu/~suits/notefreqs.html we can tell D4 is pretty close at 293.66Hz. To get 300Hz we just need to pitch shift D4 by $300/293.66$.

EmitSound[AudioPitchShift[Sound[SoundNote["D4", 1, "Violin"]], 300/293.66]]

$\endgroup$
1
  • 1
    $\begingroup$ By the way - you may notice there is a bug in Mathematica where if you EmitSound and then run a different EmitSound while the first one is still playing, the sample rate can change and the second sound will be played at a very high or very low pitch. $\endgroup$ – flinty Jun 1 '20 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.