2和音 (平均律)

Takuichi Hirano

平均律の公比を求める

Solve[440*(r^12) == 880, r]

平均律の周波数を求める関数

[Input]
オクターブ
音 (c,c#,d,d#,e,f,f#,g,g#,a,a#,b)

FreqDoReMi[Octave_, ABCTone_] := 
        Module[{r = (2^(1/12))}, 
NumTone = 
            Which[
ABCTone == "A"  ||  
                ABCTone == "a", 
              0, 
ABCTone == "A#"  ||  
                ABCTone == "a#", 
              1, 
ABCTone == "B"  ||  
                ABCTone == "b", 
              2, 
ABCTone == "C"  ||  
                ABCTone == "c", 
              3, 
ABCTone == "C#"  ||  
                ABCTone == "c#", 
              4, 
ABCTone == "D"  ||  
                ABCTone == "d", 
              5, 
ABCTone == "D#"  ||  
                ABCTone == "d#", 
              6, 
ABCTone == "E"  ||  
                ABCTone == "e", 
              7, 
ABCTone == "F"  ||  
                ABCTone == "f", 
              8, 
ABCTone == "F#"  ||  
                ABCTone == "f#", 
              9, 
ABCTone == "G"  ||  
                ABCTone == "g", 
              10, 
ABCTone == "G#"  ||  
                ABCTone == "g#", 
              11]; 
(440*(r^((Octave - 4)*12)))*
              (r^NumTone)  // N
];

dt = 2;
ω[1] = 
        2*π*FreqDoReMi[4, "C"];
ω[2] = 
        2*π*FreqDoReMi[4, "G"];
wave[t_] := 
        Sin[ω[1]*t] + Sin[ω[2]*t];
Play[
      wave[t], {t, 0, dt}, 
SampleRate -> 
        44100, 
SampleDepth -> 
        16, 
PlayRange -> {-2, 2}]