4
$\begingroup$

I am trying to use the SoundNote command with "Violin" as my instrument but I cannot see how I can play quarter tones and smaller denominations ("cents").

$\endgroup$
2
  • $\begingroup$ Please clarify the question: "quarter note" typically refers to the duration of the note. Do you mean "quarter tone", which refers to the pitch? $\endgroup$
    – Szabolcs
    May 26 '20 at 14:15
  • $\begingroup$ yes, sorry, quarter tone. $\endgroup$ May 26 '20 at 14:48
6
$\begingroup$

I suspect the answer is you cannot play MIDI notes in Mathematica at a cent pitch granularity. Try this:

music1 = Sound[SoundNote["C", 1.25, "Violin"]]
music2 = Sound[SoundNote["CSharp", 1.25, "Violin"]]
Export["music1.mid", music1]
Export["music2.mid", music2]

Diff the files: midi files diff bytes

There's no byte in between 3C and 3D and these notes were interpreted to be a semitone apart. So we know at least we probably cannot export a quarter tone from Mathematica - and I guess it cannot play these notes in the notebook either.

I was thinking maybe I could use the .mid file format spec to edit the .mid files to apply a Pitch Wheel Change message and load it back in, but we're drifting further away from Mathematica at this point. https://www.cs.cmu.edu/~music/cmsip/readings/Standard-MIDI-file-format-updated.pdf

However, if you just want to hear the note you can AudioPitchShift it. This adds some distortion. If you load the Music package you can get the ratio you need to pitch shift a standard 440Hz $A^\natural$ to get a quarter note.

<< Music`
(*https://reference.wolfram.com/language/Music/tutorial/Music.html*)
quartertoneRatio = #[[2]]/#[[1]] &@CentsToHertz[QuarterTone];
semitoneRatio = #[[3]]/#[[1]] &@CentsToHertz[QuarterTone];
music1 = Sound@SoundNote["A", 1.25, "Violin"]
quartertoneHigherAsPitchShift = AudioPitchShift[music1, quartertoneRatio]
semitoneHigher = Sound@SoundNote["ASharp", 1.25, "Violin"]
(* Verify the below Audio sounds the same as the semitoneHigher note *)
semitoneHigherAsPitchShift = AudioPitchShift[music1, semitoneRatio]
$\endgroup$
0

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.