class WAD::Sound

Overview

A normal sound effect.

Included Modules

Defined in:

wa-cr/wad/wad-data/sound.cr
write.cr

Constant Summary

PAD_BYTES = 16

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module WritingAdditions::Sound

write(file : String | Path) : UInt32
write(io : IO) : UInt32
write

Constructor Detail

def self.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")

def self.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

def self.parse(filename : String | Path) : Sound #

Parses a sound lump.

Opens a sound file and parses it:

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

def self.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 Method Detail

def self.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 Method Detail

def clone #

Returns a copy of self with all instance variables cloned.


def format_num : UInt16 #

def format_num=(format_num : UInt16) #

def sample_rate : UInt16 | UInt32 #

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


def sample_rate=(sample_rate : UInt16 | UInt32) #

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


def samples : Array(UInt8) #

def samples=(samples : Array(UInt8)) #

def samples_num : UInt16 | UInt32 #

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


def samples_num=(samples_num : UInt16 | UInt32) #

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


def 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")

def 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