操作系统:Windows 11
Julia: 1.10.3
代码如下
using SampledSignals
using Interpolations
using Unitful
using DSP
using StatsBase: mean
function rotary(x:: SampleBuf, p:: RotaryParams)
sr = x.samplerate;
buf = mean(x; dims=2);
filt_low = SecondOrderSections([Biquad(1, 1, :LP)], 1);
filt_high = SecondOrderSections([
Biquad(0, 1, :HP)
Biquad(0, 2, :LP)
], 1);
weight_low = (1 - p.balance) / 2;
weight_high = (1 + p.balance) / 2;
x_low = weight_low * filt(filt_low, buf);
x_high = weight_high * filt(filt_high, buf);
# 问题出现在这几行
x_low = [x_low x_low]
x_high = [x_high x_high]
x_low = tremvibsync(x_low, TremVibParams(0.75, 0.003, p.woofer_speed, 0));
x_high = tremvibsync(x_high, TremVibParams(0.75, 0.003, p.horn_speed, 0));
# 问题结束
...
end
如果这四行采用如上写法,会报错
MethodError: no method matching tremvibsync(::Matrix{Float64}, ::TremVibParams)
Closest candidates are:
tremvibsync(!Matched::SampleBuf, ::TremVibParams)
@ Main e:\JupyterLab\YAMAHA rot simulation.ipynb:1
但是如果将以上几行改成这样
x_low = SampleBuf([x_low x_low], sr);
x_high = SampleBuf([x_high x_high], sr);
x_low = tremvibsync(x_low, TremVibParams(0.75, 0.003, p.woofer_speed, 0));
x_high = tremvibsync(x_high, TremVibParams(0.75, 0.003, p.horn_speed, 0));
则会报另外一个错:
MethodError: no method matching SampleBuf(::SampleBuf{Float64, 2}, ::Float64)
Closest candidates are:
SampleBuf(!Matched::Array{T, N}, ::Float64) where {T, N}
@ SampledSignals D:\ProgramTemp\Julia\packages\SampledSignals\KYg5Q\src\SampleBuf.jl:12
SampleBuf(!Matched::Array{T, N}, ::Real) where {T, N}
@ SampledSignals D:\ProgramTemp\Julia\packages\SampledSignals\KYg5Q\src\SampleBuf.jl:17
SampleBuf(!Matched::Type, ::Any, !Matched::Quantity)
@ SampledSignals D:\ProgramTemp\Julia\packages\SampledSignals\KYg5Q\src\SampleBuf.jl:37
...
所以在这里的x_low
, x_high
到底是Matrix
还是SampleBuf
啊(((
求教大佬们