Series

Takuichi Hirano

周波数を求める関数

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

FreqDoReMi[Octave_, ABCTone_] := 
        Module[{d}, 
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]; 
d = (27.5*(2^Octave))/
              12; 
(27.5*(2^Octave)) + d*NumTone  // 
            N
];

周波数分割表

SpectoralBar[Octave_, Col_] := 
        Module[{}, 
f[1] = 
            FreqDoReMi[Octave, "a"]; 
f[2] = 
            FreqDoReMi[Octave, "a#"]; 
f[3] = 
            FreqDoReMi[Octave, "b"]; 
f[4] = 
            FreqDoReMi[Octave, "c"]; 
f[5] = 
            FreqDoReMi[Octave, "c#"]; 
f[6] = 
            FreqDoReMi[Octave, "d"]; 
f[7] = 
            FreqDoReMi[Octave, "d#"]; 
f[8] = 
            FreqDoReMi[Octave, "e"]; 
f[9] = 
            FreqDoReMi[Octave, "f"]; 
f[10] = 
            FreqDoReMi[Octave, "f#"]; 
f[11] = 
            FreqDoReMi[Octave, "g"]; 
f[12] = 
            FreqDoReMi[
              Octave, "g#"]; 
{{AbsoluteThickness[1], 
              RGBColor[0, 0, 0], Line[{{0, 0}, {0, 1}}]}, 
            Table[{Col, Line[{{f[i], 0}, {f[i], 1}}]}, {i, 1, 
                12}]}
];
Show[Graphics[
{
SpectoralBar[0, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 0/4], 
SpectoralBar[1, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 1/4], 
SpectoralBar[2, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 2/4], 
SpectoralBar[3, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 3/4], 
SpectoralBar[4, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 4/4], 
SpectoralBar[5, 
                Hue[-0.7*(x - 1), 1, 1]  /.  x -> 1]  
}
],
PlotRange -> {{0, 
                FreqDoReMi[5, "a"]}, {0, Automatic}},
Frame -> True,
FrameTicks -> {Table[
                27.5*(2^i), {i, 0, 5}], {}, {}, {}},
\(FrameLabel -> {"Frequency (Hz)", ""}\)];

音名番号-周波数グラフ

FreqBar[Octave_, n_, Col_] := 
        Module[{}, 
f[1] = 
            FreqDoReMi[Octave, "a"]; 
f[2] = 
            FreqDoReMi[Octave, "a#"]; 
f[3] = 
            FreqDoReMi[Octave, "b"]; 
f[4] = 
            FreqDoReMi[Octave, "c"]; 
f[5] = 
            FreqDoReMi[Octave, "c#"]; 
f[6] = 
            FreqDoReMi[Octave, "d"]; 
f[7] = 
            FreqDoReMi[Octave, "d#"]; 
f[8] = 
            FreqDoReMi[Octave, "e"]; 
f[9] = 
            FreqDoReMi[Octave, "f"]; 
f[10] = 
            FreqDoReMi[Octave, "f#"]; 
f[11] = 
            FreqDoReMi[Octave, "g"]; 
f[12] = 
            FreqDoReMi[
              Octave, "g#"]; 
{Table[{Col, 
                Rectangle[{12*Octave + (i - 1), 0}, {12*Octave + i, 
                    f[i]}]}, {i, 1, 
                12}]}
];
Show[Graphics[
{
FreqBar[0, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 0/4], 
FreqBar[1, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 1/4], 
FreqBar[2, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 2/4], 
FreqBar[3, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 3/4], 
FreqBar[4, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  x -> 4/4]  
}
],
PlotRange -> {{12*0, 12*5}, All},
Frame -> True,
FrameTicks -> {Table[{12*
                    i, "O"  <>  ToString[i]}, {i, 0, 5}], 
              Automatic, {}, {}},
FrameLabel -> {"", "Frequency \
(Hz)"}];

音名番号-波長グラフ

\(WaveLength[Octave_, n_, Col_] := 
        Module[{}, 
f[1] = 
            FreqDoReMi[Octave, "a"]; 
f[2] = 
            FreqDoReMi[Octave, "a#"]; 
f[3] = 
            FreqDoReMi[Octave, "b"]; 
f[4] = 
            FreqDoReMi[Octave, "c"]; 
f[5] = 
            FreqDoReMi[Octave, "c#"]; 
f[6] = 
            FreqDoReMi[Octave, "d"]; 
f[7] = 
            FreqDoReMi[Octave, "d#"]; 
f[8] = 
            FreqDoReMi[Octave, "e"]; 
f[9] = 
            FreqDoReMi[Octave, "f"]; 
f[10] = 
            FreqDoReMi[Octave, "f#"]; 
f[11] = 
            FreqDoReMi[Octave, "g"]; 
f[12] = 
            FreqDoReMi[
              Octave, "g#"]; 
Do[
\(λ[i] = 1/f[i];\)
, {i, 1, 
              n}
]; 
{Table[{Col, 
                Rectangle[{12*Octave + \((i - 1)\), 
                    0}, {12*Octave + i, λ[i]}]}, {i, 1, 
                12}]}
];\)
Show[Graphics[
{
WaveLength[0, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 0/4], 
WaveLength[1, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 1/4], 
WaveLength[2, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 2/4], 
WaveLength[3, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  
                  x -> 3/4], 
WaveLength[4, 12, 
                Hue[-0.7*(x - 1), 1, 1]  /.  x -> 4/4]  
}
],
PlotRange -> {{12*0, 12*5}, All},
Frame -> True,
FrameTicks -> {Table[{12*
                    i, "O"  <>  ToString[i]  <>  "("  <>  
                    ToString[Round[27.5*(2^i)]]  <>  "Hz)"}, {i, 0, 
                  5}], {}, {}, {}},
FrameLabel -> {"", "Wave Length\
"}];