Changeset 7126

Show
Ignore:
Timestamp:
01/30/10 07:14:25 (7 months ago)
Author:
dbaelde
Message:

Fix Rutils which actually did not support up-sampling at all!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/liquidsoap/src/tools/rutils.ml

    r6935 r7126  
    7777    (fun ~audio_src_rate src -> 
    7878      let sample_bytes = samplesize / 8 in 
    79       let len = (String.length src) / (sample_bytes*channels) in 
    80       let dst = 
    81         (* TODO: convert channel number? *) 
    82         Array.init channels (fun _ -> Array.make len 0.) 
    83       in 
    8479      let ratio = audio_dst_rate /. audio_src_rate in 
     80      (* Compute the length in samples, in the source data, 
     81       * then in the destination format, adding 1 to prevent rounding bugs. *) 
     82      let len_src = (String.length src) / (sample_bytes*channels) in 
     83      let len_dst = 1 + int_of_float (float len_src *. ratio) in 
     84      let dst = Array.init channels (fun _ -> Array.make len_dst 0.) in 
    8585        ignore 
    86           ( 
    87             Float_pcm.resample_s16le 
    88               src 0 len signed samplesize big_endian 
    89               ratio dst 0 
    90           ); 
    91       dst,Frame.master_of_audio len) 
    92  
    93  
    94    
     86          (Float_pcm.resample_s16le 
     87              src 0 len_src signed samplesize big_endian 
     88              ratio dst 0) ; 
     89        dst, Frame.master_of_audio len_dst)