Class: Windows::SoundStructs::WAVEFORMATEX

Inherits:
FFI::Struct
  • Object
show all
Defined in:
lib/win32/windows/structs.rb

Overview

Define WAVEFORMATEX which defines the format (PCM in this case) and various properties like sampling rate, number of channels, etc.

Instance Method Summary collapse

Constructor Details

#initialize(nSamplesPerSec = 44100, wBitsPerSample = 16, nChannels = 1, cbSize = 0) ⇒ WAVEFORMATEX

Initializes struct with sensible defaults for most commonly used values. While setting these manually is possible, please be sure you know what changes will result in, as an incorrectly set struct will result in unpredictable behavior.



27
28
29
30
31
32
33
34
35
# File 'lib/win32/windows/structs.rb', line 27

def initialize(nSamplesPerSec = 44100, wBitsPerSample = 16, nChannels = 1, cbSize = 0)
  self[:wFormatTag] = Win32::Sound::WAVE_FORMAT_PCM
  self[:nChannels] = nChannels
  self[:nSamplesPerSec] = nSamplesPerSec
  self[:wBitsPerSample] = wBitsPerSample
  self[:cbSize] = cbSize
  self[:nBlockAlign] = (self[:wBitsPerSample] >> 3) * self[:nChannels]
  self[:nAvgBytesPerSec] = self[:nBlockAlign] * self[:nSamplesPerSec]
end