public ICE(Ear lEar, Ear rEar, Source source, float height, float width) { this.lEar = lEar; this.rEar = rEar; this.source = source; this.max_dist = Math.Max(height, width); }
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(); }