This project has moved. For the latest updates, please go here.

cant click on my stop button

Nov 20, 2013 at 5:24 AM
I am pulling data from the mic and displaying it to two graphs

one time graph

and FFT graph

during real time... but I cant click on my stop button to stop sampling data..

for my graph I am using Zedgraph

now when i was using Microsoft chart that came C# i can use the stop button but not it is like it never gets call

how do I fix this ?
void waveIn_DataAvailable(object sender, WaveInEventArgs e)
        {
            
            // myPane.XAxis.MajorTic. = (1D / (double)samplerate1);
            // Make up some data points from the Sine function
            PointPairList list = new PointPairList();
           PointPairList list2 = new PointPairList();
            byte[] buffer = e.Buffer;
            int bytesRecorded = e.BytesRecorded;
            buffer1 = new float[bytesRecorded];
            //  WriteToFile(buffer, bytesRecorded);

            for (int index = 0; index < e.BytesRecorded; index += 2)
            {
                short sample = (short)((buffer[index + 1] << 8) |
                                        buffer[index + 0]);
                float sample32 = sample / 32768f;
                buffer1[index] = sample32;
            }
          //  buffer1 = new float[1024];

          /*  for (int n = 0; n < 1024; n++)
            {

                buffer1[n] = (float)(10000D * Math.Sin((2D * 2000D * Math.PI * n) / 44100D));

            }*/

            DSP = new DSPclass(buffer1, 44100);
            DSP.FFT1(buffer1);
            float[] F = new float[bytesRecorded];
            float[] C = new float[bytesRecorded];
            int temp = DSP.frequencies(F, C);
            
            for (int u = 0; u < temp; u++)
            {

            list2.Add((double)F[u], (double)C[u]);
                
            }

          //  int u = 100; 
           
            for (int i = 0; i < buffer1.Length; i++)
            {
                list.Add(counter, (double)buffer1[i]);
                counter++;
            }

            LineItem myCurve = myPane.AddCurve("", list, System.Drawing.Color.Blue, SymbolType.Circle);
            LineItem myCurve2 = myPane2.AddCurve("", list2, System.Drawing.Color.Blue, SymbolType.Circle);
            zedGraphControl1.IsShowHScrollBar = true;
            zedGraphControl1.IsAutoScrollRange = true;
            zedGraphControl1.AxisChange();
            zedGraphControl1.Refresh();

            zedGraphControl2.IsShowHScrollBar = true;
            zedGraphControl2.IsAutoScrollRange = true;
            zedGraphControl2.AxisChange();
            zedGraphControl2.Refresh();
          //  Stop();
        }

        void Stop()
        {
            if (waveIn != null)
            {
                waveIn.StopRecording();
                waveIn.Dispose();

            }
        }
Nov 20, 2013 at 6:51 PM
Dear Sir,

I also in need to get FFT work, and looks for complex for me . Can you please post your project, please.
Thanks for your support.

Waleed
Coordinator
Nov 21, 2013 at 3:28 PM
if you can't click your stop button you probably have a performance issue. You should not try to plot every single sample you receive. There are 44100 of them each second. You'd need at least 22 monitors side by side to display one second of audio.
Nov 21, 2013 at 3:35 PM
thanks Markheath...

so I ended up using a timer to and set it to 100 ms for display only..
and now i can click on the stop button