File: playwave.rb

package info (click to toggle)
ruby-sdl 2.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,344 kB
  • ctags: 4,200
  • sloc: cpp: 7,598; ansic: 4,475; ruby: 2,258; sh: 102; makefile: 97
file content (15 lines) | stat: -rw-r--r-- 287 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# This sample needs a wave file `sample.wav', please prepare.
require 'sdl'

SDL::init(SDL::INIT_AUDIO)

SDL::Mixer.open(22050, SDL::Mixer::DEFAULT_FORMAT, 2, 512)
wave = SDL::Mixer::Wave.load("sample.wav")

SDL::Mixer.play_channel(0, wave, 0)

while SDL::Mixer.play?(0)
  sleep 1
end