示例#1
0
 /// <summary>
 /// インパルス応答から周波数応答を設定する
 /// </summary>
 public void SetImpulseResponse(float[] ir)
 {
     Debug.Assert(ir.Length == impulseResponseSamples);
     Buffer.BlockCopy(ir, 0, frequencyResponseX, 0, SizeofFloat * ir.Length);
     Array.Clear(frequencyResponseX, ir.Length, blockSize - ir.Length);
     Array.Clear(frequencyResponseY, 0, blockSize);
     fft.Forward(frequencyResponseX, frequencyResponseY);
 }
示例#2
0
        /// <summary>
        /// すべてのインパルス応答を読み込む
        /// </summary>
        public static void LoadAll(Constant c)
        {
            dictionary.Clear();

            Fft fft = new Fft(c.blockSize);

            for (int i = 0; i < 360; i += 5)
            {
                // Debug.Log($"Load angle:{i}");
                var ir     = new Data(c.blockSize);
                var clip_l = WaveAudioClip.CreateWavAudioClip($"Bytes/elev0/L0e{i:000}a.wav");
                Debug.Assert(clip_l.samples == c.impulseResponseSamples);
                clip_l.GetData(ir.channelLX, 0, c.impulseResponseSamples);
                fft.Forward(ir.channelLX, ir.channelLY);
                var clip_r = WaveAudioClip.CreateWavAudioClip($"Bytes/elev0/R0e{i:000}a.wav");
                Debug.Assert(clip_r.samples == c.impulseResponseSamples);
                clip_r.GetData(ir.channelRX, 0, c.impulseResponseSamples);
                fft.Forward(ir.channelRX, ir.channelRY);
                ir.angle      = i;
                dictionary[i] = ir;
            }
        }
示例#3
0
        /// <summary>
        /// FFTテスト
        /// </summary>
        private void FftTest()
        {
            if (!fftTestFlg)
            {
                return;
            }

            debugButton.AddButton("FftTest", () =>
            {
                float[] x = new float[] { 1, 0, 0, 0 };
                float[] y = new float[] { 0, 0, 0, 0 };
                var t     = new Fft(4);
                t.Forward(x, y);
                t.Inverse(x, y);
                Debug.Log($"result =================================");
                for (int i = 0; i < x.Length; ++i)
                {
                    Debug.Log($"[{i}]:{x[i]:0.00} {y[i]:0.00}");
                }
            });
        }