locked
Microsoft.Xna; microphone problems RRS feed

  • Question

  • ok I am reading in from the microphone. I am also play back what I hear and that works fine.

    However when I display the values it is not working right.

    I know  this because when I do not make any noise and record, I still get high values like this 

    it goes up to over 250 and I am not making any noise ... I can play it back and I do hear a  humming  noise... idk why.. will more like white noise then  humming  ... 

    idk

    this is with sound

    it is the high is still around 250...

    why ?

    how do I fix this?

    it should be 0 when i am not making sound 

    here is my code 

     void  graph(ZedGraphControl zgc)                      

     {

                      

     GraphPane myPane = zgc.GraphPane;
                         // Set the titles and axis labels
                myPane.Title.Text = "My Test Graph";
                myPane.XAxis.Title.Text = " Time";
                myPane.YAxis.Title.Text = "My Y Axis";
                // Make up some data points from the Sine function
                PointPairList list = new PointPairList();

                double temp2;
                buffer = new Byte[1024];
                SByte[] bufferS = new SByte[1024];

                    double n = 0;
                    for (int n2 = 0; n2 < Microphone1.buffer.Length; n2++ )
                    {
                        temp2 = Microphone1.buffer[n2];
                        list.Add( n, temp2);
                        n = n + 0.00002267D;

                    }

               

     myPane.XAxis.MajorGrid.IsVisible = true;
                myPane.YAxis.MajorGrid.IsVisible = true;
                myPane.XAxis.MinorGrid.IsVisible = true;
                myPane.YAxis.MinorGrid.IsVisible = true;
                LineItem myCurve = myPane.AddCurve("Input", list, System.Drawing.Color.Blue, SymbolType.Circle);

                zgc.IsShowHScrollBar = true;
                zgc.IsAutoScrollRange = true;
                zgc.AxisChange();
                zgc.Refresh();   

        }

      public void record()
            {
                // Get audio data in 1/2 second chunks
                microphone.BufferDuration = TimeSpan.FromSeconds(1);

                // Allocate memory to hold the audio data
                buffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];

                // Set the stream back to zero in case there is already something in it
                stream.SetLength(0);

                // Start recording
                microphone.Start();
            }

    I am using both 

    using Microsoft.Xna;

    and

    using Microsoft.Xna.Framework.Audio;

    so what should I do ?

    • Moved by Eason_H Wednesday, October 2, 2013 2:38 AM
    Tuesday, October 1, 2013 4:38 PM

Answers

All replies

  • Hi Btb4198,

    Thank you for visiting the MSDN forum.

    I’m afraid that it is not the correct forum about this issue, since this forum is to discuss Visual C#. I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.

    Thanks for your understanding.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    • Edited by Eason_H Wednesday, October 2, 2013 2:37 AM
    Wednesday, October 2, 2013 2:33 AM
  • I'd ask in one of the XNA Game Studio forums.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})


    • Proposed as answer by Dave PatrickMVP Thursday, October 3, 2013 2:57 AM
    • Edited by Just Karl Friday, October 11, 2013 7:41 PM
    • Marked as answer by Just Karl Sunday, October 13, 2013 10:26 PM
    Wednesday, October 2, 2013 2:44 PM
  • that link did not work
    Tuesday, October 8, 2013 3:56 AM
  • Try http://xboxforums.create.msdn.com/forums/default.aspx?GroupID=6

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    Tuesday, October 8, 2013 1:15 PM