Skip to content

Commit

Permalink
dB quantities maintain floating point precision
Browse files Browse the repository at this point in the history
Adds tests for handling `Float32` numbers without promoting to `Float64`
unless necessary.
  • Loading branch information
haberdashPI committed Oct 31, 2019
1 parent 7bb9f4f commit 94ddf9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ sample rate.
"""
signal(val::Number,::Nothing,fs) = NumberSignal(val,inHz(Float64,fs))
signal(val::Unitful.Gain,::Nothing,fs) =
NumberSignal(uconvertrp(NoUnits,val),inHz(Float64,fs),dB=true)
signal(val::Unitful.Gain{<:Any,<:Any,T},::Nothing,fs) where T =
NumberSignal(float(T)(uconvertrp(NoUnits,val)),inHz(Float64,fs),dB=true)

SignalTrait(::Type{<:NumberSignal{T,S}}) where {T,S} = IsSignal{T,S,InfiniteLength}()

Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,13 @@ progress = Progress(total_test_groups,desc="Running tests...")
@test x |> append(y) |> until(13s) |> sink |> eltype == Float32
@test x |> pad(zero) |> until(15s) |> sink |> eltype == Float32
@test x |> lowpass(3Hz) |> sink |> eltype == Float32
@test x |> normpower |> amplify(-10dB) |> sink |> eltype == Float32
@test x |> normpower |> amplify(-10f0*dB) |> sink |> eltype == Float32
@test x |> mix(y) |> sink(samplerate=10Hz) |> eltype == Float32
@test x |> addchannel(y) |> sink(samplerate=10Hz) |> eltype == Float32
@test x |> channel(1) |> sink(samplerate=10Hz) |> eltype == Float32

@test_throws x |> ramp |> sink |> eltype == Float32
@test_throws x |> fadeto(y) |> sink |> eltype == Float32
@test x |> ramp |> sink |> eltype == Float32
@test x |> fadeto(y) |> sink |> eltype == Float32
end
next!(progress)

Expand Down

0 comments on commit 94ddf9d

Please sign in to comment.