@@ -24,7 +24,7 @@ include("testhelpers.jl")
2424
2525for f in (:load , :save , :loadstreaming , :savestreaming )
2626 for io in ((String, File), (IO, Stream))
27- for fmt in ((" _wav" , format " WAV" ), (" _ogg" , format " OGG" ), (" _flac" , format " FLAC" ))
27+ for fmt in ((" _wav" , format " WAV" ), (" _ogg" , format " OGG" ), (" _flac" , format " FLAC" ), ( " _aiff " , format " AIFF " ) )
2828 @eval $ (Symbol (f, fmt[1 ]))(io:: $ (io[1 ]), args... ) =
2929 LibSndFile.$ f ($ (io[2 ]){$ (fmt[2 ])}( io), args... )
3030 if f in (:loadstreaming , :savestreaming )
@@ -58,6 +58,7 @@ reference_wav_double = joinpath(dirname(@__FILE__), "440left_880right_0.5amp_dou
5858reference_wav_pcm24 = joinpath (dirname (@__FILE__ ), " 440left_880right_0.5amp_pcm24.wav" )
5959reference_ogg = joinpath (dirname (@__FILE__ ), " 440left_880right_0.5amp.ogg" )
6060reference_flac = joinpath (dirname (@__FILE__ ), " 440left_880right_0.5amp.flac" )
61+ reference_aiff = joinpath (dirname (@__FILE__ ), " 440left_880right_0.5amp.aiff" )
6162reference_buf = gen_reference (srate)
6263
6364# don't indent the individual testsets so we can more easily run them from
108109 @test mse (buf, reference_buf) < 1e-10
109110end
110111
112+ @testset " AIFF file reading" begin
113+ buf = load_aiff (reference_aiff)
114+ @test samplerate (buf) == srate
115+ @test nchannels (buf) == 2
116+ @test nframes (buf) == 100
117+ @test isapprox (domain (buf), collect (0 : 99 )/ srate)
118+ @test mse (buf, reference_buf) < 1e-10
119+ end
120+
111121@testset " OGG file reading" begin
112122 buf = load_ogg (reference_ogg)
113123 @test samplerate (buf) == srate
244254 @test mse (buf, testbuf) < 1e-10
245255end
246256
257+ @testset " AIFF file writing" begin
258+ fname = string (tempname (), " .aiff" )
259+ arr = map (PCM16Sample, rand (100 , 2 ) .- 0.5 )
260+ testbuf = SampleBuf (arr, srate)
261+ save_aiff (fname, testbuf)
262+ buf = load_aiff (fname)
263+ @test samplerate (buf) == srate
264+ @test nchannels (buf) == 2
265+ @test nframes (buf) == 100
266+ @test isapprox (domain (buf), collect (0 : 99 )/ srate)
267+ @test mse (buf, testbuf) < 1e-10
268+ end
269+
247270@testset " Writing $T data" for T in [PCM16Sample, PCM32Sample, Float32, Float64]
248271 fname = string (tempname (), " .wav" )
249272 arr = map (T, rand (100 , 2 ) .- 0.5 )
288311@testset " FileIO Integration" begin
289312 arr = map (PCM16Sample, rand (100 , 2 ) .- 0.5 )
290313 testbuf = SampleBuf (arr, srate)
291- for ext in (" .wav" , " .ogg" , " .flac" )
314+ for ext in (" .wav" , " .ogg" , " .flac" , " .aiff " )
292315 fname = string (tempname (), ext)
293316 FileIO. save (fname, testbuf)
294317 buf = FileIO. load (fname)
0 commit comments