c# - Combine existing audio files and generate new audio file from them -
i have 2 sample wavfiles.
i combine them 1 output wav this:
play first wav, wait x seconds play 2nd wav, , save results new wav file.
i'm not particularly attached wav format, happy utilize if necessary.
from research looks need convert wavs pcm, , create new output buffer , write first file output buffer. somehow create space x seconds, , write sec pcm
how go doing this?
first of you'll need undestand talking about
wav type of riff encodes sound waves pcm.
essentially pcm means discrete values of wave stored @ sample rate (typically 44 khz)
each sample may contain info 1 or more channels (typically 2)
the values of each sample stored fixed size integer or float. (typically 16 bit integer)
these attributes stored in wav header
to combine 2 seperate wav files need read header of both files , if lucky have same byterate ( == samplerate * channel count * bits/sample / 8) need concat sec file minus header end of first, , add together length of sec 'length' field of first.
in other case advise utilize library reencoding of sort.
if have time , muse, recoding yourself.
if don't want bother stuff @ seek using finish programme (i.e. sox) need.
btw.: quiet 0 values if bits per sample signed , half of max value if unsigned (typically found in 8 bit integers).
so 4 seconds of quiet need have n = 4 * sample rate * channel num * (bits / seconds) / 8 times 0
trivia: utilize constant value instead of 0 silence
c# audio
No comments:
Post a Comment