Beispiel #1
0
        /// <summary>
        /// Initialize the PracticeSharp Application
        /// </summary>
        private void InitializeApplication()
        {
            // Set process priority to high - to minimize playback hiccups
            Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.High;

            InitializeConfiguration();
            InitializeMRUFiles();

            m_versionUpdater = new VersionUpdater(this, m_appVersion);
            m_versionUpdater.CheckNewVersion();

            // Create the PracticeSharpLogic back end layer
            m_practiceSharpLogic = new PracticeSharpLogic();
            m_practiceSharpLogic.Initialize();
            m_practiceSharpLogic.StatusChanged += new PracticeSharpLogic.StatusChangedEventHandler(practiceSharpLogic_StatusChanged);
            m_practiceSharpLogic.PlayTimeChanged += new EventHandler(practiceSharpLogic_PlayTimeChanged);
            m_practiceSharpLogic.CueWaitPulsed += new EventHandler(practiceSharpLogic_CueWaitPulsed);

            EnableControls( false );

            openFileDialog.InitialDirectory = Properties.Settings.Default.LastAudioFolder;
            openFileDialog.FilterIndex = Properties.Settings.Default.LastFilterIndex;

            playPauseButton.Image = Resources.Play_Normal;
            writePresetButton.Image = Resources.save_icon;
            resetPresetButton.Image = Resources.Eraser_icon;
            openFileButton.Image = Resources.OpenFile_icon;

            cueComboBox.SelectedIndex = 0;
            m_presetControls = new Dictionary<string, PresetControl>();
            m_presetControls.Add("1", presetControl1);
            m_presetControls.Add("2", presetControl2);
            m_presetControls.Add("3", presetControl3);
            m_presetControls.Add("4", presetControl4);
            m_presetControls.Add("5", presetControl5);
            m_presetControls.Add("6", presetControl6);
            m_presetControls.Add("7", presetControl7);
            m_presetControls.Add("8", presetControl8);

            // Set defaults
            tempoTrackBar_ValueChanged(this, new EventArgs());
            pitchTrackBar_ValueChanged(this, new EventArgs());
            volumeTrackBar_ValueChanged(this, new EventArgs());
            playTimeTrackBar_ValueChanged(this, new EventArgs());

            InitializeTimeStretchProfiles();
        }
Beispiel #2
0
        /// <summary>
        /// Event handler for PracticeSharpLogic status changes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="newStatus"></param>
        private void practiceSharpLogic_StatusChanged(object sender, PracticeSharpLogic.Statuses newStatus)
        {
            if ( m_jumpMode || m_practiceSharpLogic == null || m_practiceSharpLogic.Status == PracticeSharpLogic.Statuses.Terminating || m_practiceSharpLogic.Status == PracticeSharpLogic.Statuses.Terminated)
                return;
            
            this.BeginInvoke(new MethodInvoker(delegate()
            {
                if (m_practiceSharpLogic == null || m_practiceSharpLogic.Status == PracticeSharpLogic.Statuses.Terminating || m_practiceSharpLogic.Status == PracticeSharpLogic.Statuses.Terminated)
                    return;

                appStatusLabel.Text = newStatus.ToString();

                if ( (newStatus == PracticeSharpLogic.Statuses.Stopped)
                   || (newStatus == PracticeSharpLogic.Statuses.Pausing)
                   || (newStatus == PracticeSharpLogic.Statuses.Error) )
                {
                    playPauseButton.Image = Resources.Play_Normal;
                    playTimeUpdateTimer.Enabled = false;

                    // m_ignorePlayTimeUIEvents = true;
                    // Force a last refresh of play time controls
                    UpdateCurrentUpDownControls(m_practiceSharpLogic.CurrentPlayTime);
                    int currentPlayTimeValue = 0;
                    if (m_practiceSharpLogic.FilePlayDuration.TotalSeconds > 0)
                    {
                        currentPlayTimeValue = Convert.ToInt32(100.0f * m_practiceSharpLogic.CurrentPlayTime.TotalSeconds / m_practiceSharpLogic.FilePlayDuration.TotalSeconds);
                        if (currentPlayTimeValue > playTimeTrackBar.Maximum)
                            currentPlayTimeValue = playTimeTrackBar.Maximum;
                    }
                    playTimeTrackBar.Value = currentPlayTimeValue;
                    positionMarkersPanel.Refresh();
                }
                else if (newStatus == PracticeSharpLogic.Statuses.Playing)
                {
                    playPauseButton.Image = Resources.Pause_Normal;
                    playTimeUpdateTimer.Enabled = true;
                }
            } )
            );
        }
Beispiel #3
0
        /// <summary>
        /// Form closing (before it actually closes) event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            playTimeUpdateTimer.Stop();

            if (m_practiceSharpLogic != null)
            {
                m_practiceSharpLogic.Terminate();

                m_practiceSharpLogic.StatusChanged -= new PracticeSharpLogic.StatusChangedEventHandler(practiceSharpLogic_StatusChanged);
                m_practiceSharpLogic.PlayTimeChanged -= new EventHandler(practiceSharpLogic_PlayTimeChanged);
                m_practiceSharpLogic.CueWaitPulsed -= new EventHandler(practiceSharpLogic_CueWaitPulsed);

                m_practiceSharpLogic.Dispose();
                m_practiceSharpLogic = null;

                // Allow previous events from practice sharp logic to finish - To avoid racing on MainForm which causes exceptions in PracticeSharp event handlers
                Thread.Sleep(100);
                Application.DoEvents();
            }
        }