Пример #1
0
 protected override IWavePlayer CreateWavePlayer() =>
 new WaveOutEvent()
 {
     DeviceNumber    = AudioDevices.IndexOf(SelectedAudioDevice),
     DesiredLatency  = Latency * 2, //waveout latency is total duration of all the buffers
     NumberOfBuffers = 2
 };
Пример #2
0
 public void UpdateDevices()
 {
     VideoDevices.Clear();
     AudioDevices.Clear();
     MpsseDevices.Clear();
     PeachCam.EnumerateDevices();
 }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();
            Environment.CurrentDirectory = AssemblyHelper.GetDirectory();

            tray                     = new TaskbarIcon();
            tray.Visibility          = Visibility.Hidden;
            tray.ToolTipText         = "Open Voice Modder";
            tray.TrayLeftMouseDown  += (s, e) => { tray.Visibility = Visibility.Hidden; this.Show(); this.WindowState = WindowState.Normal; };
            tray.TrayRightMouseDown += (s, e) => this.MuteOutput.IsChecked = !this.MuteOutput.IsChecked;

            this.MuteOutput.IsChecked = Properties.Settings.Default.Muted;
            try
            {
                AudioManager.instance.UpdateDevices(
                    AudioDevices.ListDevices(DataFlow.Capture)[Properties.Settings.Default.InputIndex],
                    AudioDevices.ListDevices(DataFlow.Render)[Properties.Settings.Default.OutputIndex]);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error, please update your settings.");
            }

            if (!String.IsNullOrEmpty(Properties.Settings.Default.Save))
            {
                RestoreAudioData(JObject.Parse(Properties.Settings.Default.Save));
            }

            KeyboardHook.Initialize();
            KeyboardHook.KeyIntercept += (a, k) =>
            {
                if (a == KeyAction.WM_KEYDOWN)
                {
                    foreach (UIElement element in SongsHolder.Children)
                    {
                        if (element is SoundController)
                        {
                            if ((element as SoundController).KeyBind == k.ToString())
                            {
                                (element as SoundController).Play();
                            }
                        }
                    }

                    if (k.ToString() == Properties.Settings.Default.BeepKey)
                    {
                        AudioResampler.Instance.Censor = true;
                    }
                }
                if (a == KeyAction.WM_KEYUP)
                {
                    if (k.ToString() == Properties.Settings.Default.BeepKey)
                    {
                        AudioResampler.Instance.Censor = false;
                    }
                }
            };
        }
Пример #4
0
        public void AddDevice(string deviceID)
        {
            var newItem = _getAudioDeviceAction.Invoke(deviceID);

            if (newItem != null)
            {
                AudioDevices.Add(newItem);
            }
        }
Пример #5
0
 private void RefreshAudioDevices(object sender, RoutedEventArgs e)
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         var devices = Controller.GetPlaybackDevices(DeviceState.Active);
         AudioDevices.Clear();
         foreach (var d in devices.OrderBy(x => x.Name))
         {
             AudioDevices.Add(d);
         }
     }));
 }
Пример #6
0
        public WaveOutAudioPlayer(IWaveProvider waveProvider) : base(waveProvider)
        {
            audioDevices = new ObservableCollection <string>();

            for (int i = 0; i < WaveOut.DeviceCount; i++)
            {
                var caps = WaveOut.GetCapabilities(i);
                audioDevices.Add(caps.ProductName);
            }

            SelectedAudioDevice = AudioDevices.FirstOrDefault();
        }
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         MMDevice item = AudioDevices.FirstOrDefault(q => (string.Compare(q.ToString(), value.ToString(), true) == 0));
         return(item);
     }
     else
     {
         return(base.ConvertFrom(context, culture, value));
     }
 }
        private void FillAudioDevices()
        {
            if (AudioDevices.Count > 0)
            {
                AudioDevices.Clear();
            }

            var deviceCount = WaveOut.DeviceCount;

            for (int i = 0; i < deviceCount; i++)
            {
                AudioDevices.Add(WaveOut.GetCapabilities(i));
            }
        }
Пример #9
0
 public VlcMediaPlayer(LibVLC libVLC, MediaPlayer mediaPlayer)
 {
     _libVLC                    = libVLC;
     MediaPlayer                = mediaPlayer;
     MediaPlayer.Playing       += MediaPlayer_Playing;
     MediaPlayer.Paused        += MediaPlayer_Paused;
     MediaPlayer.Muted         += MediaPlayer_Muted;
     MediaPlayer.Unmuted       += MediaPlayer_Unmuted;
     MediaPlayer.TimeChanged   += MediaPlayer_TimeChanged;
     MediaPlayer.VolumeChanged += MediaPlayer_VolumeChanged;
     MediaPlayer.ESAdded       += MediaPlayer_ESAdded;
     MediaPlayer.ESDeleted     += MediaPlayer_ESDeleted;
     MediaPlayer.ESSelected    += MediaPlayer_ESSelected;
     MediaPlayer.AudioDevice   += MediaPlayer_AudioDevice;
     AudioDevices.AddRange(MediaPlayer.AudioOutputDeviceEnum.Select(device => new VlcAudioDevice(device)));
 }
Пример #10
0
        public void AddDevice(DeviceType deviceType, int index, string description, string friendlyName)
        {
            switch (deviceType)
            {
            case DeviceType.Video:
                VideoDevices.Add(new Tuple <int, string, string>(index, description, friendlyName));
                break;

            case DeviceType.Audio:
                AudioDevices.Add(new Tuple <int, string, string>(index, description, friendlyName));
                break;

            case DeviceType.MPSSE:
                MpsseDevices.Add(new Tuple <int, string, string>(index, description, friendlyName));
                break;
            }
        }
Пример #11
0
        private static void AudioSessionManage(object sender, EventArgs e)
        {
            AudioSessionManager2   sessionManager    = GetDefaultAudioSessionManager2(DataFlow.Render);
            AudioSessionEnumerator sessionEnumerator = sessionManager.GetSessionEnumerator();

            foreach (AudioSessionControl session in sessionEnumerator)
            {
                AudioVolume(session, 100);
                AudioSession(session);
            }
            SetVolumePID(13160, 100);
            SetDefaultMasterVolume(21);

            AudioDevices test = new AudioDevices();

            test.UpdateAudioDevices();
            test.SetDefaultAudioDevice(0);
        }
        public InstrumentAudioRecorderSettingsViewModel(IViewServices viewServices, ModuleSchema schema, string midiName)
        {
            this.viewServices = viewServices;
            this.schema       = schema;
            var groups = schema.InstrumentGroups
                         .Where(ig => ig.Preset)
                         .Select(ig => ig.Description)
                         .ToList();

            groups.Insert(0, "(All)");
            InstrumentGroups        = groups;
            selectedInstrumentGroup = groups[0];
            InputDevices            = AudioDevices.GetInputDeviceNames();

            // Try to guess at a reasonable input based on known inputs including the MIDI name.
            var expectedInputDevices = new[] { $"MASTER ({midiName})", $"IN ({midiName})", $"KICK ({midiName})" };

            SelectedInputDevice = InputDevices.FirstOrDefault(inputName => expectedInputDevices.Contains(inputName));

            kitNumber = schema.KitRoots.Count;
            SelectOutputFileCommand = new DelegateCommand(SelectOutputFile, true);
        }
        private void SelectCurrentDevice()
        {
            var guid = Settings.Default.SoundOutputGuid;

            if (guid != Guid.Empty)
            {
                var device = AudioDevices.FirstOrDefault(it => it.ProductGuid == guid);

                if (device.ProductGuid != Guid.Empty)
                {
                    CurrentAudioDevice = device;
                }
                else
                {
                    Settings.Default.SoundOutputGuid = Guid.Empty;
                    Settings.Default.Save();
                }
            }
            else
            {
                CurrentAudioDevice = null;
            }
        }
Пример #14
0
        public SettingsWindow()
        {
            InitializeComponent();
            AudioDevices.ListDevices(DataFlow.Capture).ToList()
            .ForEach(dv =>
                     InputDevices.Items.Add(new DeviceData()
            {
                device = dv
            }));

            AudioDevices.ListDevices(DataFlow.Render).ToList()
            .ForEach(dv =>
                     OutputDevices.Items.Add(new DeviceData()
            {
                device = dv
            }));

            int iIndex = Properties.Settings.Default.InputIndex;
            int oIndex = Properties.Settings.Default.OutputIndex;

            if (InputDevices.Items.Count == 0 || OutputDevices.Items.Count == 0)
            {
                MessageBox.Show("Error: No avaiable audio devices !");
                Environment.Exit(-1);
                return;
            }

            iIndex = iIndex >= InputDevices.Items.Count ? 0 : iIndex;
            oIndex = oIndex >= OutputDevices.Items.Count ? 0 : oIndex;

            InputDevices.SelectedIndex  = iIndex;
            OutputDevices.SelectedIndex = oIndex;

            beepBind.Text            = Properties.Settings.Default.BeepKey;
            MinimizeToTray.IsChecked = Properties.Settings.Default.MinimizeToTray;
        }
Пример #15
0
        /// <summary>
        /// Updates the devices.
        /// </summary>
        private void UpdateDevices()
        {
            try
            {
                if (string.IsNullOrEmpty(this.FFmpegPath) || !File.Exists(this.FFmpegPath))
                {
                    return;
                }
            }
            catch { return; }

            var ffmpeg = new ProcessHelper(this.FFmpegPath)
            {
                Arguments = "-hide_banner -list_devices 1 -f dshow -i dummy"
            };

            ffmpeg.Start();
            var lines = ffmpeg.StandardError;

            var gettingVid = false;
            var gettingAud = false;

            AudioDevices.Clear();
            VideoDevices.Clear();

            foreach (var item in lines)
            {
                if (item.Contains("DirectShow video devices"))
                {
                    gettingVid = true;
                    gettingAud = false;
                    continue;
                }
                else if (item.Contains("DirectShow audio devices"))
                {
                    gettingAud = true;
                    gettingVid = false;
                    continue;
                }
                else if (string.IsNullOrEmpty(item) || item.Contains("Alternative name") || item.Contains("exit requested"))
                {
                    continue;
                }

                var quoteIndex = item.IndexOf("\"", StringComparison.Ordinal);
                if (quoteIndex < 0)
                {
                    continue;
                }

                var device = item.Remove(0, quoteIndex + 1);
                quoteIndex = device.IndexOf("\"", StringComparison.Ordinal);
                if (quoteIndex < 0)
                {
                    throw new ArgumentNullException(item);
                }

                device = device.Remove(quoteIndex);

                if (gettingAud)
                {
                    AudioDevices.Add(device);
                }
                if (gettingVid)
                {
                    VideoDevices.Add(device);
                }
            }

            OnDevicesUpdated();
        }
Пример #16
0
 private IEnumerable <AudioDevice> ConvertDeviceDescriptors(IEnumerable <AudioDevicesWatcher.AudioDeviceDescriptor> audioDeviceDescriptors)
 {
     return(audioDeviceDescriptors.Select(desc => AudioDevices.FirstOrDefault(x => x.AudioDeviceDescriptor != null && string.Equals(desc.Id, x.AudioDeviceDescriptor.Id))).Where(x => x != null).ToArray());
 }
Пример #17
0
        private async void Tick(object sender, object e)
        {
            try
            {
                if (startCounter == 10)
                {
                    startCounter--;
                    startTimer.Stop();
                    if (beat == 0)
                    {
                        reboot = await ReadStatus();
                        if (reboot) await WriteStatus(false);
                        await client.LoadQueueAsync();
                    }
                    AudioDeviceStatus();
                    startTimer.Start();
                    text2.Text = startCounter.ToString();     
                }
                else if (startCounter == 0)
                {
                    if (reboot)
                    {
                        startTimer.Stop();
                        await client.SaveQueueAsync();
                        reboot = false;
                        LibRPi.HelperClass hc = new LibRPi.HelperClass();
                        hc.Restart();
                    }
                    else
                    {
                        text1.Text = "STARTED";
                        errorText.Text = "";    
                        startTimer.Stop();

                        audioEngine = new WASAPIEngine();

                        var channels = new AudioChannel[2]
                        {
                            new AudioChannel(0, 0, ""),
                            new AudioChannel(0, 1, "")
                        };
    
                        var devParam = new AudioDevices(channels, 1);
                        var param = new AudioParameters(50000, 200, 50, 250, -50, true, true, "sample.txt", 1000, 212);
                        await audioEngine.InitializeAsync(ThreadDelegate, devParam, param);
                    }
                }
                else
                {
                    text2.Text = startCounter.ToString();
                    startCounter--;
                }
            }
            catch (Exception ex)
            {
                Error("Tick: " + ex.ToString() + " " + ex.Message + " " + ex.HResult);
            }
        }