The FromWav
method creates a SoundFile
instance from a WAV file. This method is useful for loading sound data directly from a byte array, allowing for dynamic sound generation or manipulation before loading.
The FromWav
method creates a SoundFile
instance from a WAV file. This method is useful for loading sound data directly from a byte array, allowing for dynamic sound generation or manipulation before loading.
To use the FromWav
method, provide the filename, the byte data of the WAV file, and a boolean indicating whether the sound should loop when played.
Parameters:
filename
(string): The name of the sound file. This is used for identification purposes.data
(System.Span<byte>): The byte data of the WAV file. This should contain the raw audio data.loop
(bool): A boolean value indicating whether the sound should loop when played.Returns: A SoundFile
object representing the loaded sound.
// Example of using the FromWav method to create a SoundFile string filename = "example.wav"; byte[] wavData = File.ReadAllBytes(filename); System.Span<byte> dataSpan = new System.Span<byte>(wavData); bool shouldLoop = true; SoundFile soundFile = SoundFile.FromWav(filename, dataSpan, shouldLoop); // Now you can use soundFile to play the sound, check its properties, etc.