Example #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();
        }
Example #2
0
 public SpectrumStageViewModel(ImpulsePreset preset, ImpulseConfig config, SpectrumStage stage, int index, Action onUpdateCallback)
 {
     this.applySources = preset.ImpulseConfig.TakeWhile(x => x != config).OrderBy(x => x.Index).ToArray();
     applySources      = new[] { new ImpulseConfig()
                                 {
                                     Name = "None", Index = -1
                                 } }.Concat(applySources).ToArray();
     this.config           = config;
     this.stage            = stage;
     this.onUpdateCallback = onUpdateCallback;
     Index = index;
 }
        public static string SerializePreset(ImpulsePreset preset)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings
            {
                ContractResolver = new WritablePropertiesOnlyResolver()
            };

            settings.Formatting = Formatting.Indented;

            string json = JsonConvert.SerializeObject(preset, settings);

            return(json);
        }
        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;
        }
Example #5
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();
        }