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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:49:53+00:00 2026-06-16T02:49:53+00:00

I have audio samples extracted through NAudio, i know parameters: channels bytes per sample,

  • 0

I have audio samples extracted through NAudio, i know parameters:

  • channels
  • bytes per sample,
  • samplerate

How to play that samples by using .Net api / or other .Net library

Here code:

    openFileDialog1.ShowDialog();
    using (var reader = new Mp3FileReader(openFileDialog1.FileName))
    {
        var pcmLength = (int)reader.Length;
        var _leftBuffer = new byte[pcmLength / 2];
        var buffer = new byte[pcmLength];
        var bytesRead = reader.Read(buffer, 0, pcmLength);
        int index = 0;
        for (int i = 0; i < bytesRead; i += 4)
        {
           //extracting only left channel 
           _leftBuffer[index] = buffer[i];
           index++;
           _leftBuffer[index] = buffer[i + 1];
           index++;
         }

         // How to play  _leftBuffer (Single channel, 2 bytes per sample, 44100 samples per secound)
}
  • 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-16T02:49:55+00:00Added an answer on June 16, 2026 at 2:49 am

    YES, I have found a solution: A low-level audio player in C#

    Full worked code:

    public partial class Form1 : Form
        {
            private byte[] _leftBuffer;
            private BiQuadFilter _leftFilter;
            private BiQuadFilter _rightFilter;
            public Form1()
            {
                InitializeComponent();
            }
    
    
            private void button1_Click(object sender, EventArgs e)
            {
                openFileDialog1.ShowDialog();
                using (var reader = new Mp3FileReader(openFileDialog1.FileName))
                {
                    var pcmLength = (int)reader.Length;
                    _leftBuffer = new byte[pcmLength / 2];
                    var buffer = new byte[pcmLength];
                    var bytesRead = reader.Read(buffer, 0, pcmLength);
    
                    int index = 0;
                    for (int i = 0; i < bytesRead; i += 4)
                    {
                        _leftBuffer[index] = buffer[i];
                        index++;
                        _leftBuffer[index] = buffer[i + 1];
                        index++;
                    }
                    var player = new WaveLib.WaveOutPlayer(-1, new WaveLib.WaveFormat(44100, 16, 1), _leftBuffer.Length, 1, (data, size) =>
                                                                                                                   {
                                                                                                                       byte[] b = _leftBuffer;
                                                                                                                       System.Runtime.InteropServices.Marshal.Copy(b, 0, data, size);
                                                                                                                   });
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have audio encoded at 44100Hz that means you have 44100 samples per
I have a list of bytes that represent raw samples read in from an
I have a byte array with audio samples. I want to play it, so
I have directory that contains nearly 14,000,000 audio samples in *.wav format. All plain
I have a class that will let me play a tone using audio units,
I have the problem of stitching together pcm audio samples from various parts of
I have made a sample application which constructs a filter graph to capture audio
I'm trying to have the audio file play as soon as the view controller
Good day everyone. I have an audio class, that plays a .wav file. But
I have an audio app i need to capture mic samples to encode into

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.