class Sound::FormatLibrary::MMLib::WAVEFORMATEX

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

Public Class Methods

new(nSamplesPerSec = 44100, wBitsPerSample = 16, nChannels = 1, cbSize = 0) click to toggle source

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.

# File lib/sound/format_library/mmlib.rb, line 38
def initialize(nSamplesPerSec = 44100, wBitsPerSample = 16, nChannels = 1, cbSize = 0)
  self[:wFormatTag] = 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