<commit_before>﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LiveSPICE
{
    /// <summary>
    /// Interaction logic for AudioConfiguration.xaml
    /// </summary>
    public partial class AudioStream : UserControl, INotifyPropertyChanged
    {
        protected Circuit.Quantity latency = new Circuit.Quantity(50e-3m, Circuit.Units.s);
        public Circuit.Quantity Latency
        {
            get { return latency; }
            set 
            { 
                latency.Set(value);
                OpenStream(); 
                NotifyChanged("Latency"); 
            }
        }

        private Audio.Driver driver;
        public Audio.Driver Driver
        {
            get { return driver; }
            set 
            { 
                driver = value; 
                
                devices.Items.Clear();
                if (value != null)
                {
                    App.Current.Settings.AudioDriver = driver.Name;

                    foreach (Audio.Device i in driver.Devices)
                        devices.Items.Add(new ComboBoxItem() { Content = i.Name, Tag = i });
                    Device = driver.Devices.FindOrDefault(i => i.Name == App.Current.Settings.AudioDevice, driver.Devices.FirstOrDefault());
                    OpenStream();
                }

                NotifyChanged("Driver"); 
            }
        }

        private Audio.Device device;
        public Audio.Device Device
        {
            get { return device; }
            set 
            {
                device = value;

                inputs.Items.Clear();
                outputs.Items.Clear();
                if (device != null)
                {
                    App.Current.Settings.AudioDevice = device.Name;

                    foreach (Audio.Channel i in device.InputChannels)
                        inputs.Items.Add(new ComboBoxItem() { Content = i.Name, Tag = i });
                    foreach (Audio.Channel i in device.OutputChannels)
                        outputs.Items.Add(new ComboBoxItem() { Content = i.Name, Tag = i });

                    Input = device.InputChannels.FindOrDefault(i => i.Name == App.Current.Settings.AudioInput, device.InputChannels.FirstOrDefault());
                    Output = device.OutputChannels.FindOrDefault(i => i.Name == App.Current.Settings.AudioOutput, device.OutputChannels.FirstOrDefault());
                }

                NotifyChanged("Device"); 
            }
        }

        private Audio.Channel input;
        public Audio.Channel Input
        {
            get { return input; }
            set 
            {
                input = value;
                if (input != null)
                {
                    App.Current.Settings.AudioInput = input.Name;
                    OpenStream();
                }
                NotifyChanged("InputChannel"); 
            }
        }

        private Audio.Channel output;
        public Audio.Channel Output
        {
            get { return output; }
            set
            {
                output = value;
                if (output != null)
                {
                    App.Current.Settings.AudioOutput = output.Name;
                    OpenStream();
                }
                NotifyChanged("OutputChannel"); 
            }
        }

        private double inputGain = App.Current.Settings.InputGain;
        public int InputGain 
        {
            get { return (int)Math.Round(20 * Math.Log(inputGain, 10)); }
            set 
            {
                inputGain = Math.Pow(10, value / 20.0);
                App.Current.Settings.InputGain = inputGain; 
                NotifyChanged("InputGain"); 
            }
        }

        private double outputGain = App.Current.Settings.OutputGain;
        public int OutputGain 
        {
            get { return (int)Math.Round(20 * Math.Log(outputGain, 10)); }<commit_msg>Fixed channel combo boxes<commit_after>﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace LiveSPICE
{
    /// <summary>
    /// Interaction logic for AudioConfiguration.xaml
    /// </summary>
    public partial class AudioStream : UserControl, INotifyPropertyChanged
    {
        protected Circuit.Quantity latency = new Circuit.Quantity(50e-3m, Circuit.Units.s);
        public Circuit.Quantity Latency
        {
            get { return latency; }
            set 
            { 
                latency.Set(value);
                OpenStream(); 
                NotifyChanged("Latency"); 
            }
        }

        private Audio.Driver driver;
        public Audio.Driver Driver
        {
            get { return driver; }
            set 
            { 
                driver = value; 
                
                devices.Items.Clear();
                if (value != null)
                {
                    App.Current.Settings.AudioDriver = driver.Name;

                    foreach (Audio.Device i in driver.Devices)
                        devices.Items.Add(new ComboBoxItem() { Content = i.Name, Tag = i });
                    Device = driver.Devices.FindOrDefault(i => i.Name == App.Current.Settings.AudioDevice, driver.Devices.FirstOrDefault());
                    OpenStream();
                }

                NotifyChanged("Driver"); 
            }
        }

        private Audio.Device device;
        public Audio.Device Device
        {
            get { return device; }
            set 
            {
                device = value;

                inputs.Items.Clear();
                outputs.Items.Clear();
                if (device != null)
                {
                    App.Current.Settings.AudioDevice = device.Name;

                    foreach (Audio.Channel i in device.InputChannels)
                        inputs.Items.Add(new ComboBoxItem() { Content = i.Name, Tag = i });
                    foreach (Audio.Channel i in device.OutputChannels)
                        outputs.Items.Add(new ComboBoxItem() { Content = i.Name, Tag = i });

                    Input = device.InputChannels.FindOrDefault(i => i.Name == App.Current.Settings.AudioInput, device.InputChannels.FirstOrDefault());
                    Output = device.OutputChannels.FindOrDefault(i => i.Name == App.Current.Settings.AudioOutput, device.OutputChannels.FirstOrDefault());
                }

                NotifyChanged("Device"); 
            }
        }

        private Audio.Channel input;
        public Audio.Channel Input
        {
            get { return input; }
            set 
            {
                input = value;
                if (input != null)
                {
                    App.Current.Settings.AudioInput = input.Name;
                    OpenStream();
                }
                NotifyChanged("Input"); 
            }
        }

        private Audio.Channel output;
        public Audio.Channel Output
        {
            get { return output; }
            set
            {
                output = value;
                if (output != null)
                {
                    App.Current.Settings.AudioOutput = output.Name;
                    OpenStream();
                }
                NotifyChanged("Output"); 
            }
        }

        private double inputGain = App.Current.Settings.InputGain;
        public int InputGain 
        {
            get { return (int)Math.Round(20 * Math.Log(inputGain, 10)); }
            set 
            {
                inputGain = Math.Pow(10, value / 20.0);
                App.Current.Settings.InputGain = inputGain; 
                NotifyChanged("InputGain"); 
            }
        }

        private double outputGain = App.Current.Settings.OutputGain;
        public int OutputGain 
        {
            get { return (int)Math.Round(20 * Math.Log(outputGain, 10)); }
{'fraction_non_alphanumeric': 0.09326183259501049, 'fraction_numerical': 0.0037304733038004195, 'mean_word_length': 1.3555738605162, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '959700', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2015, 'n_words': 439}