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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:41:33+00:00 2026-05-24T10:41:33+00:00

Using C# and NAudio, I have have three wave files I would like to

  • 0

Using C# and NAudio, I have have three wave files I would like to join into a single wave file having three channels, each corresponding to one of the three input files. Furthermore, I would like the audio clip from each wave file to begin at a different point in the final stream. For example, if the lengths of the three wave files are 3 sec., 5 sec. and 2 sec., respectively, the output wave file would be 10 seconds long and…

  • channel 1 contains the 3 seconds of sound from file 1 followed by 7
    seconds of silence.

  • channel 2 contains 3 seconds of silence followed by the 5 seconds of
    sound from file 2 followed by 2 seconds of silence.

  • channel 3 contains 8 seconds of silence followed by the 2 seconds of
    sound from file 3.

I have been experimenting by creating a WaveChannel32 instance for each file and then using the WaveOffsetStream class, but I’m new to this sort of thing and I’m not having much success.

Anyone have any suggestions?

  • 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-24T10:41:34+00:00Added an answer on May 24, 2026 at 10:41 am

    You would do this by writing your own custom IWaveProvider/WaveStream whose output WaveFormat has three channels. It holds a reference to each of your three input files.
    Then, in the Read method, it works out the number of samples requested, and reads the appropriate number from each source file. The samples then need to be interleaved – one from first file, one from second, one from third. To delay you simply put zeroes in.

    Here’s some untested example code that interleaves from various source files (must all be of same bit depth and sample rate) which will hopefully point you in the right direction:

    int Read(byte[] buffer, int offset, int bytesRequired)
    {
        int bytesPerSample = this.WaveFormat.BitsPerSample / 8;
        int samplesRequired = bytesRequired / bytesPerSample;
        int channels = this.WaveFormat.Channels; // 3
        int samplesPerChannel = samplesRequired / channels;
        byte[] readBuffer = new byte[samplesPerChannel * bytesPerSample];
        for (int channel = 0; channel < channels; channel++)
        {
            int read = inputs[channel].Read(readBuffer, 0, samplesPerChannel * bytesPerSample);
            int outOffset = offset + channel * bytesPerSample;
            for (int i = 0; i < read; i += bytesPerSample)
            {
                 Array.Copy(readBuffer, i, buffer, outOffset, bytesPerSample);
                 outOffset += channels * bytesPerSample;
            } 
        }
    }
    

    To keep the code from becoming overly complicated, you could do your silence insertion by creating another derived IWaveProvider / WaveStream, whose Read method returned the appropriate amount of silence, before then returning the real data from the input file. This can then be used as an input to your interleaving WaveStream.

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

Sidebar

Related Questions

I have an audio player using NAudio and I would like to display a
I have a series of wave files with individual words, each lasting about 1
I would like to convert .rm (RealPlayer Media) audio files to mp3, using c#,
I have wav file in which using the naudio lib i have been able
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
When using NAudio to playback an MP3 file [in the console], I can't figure
Using Rails 3.2.0 with haml and sass: I Would like to link an external
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 using Naudio and I have a stream which I need to read
I'm using NAudio (but it applies to reading directly) to capture microphone wave data.

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.