ほんとかよ、というノリで音を合成してみました。これが案外きれいな音が出る。ハープシコードのような音が出ます。
ハープシコードの曲を聴きながらどんな旋律を弾かせようか考えたのですが、ここは純粋かつ簡素なかの曲を弾かせてみました。
この曲がいつまでも平和のシンボルであってほしいですね。
終わらないイラク戦争でミサイルで総攻撃をかけ、殺戮と破壊の「イラク軍」(+同盟軍)へ喝采を送る市民とかいうどこかの病んだ軍事大国はよくないと思います。
戦争でないと解決しないような不安定ないどうしようもない状態で、殺戮と破壊で即片が付くかといえばそんなことはありえないわけですが、後先考えない。目的が選挙であれば勝てればいいわけですね。イラクがどうなろうとそもそもイラクのためなのか議論さえなされない。
イラク戦争を終わらせるというのはそのものがスローガンだったのですが、戦争というのは始まると終わらない、わけですね。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Audio.java -- a Karplus–Strong string synthesis implentation | |
// Copyright (c) 2016 easai | |
// Author: easai | |
// Created: Mon Oct 17 22:26:16 2016 | |
// Keywords: | |
// Commentary: | |
// A random sequence is played at certain frequencies generates harpsichord-like sounds. | |
// | |
// Code: | |
import javax.sound.sampled.*; | |
import java.lang.Math; | |
public class Audio { | |
static final int freq=44100;// sampling rate | |
byte[] org=new byte[freq]; | |
byte[] data=new byte[freq]; | |
// play a note (picth = scale, length = len) | |
void note(SourceDataLine audio, int scale,double len) | |
{ | |
double alpha=1.0; | |
for(int n=0;n<scale*len;n++) | |
{ | |
for(int i=0;i<freq;i++){ | |
data[i]=(byte)(org[i]*alpha); | |
} | |
audio.write(data, 0, (int)(freq/scale)); | |
alpha*=.99; | |
} | |
} | |
public Audio(){ | |
try{ | |
AudioFormat fmt=new AudioFormat(freq, 8, 1, true, false); | |
SourceDataLine audio=(SourceDataLine)AudioSystem.getSourceDataLine(fmt); | |
audio.open(fmt); | |
audio.start(); | |
// set random | |
for(int i=0;i<freq;i++){ | |
org[i]=(byte)(Math.random()*256-128); | |
} | |
double scale[]={261.6, 293.7, 329.6, 349.2, 392.0, 440, 493.9, 523.3, 587.3, 659.3,698.5,784}; | |
int index[]={1,0,1,2,4,2,1 | |
,2,4,5,4,5,8,6,5,4 | |
,2,4,5,8,7,8 | |
,2,4,5,4,2,4,1 | |
,5,7,8,7,8,5,4,5,4,2,1}; | |
double len[]={1,1,1,1,1,1,2 | |
,1,1,1,.5,.5,1,1,1,1 | |
,1,1,2,1,1,2 | |
,1,1,1,1,1.5,.5,2 | |
,1,1,2,1,1,1,1,1,.5,.5,2}; | |
for(int i=0;i<index.length;i++) | |
note(audio, (int)(scale[index[i]]),len[i]); | |
}catch(Exception e){ | |
e.printStackTrace(); | |
System.exit(1); | |
} | |
} | |
public static void main(String[] args){ | |
new Audio(); | |
} | |
} | |
// Audio.java ends here |