Skip to content

Commit 3db82a1

Browse files
committed
feat: Add NPM publishing, expand librosa compatibility tests, and fix algorithm accuracy
NPM publishing setup: - Add .github/workflows/publish.yml for automated NPM releases - Add .npmignore, NOTICE, README.npm.md, and update package.json Librosa compatibility test suite (new tests + reference data): - stft_test.cpp: STFT magnitude/phase against librosa reference - chroma_test.cpp: Chroma feature extraction accuracy - cqt_test.cpp: Constant-Q transform accuracy - pitch_test.cpp: YIN pitch detection accuracy - power_to_db_test.cpp: Power-to-dB conversion - spectral_test.cpp: Spectral centroid, bandwidth, rolloff, flatness, contrast - zcr_test.cpp: Zero-crossing rate and RMS energy - New reference JSON files: stft, chroma, cqt, yin, power_to_db, spectral_features, zcr_rms, beat, hpss Algorithm fixes and accuracy improvements: - core/spectrum.cpp: Spectrum computation corrections - core/window.cpp: Window function normalization fix - core/audio_io.cpp: Audio I/O buffer handling improvements - feature/chroma.cpp: Chroma normalization and bin mapping fix - feature/cqt.cpp: CQT kernel and magnitude computation fix - feature/mel_spectrogram.cpp: Mel filterbank alignment fix - effects/hpss.cpp: HPSS margin and median filter fix - effects/normalize.cpp: Peak and RMS normalization corrections - filters/dct.cpp, iir.cpp: DCT orthonormal scaling and IIR stability fix - util/math_utils.h: Numerical stability improvements Other: - sonare_c.cpp: Expand C API with chroma, CQT, spectral, and pitch functions - ci.yml: Update CI workflow matrix and coverage steps - tools/sonare_cli.cpp: Add new analysis output options
1 parent f050a63 commit 3db82a1

51 files changed

Lines changed: 95013 additions & 487 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 102 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,114 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
6-
paths:
7-
- 'src/**'
8-
- 'tests/**'
9-
- 'CMakeLists.txt'
10-
- 'Makefile'
11-
- '.github/workflows/**'
12-
- 'third_party/**'
5+
branches: [main]
6+
tags-ignore: ['**']
7+
paths-ignore:
8+
- '**.md'
9+
- 'docs/**'
10+
- 'LICENSE'
11+
- 'NOTICE'
1312
pull_request:
14-
branches: [ main ]
15-
paths:
16-
- 'src/**'
17-
- 'tests/**'
18-
- 'CMakeLists.txt'
19-
- 'Makefile'
20-
- '.github/workflows/**'
21-
- 'third_party/**'
13+
branches: [main]
14+
paths-ignore:
15+
- '**.md'
16+
- 'docs/**'
17+
- 'LICENSE'
18+
- 'NOTICE'
2219

2320
concurrency:
2421
group: ${{ github.workflow }}-${{ github.ref }}
2522
cancel-in-progress: true
2623

2724
jobs:
28-
linux-build-test-coverage:
29-
name: Linux Build, Test and Coverage
25+
lint:
3026
runs-on: ubuntu-latest
31-
3227
steps:
33-
- name: Checkout code
34-
uses: actions/checkout@v4
35-
36-
- name: Cache CMake dependencies
37-
uses: actions/cache@v4
38-
with:
39-
path: build/_deps
40-
key: ${{ runner.os }}-cmake-deps-${{ hashFiles('CMakeLists.txt', 'tests/CMakeLists.txt') }}
41-
restore-keys: |
42-
${{ runner.os }}-cmake-deps-
43-
44-
- name: Cache ccache
45-
uses: actions/cache@v4
46-
with:
47-
path: ~/.cache/ccache
48-
key: ${{ runner.os }}-ccache-${{ github.sha }}
49-
restore-keys: |
50-
${{ runner.os }}-ccache-
51-
52-
- name: Install dependencies
53-
run: |
54-
sudo apt-get update
55-
sudo apt-get install -y \
56-
cmake \
57-
build-essential \
58-
libeigen3-dev \
59-
lcov \
60-
ccache
61-
62-
- name: Setup ccache
63-
run: |
64-
ccache --set-config=max_size=500M
65-
ccache --zero-stats
66-
67-
- name: Configure CMake with coverage
68-
env:
69-
CC: ccache gcc
70-
CXX: ccache g++
71-
run: |
72-
cmake -B build \
73-
-DCMAKE_BUILD_TYPE=Debug \
74-
-DBUILD_TESTING=ON \
75-
-DENABLE_COVERAGE=ON
76-
77-
- name: Build
78-
run: cmake --build build --parallel
79-
80-
- name: Show ccache statistics
81-
run: ccache --show-stats
82-
83-
- name: Run tests
84-
run: ctest --test-dir build --output-on-failure --parallel
85-
continue-on-error: true
86-
87-
- name: Generate coverage report
88-
run: |
89-
mkdir -p build/coverage
90-
lcov --directory build --capture --output-file build/coverage/coverage.info --ignore-errors source,gcov
91-
lcov --extract build/coverage/coverage.info "${PWD}/src/*" --output-file build/coverage/coverage_filtered.info --ignore-errors unused
92-
genhtml build/coverage/coverage_filtered.info --output-directory build/coverage/html --ignore-errors source
93-
94-
- name: Upload coverage to Codecov
95-
uses: codecov/codecov-action@v4
96-
with:
97-
token: ${{ secrets.CODECOV_TOKEN }}
98-
files: ./build/coverage/coverage_filtered.info
99-
flags: unittests
100-
name: codecov-libsonare
101-
fail_ci_if_error: false
102-
verbose: true
103-
104-
- name: Upload coverage HTML report
105-
uses: actions/upload-artifact@v4
106-
with:
107-
name: coverage-report
108-
path: build/coverage/html/
109-
110-
- name: Upload build artifacts on failure
111-
if: failure()
112-
uses: actions/upload-artifact@v4
113-
with:
114-
name: build-logs
115-
path: |
116-
build/CMakeFiles/*.log
117-
build/Testing/Temporary/
28+
- uses: actions/checkout@v4
29+
- run: corepack enable
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: 22
33+
cache: yarn
34+
- run: yarn install --immutable
35+
- run: yarn lint
36+
37+
build-and-test:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: mymindstorm/setup-emsdk@v14
42+
- run: corepack enable
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: 22
46+
cache: yarn
47+
48+
- name: Cache CMake dependencies
49+
uses: actions/cache@v4
50+
with:
51+
path: build/_deps
52+
key: ${{ runner.os }}-cmake-deps-${{ hashFiles('CMakeLists.txt', 'tests/CMakeLists.txt') }}
53+
restore-keys: |
54+
${{ runner.os }}-cmake-deps-
55+
56+
- name: Cache ccache
57+
uses: actions/cache@v4
58+
with:
59+
path: ~/.cache/ccache
60+
key: ${{ runner.os }}-ccache-${{ github.sha }}
61+
restore-keys: |
62+
${{ runner.os }}-ccache-
63+
64+
- name: Install dependencies
65+
run: |
66+
sudo apt-get update
67+
sudo apt-get install -y \
68+
cmake \
69+
build-essential \
70+
libeigen3-dev \
71+
lcov \
72+
ccache
73+
74+
- name: Setup ccache
75+
run: |
76+
ccache --set-config=max_size=500M
77+
ccache --zero-stats
78+
79+
- name: Configure CMake with coverage
80+
env:
81+
CC: ccache gcc
82+
CXX: ccache g++
83+
run: |
84+
cmake -B build \
85+
-DCMAKE_BUILD_TYPE=Debug \
86+
-DBUILD_TESTING=ON \
87+
-DENABLE_COVERAGE=ON
88+
89+
- name: Build
90+
run: cmake --build build --parallel
91+
92+
- name: Show ccache statistics
93+
run: ccache --show-stats
94+
95+
- name: Run C++ tests
96+
run: ctest --test-dir build --output-on-failure --parallel
97+
98+
- name: Generate coverage report
99+
run: |
100+
mkdir -p build/coverage
101+
lcov --directory build --capture --output-file build/coverage/coverage.info --ignore-errors source,gcov
102+
lcov --extract build/coverage/coverage.info "${PWD}/src/*" --output-file build/coverage/coverage_filtered.info --ignore-errors unused
103+
104+
- name: Upload coverage to Codecov
105+
uses: codecov/codecov-action@v4
106+
with:
107+
token: ${{ secrets.CODECOV_TOKEN }}
108+
files: ./build/coverage/coverage_filtered.info
109+
flags: unittests
110+
name: codecov-libsonare
111+
fail_ci_if_error: false
112+
113+
- run: yarn install --immutable
114+
- run: yarn build
115+
- run: yarn test

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish and Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
10+
id-token: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: mymindstorm/setup-emsdk@v14
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '22'
22+
23+
- run: npm install -g npm@latest
24+
- run: corepack enable
25+
- run: corepack prepare yarn@4.12.0 --activate
26+
27+
- uses: actions/cache@v4
28+
with:
29+
path: |
30+
.yarn/cache
31+
node_modules
32+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-yarn-
35+
36+
- name: Install system dependencies
37+
run: sudo apt-get update && sudo apt-get install -y libeigen3-dev
38+
39+
- name: Build and test C++
40+
run: |
41+
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON
42+
cmake --build build --parallel
43+
ctest --test-dir build --output-on-failure
44+
45+
- run: yarn install --immutable
46+
- run: yarn build
47+
- run: yarn lint
48+
- run: yarn test
49+
50+
- name: Create GitHub Release
51+
uses: softprops/action-gh-release@v2
52+
with:
53+
name: Release ${{ github.ref_name }}
54+
tag_name: ${{ github.ref_name }}
55+
generate_release_notes: true
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- run: npm publish --access public
60+
env:
61+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.npmignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Source
2+
src/
3+
js/
4+
tests/
5+
tools/
6+
third_party/
7+
8+
# Build
9+
build/
10+
build-*/
11+
cmake-build-*/
12+
CMakeLists.txt
13+
Makefile
14+
15+
# Config
16+
biome.json
17+
tsconfig.json
18+
vitest.config.ts
19+
.yarnrc.yml
20+
CLAUDE.md
21+
22+
# CI/CD
23+
.github/
24+
.vscode/
25+
26+
# Git
27+
.git/
28+
.gitignore
29+
30+
# README swap artifacts
31+
README.npm.md
32+
.readme-backup
33+
34+
# Misc
35+
*.log
36+
*.tgz
37+
*.tsbuildinfo

NOTICE

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
libsonare
2+
Copyright 2024 libsonare contributors
3+
4+
This product includes software developed by third parties. Below is the
5+
attribution for each bundled dependency and the project from which algorithms
6+
were ported.
7+
8+
================================================================================
9+
librosa
10+
================================================================================
11+
12+
Copyright (c) 2013--2023, librosa development team
13+
14+
Licensed under the ISC License.
15+
16+
libsonare ports audio analysis algorithms from librosa, a Python library for
17+
music and audio analysis.
18+
19+
https://github.com/librosa/librosa
20+
21+
================================================================================
22+
KissFFT
23+
================================================================================
24+
25+
Copyright (c) 2003-2010, Mark Borgerding. All rights reserved.
26+
27+
Licensed under the BSD 3-Clause License (SPDX: BSD-3-Clause).
28+
29+
https://github.com/mborgerding/kissfft
30+
31+
Vendored in: third_party/kissfft/
32+
33+
================================================================================
34+
r8brain-free-src
35+
================================================================================
36+
37+
Copyright (c) 2013-2025 Aleksey Vaneev
38+
39+
Licensed under the MIT License.
40+
41+
https://github.com/avaneev/r8brain-free-src
42+
43+
Vendored in: third_party/r8brain/
44+
45+
================================================================================
46+
dr_libs (dr_wav)
47+
================================================================================
48+
49+
Copyright 2023 David Reid
50+
51+
Available as a choice of Public Domain (Unlicense) or MIT No Attribution
52+
(MIT-0).
53+
54+
https://github.com/mackron/dr_libs
55+
56+
Vendored in: third_party/dr_libs/
57+
58+
================================================================================
59+
minimp3
60+
================================================================================
61+
62+
To the extent possible under law, the author(s) have dedicated all copyright
63+
and related and neighboring rights to this software to the public domain
64+
worldwide.
65+
66+
Licensed under CC0 1.0 Universal (Public Domain Dedication).
67+
68+
https://github.com/lieff/minimp3
69+
70+
Vendored in: third_party/minimp3/

0 commit comments

Comments
 (0)