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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:16:58+00:00 2026-05-12T22:16:58+00:00

I am writing raw audio bytes from two files into a new wav file

  • 0

I am writing raw audio bytes from two files into a new wav file to combine the two files. The resultant file which is created has the contents of both the audio clips but there is also a lot of noise in the file.

Can someone point me to a good example which shows how to write raw audio bytes to a file? Here’s the basic logic that I am following

SInt32 leftSample1 = ReadSampleFromFile1(music_iter1);
leftSample1 = (SInt32)((float) leftSample1 * 0.7071); //to avoid clipping

SInt32 leftStereoSample2 = ReadLeftSample(music_iter2);
leftStereoSample2 += leftSample1;
if (leftStereoSample2 > 32767)
leftStereoSample2 = 32767;
else if (leftStereoSample2 < -32768
leftStereoSample2 = -32768;
// write leftStereoSample2 to the file
//do the same as left sample to right sample also

++music_iter2;
++music_iter1;

Thanks.

  • 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-12T22:16:59+00:00Added an answer on May 12, 2026 at 10:16 pm

    how many times are these returning true?

    if (leftStereoSample2 > 32767)
    leftStereoSample2 = 32767;
    else if (leftStereoSample2 < -32768
    leftStereoSample2 = -32768;
    

    just because you are not clipping, (because you are forcing it not to) does not mean you wont get artifacts (distortion) etc when you truncate the waves like that. i would see how often that was happening.

    core audio has mixers. smart people have written code to deal with this kind of stuff already, so we dont have to 🙂 MultiChannelMixer is one that does stereo mixing. check it out.

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

Sidebar

Related Questions

I'm writing code, which takes the raw body of the post request (from a
I would like to extract a channel audio from the an LPCM raw file
What is the Microsoft-approved way to extract the raw audio data from an audio
I have been importing my raw IIS log files into a SQL Server table
I have a capture process which writes raw video data and audio data to
I'm interested in writing a short python script which uploads a short binary file
I'm looking into writing a audio syntesizer in Java, and was wondering if anybody
I'm writing a C/C++ application under Linux that reads data from a raw socket
I am writing a descendant of FileStream which deals transparently with files with meta-data
I'm writing an attribute shim to get the raw c-string from a library's string

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.