Class: FMOD::Channel

Inherits:
Object
  • Object
show all
Includes:
Functions
Defined in:
lib/fmod/channel.rb

Constant Summary

Constants included from Enums

Enums::FMOD_CHANNELINDEX, Enums::FMOD_DELAYTYPE, Enums::FMOD_DSP_RESAMPLER, Enums::FMOD_DSP_TYPE, Enums::FMOD_OUTPUTTYPE, Enums::FMOD_RESULT, Enums::FMOD_SOUND_FORMAT

Constants included from Constants

FMOD::Constants::FMOD_2D, FMOD::Constants::FMOD_3D, FMOD::Constants::FMOD_3D_CUSTOMROLLOFF, FMOD::Constants::FMOD_3D_HEADRELATIVE, FMOD::Constants::FMOD_3D_IGNOREGEOMETRY, FMOD::Constants::FMOD_3D_LINEARROLLOFF, FMOD::Constants::FMOD_3D_LOGROLLOFF, FMOD::Constants::FMOD_3D_WORLDRELATIVE, FMOD::Constants::FMOD_ACCURATETIME, FMOD::Constants::FMOD_CDDA_FORCEASPI, FMOD::Constants::FMOD_CDDA_JITTERCORRECT, FMOD::Constants::FMOD_CREATECOMPRESSEDSAMPLE, FMOD::Constants::FMOD_CREATESAMPLE, FMOD::Constants::FMOD_CREATESTREAM, FMOD::Constants::FMOD_DEFAULT, FMOD::Constants::FMOD_HARDWARE, FMOD::Constants::FMOD_IGNORETAGS, FMOD::Constants::FMOD_INIT_3D_RIGHTHANDED, FMOD::Constants::FMOD_INIT_DISABLE_MYEARS, FMOD::Constants::FMOD_INIT_DSOUND_HRTFFULL, FMOD::Constants::FMOD_INIT_DSOUND_HRTFLIGHT, FMOD::Constants::FMOD_INIT_DSOUND_HRTFNONE, FMOD::Constants::FMOD_INIT_DTS_NEURALSURROUND, FMOD::Constants::FMOD_INIT_ENABLE_PROFILE, FMOD::Constants::FMOD_INIT_GEOMETRY_USECLOSEST, FMOD::Constants::FMOD_INIT_NORMAL, FMOD::Constants::FMOD_INIT_PS2_DISABLECORE0REVERB, FMOD::Constants::FMOD_INIT_PS2_DISABLECORE1REVERB, FMOD::Constants::FMOD_INIT_PS2_DONTUSESCRATCHPAD, FMOD::Constants::FMOD_INIT_PS2_SWAPDMACHANNELS, FMOD::Constants::FMOD_INIT_PS3_FORCE2CHLPCM, FMOD::Constants::FMOD_INIT_PS3_PREFERDTS, FMOD::Constants::FMOD_INIT_SOFTWARE_DISABLE, FMOD::Constants::FMOD_INIT_SOFTWARE_HRTF, FMOD::Constants::FMOD_INIT_SOFTWARE_OCCLUSION, FMOD::Constants::FMOD_INIT_SOFTWARE_REVERB_LOWMEM, FMOD::Constants::FMOD_INIT_STREAM_FROM_UPDATE, FMOD::Constants::FMOD_INIT_SYNCMIXERWITHUPDATE, FMOD::Constants::FMOD_INIT_SYSTEM_MUSICMUTENOTPAUSE, FMOD::Constants::FMOD_INIT_VOL0_BECOMES_VIRTUAL, FMOD::Constants::FMOD_INIT_WASAPI_EXCLUSIVE, FMOD::Constants::FMOD_INIT_XBOX_REMOVEHEADROOM, FMOD::Constants::FMOD_LOADSECONDARYRAM, FMOD::Constants::FMOD_LOOP_BIDI, FMOD::Constants::FMOD_LOOP_NORMAL, FMOD::Constants::FMOD_LOOP_OFF, FMOD::Constants::FMOD_LOWMEM, FMOD::Constants::FMOD_MPEGSEARCH, FMOD::Constants::FMOD_NONBLOCKING, FMOD::Constants::FMOD_OPENMEMORY, FMOD::Constants::FMOD_OPENMEMORY_POINT, FMOD::Constants::FMOD_OPENONLY, FMOD::Constants::FMOD_OPENRAW, FMOD::Constants::FMOD_OPENUSER, FMOD::Constants::FMOD_SOFTWARE, FMOD::Constants::FMOD_TIMEUNIT_BUFFERED, FMOD::Constants::FMOD_TIMEUNIT_MODORDER, FMOD::Constants::FMOD_TIMEUNIT_MODPATTERN, FMOD::Constants::FMOD_TIMEUNIT_MODROW, FMOD::Constants::FMOD_TIMEUNIT_MS, FMOD::Constants::FMOD_TIMEUNIT_PCM, FMOD::Constants::FMOD_TIMEUNIT_PCMBYTES, FMOD::Constants::FMOD_TIMEUNIT_RAWBYTES, FMOD::Constants::FMOD_TIMEUNIT_SENTENCE, FMOD::Constants::FMOD_TIMEUNIT_SENTENCE_MS, FMOD::Constants::FMOD_TIMEUNIT_SENTENCE_PCM, FMOD::Constants::FMOD_TIMEUNIT_SENTENCE_PCMBYTES, FMOD::Constants::FMOD_TIMEUNIT_SENTENCE_SUBSOUND, FMOD::Constants::FMOD_UNICODE, FMOD::Constants::FMOD_UNIQUE, FMOD::Constants::FMOD_VIRTUAL_PLAYFROMSTART

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Functions

#error_check

Constructor Details

#initialize(options = {}) ⇒ Channel

TODO: Need to find a way to reliably destroy this pointer



8
9
10
# File 'lib/fmod/channel.rb', line 8

def initialize(options = {})
  @memory = FFI::MemoryPointer.new(:pointer)
end

Instance Attribute Details

#pointerObject (readonly)

pointer to the channel instance



5
6
7
# File 'lib/fmod/channel.rb', line 5

def pointer
  @pointer
end

Instance Method Details

#frequencyObject



54
55
56
57
58
59
# File 'lib/fmod/channel.rb', line 54

def frequency
  FFI::MemoryPointer.new(:float) do |ptr|
    error_check(:FMOD_Channel_GetFrequency, pointer, ptr)
    return ptr.read_float
  end
end

#frequency=(float) ⇒ Object



61
62
63
# File 'lib/fmod/channel.rb', line 61

def frequency=(float)
  error_check(:FMOD_Channel_SetFrequency, pointer, float)
end

#get_delay(opts = {}) ⇒ Object



71
72
73
74
75
76
77
78
79
80
# File 'lib/fmod/channel.rb', line 71

def get_delay(opts={})
  opts = opts.keyword_args(:delaytype => :required)

  FFI::MemoryPointer.new(:int) { |hi|
    FFI::MemoryPointer.new(:int) { |lo|
      error_check(:FMOD_Channel_GetDelay, pointer, opts.delaytype, hi, lo)
      return Convert.int32_to_64(hi.read_int, lo.read_int)
    }
  }
end

#pan=(float) ⇒ Object



48
49
50
51
52
# File 'lib/fmod/channel.rb', line 48

def pan=(float)
  float = 1.0 if float > 1.0
  float = 0.0 if float < 0.0
  error_check(:FMOD_Channel_SetPan, pointer, float)
end

#pauseObject



29
30
31
# File 'lib/fmod/channel.rb', line 29

def pause
  error_check(:FMOD_Channel_SetPaused, pointer, ((paused?) ? 0 : 1))
end

#paused?Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
# File 'lib/fmod/channel.rb', line 37

def paused?
  FFI::MemoryPointer.new(:int) do |ptr|
    error_check(:FMOD_Channel_GetPaused, pointer, ptr)
    return ptr.read_int == 1
  end
end

#playing?Boolean

result = FMOD_Channel_IsPlaying(channel, &playing);

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'lib/fmod/channel.rb', line 22

def playing?
  FFI::MemoryPointer.new(:int) do |ptr|
    error_check(:FMOD_Channel_IsPlaying, pointer, ptr)
    return ptr.read_int == 1
  end
end

#pointer_addrObject



16
17
18
# File 'lib/fmod/channel.rb', line 16

def pointer_addr
  @memory
end

#set_delay(samples, opts = {}) ⇒ Object



65
66
67
68
69
# File 'lib/fmod/channel.rb', line 65

def set_delay(samples, opts={})
  opts = opts.keyword_args(:delaytype => :required)
  hi, lo = Convert.int64_to_32(samples)
  error_check(:FMOD_Channel_SetDelay, pointer, opts.delaytype, hi, lo)
end

#set_paused(bool) ⇒ Object



33
34
35
# File 'lib/fmod/channel.rb', line 33

def set_paused(bool)
  error_check(:FMOD_Channel_SetPaused, pointer, (bool ? 1 : 0))
end

#set_position(int = 0) ⇒ Object



44
45
46
# File 'lib/fmod/channel.rb', line 44

def set_position(int = 0)
  error_check(:FMOD_Channel_SetPosition, pointer, int, FMOD_TIMEUNIT_MS)
end

#set_volume(volume) ⇒ Object



82
83
84
# File 'lib/fmod/channel.rb', line 82

def set_volume(volume)
  error_check(:FMOD_Channel_SetVolume, pointer, volume)
end