diff --git a/test/test_AudioIO.jl b/test/test_AudioIO.jl index 224088f..16313fe 100644 --- a/test/test_AudioIO.jl +++ b/test/test_AudioIO.jl @@ -9,24 +9,6 @@ const TEST_BUF_SIZE = 1024 include("testhelpers.jl") -# convenience function to calculate the mean-squared error -function mse(arr1::Array, arr2::Array) - @assert length(arr1) == length(arr2) - N = length(arr1) - err = 0.0 - for i in 1:N - err += (arr2[i] - arr1[i])^2 - end - err /= N -end - -mse(X::AbstractArray, thresh=1e-8) = Y::AbstractArray -> begin - if size(X) != size(Y) - return false - end - - return mse(X, Y) < thresh -end type TestAudioStream <: AudioIO.AudioStream root::AudioIO.AudioMixer @@ -99,27 +81,6 @@ facts("AudioNode Stopping") do @fact process(test_stream) => zeros(AudioIO.AudioSample, TEST_BUF_SIZE) end -facts("WAV file write/read") do - fname = Pkg.dir("AudioIO", "test", "sinwave.wav") - - samplerate = 44100 - freq = 440 - t = [0 : 2 * samplerate - 1] / samplerate - phase = 2 * pi * freq * t - reference = int16((2 ^ 15 - 1) * sin(phase)) - - AudioIO.open(fname, "w") do f - write(f, reference) - end - - AudioIO.open(fname) do f - @fact f.sfinfo.channels => 1 - @fact f.sfinfo.frames => 2 * samplerate - actual = read(f, 2 * samplerate) - @fact reference => mse(actual) - end -end - facts("Audio Device Listing") do # there aren't any devices on the Travis machine so just test that this doesn't crash @fact get_audio_devices() => issubtype(Array) diff --git a/test/test_nodes.jl b/test/test_nodes.jl index e64dec8..ff40854 100644 --- a/test/test_nodes.jl +++ b/test/test_nodes.jl @@ -2,12 +2,8 @@ module TestAudioIONodes using FactCheck using AudioIO -import AudioIO.AudioSample -import AudioIO.AudioBuf -import AudioIO.AudioRenderer -import AudioIO.AudioNode -import AudioIO.DeviceInfo -import AudioIO.render +import AudioIO: AudioSample, AudioBuf, AudioRenderer, AudioNode +import AudioIO: DeviceInfo, render include("testhelpers.jl") diff --git a/test/testhelpers.jl b/test/testhelpers.jl index 1b56d8c..b0b4aa9 100644 --- a/test/testhelpers.jl +++ b/test/testhelpers.jl @@ -1,5 +1,5 @@ # convenience function to calculate the mean-squared error -function mse(arr1::Array, arr2::Array) +function mse(arr1::AbstractArray, arr2::AbstractArray) @assert length(arr1) == length(arr2) N = length(arr1) err = 0.0 @@ -9,6 +9,14 @@ function mse(arr1::Array, arr2::Array) err /= N end +mse(X::AbstractArray, thresh=1e-8) = Y::AbstractArray -> begin + if size(X) != size(Y) + return false + end + + return mse(X, Y) < thresh +end + issubtype(T::Type) = x -> typeof(x) <: T lessthan(rhs) = lhs -> lhs < rhs greaterthan(rhs) = lhs -> lhs > rhs