Example #1
0
        // Toolstrip menu trigger that opens the OpenFileDialog to import a .wav file into a new WaveViewer
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FileStream     fStream    = null;
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter      = "Wave Files|*.wav|All Files|*.*";
            fileDialog.FilterIndex = 1;


            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((fStream = (FileStream)fileDialog.OpenFile()) != null)
                    {
                        WaveViewer newWave = new WaveViewer(this, fStream);
                        newWave.Left      = 10;
                        newWave.Top       = 10 + (newWave.Height + 10) * getWaveCount();
                        newWave.Width     = this.Width - 40;
                        newWave.MdiParent = this;
                        newWave.Show();
                        addViewer(newWave);
                        setSelected(getWaveCount() - 1);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read from disk. Message: " + ex.Message);
                }
            }
        }
Example #2
0
        private bool threaded;     // Whether or not the main program is specified as threaded

        /*
         * Constructor that initializes the display.
         *
         * params:
         * wave - The WaveViewer that this FrequencyDomain object represents
         * data - Byte array of sample data
         * bitSample - Quantization level of given samples
         * thread - Whether or not to thread calculations
         */
        public FrequencyDomain(WaveViewer wave, byte[] data, short bitSample, bool thread)
        {
            owner          = wave;
            max            = 0;
            fBin           = 0;
            lowPass.X      = 0;
            lowPass.Y      = 0;
            lowPass.Height = this.ClientSize.Height;
            lowPass.Width  = 0;
            original       = new int[data.Length * 8 / bitSample];
            bins           = new Complex[original.Length];
            if (bitSample == 8)
            {
                for (int i = 0; i < data.Length; i++)
                {
                    original[i] = data[i];
                }
            }
            else if (bitSample == 16)
            {
                for (int i = 0; i < original.Length; i++)
                {
                    original[i] = BitConverter.ToInt16(data, i * 2);
                }
            }
            threaded = thread;
            applyWindow('n');
            InitializeComponent();
        }
Example #3
0
 // Removes the requested WaveViewer from the waves List
 public void removeWave(WaveViewer wave)
 {
     for (int i = waves.IndexOf(wave); i < waves.Count; i++)
     {
         waves[i].Top -= wave.Height + 10;
     }
     waves.Remove(wave);
 }
Example #4
0
        // Creates a new WaveViewer window with given specifications
        private void submit_Click(object sender, EventArgs e)
        {
            RadioButton buttons      = qbox.Controls.OfType <RadioButton>().FirstOrDefault(n => n.Checked);
            short       quantization = (short)(buttons.Name == "sixteen" ? 16 : 8);
            WaveViewer  newWave      = new WaveViewer(caller, (int)sampleRate.Value, quantization);

            newWave.Left      = 10;
            newWave.Top       = 10 + (newWave.Height + 10) * caller.getWaveCount();
            newWave.Width     = caller.Width - 40;
            newWave.MdiParent = caller;
            newWave.Show();
            caller.addViewer(newWave);
            caller.setSelected(caller.getWaveCount() - 1);
            Close();
        }
Example #5
0
 // Gets the index of the requested WaveViewer
 public int getWaveViewer(WaveViewer wv)
 {
     return(waves.IndexOf(wv));
 }
Example #6
0
 // Adds provided WaveViewer to the main waves List
 public void addViewer(WaveViewer wv)
 {
     waves.Add(wv);
 }
 public AddSignalDialog(WaveViewer caller)
 {
     this.caller = caller;
     InitializeComponent();
 }