private void output_SelectedIndexChanged(object sender, EventArgs e)
        {
            Ratchet.Audio.PlaybackDevice oldDevice = _Device;
            _Mixer  = new Ratchet.Audio.Mixer();
            _Device = (Ratchet.Audio.PlaybackDevice)output.SelectedItem;
            if (oldDevice != _Device)
            {
                if (_Client != null)
                {
                    _Client.Stop();
                }
                _Mixer                    = new Ratchet.Audio.Mixer();
                _Client                   = _Device.CreateClient(_Mixer);
                _Mixer.OutputFormat       = _Client.Format;
                _Mixer.OutputSampleRate   = _Client.SampleRate;
                _Mixer.OutputChannelCount = _Client.ChannelCount;
                _Client.Start();

                // Just use one or two listeners for the demo
                if (_Client.ChannelCount == 1)
                {
                    Ratchet.Audio.Mixer.Listener Center = _Mixer.CreateListener(0.0f, 0.0f, 0.0f, 0);
                }
                else if (_Client.ChannelCount >= 2)
                {
                    Ratchet.Audio.Mixer.Listener Left  = _Mixer.CreateListener(-1.0f, 0.0f, 0.0f, 0);
                    Ratchet.Audio.Mixer.Listener Right = _Mixer.CreateListener(1.0f, 0.0f, 0.0f, 1);
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Ratchet.Audio.PlaybackDevice playbackDevice = FindPlaybackDevice();
            if (playbackDevice == null)
            {
                Console.WriteLine("No playback device found on this computer.");
                System.Environment.Exit(1);
            }

            Ratchet.Audio.RecordingDevice recordingDevice = FindRecordingDevice();
            if (recordingDevice == null)
            {
                Console.WriteLine("No recording device found on this computer.");
                System.Environment.Exit(1);
            }

            Console.WriteLine("Recording Device: " + recordingDevice.Name);
            Console.WriteLine("Playback Device: " + playbackDevice.Name);

            Ratchet.Audio.RecordingClient recordingClient = recordingDevice.CreateClient();
            recordingClient.Start();
            System.Threading.Thread.Sleep(5 * 1000);
            recordingClient.Stop();

            Ratchet.Audio.Mixer Mixer = new Ratchet.Audio.Mixer();
            Mixer.AddSource(new RecordingSource(recordingClient));
            Mixer.CreateListener(-1.0f, 0.0f, 0.0f, 0);
            Mixer.CreateListener(1.0f, 0.0f, 0.0f, 1);
            Mixer.CreateListener(-1.0f, 0.0f, 0.0f, 2);
            Mixer.CreateListener(1.0f, 0.0f, 0.0f, 3);

            Ratchet.Audio.PlaybackClient audioClient = playbackDevice.CreateClient(Mixer);
            Mixer.OutputChannelCount = audioClient.ChannelCount;
            Mixer.OutputFormat       = audioClient.Format;
            Mixer.OutputSampleRate   = audioClient.SampleRate;

            audioClient.Start();
            System.Threading.Thread.Sleep(5 * 1000);
            audioClient.Stop();
        }