Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -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()'
6 changes: 6 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: TagBot

on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: "3"

Comment on lines +8 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this part about?

jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand All @@ -12,3 +17,4 @@ jobs:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
25 changes: 14 additions & 11 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,45 @@ 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
- windows-latest
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
*.jl.cov
*.jl.*.cov
*.jl.mem
.DS_Store
.vscode/
dev/
LocalPreferences.toml
Manifest.toml
Overrides.toml
18 changes: 15 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ 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"
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"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
10 changes: 5 additions & 5 deletions src/mpg123.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
69 changes: 3 additions & 66 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions test/test_mp3.jl
Original file line number Diff line number Diff line change
@@ -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