test tweaks and adds tests to travis.yml
This commit is contained in:
parent
39bae583ed
commit
a3d23268e9
3 changed files with 11 additions and 9 deletions
|
@ -10,4 +10,4 @@ before_install:
|
|||
- sudo apt-get install libpcre3-dev julia -y
|
||||
script:
|
||||
- julia -e 'Pkg.init(); run(`ln -s $(pwd()) $(Pkg.dir("PortAudio"))`); Pkg.pin("PortAudio"); Pkg.resolve(); Pkg.add("BinDeps"); Pkg.build("PortAudio")'
|
||||
- julia -e 'using PortAudio; @assert isdefined(:PortAudio); @assert typeof(PortAudio) === Module'
|
||||
- test/test.jl
|
||||
|
|
|
@ -29,6 +29,7 @@ t = linspace(0, 2, 2 * 44100)
|
|||
phase = 2pi * 100 * t
|
||||
|
||||
## Test Float32 arrays, this is currently the native audio playback format
|
||||
info("Testing Playing Float32 arrays...")
|
||||
f32 = convert(Array{Float32}, sin(phase))
|
||||
test_stream = TestAudioStream()
|
||||
player = play(f32, test_stream)
|
||||
|
@ -37,20 +38,20 @@ player = play(f32, test_stream)
|
|||
#@test process(test_stream) == zeros(PortAudio.AudioSample, TEST_BUF_SIZE)
|
||||
|
||||
|
||||
## Test Float64 arrays
|
||||
info("Testing Playing Float64 arrays...")
|
||||
f64 = convert(Array{Float64}, sin(phase))
|
||||
test_stream = TestAudioStream()
|
||||
player = play(f64, test_stream)
|
||||
@test process(test_stream) == convert(PortAudio.AudioBuf, f64[1:TEST_BUF_SIZE])
|
||||
|
||||
## Test Int8(Signed) arrays
|
||||
info("Testing Playing Int8(Signed) arrays...")
|
||||
i8 = Int8[-127:127]
|
||||
test_stream = TestAudioStream()
|
||||
player = play(i8, test_stream)
|
||||
@test_approx_eq(process(test_stream)[1:255],
|
||||
convert(PortAudio.AudioBuf, linspace(-1.0, 1.0, 255)))
|
||||
|
||||
## Test Uint8(Unsigned) arrays
|
||||
info("Testing Playing Uint8(Unsigned) arrays...")
|
||||
# for unsigned 8-bit audio silence is represented as 128, so the symmetric range
|
||||
# is 1-255
|
||||
ui8 = Uint8[1:255]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using Base.Test
|
||||
using PortAudio
|
||||
|
||||
info = PortAudio.DeviceInfo(44100, 512)
|
||||
dev_input = zeros(PortAudio.AudioSample, info.buf_size)
|
||||
test_info = PortAudio.DeviceInfo(44100, 512)
|
||||
dev_input = zeros(PortAudio.AudioSample, test_info.buf_size)
|
||||
|
||||
# A TestNode just renders out 1:buf_size each frame
|
||||
type TestNode <: PortAudio.AudioNode
|
||||
|
@ -19,17 +19,18 @@ end
|
|||
# TODO: there should be a setup/teardown mechanism and some way to isolate
|
||||
# tests
|
||||
|
||||
info("Testing AudioMixer...")
|
||||
mix = AudioMixer()
|
||||
@test mix.mix_inputs == PortAudio.AudioNode[]
|
||||
@test PortAudio.render(mix, dev_input, info) == zeros(PortAudio.AudioSample, info.buf_size)
|
||||
@test PortAudio.render(mix, dev_input, test_info) == zeros(PortAudio.AudioSample, test_info.buf_size)
|
||||
|
||||
testnode = TestNode()
|
||||
mix = AudioMixer([testnode])
|
||||
@test mix.mix_inputs == PortAudio.AudioNode[testnode]
|
||||
@test PortAudio.render(mix, dev_input, info) == PortAudio.AudioSample[1:info.buf_size]
|
||||
@test PortAudio.render(mix, dev_input, test_info) == PortAudio.AudioSample[1:test_info.buf_size]
|
||||
|
||||
test1 = TestNode()
|
||||
test2 = TestNode()
|
||||
mix = AudioMixer([test1, test2])
|
||||
@test PortAudio.render(mix, dev_input, info) == 2 * PortAudio.AudioSample[1:info.buf_size]
|
||||
@test PortAudio.render(mix, dev_input, test_info) == 2 * PortAudio.AudioSample[1:test_info.buf_size]
|
||||
|
||||
|
|
Loading…
Reference in a new issue