-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscratch.rb
49 lines (42 loc) · 920 Bytes
/
scratch.rb
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require 'lib/fmod'
start_time = Time.now
puts "initializing FMOD ..."
FMOD.init
end_time = Time.new - start_time
puts "done in #{end_time} seconds."
file = (ARGV.empty?) ? "Kids.mp3" : ARGV[0]
puts "initializing a sound ..."
start_time = Time.now
sound = FMOD::Sound.new(file)
end_time = Time.new - start_time
puts "done in #{end_time} seconds."
sound.play
puts FMOD.system.version
puts sound.channel.frequency
sleep 2
# sound.channel.frequency = 11050.0
# puts sound.channel.frequency
# 10.times do |i|
# sound.channel.set_position(i + 1000)
# sleep 0.1
# end
# sleep 2
1000.times do |i|
sound.channel.set_position(i * (rand*1000).to_i)
sleep rand
end
#
# sr = 100
# step = 1.0/sr
# time = 0.0
#
# loop do
# time += step
# val = Math.cos(time * 2 * Math::PI * 440.0) * Math.cos(time * 2 * Math::PI)
# sound.channel.frequency = val * 20000
# sleep step
# end
# block
while true
sleep 5
end