diff --git a/.travis.yml b/.travis.yml index b112196..1d6d0b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,21 @@ -language: cpp +language: julia compiler: - clang notifications: email: spencer.f.russell@gmail.com -env: - - JULIAVERSION="julianightlies" - - JULIAVERSION="juliareleases" -before_install: - - sudo add-apt-repository ppa:staticfloat/julia-deps -y - - sudo add-apt-repository ppa:staticfloat/$JULIAVERSION -y - - sudo apt-get update -qq -y - - sudo apt-get install libpcre3-dev julia -y - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi +julia: + - 0.3 + - 0.4 +# - nightly +# Fails with: +# LoadError: ccall: could not find function jl_read_sonames +# while loading /home/travis/.julia/v0.5/AudioIO/deps/build.jl, in expression starting on line 29 script: + - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - julia -e 'Pkg.init()' - julia -e 'Pkg.add("BinDeps"); Pkg.checkout("BinDeps")' # latest master needed for Pacman support - julia -e 'Pkg.clone(pwd()); Pkg.build("AudioIO")' - - julia -e 'Pkg.test("AudioIO", coverage=true)' + - julia -e 'Pkg.add("FactCheck")' # add FactCheck manually because we're not using Pkg.test() + - julia --code-coverage=user test/runtests.jl # Pkg.test disables inlining when enabling coverage, which kills our allocation tests after_success: - if [ $JULIAVERSION = "juliareleases" ]; then julia -e 'cd(Pkg.dir("AudioIO")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; fi diff --git a/deps/build.jl b/deps/build.jl index 1361396..e1c4af3 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,4 +1,5 @@ using BinDeps +using Compat @BinDeps.setup @@ -26,5 +27,5 @@ end provides(WinRPM.RPM, "libsndfile1", libsndfile, os = :Windows) end -@BinDeps.install [:libportaudio => :libportaudio, - :libsndfile => :libsndfile] +@BinDeps.install @compat(Dict(:libportaudio => :libportaudio, + :libsndfile => :libsndfile)) diff --git a/src/nodes.jl b/src/nodes.jl index 0f142b1..19b579b 100644 --- a/src/nodes.jl +++ b/src/nodes.jl @@ -228,7 +228,7 @@ function play(arr::AudioBuf, args...) end # If the array is the wrong floating type, convert it -@compat function play{T <: AbstractFloat}(arr::Array{T}, args...) +function play{T <: AbstractFloat}(arr::Array{T}, args...) arr = convert(AudioBuf, arr) play(arr, args...) end @@ -306,7 +306,7 @@ export LinRamp function render(node::LinRampRenderer, device_input::AudioBuf, info::DeviceInfo) # Resize buffer if (1) it's too small or (2) we've hit the end of the ramp - ramp_samples::Int = int(node.duration * info.sample_rate) + ramp_samples::Int = round(Int, node.duration * info.sample_rate) block_samples = min(ramp_samples, info.buf_size) if length(node.buf) != block_samples resize!(node.buf, block_samples) diff --git a/src/portaudio.jl b/src/portaudio.jl index 113727f..941ad4f 100644 --- a/src/portaudio.jl +++ b/src/portaudio.jl @@ -1,7 +1,7 @@ typealias PaTime Cdouble typealias PaError Cint typealias PaSampleFormat Culong -# PaStream is always used as an opaque type, so we're always dealing +# PaStream is always used as an opaque type, so we're always dealing # with the pointer typealias PaStream Ptr{Void} typealias PaDeviceIndex Cint @@ -23,7 +23,7 @@ const paInt8 = convert(PaSampleFormat, 0x10) const paUInt8 = convert(PaSampleFormat, 0x20) # PaHostApiTypeId values -@compat const pa_host_api_names = ( +@compat const pa_host_api_names = Dict( 0 => "In Development", # use while developing support for a new host API 1 => "Direct Sound", 2 => "MME", @@ -95,31 +95,31 @@ end The stream is unidirectional, either inout or default output see http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html """ -function Pa_OpenStream(device::PaDeviceIndex, +function Pa_OpenStream(device::PaDeviceIndex, channels::Cint, input::Bool, sampleFormat::PaSampleFormat, sampleRate::Cdouble, framesPerBuffer::Culong) streamPtr::Array{PaStream} = PaStream[0] - ioParameters = Pa_StreamParameters(device, channels, - sampleFormat, PaTime(0.001), + ioParameters = Pa_StreamParameters(device, channels, + sampleFormat, PaTime(0.001), Ptr{Void}(0)) if input - err = ccall((:Pa_OpenStream, libportaudio), PaError, + err = ccall((:Pa_OpenStream, libportaudio), PaError, (PaStream, Ref{Pa_StreamParameters}, Ptr{Void}, - Cdouble, Culong, Culong, + Cdouble, Culong, Culong, Ptr{PaStreamCallback}, Ptr{Void}), streamPtr, ioParameters, Ptr{Void}(0), - sampleRate, framesPerBuffer, 0, + sampleRate, framesPerBuffer, 0, Ptr{PaStreamCallback}(0), Ptr{Void}(0)) else - err = ccall((:Pa_OpenStream, libportaudio), PaError, + err = ccall((:Pa_OpenStream, libportaudio), PaError, (PaStream, Ptr{Void}, Ref{Pa_StreamParameters}, Cdouble, Culong, Culong, Ptr{PaStreamCallback}, Ptr{Void}), streamPtr, Ptr{Void}(0), ioParameters, - sampleRate, framesPerBuffer, 0, + sampleRate, framesPerBuffer, 0, Ptr{PaStreamCallback}(0), Ptr{Void}(0)) - end + end handle_status(err) streamPtr[1] end @@ -134,7 +134,7 @@ type Pa_AudioStream <: AudioStream sbuffer_output_waiting::Integer parent_may_use_buffer::Bool - """ + """ Get device parameters needed for opening with portaudio default is input as 44100/16bit int, same as CD audio type input """ @@ -150,7 +150,7 @@ type Pa_AudioStream <: AudioStream root = AudioMixer() datatype = PaSampleFormat_to_T(sample_format) sbuf = ones(datatype, framesPerBuffer) - this = new(root, DeviceInfo(sample_rate, framesPerBuffer), + this = new(root, DeviceInfo(sample_rate, framesPerBuffer), show_warnings, stream, sample_format, sbuf, 0, false) info("Scheduling PortAudio Render Task...") if input @@ -170,7 +170,7 @@ function read_Pa_AudioStream(stream::Pa_AudioStream) while stream.parent_may_use_buffer == false sleep(0.001) end - buffer = deepcopy(stream.sbuffer) + buffer = deepcopy(stream.sbuffer) stream.parent_may_use_buffer = false return buffer end @@ -234,7 +234,7 @@ function portaudio_task(stream::PortAudioStream) end """ - Helper function to make the right type of buffer for various + Helper function to make the right type of buffer for various sample formats. Converts PaSampleFormat to a typeof """ function PaSampleFormat_to_T(fmt::PaSampleFormat) @@ -276,7 +276,7 @@ function pa_input_task(stream::Pa_AudioStream) end err = ccall((:Pa_ReadStream, libportaudio), PaError, (PaStream, Ptr{Void}, Culong), - stream.stream, buffer, n) + stream.stream, buffer, n) handle_status(err, stream.show_warnings) stream.sbuffer[1: n] = buffer[1: n] stream.parent_may_use_buffer = true @@ -303,12 +303,12 @@ function pa_output_task(stream::Pa_AudioStream) end if (navail > 1) & (stream.parent_may_use_buffer == false) & (Pa_GetStreamWriteAvailable(stream.stream) < navail) - Pa_WriteStream(stream.stream, stream.sbuffer, + Pa_WriteStream(stream.stream, stream.sbuffer, navail, stream.show_warnings) stream.parent_may_use_buffer = true else sleep(0.005) - end + end end catch ex warn("Audio Output Task died with exception: $ex") @@ -338,7 +338,7 @@ type PaHostApiInfo defaultOutputDevice::PaDeviceIndex end -@compat type PortAudioInterface <: AudioInterface +type PortAudioInterface <: AudioInterface name::AbstractString host_api::AbstractString max_input_channels::Int diff --git a/src/sndfile.jl b/src/sndfile.jl index 66fd589..12f66a8 100644 --- a/src/sndfile.jl +++ b/src/sndfile.jl @@ -16,7 +16,7 @@ const SF_SEEK_SET = 0 const SF_SEEK_CUR = 1 const SF_SEEK_END = 2 -@compat const EXT_TO_FORMAT = ( +@compat const EXT_TO_FORMAT = Dict( ".wav" => SF_FORMAT_WAV, ".flac" => SF_FORMAT_FLAC ) @@ -28,12 +28,6 @@ type SF_INFO format::Int32 sections::Int32 seekable::Int32 - - function SF_INFO(frames::Integer, samplerate::Integer, channels::Integer, - format::Integer, sections::Integer, seekable::Integer) - new(int64(frames), int32(samplerate), int32(channels), int32(format), - int32(sections), int32(seekable)) - end end type AudioFile @@ -45,7 +39,7 @@ samplerate(f::AudioFile) = f.sfinfo.samplerate # AudioIO.open is part of the public API, but is not exported so that it # doesn't conflict with Base.open -@compat function open(path::AbstractString, mode::AbstractString = "r", +function open(path::AbstractString, mode::AbstractString = "r", sampleRate::Integer = 44100, channels::Integer = 1, format::Integer = 0) @assert channels <= 2 @@ -66,11 +60,11 @@ samplerate(f::AudioFile) = f.sfinfo.samplerate end filePtr = ccall((:sf_open, libsndfile), Ptr{Void}, - (Ptr{Uint8}, Int32, Ptr{SF_INFO}), + (Ptr{UInt8}, Int32, Ptr{SF_INFO}), path, file_mode, &sfinfo) if filePtr == C_NULL - errmsg = ccall((:sf_strerror, libsndfile), Ptr{Uint8}, (Ptr{Void},), filePtr) + errmsg = ccall((:sf_strerror, libsndfile), Ptr{UInt8}, (Ptr{Void},), filePtr) error(bytestring(errmsg)) end @@ -132,7 +126,7 @@ Base.read(file::AudioFile) = Base.read(file, Int16) function Base.write{T}(file::AudioFile, frames::Array{T}) @assert file.sfinfo.channels <= 2 - nframes = int(length(frames) / file.sfinfo.channels) + nframes = round(Int, length(frames) / file.sfinfo.channels) if T == Int16 return ccall((:sf_writef_short, libsndfile), Int64, @@ -180,7 +174,7 @@ end typealias FilePlayer AudioNode{FileRenderer} FilePlayer(file::AudioFile) = FilePlayer(FileRenderer(file)) -@compat FilePlayer(path::AbstractString) = FilePlayer(AudioIO.open(path)) +FilePlayer(path::AbstractString) = FilePlayer(AudioIO.open(path)) function render(node::FileRenderer, device_input::AudioBuf, info::DeviceInfo) @assert node.file.sfinfo.samplerate == info.sample_rate @@ -204,7 +198,7 @@ function render(node::FileRenderer, device_input::AudioBuf, info::DeviceInfo) end end -@compat function play(filename::AbstractString, args...) +function play(filename::AbstractString, args...) player = FilePlayer(filename) play(player, args...) end diff --git a/test/test_AudioIO.jl b/test/test_AudioIO.jl index 16313fe..a2672ed 100644 --- a/test/test_AudioIO.jl +++ b/test/test_AudioIO.jl @@ -1,6 +1,7 @@ module TestAudioIO using FactCheck +using Compat using AudioIO import AudioIO.AudioBuf @@ -43,32 +44,32 @@ facts("Array playback") do f32 = convert(Array{Float32}, sin(phase)) test_stream = TestAudioStream() player = play(f32, test_stream) - @fact process(test_stream) => f32[1:TEST_BUF_SIZE] + @fact process(test_stream) --> f32[1:TEST_BUF_SIZE] end context("Playing Float64 arrays") do f64 = convert(Array{Float64}, sin(phase)) test_stream = TestAudioStream() player = play(f64, test_stream) - @fact process(test_stream) => convert(AudioBuf, f64[1:TEST_BUF_SIZE]) + @fact process(test_stream) --> convert(AudioBuf, f64[1:TEST_BUF_SIZE]) end context("Playing Int8(Signed) arrays") do - i8 = Int8[-127:127] + i8 = Int8[-127:127;] test_stream = TestAudioStream() player = play(i8, test_stream) - @fact process(test_stream)[1:255] => - mse(convert(AudioBuf, linspace(-1.0, 1.0, 255))) + @fact process(test_stream)[1:255] --> + mse(convert(AudioBuf, collect(linspace(-1.0, 1.0, 255)))) end - context("Playing Uint8(Unsigned) arrays") do + context("Playing UInt8(Unsigned) arrays") do # for unsigned 8-bit audio silence is represented as 128, so the symmetric range # is 1-255 - ui8 = Uint8[1:255] + ui8 = UInt8[1:255;] test_stream = TestAudioStream() player = play(ui8, test_stream) - @fact process(test_stream)[1:255] => - mse(convert(AudioBuf, linspace(-1.0, 1.0, 255))) + @fact process(test_stream)[1:255] --> + mse(convert(AudioBuf, collect(linspace(-1.0, 1.0, 255)))) end end @@ -78,12 +79,12 @@ facts("AudioNode Stopping") do play(node, test_stream) process(test_stream) stop(node) - @fact process(test_stream) => zeros(AudioIO.AudioSample, TEST_BUF_SIZE) + @fact process(test_stream) --> zeros(AudioIO.AudioSample, TEST_BUF_SIZE) 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) + @fact get_audio_devices() --> issubtype(Array) end end # module TestAudioIO diff --git a/test/test_nodes.jl b/test/test_nodes.jl index bf05430..8ead8ea 100644 --- a/test/test_nodes.jl +++ b/test/test_nodes.jl @@ -1,5 +1,6 @@ module TestAudioIONodes +using Compat using FactCheck using AudioIO import AudioIO: AudioSample, AudioBuf, AudioRenderer, AudioNode @@ -10,7 +11,7 @@ include("testhelpers.jl") # A TestNode just renders out 1:buf_size each frame type TestRenderer <: AudioRenderer buf::AudioBuf - TestRenderer(buf_size::Integer) = new(AudioSample[1:buf_size]) + TestRenderer(buf_size::Integer) = new(AudioSample[1:buf_size;]) end typealias TestNode AudioNode{TestRenderer} @@ -31,7 +32,7 @@ facts("Validating TestNode allocation") do test = TestNode(test_info.buf_size) # JIT render(test, dev_input, test_info) - @fact (@allocated render(test, dev_input, test_info)) => 16 + @fact (@allocated render(test, dev_input, test_info)) --> 16 end #### AudioMixer Tests #### @@ -43,16 +44,17 @@ facts("AudioMixer") do context("0 Input Mixer") do mix = AudioMixer() render_output = render(mix, dev_input, test_info) - @fact render_output => AudioSample[] - @fact (@allocated render(mix, dev_input, test_info)) => 48 + @fact render_output --> AudioSample[] + # 0.4 uses 64 bytes, 0.3 uses 48 + @fact (@allocated render(mix, dev_input, test_info)) --> less_than(65) end context("1 Input Mixer") do testnode = TestNode(test_info.buf_size) mix = AudioMixer([testnode]) render_output = render(mix, dev_input, test_info) - @fact render_output => AudioSample[1:test_info.buf_size] - @fact (@allocated render(mix, dev_input, test_info)) => 64 + @fact render_output --> AudioSample[1:test_info.buf_size;] + @fact (@allocated render(mix, dev_input, test_info)) --> 64 end context("2 Input Mixer") do @@ -61,17 +63,17 @@ facts("AudioMixer") do mix = AudioMixer([test1, test2]) render_output = render(mix, dev_input, test_info) # make sure the two inputs are being added together - @fact render_output => 2 * AudioSample[1:test_info.buf_size] - @fact (@allocated render(mix, dev_input, test_info)) => 96 + @fact render_output --> 2 * AudioSample[1:test_info.buf_size;] + @fact (@allocated render(mix, dev_input, test_info)) --> 96 # now we'll stop one of the inputs and make sure it gets removed stop(test1) render_output = render(mix, dev_input, test_info) # make sure the two inputs are being added together - @fact render_output => AudioSample[1:test_info.buf_size] + @fact render_output --> AudioSample[1:test_info.buf_size;] stop(mix) render_output = render(mix, dev_input, test_info) - @fact render_output => AudioSample[] + @fact render_output --> AudioSample[] end end @@ -81,25 +83,25 @@ facts("SinOSC") do freq = 440 # note that this range includes the end, which is why there are # sample_rate+1 samples - t = linspace(0, 1, int(test_info.sample_rate+1)) + t = linspace(0, 1, round(Int, test_info.sample_rate+1)) test_vect = convert(AudioBuf, sin(2pi * t * freq)) context("Fixed Frequency") do osc = SinOsc(freq) render_output = render(osc, dev_input, test_info) - @fact mse(render_output, test_vect[1:test_info.buf_size]) => + @fact mse(render_output, test_vect[1:test_info.buf_size]) --> lessthan(MSE_THRESH) render_output = render(osc, dev_input, test_info) @fact mse(render_output, - test_vect[test_info.buf_size+1:2*test_info.buf_size]) => + test_vect[test_info.buf_size+1:2*test_info.buf_size]) --> lessthan(MSE_THRESH) - @fact (@allocated render(osc, dev_input, test_info)) => 64 + @fact (@allocated render(osc, dev_input, test_info)) --> 64 stop(osc) render_output = render(osc, dev_input, test_info) - @fact render_output => AudioSample[] + @fact render_output --> AudioSample[] end context("Testing SinOsc with signal input") do - t = linspace(0, 1, int(test_info.sample_rate+1)) + t = linspace(0, 1, round(Int, test_info.sample_rate+1)) f = 440 .- t .* (440-110) dt = 1 / test_info.sample_rate # NOTE - this treats the phase as constant at each sample, which isn't strictly @@ -112,14 +114,14 @@ facts("SinOSC") do freq = LinRamp(440, 110, 1) osc = SinOsc(freq) render_output = render(osc, dev_input, test_info) - @fact mse(render_output, expected[1:test_info.buf_size]) => + @fact mse(render_output, expected[1:test_info.buf_size]) --> lessthan(MSE_THRESH) render_output = render(osc, dev_input, test_info) @fact mse(render_output, - expected[test_info.buf_size+1:2*test_info.buf_size]) => + expected[test_info.buf_size+1:2*test_info.buf_size]) --> lessthan(MSE_THRESH) # give a bigger budget here because we're rendering 2 nodes - @fact (@allocated render(osc, dev_input, test_info)) => 160 + @fact (@allocated render(osc, dev_input, test_info)) --> 160 end end @@ -127,7 +129,7 @@ facts("AudioInput") do node = AudioInput() test_data = rand(AudioSample, test_info.buf_size) render_output = render(node, test_data, test_info) - @fact render_output => test_data + @fact render_output --> test_data end facts("ArrayPlayer") do @@ -135,13 +137,13 @@ facts("ArrayPlayer") do v = rand(AudioSample, 44100) player = ArrayPlayer(v) render_output = render(player, dev_input, test_info) - @fact render_output => v[1:test_info.buf_size] + @fact render_output --> v[1:test_info.buf_size] render_output = render(player, dev_input, test_info) - @fact render_output => v[(test_info.buf_size + 1) : (2*test_info.buf_size)] - @fact (@allocated render(player, dev_input, test_info)) => 192 + @fact render_output --> v[(test_info.buf_size + 1) : (2*test_info.buf_size)] + @fact (@allocated render(player, dev_input, test_info)) --> 192 stop(player) render_output = render(player, dev_input, test_info) - @fact render_output => AudioSample[] + @fact render_output --> AudioSample[] end context("testing end of vector") do @@ -150,7 +152,7 @@ facts("ArrayPlayer") do player = ArrayPlayer(v) render(player, dev_input, test_info) render_output = render(player, dev_input, test_info) - @fact render_output => v[test_info.buf_size+1:end] + @fact render_output --> v[test_info.buf_size+1:end] end end @@ -158,35 +160,35 @@ facts("Gain") do context("Constant Gain") do gained = TestNode(test_info.buf_size) * 0.75 render_output = render(gained, dev_input, test_info) - @fact render_output => 0.75 * AudioSample[1:test_info.buf_size] - @fact (@allocated render(gained, dev_input, test_info)) => 32 + @fact render_output --> 0.75 * AudioSample[1:test_info.buf_size;] + @fact (@allocated render(gained, dev_input, test_info)) --> 32 end context("Gain by a Signal") do gained = TestNode(test_info.buf_size) * TestNode(test_info.buf_size) render_output = render(gained, dev_input, test_info) - @fact render_output => AudioSample[1:test_info.buf_size] .* AudioSample[1:test_info.buf_size] - @fact (@allocated render(gained, dev_input, test_info)) => 48 + @fact render_output --> AudioSample[1:test_info.buf_size;] .* AudioSample[1:test_info.buf_size;] + @fact (@allocated render(gained, dev_input, test_info)) --> 48 end end facts("LinRamp") do ramp = LinRamp(0.25, 0.80, 1) - expected = convert(AudioBuf, linspace(0.25, 0.80, int(test_info.sample_rate+1))) + expected = convert(AudioBuf, collect(linspace(0.25, 0.80, round(Int, test_info.sample_rate+1)))) render_output = render(ramp, dev_input, test_info) - @fact mse(render_output, expected[1:test_info.buf_size]) => + @fact mse(render_output, expected[1:test_info.buf_size]) --> lessthan(MSE_THRESH) render_output = render(ramp, dev_input, test_info) @fact mse(render_output, - expected[(test_info.buf_size+1):(2*test_info.buf_size)]) => + expected[(test_info.buf_size+1):(2*test_info.buf_size)]) --> lessthan(MSE_THRESH) - @fact (@allocated render(ramp, dev_input, test_info)) => 64 + @fact (@allocated render(ramp, dev_input, test_info)) --> 64 end facts("Offset") do offs = TestNode(test_info.buf_size) + 0.5 render_output = render(offs, dev_input, test_info) - @fact render_output => 0.5 + AudioSample[1:test_info.buf_size] - @fact (@allocated render(offs, dev_input, test_info)) => 32 + @fact render_output --> 0.5 + AudioSample[1:test_info.buf_size;] + @fact (@allocated render(offs, dev_input, test_info)) --> 32 end end # module TestAudioIONodes diff --git a/test/test_sndfile.jl b/test/test_sndfile.jl index 75ab80d..dcc0747 100644 --- a/test/test_sndfile.jl +++ b/test/test_sndfile.jl @@ -1,19 +1,20 @@ module TestSndfile -include("testhelpers.jl") - -using AudioIO +using Compat using FactCheck +using AudioIO import AudioIO: DeviceInfo, render, AudioSample, AudioBuf +include("testhelpers.jl") + facts("WAV file write/read") do fname = Pkg.dir("AudioIO", "test", "sinwave.wav") srate = 44100 freq = 440 - t = [0 : 2 * srate - 1] / srate + t = collect(0 : 2 * srate - 1) / srate phase = 2 * pi * freq * t - reference = int16((2 ^ 15 - 1) * sin(phase)) + reference = round(Int16, (2 ^ 15 - 1) * sin(phase)) AudioIO.open(fname, "w") do f write(f, reference) @@ -21,12 +22,12 @@ facts("WAV file write/read") do # test basic reading AudioIO.open(fname) do f - @fact f.sfinfo.channels => 1 - @fact f.sfinfo.frames => 2 * srate + @fact f.sfinfo.channels --> 1 + @fact f.sfinfo.frames --> 2 * srate actual = read(f) - @fact length(reference) => length(actual) - @fact reference => actual[:, 1] - @fact samplerate(f) => srate + @fact length(reference) --> length(actual) + @fact reference --> actual[:, 1] + @fact samplerate(f) --> srate end # test seeking @@ -41,21 +42,21 @@ facts("WAV file write/read") do # convert to floating point because that's what AudioIO uses natively expected = convert(AudioBuf, reference ./ (2^15)) buf = render(node, input, test_info) - @fact expected[1:bufsize] => buf[1:bufsize] + @fact expected[1:bufsize] --> buf[1:bufsize] buf = render(node, input, test_info) - @fact expected[bufsize+1:2*bufsize] => buf[1:bufsize] + @fact expected[bufsize+1:2*bufsize] --> buf[1:bufsize] end end facts("Stereo file reading") do fname = Pkg.dir("AudioIO", "test", "440left_880right.wav") srate = 44100 - t = [0 : 2 * srate - 1] / srate - expected = int16((2^15-1) * hcat(sin(2pi*t*440), sin(2pi*t*880))) + t = collect(0:(2 * srate - 1)) / srate + expected = round(Int16, (2^15-1) * hcat(sin(2pi*t*440), sin(2pi*t*880))) AudioIO.open(fname) do f buf = read(f) - @fact buf => mse(expected, 5) + @fact buf --> mse(expected, 5) end end @@ -67,15 +68,15 @@ facts("Stereo file rendering") do bufsize = 1024 input = zeros(AudioSample, bufsize) test_info = DeviceInfo(srate, bufsize) - t = [0 : 2 * srate - 1] / srate + t = collect(0 : 2 * srate - 1) / srate expected = convert(AudioBuf, 0.5 * (sin(2pi*t*440) + sin(2pi*t*880))) AudioIO.open(fname) do f node = FilePlayer(f) buf = render(node, input, test_info) - @fact buf[1:bufsize] => mse(expected[1:bufsize]) + @fact buf[1:bufsize] --> mse(expected[1:bufsize]) buf = render(node, input, test_info) - @fact buf[1:bufsize] => mse(expected[bufsize+1:2*bufsize]) + @fact buf[1:bufsize] --> mse(expected[bufsize+1:2*bufsize]) end end