Leser: 1
4 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use Win32::Sound;
# Create the object
$WAV = new Win32::Sound::WaveOut(44100, 8, 2);
$data = "";
$counter = 0;
$increment = 440/44100;
# Generate 44100 samples ( = 1 second)
for $i (1..44100) {
# Calculate the pitch
# (range 0..255 for 8 bits)
$v = sin($counter/2*3.14) * 128 + 128;
# "pack" it twice for left and right
$data .= pack("cc", $v, $v);
$counter += $increment;
}
$WAV->Load($data); # get it
$WAV->Write(); # hear it
1 until $WAV->Status(); # wait for completion
$WAV->Save("sinus.wav"); # write to disk
$WAV->Unload(); # drop it
4 Einträge, 1 Seite |