项目作者: guonaihong

项目描述 :
Go bindings for the libsoxr audio down and up sample library (go包装的soxr音频升降采样库)
高级语言: Go
项目地址: git://github.com/guonaihong/go-soxr.git
创建时间: 2018-07-29T10:56:49Z
项目社区:https://github.com/guonaihong/go-soxr

开源协议:Apache License 2.0

下载


go-soxr

Go bindings for the libsoxr audio down and up sample library (go包装的soxr音频升降采样库)

Usage:

Create an SoxR instance

  1. var spec soxr.IoSpec
  2. //输入采样点精度
  3. //Input sampling point width
  4. spec.Itype = soxr.SOXR_INT16_I
  5. //输出采样点精度
  6. //Output sampling point width
  7. spec.Otype = soxr.SOXR_INT16_I
  8. spec.Scale = 1
  9. //Create an SoxR instance
  10. s, err := soxr.Create(float64(*inSample), float64(*outSample), 1, spec)

For processing functions, n is the number of bytes exported, and err is an error.

  1. n, err = s.Process(inBuf[:n], outBuf)
  2. if err != nil {
  3. fmt.Printf("soxr process fail:%s\n", err)
  4. }

Destroy the SoxR instance

  1. defer s.Close()

examples:

  1. env GOPATH=`pwd` go build github.com/guonaihong/go-soxr/examples/resample

Audio downsampling

  1. ./resample -in 21.16k.pcm -in_sample 16000 -out out_pcm_file_8k -out_sample 8000

Audio upsampling

  1. ./resample -in 21.8k.pcm -in_sample 8000 -out out_pcm_file_16k -out_sample 16000

This raw audio file may be played using ffplay:

  1. ffplay -f s16le -ar 16000 ./out_pcm_file_16k
  2. ffplay -f s16le -ar 8000 ./out_pcm_file_8k