public AudioSample GetSampleFromArray(byte[] data, float volume, float pitch) { Stream stream = new MemoryStream(data); if (stream.ReadByte() == 'R' && stream.ReadByte() == 'I' && stream.ReadByte() == 'F' && stream.ReadByte() == 'F') { stream.Position = 0; int channels, bits_per_sample, sample_rate; byte[] sound_data = LoadWave(stream, out channels, out bits_per_sample, out sample_rate); AudioSample sample = new AudioSample() { Pcm = sound_data, BitsPerSample = bits_per_sample, Channels = channels, Rate = sample_rate, }; return(sample); } else { stream.Position = 0; AudioSample sample = new OggDecoder().OggToWav(stream, volume, pitch); return(sample); } }
public AudioSample GetSampleFromArray(byte[] data, float volume, float pitch) { Stream stream = new MemoryStream(data); if (stream.ReadByte() == 'R' && stream.ReadByte() == 'I' && stream.ReadByte() == 'F' && stream.ReadByte() == 'F') { stream.Position = 0; int channels, bits_per_sample, sample_rate; byte[] sound_data = LoadWave(stream, out channels, out bits_per_sample, out sample_rate); AudioSample sample = new AudioSample() { Pcm = sound_data, BitsPerSample = bits_per_sample, Channels = channels, Rate = sample_rate, }; return sample; } else { stream.Position = 0; AudioSample sample = new OggDecoder().OggToWav(stream, volume, pitch); return sample; } }