Class: DXRubySDL::Sound

Inherits:
Object
  • Object
show all
Defined in:
lib/dxruby_sdl/sound.rb

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Sound

Returns a new instance of Sound.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/dxruby_sdl/sound.rb', line 7

def initialize(filename)
  if !self.class.instance_variable_get('@sdl_mixer_openend')
    SDL::Mixer.open
    SDL::Mixer.allocate_channels(2)
    self.class.instance_variable_set('@sdl_mixer_openend', true)
  end
  if /\.mid$/ =~ filename
    @sound = Music.new(filename)
  else
    @sound = Wave.new(filename)
  end
end

Instance Method Details

#playObject



20
21
22
# File 'lib/dxruby_sdl/sound.rb', line 20

def play
  @sound.play
end