Example #1
0
        private void OpenAudioFile()
        {
            var ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == true)
            {
                audioStream       = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                canComputeFourier = true;

                fileInfo = FileHeaderUtil.GetHeaderInfo(audioStream);
                audioStream.Seek(0, SeekOrigin.Begin);

                FirstSampleIndex = 0;
                OnPropertyChanged("MaximumSampleIndex");
                OnPropertyChanged("CanComputeFourier");
            }
        }
Example #2
0
        public static uint[] ReadSamples(Stream readFrom, int startAt, int windowSize, FileInfo info)
        {
            readFrom.Seek(-((info.SampleBits / 8) * (info.SampleCount - startAt)), SeekOrigin.End);
            uint[] samples = new uint[windowSize];

            int i = 0;

            for (; i < windowSize; i++)
            {
                samples[i] = SampleUtils.ReadSample(readFrom, info);
                if (info.Channels == Channel.Stereo)
                {
                    SampleUtils.ReadSample(readFrom, info);
                }
            }

            return(samples);
        }