Class: DXRubySDL::Sound

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

Defined Under Namespace

Modules: Common

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Sound

Returns a new instance of Sound.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dxruby_sdl/sound.rb', line 22

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