Class: FMOD::Sound::OpenState

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

Overview

Contains the state a sound is in after Core::Mode::NON_BLOCKING has been used to open it, or the state of the streaming buffer.

When a sound is opened with Core::Mode::NON_BLOCKING, it is opened and prepared in the background, or asynchronously. This allows the main application to execute without stalling on audio loads. This function will describe the state of the asynchronous load routine i.e. whether it has succeeded, failed or is still in progress.

If #starving? is true, then you will most likely hear a stuttering/repeating sound as the decode buffer loops on itself and replays old data. You can detect buffer under-run and use something like ChannelControl#mute to keep it quiet until it is not starving any more.

Constant Summary collapse

READY =

Opened and ready to play.

0
LOADING =

Initial load in progress.

1
ERROR =

Failed to open - file not found, out of memory etc.

2
CONNECTING =

Connecting to remote host (internet sounds only).

3
BUFFERING =

Buffering data.

4
SEEKING =

Seeking to subsound and re-flushing stream buffer.

5
PLAYING =

Ready and playing, but not possible to release at this time without stalling the main thread.

6
SET_POSITION =

Seeking within a stream to a different position.

7

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, buffered, busy, starving) ⇒ OpenState

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of OpenState.



100
101
102
# File 'lib/fmod/sound.rb', line 100

def initialize(state, buffered, busy, starving)
  @state, @buffered, @busy, @starving = state, buffered, busy, starving
end

Instance Attribute Details

#bufferedFloat (readonly)

Returns the percentage of the file buffer filled progress of a stream.

Returns:

  • (Float)

    the percentage of the file buffer filled progress of a stream.



81
82
83
# File 'lib/fmod/sound.rb', line 81

def buffered
  @buffered
end

#stateInteger (readonly)

Returns the open state of a sound.

Will be one of the following:

Returns:



76
77
78
# File 'lib/fmod/sound.rb', line 76

def state
  @state
end

Instance Method Details

#busy?Boolean

The disk busy state of a sound.

Returns:

  • (Boolean)

    true if disk is currently being accessed for the sound, otherwise false.



87
88
89
# File 'lib/fmod/sound.rb', line 87

def busy?
  @busy != 0
end

#starving?Boolean

The starving state of a sound.

Returns:

  • (Boolean)

    true f a stream has decoded more than the stream file buffer has ready for it, otherwise false.



95
96
97
# File 'lib/fmod/sound.rb', line 95

def starving?
  @starving != 0
end