Class: Beeps::Sound

Inherits:
Object
  • Object
show all
Includes:
Xot::Setter
Defined in:
lib/beeps/sound.rb

Instance Method Summary collapse

Constructor Details

#initialize(processor, seconds = 0, nchannels: 1, sample_rate: 0, **options, &block) ⇒ Sound

Returns a new instance of Sound.



15
16
17
18
19
20
21
# File 'lib/beeps/sound.rb', line 15

def initialize(
  processor, seconds = 0, nchannels: 1, sample_rate: 0, **options, &block)

  setup processor, seconds, nchannels, sample_rate
  set(**options) unless options.empty?
  Xot::BlockUtil.instance_eval_or_block_call self, &block if block
end

Instance Method Details

#play(**options, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/beeps/sound.rb', line 23

def play(**options, &block)
  play!.tap do |player|
    player.set(**options) unless options.empty?
    Xot::BlockUtil.instance_eval_or_block_call player, &block if block
  end
end