Class: RbSDL2::Audio::AudioSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/rb_sdl2/audio/audio_spec.rb

Defined Under Namespace

Modules: Reader

Constant Summary collapse

SDL_AUDIO_MASK_BITSIZE =
0xFF
SDL_AUDIO_MASK_DATATYPE =
1 << 8
SDL_AUDIO_MASK_ENDIAN =
1 << 12
SDL_AUDIO_MASK_SIGNED =
1 << 15

Instance Method Summary collapse

Constructor Details

#initialize(big_endian: false, bitsize: 16, float: false, signed: true, channels: 0, format: nil, frequency: 0, samples: 0) ⇒ AudioSpec

Returns a new instance of AudioSpec.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 16

def initialize(big_endian: false, bitsize: 16, float: false, signed: true,
               channels: 0, format: nil, frequency: 0, samples: 0)
  @st = ::SDL::AudioSpec.new
  @st[:channels] = channels
  @st[:format] = format || 0 |
    (big_endian ? SDL_AUDIO_MASK_ENDIAN : 0) |
    (bitsize & SDL_AUDIO_MASK_BITSIZE) |
    (float ? SDL_AUDIO_MASK_DATATYPE & SDL_AUDIO_MASK_SIGNED : 0) |
    (signed ? SDL_AUDIO_MASK_SIGNED : 0)
  @st[:freq] = frequency
  @st[:samples] = samples
end

Instance Method Details

#big_endian?Boolean

Returns:

  • (Boolean)


29
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 29

def big_endian? = SDL_AUDIO_MASK_ENDIAN & format != 0

#bitsizeObject



31
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 31

def bitsize = SDL_AUDIO_MASK_BITSIZE & format

#channelsObject

チャンネル数



34
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 34

def channels = @st[:channels]

#float?Boolean

Returns:

  • (Boolean)


36
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 36

def float? = SDL_AUDIO_MASK_DATATYPE & format != 0

#formatObject

音声フォーマット



39
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 39

def format = @st[:format]

#freqObject Also known as: frequency

サンプルレート



42
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 42

def freq = @st[:freq]

#samplesObject

音声バッファのサンプル数。2のべき乗。



46
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 46

def samples = @st[:samples]

#signed?Boolean

Returns:

  • (Boolean)


48
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 48

def signed? = SDL_AUDIO_MASK_SIGNED & format != 0

#silenceObject

音量レベル0の値。8ビットフォーマットの際に使用する(と思われる。型が Uint8 であるため)。SDL が決定する。



51
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 51

def silence = @st[:silence]

#sizeObject

音声バッファのサイズ(Byte)。SDL が決定する。



54
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 54

def size = @st[:size]

#to_ptrObject



56
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 56

def to_ptr = @st.to_ptr

#unknown?Boolean

Returns:

  • (Boolean)


58
# File 'lib/rb_sdl2/audio/audio_spec.rb', line 58

def unknown? = channels == 0 && format == 0 && frequency == 0