} // end enumerateDevices private void startButton_Click(object sender, EventArgs e) { List <string> inputStrings = inputsBox.CheckedItems.OfType <String>().ToList <String>(); int sampleRate = Convert.ToInt32(sampleBox.SelectedItem as String); string selectedOutput = outputBox.SelectedItem as String; RtAudio.Api api = (RtAudio.Api)apiBox.SelectedIndex; Console.WriteLine("Selected API: {0}", api.ToString()); // Try to get the global instance. If we fail, make our own. try { manager = RtAudioManager.GetInstance(); } catch (RtAudioManagerApiException) { manager = new RtAudioManager(); } // end try/catch mixer = manager.CreateMixer(inputStrings, selectedOutput, sampleRate); mixer.Start(); stopButton.Enabled = true; startButton.Enabled = false; }
static void Main(string[] args) { // Get global instance manager = RtAudioManager.GetInstance(); // Create a simple mixer, mixing the default input device to the default output device RtStreamMixer mixer = manager.CreateMixer(new List<string>() { "Default" }, "Default"); // Start the mixer mixer.Start(); // Infinite Loop while (true) { Thread.Sleep(50); } // end while } // end Main
public MainForm() { InitializeComponent(); buffer = new Byte[512]; audio = new RtAudio(); //audio1 = new RtAudio(); mixer = new RtStreamMixer(); // Setup Test Logging EventLoggerManager.TraceLoggingEvent += new LoggingEventHandler(EventLoggerManager_TraceLoggingEvent); EventLoggerManager.DebugLoggingEvent += new LoggingEventHandler(EventLoggerManager_DebugLoggingEvent); EventLoggerManager.InfoLoggingEvent += new LoggingEventHandler(EventLoggerManager_InfoLoggingEvent); EventLoggerManager.WarnLoggingEvent += new LoggingEventHandler(EventLoggerManager_WarnLoggingEvent); EventLoggerManager.ErrorLoggingEvent += new LoggingEventHandler(EventLoggerManager_ErrorLoggingEvent); EventLoggerManager.CriticalLoggingEvent += new LoggingEventHandler(EventLoggerManager_CriticalLoggingEvent); List <RtAudio.Api> compileApis = RtAudio.getCompiledApi(); // List the currently compiled APIs. logger.Debug("Compiled Apis:"); foreach (RtAudio.Api api in compileApis) { //Console.WriteLine(" {0}", api.ToString()); logger.Debug(String.Format(" {0}", api.ToString())); } // end foreach // Enumerate Devices uint deviceCount = audio.getDeviceCount(); //Console.WriteLine("Device Count: {0}", deviceCount); logger.Debug(String.Format("Device Count: {0}", deviceCount)); //Console.WriteLine("Found Devices:"); logger.Debug("Found Devices:"); for (uint idx = 0; deviceCount > idx; idx++) { RtAudio.DeviceInfo info = audio.getDeviceInfo(idx); //Console.WriteLine("ID {1}: {0}:", info.name, idx); //Console.WriteLine(" InputChannels: {0}", info.inputChannels); //Console.WriteLine(" OutputChannels: {0}", info.outputChannels); //Console.WriteLine(" DuplexChannels: {0}", info.duplexChannels); logger.Debug(String.Format("ID {1}: {0}:", info.name, idx)); logger.Debug(String.Format(" InputChannels: {0}", info.inputChannels)); logger.Debug(String.Format(" OutputChannels: {0}", info.outputChannels)); logger.Debug(String.Format(" DuplexChannels: {0}", info.duplexChannels)); if (info.inputChannels > 0) { inputCombo.Items.Add(info.name); inputCombo.SelectedIndex = 0; } // end if if (info.outputChannels > 0) { outputCombo.Items.Add(info.name); outputCombo.SelectedIndex = 0; } // end if } // end for }