コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        // looking
        this.fpsCamera = FindObjectOfType <Camera>();
        this.fpsCamera.transform.eulerAngles = this.transform.eulerAngles;

        // moving
        this.animator  = GetComponent <Animator>();
        this.height    = GetComponent <Collider>().bounds.extents.y;
        this.rigidbody = GetComponent <Rigidbody>();

        // ICETest
        this.speaker       = GameObject.Find("Speaker2");
        this.speakerOutput = new WaveOut()
        {
            DesiredLatency = 100
        };
        sourceLocation = new SourceLocation(0, 0, 1);
        VoiceStream     voiceStream    = new VoiceStream(mp3Reader.ToSampleProvider(), new ILowLevelVoiceEffect[] { new ICEFilter(sourceLocation) }, new IHighLevelVoiceEffect[0]);
        ISampleProvider sampleProvider = voiceStream.GetSampleProvider();

        voiceStream.Run();
        speakerOutput.PlaybackStopped += (_, __) =>
        {
            mp3Reader.Dispose();
        };
        speakerOutput.Init(sampleProvider);
        speakerOutput.Play();
    }
コード例 #2
0
ファイル: Form1.cs プロジェクト: lukyhruska96/VRLife
        public Form1()
        {
            InitializeComponent();
            this.center = new Point(this.panel1.Width / 2, this.panel1.Height / 2);
            this.lEar   = new Ear(side_e.E_LEFT, new Point(this.center.X + 60, this.center.Y));
            //this.rEar = new Ear(side_e.E_RIGHT, new Point(this.center.X + 60, this.center.Y));
            this.source = new Source(center);
            enumObjects.Add(this.lEar);
            //enumObjects.Add(this.rEar);
            enumObjects.Add(this.source);
            timer.Enabled  = true;
            timer.Interval = 20;
            timer.Tick    += new EventHandler(TimerCallback);
            mp3Reader      = new Mp3FileReader("test.mp3");
            WaveOut player = new WaveOut()
            {
                DesiredLatency = 100
            };

            sourceLocation = new SourceLocation(0, 0, 1);
            VoiceStream     voiceStream    = new VoiceStream(mp3Reader.ToSampleProvider(), new ILowLevelVoiceEffect[] { new ICEFilter(sourceLocation) }, new IHighLevelVoiceEffect[0]);
            ISampleProvider sampleProvider = voiceStream.GetSampleProvider();

            voiceStream.Run();
            //using (WaveFileWriter writer = new WaveFileWriter("output.wav", sampleProvider.WaveFormat))
            //{
            //    int size = 13 * 777;
            //    float[] buff = new float[size];
            //    //int read = sampleProvider.Read(buff, 0, size);
            //    //writer.WriteSamples(buff, 0, read);
            //    for (int i = 0; i < 10; ++i)
            //    {
            //        int read = sampleProvider.Read(buff, 0, size);
            //        writer.WriteSamples(buff, 0, read);
            //    }
            //}

            player.PlaybackStopped += (_, __) =>
            {
                mp3Reader.Dispose();
            };
            player.Init(sampleProvider);
            player.Play();
        }