Class: FMOD::Sound

Inherits:
Object
  • Object
show all
Includes:
Functions
Defined in:
lib/fmod/sound.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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Functions

#error_check

Constructor Details

#initialize(file, options = {}) ⇒ Sound

Returns a new instance of Sound.



6
7
8
9
10
11
# File 'lib/fmod/sound.rb', line 6

def initialize(file, options = {})
  @system_pointer  = FMOD.system.pointer
  @channel = options[:channel] || Channel.new
  @file = file
  @sound_ptr = nil
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



4
5
6
# File 'lib/fmod/sound.rb', line 4

def channel
  @channel
end

Instance Method Details

#length(unit = FMOD_TIMEUNIT_MS) ⇒ Object



13
14
15
16
17
18
# File 'lib/fmod/sound.rb', line 13

def length(unit = FMOD_TIMEUNIT_MS)
  FFI::MemoryPointer.new(:int) do |ptr|
    error_check(:FMOD_Sound_GetLength, sound_ptr, ptr, FMOD_TIMEUNIT_MS)
    return ptr.read_int
  end
end

#play(opts = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/fmod/sound.rb', line 20

def play(opts={})
  opts = opts.keyword_args(:paused)
  # FMOD_RESULT = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, 0, &channel);
  error_check(:FMOD_System_PlaySound, FMOD.system.pointer, :FMOD_CHANNEL_FREE, sound_ptr, opts.paused ? 1 : 0, @channel.pointer_addr)
  true
end

#releaseObject



27
28
29
30
31
# File 'lib/fmod/sound.rb', line 27

def release
  return unless @sound_ptr
  error_check(:FMOD_Sound_Release, @sound_ptr)
  @sound_ptr = nil
end