How to trim PCM data to identify sample count or frame count to feed?

亡梦爱人 提交于 2019-12-11 18:12:43

问题


I want to feed libsamplerate (a library to downsample audio data which needs the following struct filled:

typedef struct
  {   float  *data_in, *data_out ;

      long   input_frames, output_frames ;
      long   input_frames_used, output_frames_gen ;

      int    end_of_input ;

      double src_ratio ;
  } SRC_DATA ;

The fields of this struct which must be filled in by the caller are:

  data_in       : A pointer to the input data samples.
  input_frames  : The number of frames of data pointed to by data_in.
  data_out      : A pointer to the output data samples.
  output_frames : Maximum number of frames pointer to by data_out.
  src_ratio     : Equal to output_sample_rate / input_sample_rate.
  end_of_input  : Equal to 0 if more input data is available and 1 
                  otherwise.

To fill this struct, I have data_in but I don't know the frame count so I cannot define input_frames. Is there an easy way to trim the PCM byte stream? So I can input it into this function also with the correct number of frames. (So this question is not directly related to libsamplerate)

来源:https://stackoverflow.com/questions/17789917/how-to-trim-pcm-data-to-identify-sample-count-or-frame-count-to-feed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!