public void Remove_Channel(AudioPanel delete)
        {
            audioPanels.Remove(delete);
            this.Controls.Remove(delete);

            Resize_Panel();
        }
        public RIFFData GenerateRIFFData(AudioPanel panel)
        {
            RIFFData riff = new RIFFData();

            // RIFF Properties
            char[] chunkID = { 'R', 'I', 'F', 'F' };
            riff.ChunkID = Encoding.ASCII.GetBytes(chunkID);
            char[] riffType = { 'W', 'A', 'V', 'E' };
            riff.RIFFType = Encoding.ASCII.GetBytes(riffType);

            // FMT Properties
            char[] formatID = { 'f', 'm', 't', ' ' };
            riff.FormatID   = Encoding.ASCII.GetBytes(formatID);
            riff.FormatSize = 16;
            riff.FormatCode = 1;
            if (panel.Menu.IsMono)
            {
                riff.Channels = 1;
            }
            else
            {
                riff.Channels = 2;
            }
            riff.BitsPerSample = panel.Menu.manager.bits[panel.Menu.manager.checkedBits].Value;

            // Check that loaded file is standard samplerate
            // Use the loaded value if not selectable
            if (panel.PanelData.RIFFData.SampleRate != panel.Menu.manager.khz[panel.Menu.manager.checkedKHZ].Value && panel.PanelData.RIFFData.SampleRate != 0)
            {
                riff.SampleRate = panel.PanelData.RIFFData.SampleRate;
            }
            else
            {
                riff.SampleRate = panel.Menu.manager.khz[panel.Menu.manager.checkedKHZ].Value;
            }
            riff.ByteRate   = riff.BitsPerSample / 8 * riff.SampleRate * riff.Channels;
            riff.BlockAlign = (short)(riff.Channels * riff.BitsPerSample / 8);
            char[] subChunkID = { 'd', 'a', 't', 'a' };
            riff.SubChunkID = Encoding.ASCII.GetBytes(subChunkID);

            // Set the data chunk to be loaded data or null
            if (panel.PanelData.RawChannelData != null)
            {
                riff.Data         = Interleave_Bytes(panel, riff);
                riff.SubChunkSize = riff.Data.Length;
                Console.WriteLine("Data size:" + riff.Data.Length);
            }
            else
            {
                riff.SubChunkSize = 0;
                riff.Data         = null;
            }
            riff.FileSize = 36 + riff.SubChunkSize;

            return(riff);
        }
        public void Click_AddChannel(object sender, EventArgs e)
        {
            Point      p          = new Point(0, SumChannelHeight());
            AudioPanel addedPanel = new AudioPanel(this, p);

            audioPanels.AddLast(addedPanel);
            this.Controls.Add(addedPanel);

            Resize_Panel();
        }
        public byte[] Interleave_Bytes(AudioPanel panel, RIFFData riff)
        {
            int         size   = panel.PanelData.RawChannelData[0].Count;
            List <byte> output = new List <byte>();
            int         inc    = riff.BitsPerSample / 8;

            for (int i = 0; i < size; i += inc)
            {
                for (int ch = 0; ch < riff.Channels; ch++)
                {
                    for (int b = 0; b < inc; b++)
                    {
                        output.Add(panel.PanelData.RawChannelData[ch][i + b]);
                    }
                }
            }

            return(output.ToArray());
        }
        public PasteWorker(AudioPanel entry)
        {
            this.panel               = entry;
            this.DoWork             += new DoWorkEventHandler(Paste);
            this.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CallbackMain);
            panel.ParentRef.Enable_Edit(false);

            this.threads = new Thread[4];

            idftResults = new List <List <int> >();
            idftResults.Add(new List <int>());
            idftResults.Add(new List <int>());
            idftResults.Add(new List <int>());
            idftResults.Add(new List <int>());

            convolutionResults = new List <List <int> >();
            convolutionResults.Add(new List <int>());
            convolutionResults.Add(new List <int>());
            convolutionResults.Add(new List <int>());
            convolutionResults.Add(new List <int>());
        }
Example #6
0
        public AP_PlayBar(AudioPanel panel, int xPos, int yPos, int width, int height)
        {
            this.panel      = panel;
            this.BackColor  = Color.FromArgb(255, 40, 40, 40);
            this.Location   = new Point(xPos, yPos);
            this.ClientSize = new Size(width, height);

            play           = new Button();
            play.Text      = "Play";
            play.ForeColor = Color.White;
            play.Click    += new EventHandler(Play_Click);
            play.Location  = new Point(5, 5);
            this.Controls.Add(play);

            stop           = new Button();
            stop.Text      = "Stop";
            stop.ForeColor = Color.White;
            stop.Click    += new EventHandler(Stop_Click);
            stop.Location  = new Point(105, 5);
            stop.Enabled   = false;
            this.Controls.Add(stop);

            record           = new Button();
            record.Text      = "Record";
            record.ForeColor = Color.White;
            record.Click    += new EventHandler(Record_Click);
            record.Location  = new Point(210, 5);
            this.Controls.Add(record);

            timer          = new System.Timers.Timer(100.0);
            timer.Elapsed += HandleTimer;
            timeElapsed    = 0;

            time           = new Label();
            time.Text      = 0 + " / " + 0 + " seconds";
            time.ForeColor = Color.White;
            time.Width     = 200;
            time.Location  = new Point(5, 35);
            this.Controls.Add(time);
        }
 public DeleteWorker(AudioPanel entry)
 {
     this.entry               = entry;
     this.DoWork             += new DoWorkEventHandler(ZeroYValues);
     this.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CallbackAsync);
 }