private void InitDevices() { List <string> toAdd = new List <string>(); for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { toAdd.Add(string.Format("{0} - {1}", i, device.name)); } } cboDevices.Dispatcher.Invoke(() => { cboDevices.Items.Clear(); foreach (string s in toAdd) { cboDevices.Items.Add(s); } }); //cboDevices.SelectedIndex = 0; Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); if (!Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)) { MessageBox.Show("Error while initializing the sound device"); } deviceListInitialized = true; }
private void DefaultWASAPIAudioOutput_Load(object sender, EventArgs e) { try { if ((int)KeppySynthConfiguratorMain.SynthSettings.GetValue("wasapiex", 0) == 1) { ExAccess.Checked = true; } DevicesList.Items.Add("Default WASAPI output device"); int selecteddeviceprev = (int)KeppySynthConfiguratorMain.SynthSettings.GetValue("defaultWdev", 0); BASS_WASAPI_DEVICEINFO info = new BASS_WASAPI_DEVICEINFO(); for (int n = 0; BassWasapi.BASS_WASAPI_GetDeviceInfo(n, info); n++) { AddLineToList(info, n, selecteddeviceprev); } try { DevicesList.SelectedIndex = selecteddeviceprev; } catch { DevicesList.SelectedIndex = 0; } DevicesList.SelectedIndexChanged += new System.EventHandler(this.DevicesList_SelectedIndexChanged); } catch (Exception ex) { MessageBox.Show("Unable to load the dialog.\nBASS is probably unable to start, or it's missing.\n\nError:\n" + ex.ToString(), "Oh no! Keppy's Synthesizer encountered an error!", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); Dispose(); } }
private void init() { for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (!device.IsEnabled) { continue; } var descriptor = string.Format("{0} - {1}", i, device.name); Console.WriteLine(descriptor); Console.WriteLine(" device.IsInput: " + (device.IsInput ? "true" : "false")); Console.WriteLine(" device.IsLoopback: " + (device.IsLoopback ? "true" : "false")); Console.WriteLine(" device.IsDefault: " + (device.IsDefault ? "true" : "false")); Console.WriteLine(" device.IsEnabled: " + (device.IsEnabled ? "true" : "false")); Console.WriteLine(" device.IsDisabled: " + (device.IsDisabled ? "true" : "false")); Console.WriteLine(" device.IsInitialized: " + (device.IsInitialized ? "true" : "false")); Console.WriteLine(" device.IsUnplugged: " + (device.IsUnplugged ? "true" : "false")); if (device.IsLoopback) { inlist.Items.Add(descriptor); } else if (!device.IsInput) { outlist.Items.Add(descriptor); } } inlist.SelectedIndex = 0; outlist.SelectedIndex = 0; }
/// <summary> /// Retrieves information on a device and adds it to the static deviceinfo dictionary do it can be reused later. /// </summary> /// <param name="deviceNo">Device number to retrieve information on.</param> protected void CollectDeviceInfo(int deviceNo) { // Device info is saved in a dictionary so it can be reused lateron. if (!_deviceInfos.ContainsKey(deviceNo)) { Log.Debug("Collecting device info"); BASS_WASAPI_DEVICEINFO bassDeviceInfo = BassWasapi.BASS_WASAPI_GetDeviceInfo(deviceNo); if (bassDeviceInfo == null) { throw new BassLibraryException("BASS_WASAPI_GetDeviceInfo"); } BASS_WASAPI_INFO bassInfo = BassWasapi.BASS_WASAPI_GetInfo(); if (bassInfo == null) { throw new BassLibraryException("BASS_WASAPI_GetInfo"); } DeviceInfo deviceInfo = new DeviceInfo { Name = bassDeviceInfo.name, Driver = "WASAPI", Channels = bassInfo.chans, MinRate = bassInfo.freq, MaxRate = bassInfo.freq, }; GetDeviceFormats(deviceNo, deviceInfo); lock (_deviceInfos) _deviceInfos.Add(deviceNo, deviceInfo); } Log.Debug("WASAPI device info: {0}", _deviceInfos[_deviceNo].ToString()); }
private void Init() { bool result = false; //Old code takes years to find devices (because he cycles through devices that aren't even attached) /*for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) * { * var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); * if (device.IsEnabled && device.IsLoopback) * { * windowInst.devicesCombo.Items.Add(string.Format("{0} - {1}", i, device.name)); * } * }*/ BASS_WASAPI_DEVICEINFO info; for (int i = 1; (info = BassWasapi.BASS_WASAPI_GetDeviceInfo(i)) != null; i++) { if (info.IsEnabled && info.IsLoopback) { AudioDevice d = new AudioDevice(info.name, i); devices.Add(d); windowInst.devicesCombo.Items.Add(string.Format("{0} (ID: {1})", d.m_deviceName, d.m_deviceID)); } } windowInst.devicesCombo.SelectedIndex = 0; Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, false); result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init error!"); } }
private void Main_Load(object sender, EventArgs e) { if (IsWinXPOrOlder()) { if (!Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)) { Error("Can't initialize device"); return; } } else { Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero); BassWasapi.BASS_WASAPI_Init(-1, 0, 2, BASSWASAPIInit.BASS_WASAPI_BUFFER | BASSWASAPIInit.BASS_WASAPI_SHARED, 0, 0, null, IntPtr.Zero); BASS_WASAPI_DEVICEINFO info = new BASS_WASAPI_DEVICEINFO(); BassWasapi.BASS_WASAPI_GetDeviceInfo(BassWasapi.BASS_WASAPI_GetDevice(), info); BassWasapi.BASS_WASAPI_Free(); Bass.BASS_Free(); if (!Bass.BASS_Init(0, info.mixfreq, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero)) { Error("Can't initialize device"); return; } } GetInfoFromStream.RunWorkerAsync(); KSIntegration.RunWorkerAsync(); VoiceBar.Value = 100; VoiceBar.ContextMenu = VoiceUnlock; Position.ContextMenu = ShowTime; Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_MIDI_VOICES, 100000); }
/* * private void CreateContextMenu() * { * _notifyIcon.ContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(); * _notifyIcon.ContextMenuStrip.Items.Add("Dashboard").Click += (s, e) => ShowMainWindow(); * _notifyIcon.ContextMenuStrip.Items.Add("Enable All").Click += (s, e) => MyUtils.EnableAll(); * _notifyIcon.ContextMenuStrip.Items.Add("Disable All").Click += (s, e) => MyUtils.DisableAll(); * * ToolStrip ts = new ToolStrip(); * ToolStripDropDownButton tsddb = new ToolStripDropDownButton("device x"); * ts.Items.Add(tsddb); * //tsddb.DropDown = _notifyIcon.ContextMenuStrip; * * * _notifyIcon.ContextMenuStrip.Items.Add("Exit").Click += (s, e) => ExitApplication(); * } */ private void CreateContextMenu2() { System.Windows.Forms.ContextMenu m = new System.Windows.Forms.ContextMenu(); m.MenuItems.Add("Dashboard").Click += (s, e) => ShowMainWindow(); m.MenuItems.Add("Enable All").Click += (s, e) => MyUtils.EnableAll(); m.MenuItems.Add("Disable All").Click += (s, e) => MyUtils.DisableAll(); List <MenuItem> mItems = new List <MenuItem>(); for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { var x = new MenuItem(string.Format("{0} - {1}", i, device.name), AudioSwitching); mItems.Add(x); } } MenuItem mi = new MenuItem("Audio Device", mItems.ToArray()); m.MenuItems.Add(mi); //tsddb.DropDown = _notifyIcon.ContextMenuStrip; m.MenuItems.Add("Exit").Click += (s, e) => ExitApplication(); _notifyIcon.ContextMenu = m; }
public static void BASSInitSystem(Boolean PreviewMode) { try { Bass.BASS_StreamFree(MainWindow.KMCGlobals._recHandle); Bass.BASS_Free(); Bass.BASS_Init(0, Properties.Settings.Default.AudioFreq, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero); if (!PreviewMode) { Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_MIDI_VOICES, 100000); } else { BassWasapi.BASS_WASAPI_Init(-1, 0, 2, BASSWASAPIInit.BASS_WASAPI_BUFFER, 0, 0, null, IntPtr.Zero); BASS_WASAPI_DEVICEINFO info = new BASS_WASAPI_DEVICEINFO(); BassWasapi.BASS_WASAPI_GetDeviceInfo(BassWasapi.BASS_WASAPI_GetDevice(), info); MainWindow.KMCGlobals.RealTimeFreq = info.mixfreq; BassWasapi.BASS_WASAPI_Free(); Bass.BASS_Free(); Bass.BASS_Init(0, info.mixfreq, BASSInit.BASS_DEVICE_NOSPEAKER, IntPtr.Zero); Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_MIDI_VOICES, 2000); } } catch (Exception ex) { BASSCloseStreamCrash(ex); } }
//Reinitializes active WASAPI device if necessary private void UpdateDevice() { if (WASAPIDeviceIndex == -1) { return; } if (deviceInitialized) { Console.WriteLine("Deinitializing WASAPI device"); BassWasapi.BASS_WASAPI_Stop(true); BassWasapi.BASS_WASAPI_Free(); deviceInitialized = false; } BASS_WASAPI_DEVICEINFO devInfo = BassWasapi.BASS_WASAPI_GetDeviceInfo(WASAPIDeviceIndex); if (devInfo == null) { throw new WASAPIInitializationException("Device " + WASAPIDeviceIndex + " is invalid!"); } if (!BassWasapi.BASS_WASAPI_Init(WASAPIDeviceIndex, devInfo.mixfreq, devInfo.mixchans, BASSWASAPIInit.BASS_WASAPI_AUTOFORMAT | BASSWASAPIInit.BASS_WASAPI_BUFFER, 0f, 0f, WasapiProc, IntPtr.Zero)) { BASSError error = Bass.BASS_ErrorGetCode(); throw new WASAPIInitializationException("Unable to initialize WASAPI device " + WASAPIDeviceIndex, error); } if (!BassWasapi.BASS_WASAPI_Start()) { BASSError error = Bass.BASS_ErrorGetCode(); throw new WASAPIInitializationException("Unable to start WASAPI!", error); } Console.WriteLine("WASAPI device initialized"); deviceNumber = WASAPIDeviceIndex; sampleFrequency = devInfo.mixfreq; BuildLookupTables(); deviceInitialized = true; }
// initialization private void Init() { bool result = false; for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { _devicelist.Items.Add(string.Format("{0} - {1}", i, device.name)); } } foreach (var entry in visualizers) { _visBoz.Items.Add(entry); } _visBoz.SelectedIndex = _visBoz.Items.Count - 1; Visuualizer = visualizers[_visBoz.SelectedIndex]; _devicelist.SelectedIndex = 0; Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } }
public void PrintDevices() { for (int Index = 0; Index < BassWasapi.BASS_WASAPI_GetDeviceCount(); Index++) { var BassDevice = BassWasapi.BASS_WASAPI_GetDeviceInfo(Index); if (BassDevice.IsEnabled && BassDevice.IsLoopback) { Console.WriteLine(string.Format("{0} - {1}", Index, BassDevice.name)); } } }
public static void InitDeviceComboBox(ComboBox deviceComboBox) { for (var i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { deviceComboBox.Items.Add($"{i} - {device.name}"); } } deviceComboBox.SelectedIndex = 0; }
public void GetDevices() { for (int i = 0; i < devCount; i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { _devicelist.Items.Add(string.Format("{0}-{1}", i, device.name)); } } _devicelist.SelectedIndex = 0; }
public List <String> ReturnDevices() { List <String> Devices = new List <String>(); for (int Index = 0; Index < BassWasapi.BASS_WASAPI_GetDeviceCount(); Index++) { var BassDevice = BassWasapi.BASS_WASAPI_GetDeviceInfo(Index); if (BassDevice.IsEnabled && BassDevice.IsLoopback) { Devices.Add(string.Format("{0} - {1}", Index, BassDevice.name)); } } return(Devices); }
public List <string> GetDevices() { List <string> Devices = new List <string>(); for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { BASS_WASAPI_DEVICEINFO device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { Devices.Add(string.Format("{0} - {1}", i, device.name)); } } return(Devices); }
// initialization private void NewInit() { _t.Stop(); _deviceCount = 0; bool result = false; List <int> DeviceActiveIndex = new List <int>(); for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { DeviceActiveIndex.Add(i); _deviceCount++; } } Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } if (_enable) { if (!_initialized) { devindex = DeviceActiveIndex[DeviceActiveIndex.Count - 1]; result = BassWasapi.BASS_WASAPI_Init(devindex, 0, 0, BASSWASAPIInit.BASS_WASAPI_BUFFER, 1f, 0.05f, _process, IntPtr.Zero); if (!result) { var error = Bass.BASS_ErrorGetCode(); MessageBox.Show(error.ToString()); } else { _initialized = true; } } BassWasapi.BASS_WASAPI_Start(); } else { BassWasapi.BASS_WASAPI_Stop(true); } System.Threading.Thread.Sleep(500); _t.Start(); }
// initialization private void Init() { settings = new SettingGroup("Audio Spectrum Settings", ""); selectedDevice = new Setting("Selected Device", "", SettingControl.Dropdown, SettingType.Text, ""); selectedDevice.configuration["options"] = new List <string>(); settings.settings.Add(selectedDevice); channelCount = new Setting("Channels", "", SettingControl.Numeric, SettingType.Integer, 8); channelCount.configuration["interval"] = 1; settings.settings.Add(channelCount); bool result = false; Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { //AudioSpectrumDevice audioDevice = new AudioSpectrumDevice(device,i); //this.Devices.Add(audioDevice); selectedDevice.configuration["options"].Add(string.Format("{0} - {1}", i, device.name)); } //Console.WriteLine(string.Format("{0} - {1}", i, device.name)); } settings.loadSettings(); if (!string.IsNullOrWhiteSpace(selectedDevice.settingValue)) { var str = (selectedDevice.settingValue as string); var array = str.Split(' '); int devindex = Convert.ToInt32(array[0]); var myDevice = BassWasapi.BASS_WASAPI_GetDeviceInfo(devindex); AudioSpectrumDevice audioDevice = new AudioSpectrumDevice(myDevice, devindex, (int)Math.Floor((double)channelCount.settingValue)); this.Devices.Add(audioDevice); } selectedDevice.PropertyChanged += SelectedDevice_PropertyChanged; }
public void UpdateDevices() { windowInst.devicesCombo.Items.Clear(); devices.Clear(); BASS_WASAPI_DEVICEINFO info; for (int i = 1; (info = BassWasapi.BASS_WASAPI_GetDeviceInfo(i)) != null; i++) { if (info.IsEnabled && info.IsLoopback) { AudioDevice d = new AudioDevice(info.name, i); devices.Add(d); windowInst.devicesCombo.Items.Add(string.Format("{0} (ID: {1})", d.m_deviceName, d.m_deviceID)); } } windowInst.devicesCombo.SelectedIndex = 0; }
private void Init() { Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); if (!Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)) { throw new Exception("Init Error"); } for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { BASS_WASAPI_DEVICEINFO device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { devicelist.Items.Add(string.Format("{0} - {1}", i, device.name)); } } devicelist.SelectedIndex = 0; }
// initialization private void Init() { for (var i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { _devicelist.Items.Add($"{i} - {device.name}"); } } _devicelist.SelectedIndex = 0; Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); var result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } }
private void SelectedDevice_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (!string.IsNullOrWhiteSpace(selectedDevice.settingValue)) { foreach (Device dev in Devices) { dev.Dispose(); //Devices.Remove(dev); } //this.Devices.Clear(); var str = (selectedDevice.settingValue as string); var array = str.Split(' '); int devindex = Convert.ToInt32(array[0]); var myDevice = BassWasapi.BASS_WASAPI_GetDeviceInfo(devindex); AudioSpectrumDevice audioDevice = new AudioSpectrumDevice(myDevice, devindex, (int)Math.Floor((double)channelCount.settingValue)); this.Devices.Add(audioDevice); } }
// initialization private void Init() { try { Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UNICODE, true); } catch (System.TypeInitializationException e) { return; // throw new Exception("Init Error", e); } if (!(Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))) { throw new Exception("Init Error"); } try { for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { _devicelist.Items.Add(string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0} - {1}", i, device.name)); System.Diagnostics.Debug.Print("Found device: " + device.name); System.Diagnostics.Debug.Print("Default? " + device.IsDefault); System.Diagnostics.Debug.Print("Input? " + device.IsInput); System.Diagnostics.Debug.Print("Loopb? " + device.IsLoopback); System.Diagnostics.Debug.Print("Unplugged? " + device.IsUnplugged); System.Diagnostics.Debug.Print("Init? " + device.IsInitialized); System.Diagnostics.Debug.Print(device + "\n"); } } } catch (System.DllNotFoundException e) { System.Diagnostics.Debug.Print("It seems like you loaded the wrong basswasapi.dll. Be sure to put the x64-dll to the x64-Build folder and the same with x32-dll in the x32 folder: " + e.Message); } _devicelist.SelectedIndex = 0; absNotRel = false; minSliderValue = 0; }
// initialization private void Init() { bool result = false; for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && (device.IsInput || device.IsLoopback))// && device.IsLoopback) { _devicelist.Items.Add(string.Format("{0} - {1}", i, device.name)); } } _devicelist.SelectedIndex = (_devicelist.Items.Count > 0?1:0); Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } }
public void InitializeBass() { MainFormClass.AudioSourceComboBox.Items.Clear(); int DeviceCount = BassWasapi.BASS_WASAPI_GetDeviceCount(); for (int i = 0; i < DeviceCount; i++) { SetLoadingLabelTo("BASS.NET: Device " + i + " out of " + DeviceCount); var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { MainFormClass.AudioSourceComboBox.Items.Add(string.Format("{0} - {1}", i, device.name)); } } foreach (string s in SerialPort.GetPortNames()) { MainFormClass.ComPortsComboBox.Items.Add(s); } }
private void Init() { Boolean Result = false; for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { BASS_WASAPI_DEVICEINFO device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { _devace.Add(String.Format("{0} - {1}", i, device.name)); } } Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); Result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!Result) { throw new Exception("Ошибка инициализации"); } }
private void Init() { bool result = false; for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { AudioDevice newdevice = new AudioDevice(); newdevice.deviceIndex = i; newdevice.Name = device.name; _devicelist.Add(newdevice); } } Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } }
private async void Grid_Loaded(object sender, RoutedEventArgs e) { if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\Saves")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\Saves"); } SaveFileDialog.DefaultExt = ".txt"; LoadFileDialog.DefaultExt = ".txt"; SaveFileDialog.AddExtension = true; LoadFileDialog.AddExtension = true; AudioSourceCombobox.Items.Clear(); int DeviceCount = BassWasapi.BASS_WASAPI_GetDeviceCount(); for (int i = 0; i < DeviceCount; i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { AudioSourceCombobox.Items.Add(string.Format("{0} - {1}", i, device.name)); } } AudioSourceCombobox.SelectedIndex = 0; RefreshRateCombobox.Items.Clear(); for (int i = 0; i < 105; i += 5) { RefreshRateCombobox.Items.Add(i.ToString()); } RefreshRateCombobox.SelectedIndex = 0; if (File.Exists("Saves\\autosave.txt")) { LoadConfig("Saves\\autosave.txt"); } await GI.FadeIn(this); }
private void DeviceBox_DropDownOpened(object sender, EventArgs e) { if (DeviceBox.Items.Count == 0) { bool result = false; for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { DeviceBox.Items.Add(string.Format("{0} - {1}", i, device.name)); } } DeviceBox.SelectedIndex = 0; Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } } }
public SoundAnalyzer(int channels) { DispatcherTimer = new DispatcherTimer(); DispatcherTimer.Tick += OnDispatcherTimerTick; DispatcherTimer.Interval = TimeSpan.FromMilliseconds(25); DispatcherTimer.IsEnabled = false; isInitialised = false; SpectrumData = new byte[channels]; Channels = channels; Devices = new List <BASS_WASAPI_DEVICEINFO>(); for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { ((List <BASS_WASAPI_DEVICEINFO>)Devices).Add(device); if (device.IsDefault) { CurrentDevice = i; } } } if (CurrentDevice == -1) { CurrentDevice = Devices.Count() - 1; } Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATETHREADS, false); bool result = Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); if (!result) { throw new Exception("Init Error"); } }
private void _t2_Tick(object sender, EventArgs e) { int temp = 0; for (int i = 0; i < BassWasapi.BASS_WASAPI_GetDeviceCount(); i++) { var device = BassWasapi.BASS_WASAPI_GetDeviceInfo(i); if (device.IsEnabled && device.IsLoopback) { temp++; } } if (temp != _deviceCount) { _hanctr = 0; _l.Value = 0; _r.Value = 0; _initialized = false; Free(); NewInit(); } }