From 4f7ceb243fb3a74e9a2e3b2f7c1884ec53348d1f Mon Sep 17 00:00:00 2001 From: Phillip Alday Date: Wed, 9 Oct 2024 09:27:25 -0500 Subject: [PATCH] missing qualification --- examples/flac.jl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/flac.jl b/examples/flac.jl index 3fb54ee4..41afc085 100644 --- a/examples/flac.jl +++ b/examples/flac.jl @@ -38,7 +38,7 @@ FLACFormat(info; kwargs...) = FLACFormat(LPCMFormat(info); sample_rate=info.samp Onda.register_lpcm_format!(file_format -> file_format == "flac" ? FLACFormat : nothing) -file_format_string(::FLACFormat) = "flac" +Onda.file_format_string(::FLACFormat) = "flac" function flac_raw_specification_flags(format::FLACFormat{S}) where {S} return (level="--compression-level-$(format.level)", @@ -56,7 +56,8 @@ end function Onda.deserializing_lpcm_stream(format::FLACFormat, io) flags = flac_raw_specification_flags(format) cmd = flac() do flac_path - return open(`$flac_path - --totally-silent -d --force-raw-format $(flags.endian) $(flags.is_signed)`, io) + return open(`$flac_path --decode --force-raw-format $(flags.level) $(flags.endian) $(flags.is_signed) -`, + io; read=true) end return FLACStream(Onda.LPCMStream(format.lpcm, cmd)) end @@ -64,7 +65,7 @@ end function Onda.serializing_lpcm_stream(format::FLACFormat, io) flags = flac_raw_specification_flags(format) cmd = flac() do flac_path - return open(`$flac_path --totally-silent $(flags) -`, io; write=true) + return open(`$flac_path --force-raw-format $(flags) -`, io; write=true) end return FLACStream(Onda.LPCMStream(format.lpcm, cmd)) end @@ -91,7 +92,7 @@ function Onda.serialize_lpcm(format::FLACFormat, samples::AbstractMatrix) stream = serializing_lpcm_stream(format, io) serialize_lpcm(stream, samples) finalize_lpcm_stream(stream) - return take!(io) + return take!(seekstart(io)) end ##### @@ -111,11 +112,14 @@ if VERSION >= v"1.1.0" sample_rate=50) data = saws(info, Minute(3)) samples = encode(Samples(data, info, false)) - fmt = FLACFormat(info) + fmt = FLACFormat(info; level=0) bytes = serialize_lpcm(fmt, samples.data) + # fail @test deserialize_lpcm(fmt, bytes) == samples.data + # fail @test deserialize_lpcm(fmt, bytes, 99) == view(samples.data, :, 100:size(samples.data, 2)) + # pass @test deserialize_lpcm(fmt, bytes, 99, 201) == view(samples.data, :, 100:300) io = IOBuffer() @@ -124,13 +128,17 @@ if VERSION >= v"1.1.0" @test finalize_lpcm_stream(stream) seekstart(io) stream = deserializing_lpcm_stream(fmt, io) + # fail @test deserialize_lpcm(stream) == samples.data finalize_lpcm_stream(stream) && close(io) io = IOBuffer(bytes) stream = deserializing_lpcm_stream(fmt, io) + # pass @test deserialize_lpcm(stream, 49, 51) == view(samples.data, :, 50:100) + # pass @test deserialize_lpcm(stream, 49, 51) == view(samples.data, :, 150:200) + # fail @test deserialize_lpcm(stream, 9) == view(samples.data, :, 210:size(samples.data, 2)) finalize_lpcm_stream(stream) && close(io) end