class

WAD::Sound

Inherits WritingAdditions::Sound < Reference < Object

A normal sound effect.

Constants

PAD_BYTES = 16

Constructors

from_wav(filename : String | Path) : Sound

Converts a .wav file to a WAD::Sound given a filename

my_wav_sound = WAD::Sound.from_wav("Path/To/Sound.wav")
from_wav(io : IO) : Sound

Converts a .wav file to a WAD::Sound given a io

File.open("Path/To/Sound.wav") do |io|
  my_wav_sound = WAD::Sound.from_wav(io)
end
parse(filename : String | Path) : Sound

Parses a sound lump.

Opens a sound file and parses it:

my_sound = WAD::Sound.parse("Path/To/Sound")
parse(io : IO) : Sound

Parses a sound lump.

Opens a sound io and parses it:

File.open("Path/To/Sound") do |file|
  my_sound = WAD::Sound.parse(file)
end

Class methods

is_sound?(name : String)

Checks to see if name is a sound with name format 'DSx..x'.

Returns true if the name is a sound:

sound_name = "DSNOWAY"
if WAD::Sound.is_sound?(sound_name)
  puts "Is a Sound"
else
  puts "Is not a Sound"
end

Instance methods

clone

Returns a copy of self with all instance variables cloned.

format_num
format_num=(format_num : UInt16)
sample_rate

UInt16 | UInt32 because when reading from a .wav, sample_rate is given in a UInt32

sample_rate=(sample_rate : UInt16 | UInt32)

UInt16 | UInt32 because when reading from a .wav, sample_rate is given in a UInt32

samples
samples=(samples : Array(UInt8))
samples_num

UInt16 | UInt32 because when reading from a .wav, sample_num is given in a UInt32

samples_num=(samples_num : UInt16 | UInt32)

UInt16 | UInt32 because when reading from a .wav, sample_num is given in a UInt32

to_wav(filename : String | Path) : UInt32

Writes to wav file given an output file and returns the written file's size.

Writes a 'wav' file from the my_wad sound "DSPISTOL":

my_wad.sounds["DSPISTOL"].to_wav("Path/To/MyWav.wav")
to_wav(io : IO) : UInt32

Writes to wav file given an output io and returns the written file's size.

Writes a 'wav' file from the my_wad sound "DSPISTOL":

File.open("Path/To/MyWav.wav", "w+") do |io|
  my_wad.sounds["DSPISTOL"].to_wav(io)
end