Esempio n. 1
0
    /// <summary>
    /// 頻繁に呼んでバッファを補充する
    /// </summary>
    /// <returns></returns>
    public void Streaming()
    {
        if (ChannelBuffers[0].Buffercount > 0)
        {
            double needsmsec = _streambuffermsec - bufwaveprovider16.BufferedDuration.TotalMilliseconds;
            string s;
            s  = "Streaming  ";
            s += "WaveProvider16=" + bufwaveprovider16.BufferedDuration.TotalMilliseconds.ToString();

            if (needsmsec > 0)
            {
                Buffer2NAudio(_streambuffermsec);
                s += "    500msec送信";
            }
            LogMake.Print(s);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 44100Hz,2chのファイル読み込み("main"で追加される)
    /// </summary>
    /// <param name="filename"></param>
    public static void MainFileLoad(string filename)
    {
        IWaveProvider   FloatStereo44100Provider;
        AudioFileReader reader;

        reader          = new AudioFileReader(filename);
        audiofilereader = reader;
        LogMake.Print("Volume消す");

        IWaveProvider stereo;

        if (reader.WaveFormat.Channels == 1)
        {
            if (reader.WaveFormat.Encoding == WaveFormatEncoding.IeeeFloat)
            {
                //NAudio.Wave.SampleProviders.MonoToStereoSampleProvider s = new NAudio.Wave.SampleProviders.MonoToStereoSampleProvider(reader);
                stereo = new Wave16ToFloatProvider(new MonoToStereoProvider16(new WaveFloatTo16Provider(reader)));
                WaveFormatConversionProvider conv = new WaveFormatConversionProvider(new WaveFormat(44100, 2), stereo);
            }
            else if (reader.WaveFormat.Encoding == WaveFormatEncoding.Pcm)
            {
                stereo = new Wave16ToFloatProvider(new MonoToStereoProvider16(reader));
            }
            else
            {
                return;
            }
        }
        else
        {
            stereo = reader;
        }

        FloatStereo44100Provider = stereo;//最終的にこの形式に統一44100にするかどうかは検討の余地あり

        SoundDriver.AddWaveProvider(FloatStereo44100Provider, "main");
    }