コード例 #1
0
        //--------------------------------------------------------------------------------------------------------
        public MainViewModel()
        {
            RecordCollection = new CollectionRecord();

            this.visualizations = new SpectrumAnalyzerVisualization();
            this.AudioPlayBack  = new AudioPlayBack();

            AudioPlayBack.MaximumCalculated += audioGraph_MaximumCalculated;
            AudioPlayBack.FftCalculated     += audioGraph_FftCalculated;

            var enumerator = new MMDeviceEnumerator();

            CaptureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();
            var defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);

            SelectedDevice         = CaptureDevices.FirstOrDefault(c => c.ID == defaultDevice.ID);
            synchronizationContext = SynchronizationContext.Current;

            this.OpenFileCommand = new RelayCommand(this.OpenFolderAndLoadSound);

            this.PlayCommand = new RelayCommand(this.Play);
            this.StopCommand = new RelayCommand(this.Stop);

            this.NextSound     = new RelayCommand(this.NextTrack);
            this.PreviousSound = new RelayCommand(this.PreviosTrack);

            this.StartRecordCommand = new RelayCommand(this.Record);
            this.StopRecordCommand  = new RelayCommand(this.StopRecord);

            this.CloseWindowCommand = new RelayCommand(this.CloseWindow);
            //---------------------------------------------------------------
            timer.Interval = TimeSpan.FromMilliseconds(900); //Интервал вызова - Обновлять позицию каждые 900 миллисекунд
            timer.Tick    += TimerOnTick;                    //Привязка метода к таймеру
        }
コード例 #2
0
        public AudioCaptureSettingsViewModel()
        {
            CaptureProviders = Modules.Capture;

            IAudioCaptureProvider savedCaptureProvider = Modules.Capture.FirstOrDefault(p => p.GetType().GetSimpleName() == Settings.VoiceProvider);

            if (savedCaptureProvider == null)
            {
                CurrentCaptureProvider = Modules.Capture.FirstOrDefault();
            }
            else
            {
                CurrentCaptureProvider = savedCaptureProvider;

                if (Settings.VoiceDevice != null)
                {
                    var setDevice = CaptureDevices.FirstOrDefault(d => d.Device.Name == Settings.VoiceDevice);
                    if (setDevice != null)
                    {
                        CurrentCaptureDevice = setDevice;
                    }
                }
            }

            VoiceActivationThreshold        = Settings.VoiceActivationLevel;
            VoiceActivationSilenceThreshold = Settings.VoiceActivationContinueThreshold / 100;
            UseVoiceActivation = !Settings.UsePushToTalk;
        }
コード例 #3
0
        private void TryInitializeDevices()
        {
            var enumerator = new MMDeviceEnumerator();

            CaptureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();
            IsAnyDevice    = CaptureDevices.Any();
            var defaultDevice = TryGetDevice(enumerator);

            SelectedDevice = CaptureDevices.FirstOrDefault(c => c.ID == defaultDevice?.ID);
        }
コード例 #4
0
        public void RemoveCaptureDevice(Item item, int count = 1)
        {
            if (CaptureDevices[item] < count)
            {
                return;
            }

            CaptureDevices[item] -= count;

            if (CaptureDevices[item] == 0)
            {
                CaptureDevices.Remove(item);
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: usetool/MyProjects
        public Form1()
        {
            wi = new WaveIn(WaveCallbackInfo.FunctionCallback());//初始化WaveIn对象
            wi.DataAvailable += new EventHandler <WaveInEventArgs>(wi_DataAvailable);
            InitializeComponent();
            //第二步
            MMDeviceEnumerator enumerator = new MMDeviceEnumerator();

            //第三步
            CaptureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();
            //MMDevice defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);
            //第四步
            selectedDevice = CaptureDevices.FirstOrDefault();
            //c => c.ID == defaultDevice.ID
        }
コード例 #6
0
ファイル: WasapiCaptureViewModel.cs プロジェクト: jnm2/NAudio
        public WasapiCaptureViewModel()
        {
            synchronizationContext = SynchronizationContext.Current;
            var enumerator = new MMDeviceEnumerator();

            CaptureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();
            var defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);

            SelectedDevice = CaptureDevices.FirstOrDefault(c => c.ID == defaultDevice.ID);
            RecordCommand  = new DelegateCommand(Record);
            StopCommand    = new DelegateCommand(Stop)
            {
                IsEnabled = false
            };
            RecordingsViewModel = new RecordingsViewModel();
        }
コード例 #7
0
        public MainWindowViewModel()
        {
            Title        = "Photomaton";
            IsFullScreen = true;

            CaptureCommand            = new DelegateCommand(Capture, CanCapture);
            ToggleFullScreenCommand   = new DelegateCommand(ToggleFullScreen, CanToggleFullScreen);
            ToggleStretchCommand      = new DelegateCommand <StretchModes>(ToggleStretch, CanToggleStretch);
            OpenStretchOptionsCommand = new DelegateCommand(OpenStretchOptions, CanOpenStretchOptions);
            OpenSettingsCommand       = new DelegateCommand(OpenSettings, CanOpenSettings);
            ChangeDeviceCommand       = new DelegateCommand <DsDevice>(ChangeDevice, CanChangeDevice);

            if (!Directory.Exists(ImgFolder))
            {
                Directory.CreateDirectory(ImgFolder);
            }

            RefreshDevicesList();
            CaptureDevice = CaptureDevices.FirstOrDefault();
        }