audio - C# NAudio makes Noise WAV file without errors after POST from another page -
i posting file in callback(base64data); server using. when file seems file sounds white noise. help.
protected void page_load(object sender, eventargs e) { var struser = request.form["userid"]; int userid = convert.toint32(struser); var reader = new rawsourcewavestream(httpcontext.current.request.inputstream, new waveformat(44100, 16, 1)); var timestamp = datetime.now.tostring("yyyymmddhhmmssfff"); var target = new waveformat(44100, 8, 1); var lastfilename = timestamp + "_" + struser + ".wav"; var savestreamfile = @"c:\soundbox\" + lastfilename; var str = new waveformatconversionstream(target, reader); wavefilewriter.createwavefile(savestreamfile, str); reader.close(); str.close();
now have this: (please let me know silly things jump out @ make wav sound slow motion) made wav plays slooooowly:
var savestreamfile = @"c:\soundbox\" + lastfilename; var wavfilestr = convert.frombase64string(request["data"].replace("-", "+").replace("_", "/").replace("\n", string.empty).replace("\r", string.empty).replace("data:audio/wav;base64,", string.empty)); memorystream stm = new memorystream(wavfilestr, 0, wavfilestr.length); var target = new waveformat(44100, 16, 1); var reader = new rawsourcewavestream(stm, new waveformat(44100, 16, 1)); var str = new waveformatconversionstream(target, reader); wavefilewriter.createwavefile(savestreamfile, str); reader.close(); str.close();
the explanation file playing you've got wrong wave format. number of channels , sample rate being explanation.
so have new waveformat(44100, 16, 1)
, how know correct format? i'd suggest trying 2 channels - new waveformat(44100, 16, 2)
, - double playback speed.
Comments
Post a Comment