Hi all It's my trouble - i need convert audio (raw pcm data) from 44100/stereo to X/Y How i try: [delphi code] const buf_len = 44100*2*2; // buffer for 1 sec audio - my audio is 44100, stereo var fs, fs_res: TFileStream; buf: pointer; readed: integer; resample_context: PReSampleContext; out_buf: PWord; out_result: integer; begin // in file test_dec.wav - raw pcm data without header fs :=TFileStream.Create ('c:\test_dec.wav', fmOpenRead); fs_res := TFileStream.Create ('c:\test_resample.wav', fmCreate or fmOpenWrite); try buf := AllocMem (buf_len); out_buf := AllocMem (buf_len); resample_context := audio_resample_init (2, 2, 22050, 44100); // i need 22050/stereo audio on output while fs.Position < fs.Size do begin readed := fs.Read (buf^, buf_len); // readed always (except end of file) = 176400 // how many samples in INPUT buffer? imho 176400 / 2 (stereo) / 2 (16 bit in sample) = 44100 :) out_result := audio_resample (resample_context, out_buf, buf, readed div 2 div 2); // i belive 44100 -> 22050 - each second sample drop // in this place after first iteration out_result = 22042, not 22050! fs_res.Write (out_buf^, out_result); end; finally audio_resample_close (resample_context); freemem (buf); FreeMem (out_buf); fs_res.Free; fs.Free; end; end; [/code] But output audio is corrupted: length of input audio = 00:34 sec's, length of output - only 00:08, from audio "drop" "frames" Where error in my code? wbr, Victor
participants (1)
-
mail@zinetz.info