public void append(double[] left, double[] right, int length)
 {
     while (RateConvertContext.convert(mContext, left, right, length))
     {
         mReceiver.append(mContext.bufferLeft, mContext.bufferRight, mContext.length);
     }
 }
        public static void run()
        {
            string    dir    = System.Windows.Forms.Application.StartupPath;
            const int LEN    = 100000;
            const int BUFLEN = 1000;
            // 元データのサンプルレート
            int rate_from = 48000;
            // 変換するサンプルレート
            int rate_to = 44100;
            // 何ヘルツの音のサイン波を作るか
            const double hz = 440.0;
            // 周期
            double             period = 1.0 / hz;
            RateConvertContext c      = new RateConvertContext(rate_from, rate_to);

            double[] left    = new double[BUFLEN];
            double[] right   = new double[BUFLEN];
            int      j       = 0;
            int      total_s = 0;
            int      total_d = 0;

            using (System.IO.StreamWriter sw_src = new System.IO.StreamWriter(System.IO.Path.Combine(dir, "TestRateConvertContext_src.txt")))
                using (System.IO.StreamWriter sw_dst = new System.IO.StreamWriter(System.IO.Path.Combine(dir, "TestRateConvertContext_dst.txt"))) {
                    for (int i = 0; i < LEN; i++)
                    {
                        double x = i / (double)rate_from;
                        double y = Math.Sin(2.0 * Math.PI * x / period);
                        left[j]  = y;
                        right[j] = y;
                        j++;
                        if (j >= BUFLEN)
                        {
                            // srcログに時系列データを書き込み
                            for (int k = 0; k < BUFLEN; k++)
                            {
                                double sx = total_s / (double)rate_from;
                                sw_src.WriteLine(sx + "\t" + left[k]);
                                total_s++;
                            }
                            while (RateConvertContext.convert(c, left, right, j))
                            {
                                for (int k = 0; k < c.length; k++)
                                {
                                    double dx = total_d / (double)rate_to;
                                    sw_dst.WriteLine(dx + "\t" + c.bufferRight[k]);
                                    total_d++;
                                }
                            }
                            j = 0;
                        }
                    }
                    if (j > 0)
                    {
                        // srcログに時系列データを書き込み
                        for (int k = 0; k < BUFLEN; k++)
                        {
                            double sx = total_s / (double)rate_from;
                            sw_src.WriteLine(sx + "\t" + left[k]);
                            total_s++;
                        }
                        while (RateConvertContext.convert(c, left, right, j))
                        {
                            for (int k = 0; k < c.length; k++)
                            {
                                double dx = total_d / (double)rate_to;
                                sw_dst.WriteLine(dx + "\t" + c.bufferRight[k]);
                                total_d++;
                            }
                        }
                    }
                }
        }