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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:34:34+00:00 2026-05-18T02:34:34+00:00

I am making an audio recorded using NAudio in C# and i need to

  • 0

I am making an audio recorded using NAudio in C# and i need to remove the stop button used and simply stop the recording on its own after some time delay.

The code for the record event is

     private void cmbRecord_Click(object sender, EventArgs e)
     {
            outputFilename = "file address";

            waveInStream = new WaveIn(44100,2);
            writer = new WaveFileWriter(outputFilename, waveInStream.WaveFormat);

            waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
            waveInStream.StartRecording();


            // Just controling the objects on the screen.
            cmbRecord.Enabled = false;
            cmbStop.Enabled = true;

    } 


     void waveInStream_DataAvailable(object sender, WaveInEventArgs e)
    {
        writer.WriteData(e.Buffer, 0, e.BytesRecorded);
        int secondsRecorded = (int)(writer.Length / writer.WaveFormat.AverageBytesPerSecond);

    }

The stop button is given as

      private void cmbStop_Click(object sender, EventArgs e)
    {
        waveInStream.StopRecording();
        waveInStream.Dispose();
        waveInStream = null;
        writer.Close();
        writer = null;

        cmbRecord.Enabled = true;
        cmbStop.Enabled = false;
    }

I need to stop the recording automatically inside the cmbRecord_Click event.
Thanks in advance.

  • 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-18T02:34:35+00:00Added an answer on May 18, 2026 at 2:34 am

    use a Timer, set the Interval and copy the code in cmbStop_Click event over to timer’s OnTick event. Enable the timer in the mbRecord_Click event and & remember to disable the timer in cmbStop_Click event

    Edit:

    Create a new timer and set its value

    //put this line in your form class level

      System.Windows.Forms.Timer mytimer=new System.Windows.Forms.Timer(); //create a new Timer
    

    //put these two into your form constructor just after InitializeComponent();

    mytimer.Interval=1000; //set the interval to 1 second.
    mytimer.Tick += new EventHandler(mytimer_Tick);
    

    Enable the timer in the mbRecord_Click event

    private void cmbRecord_Click(object sender, EventArgs e)
    {
                outputFilename = "file address";
    
                waveInStream = new WaveIn(44100,2);
                writer = new WaveFileWriter(outputFilename, waveInStream.WaveFormat);
    
                waveInStream.DataAvailable += new EventHandler<WaveInEventArgs>(waveInStream_DataAvailable);
                waveInStream.StartRecording();
    
    
                // Just controling the objects on the screen.
                cmbRecord.Enabled = false;
                cmbStop.Enabled = true;
    
                //Enable the timer to fire
                mytimer.Enabled = true;
    
    }
    

    Stop recording after 1 second..

    void mytimer_Tick(object sender, EventArgs e)
    {       
            waveInStream.StopRecording();
            waveInStream.Dispose();
            waveInStream = null;
            writer.Close();
            writer = null;
    
            cmbRecord.Enabled = true;
            cmbStop.Enabled = false;
    //disable the timer here so it won't fire again...
            mytimer.Enabled = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Windows Phone 7.1/7.5/Mango Silverlight App. Coming from here: Need clarification on using audio on
I'm making an Android application where I need to slow down the audio being
I'm making an app that records uncompressed (wav format) audio. I'm using this class
I'm making a java application and I need to play audio. I'm playing mainly
m making an app which requires to play recorded audio files. For that m
I am making simple AS3 application that will record audio from microphone and after
I am making a project where i am drawing waveform of an audio file
I am making an app in which I have to open default audio player.
I am currently using Audio Queues on the iPhone to record and playback audio.
I've been making some progress with audio programming for iPhone. Now I'm doing some

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.