Class: NativeAudio::AudioSource

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clip) ⇒ AudioSource

Returns a new instance of AudioSource.



16
17
18
19
20
# File 'lib/native_audio.rb', line 16

def initialize(clip)
  @clip = clip
  @channel = AudioSource.channels.count
  AudioSource.channels << self
end

Class Method Details

.channelsObject



46
47
48
# File 'lib/native_audio.rb', line 46

def self.channels
  @channels ||= []
end

Instance Method Details

#pauseObject



30
31
32
# File 'lib/native_audio.rb', line 30

def pause
  Audio.pause(@channel)
end

#playObject



22
23
24
# File 'lib/native_audio.rb', line 22

def play
  Audio.play(@channel, @clip.clip)
end

#resumeObject



34
35
36
# File 'lib/native_audio.rb', line 34

def resume
  Audio.resume(@channel)
end

#set_pos(angle, distance) ⇒ Object



38
39
40
# File 'lib/native_audio.rb', line 38

def set_pos(angle, distance)
  Audio.set_pos(@channel, angle, distance)
end

#set_volume(volume) ⇒ Object



42
43
44
# File 'lib/native_audio.rb', line 42

def set_volume(volume)
  Audio.set_volume(@channel, volume)
end

#stopObject



26
27
28
# File 'lib/native_audio.rb', line 26

def stop
  Audio.stop(@channel)
end