music

Scilab: constructing wav sound and playing it


clear;
c=0.0299;
tmax=5*2*%pi/c;
fc=c*264;
t=fc*[0:0.01:tmax];
A=[1,1,0.5,0.3,0.2,0.1,0.1,0.1,0.1,0.1,0.1];
s=0;
for i=1:size(A,2),s=s+A(i)*sin(i*t);end
v=0.04*exp(-0.002*t);
s=s.*v;
filename='sample';
wavwrite(s,filename);
playsnd(s);

BONUS:
Listen to a Chinese-sounding short piece out of the generated wav sounds.

Rapu-Rapu atbp., Taghoy ng Kalikasan

Listen to the songs concerning the destruction of Isla Rapu-Rapu and the livelihood of the residents of the island due to large-scale mining.

Awit ni Bobby

For the full lyrics and an English translation, click here.

Constructing a piano tone from sine wave

Sobrang mahal kasi ng piano kaya ito na lang ginawa ko. Ang tawag ko dito ay precision music (tingnan din ang aking precision art).

Sine wave

Sine wave + 50% 1st harmonic

Sine wave + 50% 2nd harmonic

Sine wave + 50% 3rd harmonic

Sine wave + 50% 4th harmonic

Sine wave + 50% 1st harmonic + 33% 2nd harmonics

Sine wave + 50% 1st harmonic + 33% 2nd harmonics + 25% 3rd harmonic

Sine wave + 50% 1st harmonic + 33% 2nd harmonics + 25% 3rd harmonic + 20% 4th harmonic

Suppose when a key is pressed an instrument produces a note with 21%, 8%, 21%, and 8% 1st, 2nd, 3rd, and 4th harmonics, respectively.

Sine wave + 21% 1st harmonic + 8% 2nd harmonics + 21% 3rd harmonic + 8% 4th harmonic

In reality, a note has to start and end at zero amplitudes--it has zero amplitude right before the key was pressed and zero amplitude after the note has died down. Right after the key was pressed, the amplitude shots up to maximum and suppose it decays to zero afterwards in a sort of exponential manner.

Sine wave + 21% 1st harmonic + 8% 2nd harmonics + 21% 3rd harmonic + 8% 4th harmonic

Two successive half-notes have frequency ratios of 2^(1/12). Using the note we constructed above for middle C, we can construct the entire keyboard by stretching or compressing the wave. The result below only plays the middle octave.

Do-Re-Mi-Fa-So-La-Ti-Do

and combining these notes, I constructed the following composition.
Composition No. 1

How much of each of the first four harmonics were used to generate the tones for the following sound?







BONUS: Raising a sine wave to a power. Techno?
Square-root-of-sine wave

Tenth-root-of-sine wave

Square-sine wave

5th-power-sine wave

10th-power-sine wave

Syndicate content