|
65 | 65 | # @test !hasiconbtn(output, "fa-stop") |
66 | 66 | # end |
67 | 67 |
|
68 | | - @testset "wavwrite Generates valid WAV file" begin |
69 | | - buf = SampleBuf(rand(Int16, 16, 2), 48000) |
| 68 | + @testset "wavwrite Generates valid WAV file with raw Int16" begin |
| 69 | + buf = SampleBuf(rand(Int16, 4, 2), 48000) |
70 | 70 | io = IOBuffer() |
71 | 71 | SampledSignals.wavwrite(io, buf) |
72 | 72 | samples, fs, nbits, opt = wavread(IOBuffer(take!(io)), format="native") |
|
75 | 75 | @test nbits == 16 |
76 | 76 | end |
77 | 77 |
|
| 78 | + @testset "wavwrite Generates valid WAV file with raw 16-bit Fixed-point" begin |
| 79 | + buf = SampleBuf(reinterpret.(Fixed{Int16, 15}, rand(Int16, 4, 2)), 48000) |
| 80 | + io = IOBuffer() |
| 81 | + SampledSignals.wavwrite(io, buf) |
| 82 | + samples, fs, nbits, opt = wavread(IOBuffer(take!(io)), format="native") |
| 83 | + @test samples == reinterpret.(convert(Array, buf)) |
| 84 | + @test fs == 48000 |
| 85 | + @test nbits == 16 |
| 86 | + end |
| 87 | + |
78 | 88 | @testset "wavwrite converts float values to 16-bit int wav" begin |
79 | | - buf = SampleBuf(rand(16, 2), 48000) |
| 89 | + buf = SampleBuf(rand(4, 2), 48000) |
80 | 90 | io = IOBuffer() |
81 | 91 | SampledSignals.wavwrite(io, buf) |
82 | 92 | samples, fs, nbits, opt = wavread(IOBuffer(take!(io)), format="native") |
|
85 | 95 | @test nbits == 16 |
86 | 96 | end |
87 | 97 |
|
| 98 | + @testset "wavwrite converts Int32 values to 16-bit int wav" begin |
| 99 | + data = rand(4, 2)*0.9 |
| 100 | + buf = SampleBuf(Fixed{Int32, 31}.(data), 48000) |
| 101 | + io = IOBuffer() |
| 102 | + SampledSignals.wavwrite(io, buf) |
| 103 | + samples, fs, nbits, opt = wavread(IOBuffer(take!(io)), format="native") |
| 104 | + # convert 32-bit int buf to float, then to 16-bit, for testing |
| 105 | + @test samples == reinterpret.(convert(Array{PCM16Sample}, Float32.(buf))) |
| 106 | + @test fs == 48000 |
| 107 | + @test nbits == 16 |
| 108 | + end |
| 109 | + |
88 | 110 | # this is used to display spectrum magnitudes using the same infrastructure |
89 | 111 | # as displaying/playing time-domain buffers |
90 | 112 | # @testset "wavwrite converts complex float values to 16-bit int wav" begin |
|
0 commit comments