c# - Float array of samples to WAV file format -
i working on application applies filters on sound files, filters applied in frequency domain samples .wav file using naudio library code :
audio = new audiofilereader(wav_file); samples = new float[wave.length]; audio.read(samples, 0, samples.length);
after applying previous code, have samples array of float, apply short-time fourier transform on samples getting frequency domain data, , filters applied on frequency domain data.
, inverse short-time fourier transform applied on frequency domain data convert time domain should similar initial samples filters applied.
steps again:
- get samples (time domain data) array wav file.
- apply short-time fourier transform on samples frequency domain data.
- apply filters on frequency domain data.
- apply inverse short-time fourier transform on frequency domain data samples (time domain data).
- convert samples wav form again save , play it.
now problem in last step, have float array of samples (time domain data), how convert .wav file , play it?
to save samples .wav file, following code used:
waveformat waveformat = new waveformat(samplerate, bitdepth, channels); using (wavefilewriter writer = new wavefilewriter("c:\\track1.wav", waveformat)) { writer.writesamples(floatoutput, 0, floatoutput.length); }
the samplerate
, bitdepth
, , channels
extracted input file this:
samplerate = wave.waveformat.samplerate; bitdepth = wave.waveformat.bitspersample; channels = wave.waveformat.channels;
Comments
Post a Comment