Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
18
Task/Musical-scale/Pluto/musical-scale.pluto
Normal file
18
Task/Musical-scale/Pluto/musical-scale.pluto
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
local audio = require "audio"
|
||||
require "table2"
|
||||
|
||||
local sample_rate = 44100
|
||||
local duration = 8
|
||||
local data = table.rep(sample_rate * duration, 0)
|
||||
local freqs = {261.6, 293.6, 329.6, 349.2, 392.0, 440.0, 493.9, 523.3}
|
||||
for j = 0, duration - 1 do
|
||||
local freq = freqs[j + 1]
|
||||
local omega = 2 * math.pi * freq
|
||||
for i = 0, sample_rate - 1 do
|
||||
local y = math.round(32 * math.sin(omega * i / sample_rate)) & 255
|
||||
data[i + j * sample_rate + 1] = y
|
||||
end
|
||||
end
|
||||
local filepath = "musical_scale.wav"
|
||||
audio.create(filepath, data, sample_rate)
|
||||
audio.play(filepath)
|
||||
Loading…
Add table
Add a link
Reference in a new issue