/// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes an object to read SA data from the SA database.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool Initialize(string audioFilePath, bool isForTmpOperation)
        {
            // Check if the DB used in some beta versions still exists. If so,
            // then convert the documents therein to companion transcription files.
            ConvertOldDatabaseToCompanionFiles();

            m_doc = SaAudioDocument.Load(audioFilePath, isForTmpOperation, true);
            if (m_doc != null)
            {
                ResetSegmentEnumerators();
                return(true);
            }

            try {
                using (AudioReader audioReader = new AudioReader()) {
                    AudioReader.InitResult result = audioReader.Initialize(audioFilePath);
                    if (result == AudioReader.InitResult.FileNotFound)
                    {
                        string msg = string.Format(Resources.kstidWaveFileNotFound, GUI.Utils.PrepFilePathForMsgBox(audioFilePath));
                        GUI.Utils.MsgBox(msg, MessageBoxButtons.OK);
                        return(false);
                    }

                    if ((result == AudioReader.InitResult.InvalidFormat))
                    {
                        string msg = string.Format(Resources.kstidInvalidWaveFile, GUI.Utils.PrepFilePathForMsgBox(audioFilePath));
                        GUI.Utils.MsgBox(msg, MessageBoxButtons.OK);
                        return(false);
                    }

                    // Try reading data from older SA audio files, converting
                    // it to Unicode along the way.
                    if (!audioReader.Read())
                    {
                        return(false);
                    }

                    // Now try reading the companion transcription file again.
                    m_doc = SaAudioDocument.Load(audioFilePath, isForTmpOperation, false);
                    ResetSegmentEnumerators();
                }
            } catch (Exception e) {
                string msg = string.Format(Resources.kstidErrorInitializingDocReader, e.Message);
                GUI.Utils.MsgBox(msg, MessageBoxButtons.OK);
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private bool Initialize(string audioFilePath)
        {
            m_doc = SaAudioDocument.Load(audioFilePath, false, true);
            if (m_doc != null)
            {
                ResetSegmentEnumerators();
                return(true);
            }

            try
            {
                using (AudioReader audioReader = new AudioReader())
                {
                    AudioReader.InitResult result = audioReader.Initialize(audioFilePath);
                    if (result == AudioReader.InitResult.FileNotFound)
                    {
                        return(false);
                    }

                    if ((result == AudioReader.InitResult.InvalidFormat))
                    {
                        return(false);
                    }

                    // Try reading data from older SA audio files, converting
                    // it to Unicode along the way.
                    if (!audioReader.Read(true))
                    {
                        return(false);
                    }

                    // Now try reading the companion transcription file again.
                    m_doc = SaAudioDocument.Load(audioFilePath, false, false);
                    ResetSegmentEnumerators();
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes an object to write SA data to the SA database.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public bool Initialize(string audioFilePath, bool isForTmpOperation)
 {
     m_doc = SaAudioDocument.Load(audioFilePath, isForTmpOperation, false);
     return(true);
 }