class WAD::Sound
- WAD::Sound
- Reference
- Object
Overview
A normal sound effect.
Included Modules
Defined in:
wa-cr/wad/wad-data/sound.crwrite.cr
Constant Summary
-
PAD_BYTES =
16
Constructors
-
.from_wav(filename : String | Path) : Sound
Converts a .wav file to a
WAD::Sound
given a filename -
.from_wav(io : IO) : Sound
Converts a .wav file to a
WAD::Sound
given a io -
.parse(filename : String | Path) : Sound
Parses a sound lump.
-
.parse(io : IO) : Sound
Parses a sound lump.
Class Method Summary
-
.is_sound?(name : String)
Checks to see if name is a sound with name format 'DSx..x'.
Instance Method Summary
-
#clone
Returns a copy of
self
with all instance variables cloned. - #format_num : UInt16
- #format_num=(format_num : UInt16)
-
#sample_rate : UInt16 | UInt32
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 : Array(UInt8)
- #samples=(samples : Array(UInt8))
-
#samples_num : UInt16 | UInt32
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.
-
#to_wav(io : IO) : UInt32
Writes to wav file given an output io and returns the written file's size.
Instance methods inherited from module WritingAdditions::Sound
write(file : String | Path) : UInt32write(io : IO) : UInt32 write
Constructor Detail
Converts a .wav file to a WAD::Sound
given a filename
my_wav_sound = WAD::Sound.from_wav("Path/To/Sound.wav")
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
Parses a sound lump.
Opens a sound file and parses it:
my_sound = WAD::Sound.parse("Path/To/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
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
UInt16 | UInt32 because when reading from a .wav, sample_rate is given in a UInt32
UInt16 | UInt32 because when reading from a .wav, sample_rate is given in a UInt32
UInt16 | UInt32 because when reading from a .wav, sample_num is given in a UInt32
UInt16 | UInt32 because when reading from a .wav, sample_num is given in a 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")
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