32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/gemwarrior/misc/audio.rb', line 32
def self.play_synth(audio_cue_symbol)
if GameOptions.data['sound_enabled']
case GameOptions.data['sound_system']
when 'win32-sound'
require_relative 'audio_cues'
require_relative 'musical_notes'
Thread.start do
AudioCues.cues[audio_cue_symbol][:synth].each do |seq|
threads = []
seq[:frequencies].split(',').each do |note|
threads << Thread.new do
Win32::Sound::play_freq(Notes::NOTE_FREQ[note], seq[:duration], GameOptions.data['sound_volume'])
end
end
threads.each { |th| th.join }
end
end
when 'feep'
require_relative 'audio_cues'
feep_defaults = {
frequencies: '440',
waveform: 'sine',
volume: GameOptions.data['sound_volume'],
duration: 500,
notext: true
}
Thread.start do
AudioCues.cues[audio_cue_symbol][:synth].each do |seq|
seq = feep_defaults.merge(seq)
Feep::Base.new({
freq_or_note: seq[:frequencies],
waveform: seq[:waveform],
volume: seq[:volume],
duration: seq[:duration],
notext: seq[:notext]
})
end
end
when 'bloops'
require_relative 'bloops_cues'
Thread.start do
BloopsCues.cues[audio_cue_symbol][:synth].each do |seq|
threads = []
seq.each do |note|
threads << Thread.new do
b = Bloops.new
b.tempo = 240
snd = b.sound Bloops::SQUARE
snd.punch = GameOptions.data['sound_volume']/2
snd.sustain = 0.7
snd.decay = 0.2
b.tune snd, note[1]
b.play
sleep 0.1 while !b.stopped?
end
end
threads.each { |th| th.join }
end
end
end
end
end
|