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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:19:53+00:00 2026-06-14T10:19:53+00:00

I have this class called AudioInput: class AudioInput { private WaveIn waveIn; public delegate

  • 0

I have this class called AudioInput:

class AudioInput
{
    private WaveIn waveIn;
    public delegate void DataAvailableEventHandler(byte[] data, int size);
    private DataAvailableEventHandler dataAvailableProc;

    public AudioInput(DataAvailableEventHandler dataHandlerProc)
    {
        dataAvailableProc = dataHandlerProc;
    }
    private void initWaveInMic()
    {
        Console.WriteLine("initWaveInMic");
        waveIn = new WaveIn();
        waveIn.BufferMilliseconds = 50;
        waveIn.DeviceNumber = 0;
        waveIn.WaveFormat = new WaveFormat(8000, 1);
        waveIn.DataAvailable += new EventHandler<WaveInEventArgs>(waveIn_DataAvailable);
        waveIn.StartRecording();
    }
    void waveIn_DataAvailable(object sender, WaveInEventArgs e)
    {
        Console.WriteLine("waveIn_DataAvailable e.buffer length: {0}", e.Buffer.Length);
        dataAvailableProc(e.Buffer, e.Buffer.Length);
    }
     public void startNAudio()
    {
        this.initWaveInMic();  //start mic wavein
    }
}

From the calling class:

public partial class AudioTest : Form
{
    Thread audioInputThread;
    AudioInput audioInput;

    private void audioInputCreateThread()
    {
        audioInput = new AudioInput(audioDataToSend);
        audioInput.startNAudio();
        Console.WriteLine("audioInputCreateThread at the end");
    }

    private void AudioTest_Load(object sender, EventArgs e)
    {
        // this will work
        //audioInputCreateThread();

        //this will not work
        audioInputThread = new Thread(audioInputCreateThread);
        audioInputThread.Start();
    }

    private void audioDataToSend(byte[] data, int size)
    {
        Console.WriteLine("audioDataToSend size: {0}", size);
    }
}

The waveIn_DataAvailable callback in the AudioInput class is not getting called. Any suggestions what I did wrong?

  • 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-06-14T10:19:54+00:00Added an answer on June 14, 2026 at 10:19 am

    The WaveInEvent class should be used in this instance. It will create its own background thread, and use a SyncContext to marshal callbacks onto the GUI thread if possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called Paragens like this: public class Paragens { static int
I have this class called SiteAsyncDownload.cs Here's the code: public class SiteAsyncDownloader { WebClient
I have this in a class called MessageQueueReceive. public MessageQueueTransaction BlockingReceive(out Message message) {
I have this class called identity namespace Game.World.Entities { [XmlRoot(Identity)] public class Identity {
I have a class called 'subscribedQueue'. This class receives its data via its subscribed
I have this class called Table: class Table { public string Name { get
i have this class called MemoryManager, it is supposed to implement a simple smart
I have this class called PollFrame that extends JFrame in a file called PollFrame.java
I'm trying to validate an ID. I have this class called ManejadorTickets in which
I have this small class called City that simply holds some information about a

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.