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 6245975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:36:20+00:00 2026-05-24T12:36:20+00:00

I am trying to record audio in C# using NAudio. After looking at the

  • 0

I am trying to record audio in C# using NAudio. After looking at the NAudio Chat Demo, I used some code from there to record.

Here is the code:

using System;
using NAudio.Wave;

public class FOO
{
    static WaveIn s_WaveIn;

    static void Main(string[] args)
    {
        init();
        while (true) /* Yeah, this is bad, but just for testing.... */
            System.Threading.Thread.Sleep(3000);
    }

    public static void init()
    {
        s_WaveIn = new WaveIn();
        s_WaveIn.WaveFormat = new WaveFormat(44100, 2);

        s_WaveIn.BufferMilliseconds = 1000;
        s_WaveIn.DataAvailable += new EventHandler<WaveInEventArgs>(SendCaptureSamples);
        s_WaveIn.StartRecording();
    }

    static void SendCaptureSamples(object sender, WaveInEventArgs e)
    {
        Console.WriteLine("Bytes recorded: {0}", e.BytesRecorded);
    }
}

However, the eventHandler is not being called. I am using .NET version ‘v2.0.50727’ and compiling it as:

csc file_name.cs /reference:Naudio.dll /platform:x86
  • 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-24T12:36:21+00:00Added an answer on May 24, 2026 at 12:36 pm

    If this is your whole code, then you are missing a message loop. All the eventHandler specific events requires a message loop. You can add a reference to Application or Form as per your need.

    Here is an example by using Form:

    using System;
    using System.Windows.Forms;
    using System.Threading;
    using NAudio.Wave;
    
    public class FOO
    {
        static WaveIn s_WaveIn;
    
        [STAThread]
        static void Main(string[] args)
        {
            Thread thread = new Thread(delegate() {
                init();
                Application.Run();
            });
    
            thread.Start();
    
            Application.Run();
        }
    
        public static void init()
        {
            s_WaveIn = new WaveIn();
            s_WaveIn.WaveFormat = new WaveFormat(44100, 2);
    
            s_WaveIn.BufferMilliseconds = 1000;
            s_WaveIn.DataAvailable += new EventHandler<WaveInEventArgs>(SendCaptureSamples);
            s_WaveIn.StartRecording();
        }
    
        static void SendCaptureSamples(object sender, WaveInEventArgs e)
        {
            Console.WriteLine("Bytes recorded: {0}", e.BytesRecorded);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using the code in http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html to record audio. Basically this code:
I am trying to record data from my mobile phone's audio interface. I used
I am trying to record using the iphones microphone: This is my code: NSArray
I'm trying to record sound by creating an android application. here is the code:
i've been trying to record and play recorded audio in android . I've used
I'm trying to develop an Audio Capture application using the AudioRecord class from android
i'm trying to record an audio sample with AudioRecord. I've used a thread to
I am trying to record audio using an iPhone app and send the audio
I am trying to record some audio in my app. i open the audio
I am trying out the record outgoing call using mic written this code 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.