public ImpulseConfigViewModel(ImpulseConfig config, ImpulsePreset preset, string loadSampleDirectory) { this.impulseConfig = config; this.preset = preset; this.loadSampleDirectory = loadSampleDirectory; this.updateRateLimiter = new LastRetainRateLimiter(100, UpdateInner); LoadSampleCommand = new DelegateCommand(_ => LoadSampleDialog()); ClearSampleCommand = new DelegateCommand(_ => ClearSample()); PreviousSampleCommand = new DelegateCommand(_ => LoadPreviousSample()); NextSampleCommand = new DelegateCommand(_ => LoadNextSample()); AddStageCommand = new DelegateCommand(_ => AddStage()); RemoveStageCommand = new DelegateCommand(_ => RemoveStage()); MoveStageLeftCommand = new DelegateCommand(_ => MoveStageLeft()); MoveStageRightCommand = new DelegateCommand(_ => MoveStageRight()); PlotImpulseBase = true; LoadSampleData(); selectedSpectrumStageIndex = config.SpectrumStages.Length - 1; }
public MixingViewModel(MixingConfig mixingConfig, double samplerate) { this.mixingConfig = mixingConfig; this.Samplerate = samplerate; this.updateRateLimiter = new LastRetainRateLimiter(100, UpdateInner); StereoEq = new ObservableCollection <double>(mixingConfig.StereoEq); StereoEq.CollectionChanged += (s, e) => { mixingConfig.StereoEq[e.NewStartingIndex] = (double)e.NewItems[0]; Update(); }; StereoPhase = new ObservableCollection <double>(mixingConfig.StereoPhase); StereoPhase.CollectionChanged += (s, e) => { mixingConfig.StereoPhase[e.NewStartingIndex] = (double)e.NewItems[0]; Update(); }; }
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(); }