Mathematicaは音を鳴らすことができる.
たとえばコードの最後の行に次のコマンドを入れておくだけで,計算終了時にピーッという音が鳴る.
EmitSound@Play[Sin[2 Pi 880 t], {t, 0, 0.5}] (* finish *)
Sachiko Mみたいに淡々と正弦波を鳴らすのも好きなので私はこれを何年も使っているのだが,味気ないので計算の待ち時間を利用して別のものも作ってみた.
sn[list_, length_: 1] := SoundNote[list, length length4 ]
(* define *)
sound1 := Block[{length4 = 0.2}, EmitSound@
Sound[{"ElectricPiano", sn[{"D3", "F", "C5"}], sn[{"F", "C5"}],
sn[{"A3", "F", "C5"}], sn[{"D"}, 1/2], sn[{"D", "F", "C5"}],
sn[{"F", "C5"}], sn[{"D"}, 1/2], sn[{"A3", "F", "C5"}, 1/2],
sn[{"D"}, 1/2], sn[{ "F", "C5"}],
sn[{"C3", "E", "B"}], sn[{"E", "B"}], sn[{"G3", "E", "B"}],
sn[{"C"}, 1/2], sn[{"C", "E", "B"}],
sn[{"E", "B"}], sn[{"C"}, 1/2], sn[{"G3", "E", "B"}, 1/2],
sn[{"C"}, 1/2], sn[{ "E", "B"}]
}] ]
(* run *)
sound1
無敵になれた気がしますね.
エレピの音を読み込むのに初回実行時のみ少々時間がかかるので注意("ElectricPiano"を単に"Piano"とすればおそらく読み込み不要).
もう少し短いのだと,
sound2 := Block[{length4 = 0.225},EmitSound@
Sound[{"ElectricPiano", sn[{"G3", "G4", "B4"}, 1/ 2],
sn[{"D5", "F5"}] , sn[{"G3", "D5", "F5"}, 1/2] ,
sn[{"G3", "D5", "F5"}, 2/3] , sn[{"A3", "C5", "E5"}, 2/3] ,
sn[{"B3", "B4", "D5"}, 2/3] ,
sn[{"C4", "G4", "C5"}, 1/ 2], sn[{ "E"}, 1/ 2], sn[{"G3"}, 1/ 2],
sn[{ "E"}, 1/ 2], sn[{ "C3", "C4"}]
}] ]
(* run *)
sound2
もちろん著作権は私のものではない.
たとえばコードの最後の行に次のコマンドを入れておくだけで,計算終了時にピーッという音が鳴る.
EmitSound@Play[Sin[2 Pi 880 t], {t, 0, 0.5}] (* finish *)
Sachiko Mみたいに淡々と正弦波を鳴らすのも好きなので私はこれを何年も使っているのだが,味気ないので計算の待ち時間を利用して別のものも作ってみた.
sn[list_, length_: 1] := SoundNote[list, length length4 ]
(* define *)
sound1 := Block[{length4 = 0.2}, EmitSound@
Sound[{"ElectricPiano", sn[{"D3", "F", "C5"}], sn[{"F", "C5"}],
sn[{"A3", "F", "C5"}], sn[{"D"}, 1/2], sn[{"D", "F", "C5"}],
sn[{"F", "C5"}], sn[{"D"}, 1/2], sn[{"A3", "F", "C5"}, 1/2],
sn[{"D"}, 1/2], sn[{ "F", "C5"}],
sn[{"C3", "E", "B"}], sn[{"E", "B"}], sn[{"G3", "E", "B"}],
sn[{"C"}, 1/2], sn[{"C", "E", "B"}],
sn[{"E", "B"}], sn[{"C"}, 1/2], sn[{"G3", "E", "B"}, 1/2],
sn[{"C"}, 1/2], sn[{ "E", "B"}]
}] ]
(* run *)
sound1
無敵になれた気がしますね.
エレピの音を読み込むのに初回実行時のみ少々時間がかかるので注意("ElectricPiano"を単に"Piano"とすればおそらく読み込み不要).
もう少し短いのだと,
sound2 := Block[{length4 = 0.225},EmitSound@
Sound[{"ElectricPiano", sn[{"G3", "G4", "B4"}, 1/ 2],
sn[{"D5", "F5"}] , sn[{"G3", "D5", "F5"}, 1/2] ,
sn[{"G3", "D5", "F5"}, 2/3] , sn[{"A3", "C5", "E5"}, 2/3] ,
sn[{"B3", "B4", "D5"}, 2/3] ,
sn[{"C4", "G4", "C5"}, 1/ 2], sn[{ "E"}, 1/ 2], sn[{"G3"}, 1/ 2],
sn[{ "E"}, 1/ 2], sn[{ "C3", "C4"}]
}] ]
(* run *)
sound2
もちろん著作権は私のものではない.
No comments:
Post a Comment