public MainViewModel()
        {
            UserInterface = new PolygonWaveFormControl();
            //Always using polygon wave form to display
            this.visualizations = new List <IVisualizationPlugin>()
            {
                new PolygonWaveFormVisualization()
            };
            this.selectedVisualization = this.visualizations.FirstOrDefault();

            this.audioPlayback = new AudioPlayback();
            audioPlayback.MaximumCalculated += audioGraph_MaximumCalculated;
            audioPlayback.FftCalculated     += audioGraph_FftCalculated;



            SelectedIndex      = 0;
            CurrentSimFileName = "No file is selected";
            //CurrentGenoration = "No simulation is currently running";
            OpenFolderCommand = new RelayButtonCommand(o => LoadPreviousSim());
            LoadSoundFile     = new RelayButtonCommand(o => LoadSoundFileForSimulation());
            RunSimulation     = new RelayButtonCommand(o => RunGeneticSimulation());

            //PlayAudioCommand = new RelayButtonCommand(o => PlaySelectedAudioFile());
            PlayAudioCommand = new RelayButtonCommand(o => PlaySelectedAudioFile());

            PauseAudioCommand   = new RelayButtonCommand(o => PauseSelectedAudioFile());
            NextFileCommand     = new RelayButtonCommand(o => NextAudioFile());
            PreviousFileCommand = new RelayButtonCommand(o => PreviousAudioFile());
            StopAudioCommand    = new RelayButtonCommand(o => StopSelectedAudioFile());

            GenerationNameDisplay = "";
        }
Пример #2
0
        private async void Initialize(string filePath)
        {
            Workspace.Instance.SetStatus(TaskStatusType.Loading, $"Loading a file... ({filePath})"); // Set status.

            // Load file.
            string loadedFilePath = await FileLoadAsync(filePath);

            try
            {
                if (loadedFilePath == null)
                {
                    OnClose();
                    return;
                }
                else
                {
                    // Initialize AudioPlayback and Visualizations.
                    _visualizations        = ReflectionHelper.CreateAllInstancesOf <IVisualizationPlugin>().ToList();
                    _selectedVisualization = _visualizations.FirstOrDefault();

                    _audioPlayback = new AudioPlayback();
                    _audioPlayback.MaximumCalculated += OnAudioGraphMaximumCalculated;
                    _audioPlayback.FftCalculated     += OnAudioGraphFftCalculated;

                    string extension = Path.GetExtension(filePath).ToLower();

                    if (extension == ".ogg" || extension == ".rpgmvo" || extension == ".ogg_")
                    {
                        _audioPlayback.Load(loadedFilePath, true); // Load audio file using Ogg Vorbis wave reader.
                    }
                    else
                    {
                        _audioPlayback.Load(loadedFilePath);
                    }

                    // Initialize track bar.
                    _trackBarTimer          = new Timer();
                    _trackBarTimer.Interval = 500;
                    _trackBarTimer.Elapsed += new ElapsedEventHandler(OnTrackBarTimerElapsed);

                    _trackBarMaximumValue = _audioPlayback.GetTotalTime();

                    TimeSpan current = TimeSpan.Zero;
                    _trackBarString = $"{current.ToString(@"hh\:mm\:ss")} / {_trackBarMaximumValue.ToString(@"hh\:mm\:ss")}";

                    // Load file properties.
                    _fileProperties = new FileProperties(filePath);
                }
            }
            catch (Exception ex)
            {
                Workspace.Instance.Report.AddReportWithIdentifier($"{ex.Message}\r\n{ex.StackTrace}", ReportType.Warning);
            }
            finally
            {
                Workspace.Instance.SetStatus(TaskStatusType.Completed, $"Completed."); // Set status.
            }
        }
Пример #3
0
        //--------------------------------------------------------------------------------------------------------
        //------------------------- </RECORD MICROPHONE> ---------------------------------------------------------
        //--------------------------------------------------------------------------------------------------------
        #endregion


        private void CloseWindow()
        {
            timer.Stop();
            Dispose();
            AudioPlayBack.Dispose();
            visualizations = null;
            SelectedDevice = null;
            AudioPlayBack  = null;

            Environment.Exit(0);
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();
            network = new NeuroNetwork.NeuroNetwork(instruments.Count, "weights2");
            network.SaveWeights("weights");
            player = new SoundPlayer();
            player.FftCalculated += audioGraph_FFTCalculated;

            this.visualizations = new List <IVisualizationPlugin> {
                new PolylineWaveFormVisualization()
            };
            this.selectedVisualization = this.visualizations.FirstOrDefault();
        }
Пример #5
0
        public AudioPlaybackViewModel(IEnumerable <IVisualizationPlugin> visualizations)
        {
            this.visualizations        = new List <IVisualizationPlugin>(visualizations);
            this.selectedVisualization = this.visualizations.FirstOrDefault();

            this.audioPlayback = new AudioPlayback();
            audioPlayback.MaximumCalculated += audioGraph_MaximumCalculated;
            audioPlayback.FftCalculated     += audioGraph_FftCalculated;

            PlayCommand     = new DelegateCommand(Play);
            OpenFileCommand = new DelegateCommand(OpenFile);
            StopCommand     = new DelegateCommand(Stop);
            PauseCommand    = new DelegateCommand(Pause);
        }
Пример #6
0
        public AudioPlaybackViewModel(IEnumerable<IVisualizationPlugin> visualizations)
        {
            this.visualizations = new List<IVisualizationPlugin>(visualizations);
            this.selectedVisualization = this.visualizations.FirstOrDefault();

            this.audioPlayback = new AudioPlayback();
            audioPlayback.MaximumCalculated += audioGraph_MaximumCalculated;
            audioPlayback.FftCalculated += audioGraph_FftCalculated;

            PlayCommand = new DelegateCommand(Play);
            OpenFileCommand = new DelegateCommand(OpenFile);
            StopCommand = new DelegateCommand(Stop);
            PauseCommand = new DelegateCommand(Pause);
        }
Пример #7
0
        public AudioPlaybackViewModel(IEnumerable <IVisualizationPlugin> visualizations)
        {
            this.visualizations        = new List <IVisualizationPlugin>(visualizations);
            this.selectedVisualization = this.visualizations.FirstOrDefault();

            this.audioPlayback = new AudioPlayback();
            audioPlayback.MaximumCalculated += new EventHandler <MaxSampleEventArgs>(audioGraph_MaximumCalculated);
            audioPlayback.FftCalculated     += new EventHandler <FftEventArgs>(audioGraph_FftCalculated);

            PlayCommand = new RelayCommand(
                () => this.Play(),
                () => true);
            OpenFileCommand = new RelayCommand(
                () => this.OpenFile(),
                () => true);
            StopCommand = new RelayCommand(
                () => this.Stop(),
                () => true);
            PauseCommand = new RelayCommand(
                () => this.Pause(),
                () => true);
        }
Пример #8
0
        public AudioPlaybackViewModel(IEnumerable<IVisualizationPlugin> visualizations)
        {
            this.visualizations = new List<IVisualizationPlugin>(visualizations);
            this.selectedVisualization = this.visualizations.FirstOrDefault();

            this.audioPlayback = new AudioPlayback();
            audioPlayback.MaximumCalculated += new EventHandler<MaxSampleEventArgs>(audioGraph_MaximumCalculated);
            audioPlayback.FftCalculated += new EventHandler<FftEventArgs>(audioGraph_FftCalculated);

            PlayCommand = new RelayCommand(
                        () => this.Play(),
                        () => true);
            OpenFileCommand = new RelayCommand(
                        () => this.OpenFile(),
                        () => true);
            StopCommand = new RelayCommand(
                        () => this.Stop(),
                        () => true);
            PauseCommand = new RelayCommand(
                        () => this.Pause(),
                        () => true);
        }