/// <summary>
        /// Bake a new AudioClip from the original source with the given parameters
        /// </summary>
        /// <returns>The new AudioClip baked with the given parameters</returns>
        public AudioClip Bake()
        {
            // Create a new AudioClip
            AudioClip ajusted = AudioClip.Create("Footstep", source.samples, source.channels, source.frequency, false);

            // Read the samples from the source clip
            float[] samples = new float[source.samples];
            source.GetData(samples, 0);

            // Pitch the samples acording to the given pitch
            Profiler.BeginSample("Bake single AudioClip");
            PitchShifter.PitchShift(pitch, samples.Length, 32, 32, ajusted.frequency, samples);
            Profiler.EndSample();

            // Normalize the audio
            AudioNormalizer.Normalize(samples);

            // Write the ajusted samples to the new AudioClip
            ajusted.SetData(samples, 0);

            return(ajusted);
        }
        private void ValidateWMAFile(byte[] wmaFileData)
        {
            bool      flag           = true;
            Exception innerException = null;
            string    text           = null;
            string    text2          = null;
            string    text3          = null;

            try
            {
                text  = Path.GetTempFileName();
                text2 = Path.GetTempFileName();
                text3 = Path.GetTempFileName();
                using (FileStream fileStream = new FileStream(text3, FileMode.Create, FileAccess.ReadWrite, FileShare.None))
                {
                    BinaryWriter binaryWriter = new BinaryWriter(fileStream);
                    binaryWriter.Write(wmaFileData);
                    fileStream.Flush();
                }
                using (WmaReader wmaReader = new WmaReader(text3))
                {
                    using (PcmWriter pcmWriter = new PcmWriter(text, wmaReader.Format))
                    {
                        byte[] array = new byte[wmaReader.SampleSize * 2];
                        int    count;
                        while ((count = wmaReader.Read(array, array.Length)) > 0)
                        {
                            pcmWriter.Write(array, count);
                        }
                    }
                }
                using (PcmReader pcmReader = new PcmReader(text))
                {
                    using (WmaWriter wmaWriter = new Wma8Writer(text2, pcmReader.WaveFormat))
                    {
                        byte[] array2 = new byte[wmaWriter.BufferSize];
                        double num    = 0.0;
                        int    num2;
                        while ((num2 = pcmReader.Read(array2, array2.Length)) > 0)
                        {
                            AudioNormalizer.ProcessBuffer(array2, num2, 9E-05, 0.088, ref num);
                            wmaWriter.Write(array2, num2);
                        }
                    }
                }
                using (FileStream fileStream2 = new FileStream(text2, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    if (fileStream2.Length > (long)ImportRecipientDataProperty.MaxWmaSize.ToBytes())
                    {
                        base.WriteError(new ArgumentException(Strings.ErrorWMAFileTooBig), ErrorCategory.InvalidData, null);
                    }
                    BinaryReader binaryReader = new BinaryReader(fileStream2);
                    this.data = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length);
                }
            }
            catch (InvalidWmaFormatException ex)
            {
                flag           = false;
                innerException = ex;
            }
            catch (UnsupportedAudioFormat unsupportedAudioFormat)
            {
                flag           = false;
                innerException = unsupportedAudioFormat;
            }
            catch (COMException ex2)
            {
                flag           = false;
                innerException = ex2;
            }
            catch (IOException exception)
            {
                base.WriteError(exception, ErrorCategory.InvalidOperation, null);
            }
            finally
            {
                if (File.Exists(text))
                {
                    File.Delete(text);
                }
                if (File.Exists(text2))
                {
                    File.Delete(text2);
                }
                if (File.Exists(text3))
                {
                    File.Delete(text3);
                }
                if (!flag)
                {
                    base.WriteError(new FormatException(Strings.ErrorInvalidWMAFormat, innerException), ErrorCategory.InvalidData, null);
                }
            }
        }