sound.rb 512 B

1234567891011121314151617181920
  1. # Models a Sound, that is a sample or audio clip that has been loaded from disk
  2. # and kept in storage.
  3. class Sound < Store
  4. extend Store::Forward
  5. # Loads the sound sample. Supports wav files.
  6. # Can load 8/16 bits little endian .wav files and and .flac files.
  7. def self.load(name, vpath)
  8. load_something(forward_name(name), vpath, self) do | nid |
  9. Eruta::Store.load_sample(nid, vpath)
  10. end
  11. end
  12. # Plays this sample immediately
  13. def play!
  14. Eruta::Audio.play_sample @id
  15. end
  16. end