MakeHammingWindow() 공개 정적인 메소드

Fills the provided array with normalized Hamming Window data
public static MakeHammingWindow ( float data ) : void
data float
리턴 void
예제 #1
0
        public void GetMidiCodes(int offset, int fftSize = 4096, int maxFreq = 5000)
        {
            AudioClip clip;

            float[]           real, im, window;
            FloatFFT          fft;
            string            assetPath;
            float             binWidth;
            List <FFTBinInfo> binInfos;
            int i;

            real   = new float[fftSize];
            im     = new float[fftSize];
            window = new float[fftSize];

            GATMaths.MakeHammingWindow(window);

            fft = new FloatFFT();
            fft.init(( uint )Mathf.Log(fftSize, 2));
            binWidth = ( float )_sampleRate / fftSize;

            int maxBin = ( int )(( float )maxFreq / binWidth);

            foreach (GATSampleInfo info in _sampleInfos)
            {
                assetPath = AssetDatabase.GUIDToAssetPath(info.GUID);
                clip      = AssetDatabase.LoadAssetAtPath(assetPath, typeof(AudioClip)) as AudioClip;
                if (clip.channels > 1)
                {
                    throw new GATException("Get Midi Codes is a beta feature only available for mono clips");
                }
                clip.GetData(real, offset);
                System.Array.Clear(im, 0, im.Length);
                fft.run(real, im);

                for (i = 0; i < maxBin; i++)
                {
                    real[i] = Mathf.Sqrt(real[i] * real[i] + im[i] * im[i]);
                }

                binInfos = FFTBinInfo.GetLowerMaxBins(real, 0, maxBin, binWidth, .2f);

                info.MidiCode = binInfos[binInfos.Count - 1].GetMidiCode();
            }

            SortByMidiCode();
        }
예제 #2
0
        /// <summary>
        /// Sets and pre-computes the specified
        /// WindowFunction for faster processing.
        /// </summary>
        public void SetWindow(WindowFunction windowFunction)
        {
            if (_windowData == null || _windowData.Length != _appliedFFTSize)
            {
                _windowData = new float[_appliedFFTSize];
            }

            switch (window)
            {
            case WindowFunction.Hanning:

                GATMaths.MakeHanningWindow(_windowData);

                break;

            case WindowFunction.Hamming:

                GATMaths.MakeHammingWindow(_windowData);

                break;
            }
        }