From d03c33e4eecfab8a041b2a881c916e63691eb634 Mon Sep 17 00:00:00 2001 From: "Albert R. Gnadt" <20693045+gnadt@users.noreply.github.com> Date: Fri, 20 Jun 2025 17:31:14 -0500 Subject: [PATCH 1/6] Update .gitignore with standard stuff --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 8c960ec..3cf7dd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ *.jl.cov *.jl.*.cov *.jl.mem +.DS_Store +.vscode/ +dev/ +LocalPreferences.toml +Manifest.toml +Overrides.toml From ddd84a495b76297f91bde437e9c318526832161b Mon Sep 17 00:00:00 2001 From: "Albert R. Gnadt" <20693045+gnadt@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:07:04 -0500 Subject: [PATCH 2/6] Add compat --- Project.toml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 3c026b7..a369644 100644 --- a/Project.toml +++ b/Project.toml @@ -3,13 +3,22 @@ uuid = "84e92333-4865-4a61-b1f2-d6ec26b83890" version = "1.1.0" [deps] -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" -SampledSignals = "bd7594eb-a658-542f-9e75-4c4d8908c167" LAME_jll = "c1c5ebd0-6772-5130-a774-d5fcae4a789d" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +SampledSignals = "bd7594eb-a658-542f-9e75-4c4d8908c167" mpg123_jll = "3205ef68-7822-558b-ad0d-1b4740f12437" +[compat] +FileIO = "1" +FixedPointNumbers = "0.8" +LAME_jll = "3.100.1" +LinearAlgebra = "1" +SampledSignals = "2.1" +Test = "1" +mpg123_jll = "1.25.12" + [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" From bf970cd323285fac3e2ef062c56e606459b74d00 Mon Sep 17 00:00:00 2001 From: "Albert R. Gnadt" <20693045+gnadt@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:22:25 -0500 Subject: [PATCH 3/6] Update workflows --- .github/workflows/CompatHelper.yml | 20 ++++++-------------- .github/workflows/TagBot.yml | 6 ++++++ .github/workflows/Tests.yml | 25 ++++++++++++++----------- Project.toml | 1 + 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index c8ce604..23d43e6 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -1,25 +1,17 @@ name: CompatHelper + on: schedule: - cron: 0 0 * * * workflow_dispatch: + jobs: CompatHelper: runs-on: ubuntu-latest steps: - - name: "Install CompatHelper" - run: | - import Pkg - name = "CompatHelper" - uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" - version = "2" - Pkg.add(; name, uuid, version) - shell: julia --color=yes {0} - - name: "Run CompatHelper" - run: | - import CompatHelper - CompatHelper.main() - shell: julia --color=yes {0} + - name: Pkg.add("CompatHelper") + run: julia -e 'using Pkg; Pkg.add("CompatHelper")' + - name: CompatHelper.main() env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} + run: julia -e 'using CompatHelper; CompatHelper.main()' diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index 778c06f..ee6cdb3 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -1,9 +1,14 @@ name: TagBot + on: issue_comment: types: - created workflow_dispatch: + inputs: + lookback: + default: "3" + jobs: TagBot: if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' @@ -12,3 +17,4 @@ jobs: - uses: JuliaRegistries/TagBot@v1 with: token: ${{ secrets.GITHUB_TOKEN }} + ssh: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index 594900c..ef14f25 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -2,26 +2,27 @@ name: Tests on: pull_request: + branches: + - master push: branches: - master tags: '*' - jobs: test: timeout-minutes: 30 - name: ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + name: ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} runs-on: ${{ matrix.os }} + permissions: # needed for julia-actions/cache to delete old caches + actions: write + contents: read strategy: fail-fast: false matrix: version: - - '1.3' - - '1.4' - - '1.5' + - 'lts' - '1' - - 'nightly' os: - ubuntu-latest - macOS-latest @@ -29,15 +30,17 @@ jobs: arch: - x64 - x86 - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} + - uses: julia-actions/cache@v2 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v5 with: - file: lcov.info + files: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: false diff --git a/Project.toml b/Project.toml index a369644..3c48398 100644 --- a/Project.toml +++ b/Project.toml @@ -18,6 +18,7 @@ LinearAlgebra = "1" SampledSignals = "2.1" Test = "1" mpg123_jll = "1.25.12" +julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" From b456c950bae18140c7e1091bce848fd5093e2381 Mon Sep 17 00:00:00 2001 From: "Albert R. Gnadt" <20693045+gnadt@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:40:37 -0500 Subject: [PATCH 4/6] Refactor tests to use TestItemRunner --- Project.toml | 4 ++- test/runtests.jl | 69 +++--------------------------------------------- test/test_mp3.jl | 63 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 67 deletions(-) create mode 100644 test/test_mp3.jl diff --git a/Project.toml b/Project.toml index 3c48398..07006cd 100644 --- a/Project.toml +++ b/Project.toml @@ -17,11 +17,13 @@ LAME_jll = "3.100.1" LinearAlgebra = "1" SampledSignals = "2.1" Test = "1" +TestItemRunner = "1" mpg123_jll = "1.25.12" julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" [targets] -test = ["Test"] +test = ["Test", "TestItemRunner"] diff --git a/test/runtests.jl b/test/runtests.jl index c43331c..086f18a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,68 +1,5 @@ -using FileIO -using MP3 -using SampledSignals +using TestItemRunner -using Test +@testitem "Test MP3" begin include("test_mp3.jl") end -# encoding and decoding can introduce some delay -DELAY_THRESHOLD = 1160 - -# write your own tests here -@testset "Loading MP3" begin - reference = load(joinpath(dirname(@__FILE__), "Sour_Tennessee_Red_Sting.mp3")) - @test typeof(reference) == SampledSignals.SampleBuf{PCM16Sample,2} - @test size(reference, 2) == 2 - @test abs(size(reference, 1) - 245376) <= DELAY_THRESHOLD - @test reference.samplerate == 44100 -end - -@testset "Saving MP3" begin - # drop the volume so we don't get any clipping during resampling - reference = load(joinpath(dirname(@__FILE__), "Sour_Tennessee_Red_Sting.mp3")) * 0.9 - - outpath = "$(tempname()).mp3" - save(outpath, reference) - audio = load(outpath) - @test size(audio) == size(reference) - @test audio.samplerate == reference.samplerate - - for samplerate in [8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000] - save(outpath, reference; samplerate = samplerate) - audio = load(outpath) - @test audio.samplerate == samplerate - end - - for bitrate in [96, 128, 160, 192, 224, 256, 320] - save(outpath, reference; bitrate = bitrate) - audio = load(outpath) - @test size(audio, 2) == size(reference, 2) - @test abs(size(audio, 1) - size(reference, 1)) <= DELAY_THRESHOLD - end - - save(outpath, reference[:, 1]) - audio = load(outpath) - @test size(audio, 2) == 1 - - save(outpath, reference[:, 2]) - audio = load(outpath) - @test size(audio, 2) == 1 - - save(outpath, reference[:, 1]; nchannels = 2) - audio = load(outpath) - @test size(audio, 2) == 2 - - f32 = map(Float32, reference) - save(outpath, f32) - audio = load(outpath) - @test audio.samplerate == 44100 - @test size(audio, 2) == size(reference, 2) - @test abs(size(audio, 1) - size(reference, 1)) <= DELAY_THRESHOLD - - f64 = map(Float32, reference) - save(outpath, f64) - @test audio.samplerate == 44100 - @test size(audio, 2) == size(reference, 2) - @test abs(size(audio, 1) - size(reference, 1)) <= DELAY_THRESHOLD - - rm(outpath) -end +@run_package_tests diff --git a/test/test_mp3.jl b/test/test_mp3.jl new file mode 100644 index 0000000..55edf08 --- /dev/null +++ b/test/test_mp3.jl @@ -0,0 +1,63 @@ +using FileIO, MP3, SampledSignals, Test + +# encoding and decoding can introduce some delay +DELAY_THRESHOLD = 1160 + +@testset "Load MP3" begin + reference = load(joinpath(dirname(@__FILE__), "Sour_Tennessee_Red_Sting.mp3")) + @test typeof(reference) == SampledSignals.SampleBuf{PCM16Sample,2} + @test size(reference, 2) == 2 + @test abs(size(reference, 1) - 245376) <= DELAY_THRESHOLD + @test reference.samplerate == 44100 +end + +@testset "Save MP3" begin + # drop the volume so we don't get any clipping during resampling + reference = load(joinpath(dirname(@__FILE__), "Sour_Tennessee_Red_Sting.mp3")) * 0.9 + + outpath = "$(tempname()).mp3" + save(outpath, reference) + audio = load(outpath) + @test size(audio) == size(reference) + @test audio.samplerate == reference.samplerate + + for samplerate in [8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000] + save(outpath, reference; samplerate = samplerate) + audio = load(outpath) + @test audio.samplerate == samplerate + end + + for bitrate in [96, 128, 160, 192, 224, 256, 320] + save(outpath, reference; bitrate = bitrate) + audio = load(outpath) + @test size(audio, 2) == size(reference, 2) + @test abs(size(audio, 1) - size(reference, 1)) <= DELAY_THRESHOLD + end + + save(outpath, reference[:, 1]) + audio = load(outpath) + @test size(audio, 2) == 1 + + save(outpath, reference[:, 2]) + audio = load(outpath) + @test size(audio, 2) == 1 + + save(outpath, reference[:, 1]; nchannels = 2) + audio = load(outpath) + @test size(audio, 2) == 2 + + f32 = map(Float32, reference) + save(outpath, f32) + audio = load(outpath) + @test audio.samplerate == 44100 + @test size(audio, 2) == size(reference, 2) + @test abs(size(audio, 1) - size(reference, 1)) <= DELAY_THRESHOLD + + f64 = map(Float32, reference) + save(outpath, f64) + @test audio.samplerate == 44100 + @test size(audio, 2) == size(reference, 2) + @test abs(size(audio, 1) - size(reference, 1)) <= DELAY_THRESHOLD + + rm(outpath) +end From 4ec55a1cf90a8ea5a11a77d2027d73d071b1ae40 Mon Sep 17 00:00:00 2001 From: "Albert R. Gnadt" <20693045+gnadt@users.noreply.github.com> Date: Fri, 20 Jun 2025 18:47:16 -0500 Subject: [PATCH 5/6] Update readme links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 184ed20..e3f867a 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ *This project is unmaintained* [![Tests](https://github.com/JuliaAudio/MP3.jl/actions/workflows/Tests.yml/badge.svg)](https://github.com/JuliaAudio/MP3.jl/actions/workflows/Tests.yml) -[![codecov.io](http://codecov.io/github/JuliaAudio/MP3.jl/coverage.svg?branch=master)](http://codecov.io/github/JuliaAudio/MP3.jl?branch=master) +[![codecov.io](https://codecov.io/github/JuliaAudio/MP3.jl/coverage.svg?branch=master)](https://app.codecov.io/github/JuliaAudio/MP3.jl?branch=master) -MP3 is a [Julia](http://julialang.org/) library for reading and writing MP3 files. +MP3 is a [Julia](https://julialang.org/) library for reading and writing MP3 files. ## Usage @@ -39,4 +39,4 @@ julia> save("down.mp3", audio; samplerate = 8kHz) # downsample to 8 kHz ## License -This [Julia](http://julialang.org/) library is distributed under MIT license. It uses [LAME](http://lame.sourceforge.net/) for encoding and [mpg123](https://www.mpg123.de/) for decoding mp3, which are dynamically linked, binding to the terms of their LGPL. +This [Julia](https://julialang.org/) library is distributed under MIT license. It uses [LAME](https://lame.sourceforge.io/) for encoding and [mpg123](https://www.mpg123.de/) for decoding mp3, which are dynamically linked, binding to the terms of their LGPL. From de1ada70bb9137f140197f4f9b3c3cca49be5230 Mon Sep 17 00:00:00 2001 From: "Albert R. Gnadt" <20693045+gnadt@users.noreply.github.com> Date: Fri, 20 Jun 2025 19:04:13 -0500 Subject: [PATCH 6/6] Rename bitrate to samplerate in mpg123_getformat()... addresses #12 --- src/mpg123.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mpg123.jl b/src/mpg123.jl index 552bb1d..6bfd0c2 100644 --- a/src/mpg123.jl +++ b/src/mpg123.jl @@ -97,18 +97,18 @@ end """return birtate, number of channels and encoding of the mp3 file""" function mpg123_getformat(mpg123::MPG123) - bitrate = Ref{Clong}(0) - nchannels = Ref{Cint}(0) - encoding = Ref{Cint}(0) + samplerate = Ref{Clong}(0) + nchannels = Ref{Cint}(0) + encoding = Ref{Cint}(0) err = ccall((:mpg123_getformat, libmpg123), Cint, (MPG123, Ref{Clong}, Ref{Cint}, Ref{Cint}), - mpg123, bitrate, nchannels, encoding) + mpg123, samplerate, nchannels, encoding) if err != MPG123_OK error("Could not read format: ", mpg123_plain_strerror(err)) end - bitrate.x, nchannels.x, encoding.x + samplerate.x, nchannels.x, encoding.x end """return the appropriate block size for handling this mpg123 handle"""