Class: Plaything::OpenAL::Source

Inherits:
TypeClass
  • Object
show all
Defined in:
lib/plaything/objects/source.rb

Instance Method Summary collapse

Instance Method Details

#buffers_processedInteger

Note:

returns #buffers_queued if source is not playing!

Returns number of processed buffers.

Returns:

  • (Integer)

    number of processed buffers.



47
48
49
# File 'lib/plaything/objects/source.rb', line 47

def buffers_processed
  get(:buffers_processed, Integer)
end

#buffers_queuedInteger

Returns number of queued buffers.

Returns:

  • (Integer)

    number of queued buffers.



41
42
43
# File 'lib/plaything/objects/source.rb', line 41

def buffers_queued
  get(:buffers_queued, Integer)
end

#detach_buffersObject

Note:

all buffers must be processed for this operation to succeed.

Note:

all buffers are considered processed when #stopped?.

Detach all queued or attached buffers.



55
56
57
# File 'lib/plaything/objects/source.rb', line 55

def detach_buffers
  set(:buffer, 0)
end

#pauseObject

Pause playback.



13
14
15
16
# File 'lib/plaything/objects/source.rb', line 13

def pause
  @should_be_playing = false
  OpenAL.source_pause(self)
end

#playObject

Start playback.



7
8
9
10
# File 'lib/plaything/objects/source.rb', line 7

def play
  @should_be_playing = true
  OpenAL.source_play(self)
end

#playing?Boolean

Returns true if source is in stopped state.

Returns:

  • (Boolean)

    true if source is in stopped state.



70
71
72
# File 'lib/plaything/objects/source.rb', line 70

def playing?
  state == :playing
end

#sample_offsetInteger

Returns how many samples (/ channels) that have been played from the queued buffers.

Returns:

  • (Integer)

    how many samples (/ channels) that have been played from the queued buffers



36
37
38
# File 'lib/plaything/objects/source.rb', line 36

def sample_offset
  get(:sample_offset, Integer)
end

#should_be_playing?Boolean

Returns true if source should currently be playing audio.

Returns:

  • (Boolean)

    true if source should currently be playing audio



31
32
33
# File 'lib/plaything/objects/source.rb', line 31

def should_be_playing?
  @should_be_playing
end

#starved?Boolean

Returns true if audio should be playing (#play has been called, but not #stop or #pause), but isn’t playing.

Returns:

  • (Boolean)

    true if audio should be playing (#play has been called, but not #stop or #pause), but isn’t playing



26
27
28
# File 'lib/plaything/objects/source.rb', line 26

def starved?
  should_be_playing? and not playing?
end

#stateSymbol

Returns :initial, :paused, :playing, :stopped.

Returns:

  • (Symbol)

    :initial, :paused, :playing, :stopped



60
61
62
# File 'lib/plaything/objects/source.rb', line 60

def state
  get(:source_state)
end

#stopObject

Stop playback and rewind the source.



19
20
21
22
# File 'lib/plaything/objects/source.rb', line 19

def stop
  @should_be_playing = false
  OpenAL.source_stop(self)
end

#stopped?Boolean

Returns true if source is in stopped state.

Returns:

  • (Boolean)

    true if source is in stopped state.



65
66
67
# File 'lib/plaything/objects/source.rb', line 65

def stopped?
  state == :stopped
end