示例#1
0
        public override bool Equals(object obj)
        {
            if ((obj == null) || (GetType() != obj.GetType()))
            {
                return(false);
            }
            WAVFormat format = (WAVFormat)obj;

            return(this == format);
        }
        /// <summary>
        /// Add a filename to our list of files for processing
        /// </summary>
        /// <param name="filename">The completely pathed filename of the file to read</param>
        private void AddAudioFilename(String filename)
        {
            WAVFormat format = WAVFile.GetAudioFormat(filename);

            if (format.NumChannels > 1)
            {
                //TODO: Pop up something here
                return;
            }

            if (format.BitsPerSample != 8 && format.BitsPerSample != 16)
            {
                Console.Out.WriteLine(format.BitsPerSample);
                return;
            }

            if (!WAVFile.IsWaveFile(filename))
            {
                //TODO: Pop up a window to alert the user that an invalid file was specified
                return;
            }

            Downsampler.WavetableRef wavref = new WavetableRef();
            wavref.filename = Path.GetFileName(filename);
            wavref.filedir  = Path.GetDirectoryName(filename);
            wavref.filepath = filename;
            mSoundFiles.Add(wavref);

            fileGridView.Rows.Add(1);

            int rowNum = fileGridView.Rows.Count - 1;

            fileGridView.Columns[0].AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            fileGridView.Rows[rowNum].Cells[0].Value = wavref.filename;
            fileGridView.Rows[rowNum].Cells[1].Value = "Copy (As Array)";
            fileGridView.Rows[rowNum].Cells[2].Value = "Remove";
        }
示例#3
0
    /// <summary>
    /// Returns a WAVFormat struct containing audio format information
    /// (# channels, sample rate, and bits per sample) for a WAV file.
    /// </summary>
    /// <param name="pFilename">The name of the file about which to retrieve format information</param>
    /// <returns>A WAVFormat struct object containing the audio format information for the open file</returns>
    public static WAVFormat GetAudioFormat(String pFilename)
    {
        WAVFormat format = new WAVFormat();

        WAVFile audioFile = new WAVFile();
        if (audioFile.Open(pFilename, WAVFileMode.READ).Length == 0)
        {
            format.BitsPerSample = audioFile.mBitsPerSample;
            format.NumChannels = audioFile.mNumChannels;
            format.SampleRateHz = audioFile.mSampleRateHz;

            audioFile.Close();
        }

        return (format);
    }