Class: RubySketch::Sound
- Inherits:
-
Object
- Object
- RubySketch::Sound
- Defined in:
- lib/rubysketch/sound.rb
Overview
Sound object.
Class Method Summary collapse
-
.load(path) ⇒ Sound
Load a sound file.
Instance Method Summary collapse
-
#play(gain: 1.0) ⇒ nil
Play sound.
-
#playing? ⇒ Boolean
Returns whether or not playback is in progress.
-
#stop ⇒ nil
Stop playing sounds.
Class Method Details
.load(path) ⇒ Sound
Load a sound file.
51 52 53 54 |
# File 'lib/rubysketch/sound.rb', line 51 def self.load(path) f = Beeps::FileIn.new path self.new Beeps::Sound.new(f, f.seconds, nchannels: f.nchannels) end |
Instance Method Details
#play(gain: 1.0) ⇒ nil
Play sound.
20 21 22 23 24 |
# File 'lib/rubysketch/sound.rb', line 20 def play(gain: 1.0) clean_stopped_players @players.push @sound.play(gain: gain) nil end |
#playing? ⇒ Boolean
Returns whether or not playback is in progress.
40 41 42 43 |
# File 'lib/rubysketch/sound.rb', line 40 def () clean_stopped_players not @players.empty? end |
#stop ⇒ nil
Stop playing sounds.
30 31 32 33 34 |
# File 'lib/rubysketch/sound.rb', line 30 def stop() @players.each &:stop @players.clear nil end |