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 of the WAV file, the byte data of the WAV file, and a boolean indicating whether the sound should loop when played.
Parameters:
filename
(System.String
): The name of the WAV file. This is used for identification purposes and does not need to correspond to an actual file on disk.data
(System.Span<System.Byte>
): The byte data of the WAV file. This should contain the raw WAV file data.loop
(System.Boolean
): A boolean value indicating whether the sound should loop when played.// Example of using the FromWav method to create a SoundFile string filename = "example.wav"; byte[] wavData = File.ReadAllBytes("path/to/example.wav"); 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.