private void Initialize(SoundReader reader, SampleInfo info) { // Retrieve the sound parameters long sampleCount = info.SampleCount; int channelCount = info.ChannelCount; int sampleRate = info.SampleRate; // Read the samples from the provided file using (reader) { _samples = new short[sampleCount]; if (reader.Read(_samples, sampleCount) == sampleCount) { // Update the internal buffer with the new samples Update(channelCount, sampleRate); } else { throw new Exception("Failed to decode the sound data."); } } }