Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:14:16+00:00 2026-05-23T16:14:16+00:00

I’m using NAudio (but it applies to reading directly) to capture microphone wave data.

  • 0

I’m using NAudio (but it applies to reading directly) to capture microphone wave data. It seems that if my app is busy it drops/skips some input data from the mic.

I’ve set the reading thread to top priority, but I’m doing heavy calculations in several other thread at the same time.

Is there a way to read data lossless?
(Or is it lossless, and my bug elsewhere?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:14:17+00:00Added an answer on May 23, 2026 at 4:14 pm

    When I was making a similar app and had a similar problem, it turned out that I needed a buffer that can hold at least 3 seconds of data. Try to increase the buffer to 10 seconds of data and if it doesn’t solve your problem then there are more issues. If it works try decreasing the buffer size until it works properly

    EDIT: Here a quick & dirty managed dx recording for you to try.

        public class BMSRecordingEventArgs : EventArgs
    {
        byte[] data;
        bool endRec;
    
        public BMSRecordingEventArgs(byte[] data, bool endRec)
        {
            this.data = data;
            this.endRec = endRec;
        }
        public byte[] Data
        {
            get { return data; }
        }
        public bool EndRec
        {
            get { return endRec; }
        }
    }
    public class AudioRecorder
    {
        public delegate void DataReceivedHandler(object sender, BMSRecordingEventArgs e);
        public event DataReceivedHandler DataReceivedHandle;
    
        public const int CAPTURE_BUFFER_SIZE = 32000;
        DXS.Capture dxsCapDev;
        DXS.CaptureBuffer dxsCapBuffer;
        DXS.CaptureBufferDescription dxsCapBufferDesc;
        System.Threading.Thread thrdCapturingThread;
        DXS.BufferPositionNotify[] dxsBpna;
        private volatile bool StopRec;
    
        System.Threading.ManualResetEvent mreStillRunning = new System.Threading.ManualResetEvent(false);
        DXS.BufferPositionNotify dxsBPNHalf;
        DXS.BufferPositionNotify dxsBPNFull;
        DXS.Notify Notify;
        System.Threading.AutoResetEvent ARE;
    
        public AudioRecorder(Guid DeviceGuid,DXS.WaveFormat wfWaveFormat,DXS.CaptureEffectDescription[] dxsCapEffectDesc)
        {
    
            dxsCapDev = new Microsoft.DirectX.DirectSound.Capture(DeviceGuid);
            dxsCapBufferDesc = new Microsoft.DirectX.DirectSound.CaptureBufferDescription();
            dxsCapBufferDesc.BufferBytes = CAPTURE_BUFFER_SIZE;
            dxsCapBufferDesc.Format = wfWaveFormat;
            dxsCapBufferDesc.WaveMapped = true;
            dxsCapBufferDesc.CaptureEffectDescription = dxsCapEffectDesc;
            dxsCapBufferDesc.ControlEffects = true;
    
    
            dxsCapBuffer = new Microsoft.DirectX.DirectSound.CaptureBuffer(dxsCapBufferDesc, dxsCapDev);
    
            ARE = new System.Threading.AutoResetEvent(false);
            dxsBPNHalf = new Microsoft.DirectX.DirectSound.BufferPositionNotify();
            dxsBPNFull = new Microsoft.DirectX.DirectSound.BufferPositionNotify();
            dxsBPNHalf.Offset = CAPTURE_BUFFER_SIZE / 2 - 1;
            dxsBPNFull.Offset = CAPTURE_BUFFER_SIZE-1;
            dxsBPNFull.EventNotifyHandle = ARE.SafeWaitHandle.DangerousGetHandle();
            dxsBPNHalf.EventNotifyHandle = ARE.SafeWaitHandle.DangerousGetHandle();
    
    
            dxsBpna = new Microsoft.DirectX.DirectSound.BufferPositionNotify[2];
            dxsBpna[0] = dxsBPNHalf;
            dxsBpna[1] = dxsBPNFull;
    
            Notify = new Microsoft.DirectX.DirectSound.Notify(dxsCapBuffer);
            Notify.SetNotificationPositions(dxsBpna);
    
        }
    
        public void StartRecording()
        {
            if (thrdCapturingThread != null)
                throw new Exception("Already Recording !");
            StopRec = false;
            thrdCapturingThread = new System.Threading.Thread(Record);
            thrdCapturingThread.Start();
    
    
        }
        private void Record()
        {
            DataReceivedHandler drh2 = DataReceivedHandle;
    
    
            dxsCapBuffer.Start(true);
            byte[] TempBaf = new byte[CAPTURE_BUFFER_SIZE / 2];
            int StartingOffset = 0;
            while (dxsCapBuffer.Capturing && !StopRec)
            {
                ARE.WaitOne(-1,false);
    
                    StartingOffset %= CAPTURE_BUFFER_SIZE;
                    TempBaf = (byte[])dxsCapBuffer.Read(StartingOffset, typeof(byte), Microsoft.DirectX.DirectSound.LockFlag.FromWriteCursor, CAPTURE_BUFFER_SIZE / 2);
                    StartingOffset += TempBaf.Length;
                    if (drh2 != null)
                        drh2(this, new BMSRecordingEventArgs(TempBaf, false));
    
            }
            dxsCapBuffer.Stop();
            if (drh2 != null)
                drh2(this, new BMSRecordingEventArgs(TempBaf, true));
    
            mreStillRunning.Set();
    
    
        }
        public void StopRecording()
        {
            StopRec = true;
            mreStillRunning.WaitOne(-1,false);
            thrdCapturingThread = null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.