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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:37:49+00:00 2026-06-01T05:37:49+00:00

From all the samples I’ve seen using NAudio’s MeteringSampleProvider to update a VolumeMeter control,

  • 0

From all the samples I’ve seen using NAudio’s MeteringSampleProvider to update a VolumeMeter control, I think I’ve got the right code, but it seems that the event for the MeteringSampleProvider as well as the SampleChannel never fire. I’m writing to a wav file at the same time and when I play it back, the recording has worked fine. Any ideas?

IWaveIn wavStream;
WaveFileWriter wavWriter;
BufferedWaveProvider bufferedWaveProvider;
SampleChannel sampleChannel;
MeteringSampleProvider meteringSampleProvider;

wavStream = new WaveIn();
wavWriter = new WaveFileWriter(CurrentRecording.Filename, wavStream.WaveFormat);

wavStream.DataAvailable += new EventHandler<WaveInEventArgs>((s2, e2) =>
{
  //Add sample to the buffered provider
  bufferedWaveProvider.AddSamples(e2.Buffer, 0, e2.BytesRecorded);

  //************************************************************
  //EDIT: This is how I solved the issue!!!      
  var tmpBuffer = new float[e2.BytesRecorded];
  if (meteringSampleProvider != null)
    meteringSampleProvider.Read(tmpBuffer, 0, e2.BytesRecorded);
  //END EDIT
  //************************************************************

  //Write to the wave file
  wavWriter.Write(e2.Buffer, 0, e2.BytesRecorded);  
});

//Create our Buffered provider
bufferedWaveProvider = new BufferedWaveProvider(wavStream.WaveFormat);
bufferedWaveProvider.DiscardOnBufferOverflow = true;

//Create the sample channel
sampleChannel = new SampleChannel(bufferedWaveProvider);
sampleChannel.PreVolumeMeter += new EventHandler<StreamVolumeEventArgs>((s2, e2) =>
{
  Console.WriteLine("PreVolumeMeter");
});

//Create the metering sample provider
meteringSampleProvider = new MeteringSampleProvider(sampleChannel);
meteringSampleProvider.StreamVolume += new EventHandler<StreamVolumeEventArgs>((s2, e2) =>
{
  Console.WriteLine("PostVolumeMeter");
});


//Start Recording
wavStream.StartRecording();
  • 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-01T05:37:50+00:00Added an answer on June 1, 2026 at 5:37 am

    You’re not reading from the meteringSampleProvider, so no events will be raised. Normally of course this would be the IWavePlayer that is calling Read, but if you are not playing audio, you’ll need to pull the audio through your pipeline some other way.

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

Sidebar

Related Questions

I want to remotely uninstall apps from clients using c#. In all the samples
I've seen some code samples that allow to load specific PowerShell scripts from C#,
Is it possible to deny from all apache htaccess style using php. I can't
I've got a table of temperature samples over time from several sources and I
While there are many samples around about using OpenGL ES on Android all of
Consider the SlidingDrawer in Android. All samples I've seen have a large button as
Does anybody know any reasons why IMemAllocator:GetBuffer (Directshow) hangs, apart from all samples being
All samples that I encountered so far for using TableView were using UITableViewController. But
I see all sample from nServiceBus to be a standalone process, so can it
To all, I was looking at the sample project from http://iphoneonrails.com/ and I saw

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.