protected void CallbackAsync(object sender, EventArgs e)
        {
            WavPackager packager = new WavPackager(null);
            RIFFData    riff;

            switch (entry.PanelData.RIFFData.BitsPerSample)
            {
            case 8:
                entry.PanelData.RawChartData[0].RemoveRange(smaller, bigger - smaller);
                entry.PanelData.RawChannelData[0].RemoveRange(smaller, bigger - smaller);
                riff = packager.GenerateRIFFData(entry);
                entry.PanelData.RIFFData = riff;
                break;

            case 16:
                entry.PanelData.RawChartData[0].RemoveRange(smaller, bigger - smaller);
                entry.PanelData.RawChannelData[0].RemoveRange(smaller * 2, (bigger * 2) - (smaller * 2));
                riff = packager.GenerateRIFFData(entry);
                entry.PanelData.RIFFData = riff;
                break;

            case 24:
                entry.PanelData.RawChartData[0].RemoveRange(smaller, bigger - smaller);
                entry.PanelData.RawChannelData[0].RemoveRange(smaller * 3, (bigger * 3) - (smaller * 3));
                riff = packager.GenerateRIFFData(entry);
                entry.PanelData.RIFFData = riff;
                break;

            case 32:
                entry.PanelData.RawChartData[0].RemoveRange(smaller, bigger - smaller);
                entry.PanelData.RawChannelData[0].RemoveRange(smaller * 4, (bigger * 4) - (smaller * 4));
                riff = packager.GenerateRIFFData(entry);
                entry.PanelData.RIFFData = riff;
                break;

            default:
                Console.WriteLine("DeleteWorker - Unsupported bits per sample");
                break;
            }

            entry.TimeChannel1.RefreshViewablePoints();
            if (entry.TimeChannel2 != null)
            {
                entry.TimeChannel2.RefreshViewablePoints();
            }
        }
        protected void CallbackMain(object sender, EventArgs e)
        {
            // Adds last point, since it has changed and needs to expand the scroll range
            AudioChannel load = panel.TimeChannel1;

            if (load.Series.Points[load.Series.Points.Count - 1].XValue != panel.PanelData.RawChartData[0].Count - 1)
            {
                load.Series.Points.AddXY(panel.PanelData.RawChartData[0].Count - 1, panel.PanelData.RawChartData[0][panel.PanelData.RawChartData[0].Count - 1]);
            }
            if (panel.PanelData.RIFFData.Channels > 1)
            {
                load = panel.TimeChannel2;
                if (load.Series.Points[load.Series.Points.Count - 1].XValue != panel.PanelData.RawChartData[1].Count - 1)
                {
                    load.Series.Points.AddXY(panel.PanelData.RawChartData[1].Count - 1, panel.PanelData.RawChartData[1][panel.PanelData.RawChartData[1].Count - 1]);
                }
            }

            // Forced zoom to add scrollbar to new chunk
            double viewMin = panel.TimeChannel1.ChartArea.AxisX.ScaleView.ViewMinimum;
            double viewMax = panel.TimeChannel1.ChartArea.AxisX.ScaleView.ViewMaximum;

            panel.TimeChannel1.ChartArea.AxisX.ScaleView.Zoom(viewMin, viewMax - viewMin);

            // Refresh the viewable area
            panel.TimeChannel1.RefreshViewablePoints();

            if (panel.TimeChannel2 != null)
            {
                panel.TimeChannel2.ChartArea.AxisX.ScaleView.Zoom(viewMin, viewMax - viewMin);
                panel.TimeChannel2.RefreshViewablePoints();
            }

            // Repackage data for playback
            WavPackager packager = new WavPackager(null);

            panel.PanelData.RIFFData = packager.GenerateRIFFData(panel);
            panel.ParentRef.Enable_Edit(true);
            Console.WriteLine("Paste RIFF generated");
        }
Exemple #3
0
        public void Record_Click(object sender, EventArgs e)
        {
            if (Service.DLLWrapper.Safe)
            {
                if (panel.PanelData.RIFFData.SubChunkSize == 0)
                {
                    recording = !recording;
                    if (recording)
                    {
                        play.Enabled = false;
                        record.Text  = "Stop";
                        WavPackager packager = new WavPackager(null);
                        RIFFData    riff     = packager.GenerateRIFFData(panel);
                        panel.PanelData.RIFFData = riff;
                        Service.DLLWrapper.Record(riff);
                    }
                    else
                    {
                        play.Enabled = true;
                        Enable_Record(false);
                        RIFFData riff = panel.PanelData.RIFFData;
                        riff.Data                = Service.DLLWrapper.RecordStop();
                        riff.SubChunkSize        = riff.Data.Length;
                        panel.PanelData.RIFFData = riff;

                        panel.PanelData.SplitWavData();
                        panel.ClearAllCharts();

                        panel.PanelData.RawChartData.Add(panel.PanelData.GetReadableChannel(0));

                        Workers.ChartRenderWorker worker = new Workers.ChartRenderWorker(panel, 0, true);
                        worker.RunWorkerAsync();

                        if (panel.PanelData.RawChannelData.Count > 1)
                        {
                            panel.Menu.manager.Stereo_Click();
                            panel.Menu.manager.Mono.Enabled = false;

                            panel.PanelData.RawChartData.Add(panel.PanelData.GetReadableChannel(1));

                            Workers.ChartRenderWorker worker2 = new Workers.ChartRenderWorker(panel, 1, true);
                            worker2.RunWorkerAsync();
                        }
                        else
                        {
                            panel.Menu.manager.Mono_Click();
                            panel.Menu.manager.Stereo.Enabled = false;
                        }
                    }

                    panel.Menu.manager.Open_Click();
                }
                else
                {
                    ScrollPanel scroll = (ScrollPanel)panel.ParentRef;
                    scroll.Click_AddChannel(null, EventArgs.Empty);
                    scroll.audioPanels.Last.Value.PlayBar.Record_Click(null, EventArgs.Empty);
                }
            }
            else
            {
                Console.WriteLine("Unsafe Record action attempted and ignored.");
            }
        }