Пример #1
0
        private void ApplyPreset(ImpulsePreset newPreset)
        {
            preset = newPreset;
            ImpulseConfig.Clear();
            foreach (var ic in preset.ImpulseConfig)
            {
                var vm = AddImpulseConfigVm(ic);
                Task.Delay(100).ContinueWith(_ => vm.Update());
            }

            MixingConfig = new MixingViewModel(preset.MixingConfig, preset.SamplerateTransformed)
            {
                OnUpdateCallback = () => updateRateLimiter.Pulse()
            };

            SelectedImpulseConfigIndex = 0;
            NotifyPropertyChanged(nameof(MixingConfig));
            NotifyPropertyChanged(nameof(Samplerate));
            NotifyPropertyChanged(nameof(ImpulseLength));
            NotifyPropertyChanged(nameof(Normalize));
            NotifyPropertyChanged(nameof(WindowMethod));
            NotifyPropertyChanged(nameof(SamplerateReadout));
            NotifyPropertyChanged(nameof(ImpulseLengthReadout));
            updateRateLimiter.Pulse();
        }
Пример #2
0
        public MainViewModel()
        {
            Logging.SetupLogging();
            PortAudio.Pa_Initialize();

            var realtimeProcesingExePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "IrWorkshop.RealtimeProcessing.exe");

            realtimeProcess = new RealtimeProcessManager(realtimeProcesingExePath);
            realtimeProcess.PrematureTerminationCallback = logOutput => ExceptionDialog.ShowDialog("Audio engine has died", string.Join("\r\n", logOutput));

            //ensure copy dependency
            // ReSharper disable once UnusedVariable
            var ttt = typeof(RealtimeProcessing.Program);

            var mSec = new MemoryMappedFileSecurity();

            mSec.AddAccessRule(new AccessRule <MemoryMappedFileRights>(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MemoryMappedFileRights.FullControl, AccessControlType.Allow));
            try
            {
                memoryMap  = MemoryMappedFile.CreateNew("Global\\IRWorkshopMap", 65536, MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.None, mSec, HandleInheritability.Inheritable);
                mmAccessor = memoryMap.CreateViewAccessor();
            }
            catch (IOException ex)
            {
                if (ex.Message.Contains("already exists"))
                {
                    Logging.ShowMessage("IR Workshop Studio is already running", LogType.Information, true);
                    Environment.Exit(0);
                }

                throw;
            }
            catch (Exception)
            {
                Logging.ShowMessage("This software needs to run in Administrator mode", LogType.Error, true);
                throw;
            }

            volumeSlider  = 0.7;
            preset        = new ImpulsePreset();
            ImpulseConfig = new ObservableCollection <ImpulseConfigViewModel>();
            MixingConfig  = new MixingViewModel(preset.MixingConfig, preset.SamplerateTransformed)
            {
                OnUpdateCallback = () => updateRateLimiter.Pulse()
            };

            Title        = "IR Workshop - v" + Assembly.GetExecutingAssembly().GetName().Version;
            settingsFile = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "settings.json");

            NewPresetCommand  = new DelegateCommand(_ => NewPreset());
            OpenPresetCommand = new DelegateCommand(_ => OpenPreset());
            SavePresetCommand = new DelegateCommand(_ => SavePreset());

            AudioSetupCommand         = new DelegateCommand(_ => AudioSetup());
            RestartAudioEngineCommand = new DelegateCommand(_ => RestartAudioEngine());
            ExportWavCommand          = new DelegateCommand(_ => ExportWav());
            ShowAboutCommand          = new DelegateCommand(_ => ShowAbout());
            CheckForUpdatesCommand    = new DelegateCommand(_ => Process.Start("https://github.com/ValdemarOrn/IRWorkshop"));

            AddImpulseCommand       = new DelegateCommand(_ => AddImpulse());
            RemoveImpulseCommand    = new DelegateCommand(_ => RemoveImpulse());
            MoveImpulseLeftCommand  = new DelegateCommand(_ => MoveImpulseLeft());
            MoveImpulseRightCommand = new DelegateCommand(_ => MoveImpulseRight());
            CloneImpulseCommand     = new DelegateCommand(_ => CloneImpulse());
            SwitchGraphsCommand     = new DelegateCommand(_ => SwitchGraphs());
            selectedInputL          = -1;
            selectedInputR          = -1;
            selectedOutputL         = -1;
            selectedOutputR         = -1;

            updateRateLimiter = new LastRetainRateLimiter(100, Update);

            LoadSettings();

            var t = new Thread(SaveSettingsLoop)
            {
                IsBackground = true
            };

            t.Priority = ThreadPriority.Lowest;
            t.Start();

            var t3 = new Thread(UpdateClipIndicators)
            {
                IsBackground = true
            };

            t3.Priority = ThreadPriority.Lowest;
            t3.Start();

            AddImpulse();
            Update();
            UpdateMemoryMap();
            StartAudioEngine();

            CheckPreviousRunException();
        }