高度可定制的 Chirp 信号生成库

介绍一个线性调频扫频正弦发生器。

安装

进入REPL模式并通过以下方式从最新存储库中添加模块:

]add https://github.com/sonosole/ChirpSignal.git

或者从julia的官方仓库:

]add ChirpSignal

两个公共API

chirp(T, fs, fl, fh; method="linear", phase=0.0) -> Array{Float64,1}
chirp(T, fs, f::Function; phase::Real=0.0) -> Array{Float64,1}

示例

using WAV
using ChirpSignal

fs = 16000.0; # sampling frequency
fl = 500.0;   # lower bound frequency
fh = 8000.0;  # upper bound frequency
T  = 5.0 ;    # total time of chirp signal

线性

# f(t) = (fh-fl)/T * t + fl
wav = chirp(T, fs, fl, fh; method="linear");
wavwrite(wav, "./doc/chirpLinear.wav", Fs=fs, nbits=32)

二次型

# f(t) = k * t^2 + fl, k = (fh-fl)/T^2
wav = chirp(T, fs, fl, fh; method="quadratic");
wavwrite(wav, "./doc/chirpQuadratic.wav", Fs=fs, nbits=32)

自定义示例

用户自己定义频率随时间的变化函数,例如这里的 fun(t) = 2000*t

fun(t) = 2000*t
wav = chirp(2.0, 16000.0, fun)
wavwrite(wav, "./doc/0_4000hz_linear.wav", Fs=fs, nbits=32)

更多

请访问仓库 ChirpSignal

2 个赞