Skip to content

Commit 34ced59

Browse files
committed
Version 3.4.3
1 parent b89f5ac commit 34ced59

18 files changed

Lines changed: 1368 additions & 16 deletions

‎.github/workflows/npm-publish.yml‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,20 @@ jobs:
8787
# Case 1: Triggered by a successful jpackage release workflow
8888
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
8989
echo "🔄 Syncing version from Git tag..."
90-
TAG_REF="${{ github.event.workflow_run.head_branch }}"
91-
# The head_branch for a tag event is the tag name itself, e.g., "v1.2.3"
92-
VERSION_FROM_TAG="${TAG_REF#v}"
90+
# For tag-based workflows, we need to find the tag that triggered the workflow
91+
# First, get all tags that point to the head_sha
92+
git fetch --tags
93+
TAG_REF=$(git tag --points-at ${{ github.event.workflow_run.head_sha }} | grep "^v" | head -n 1)
94+
95+
if [[ -z "$TAG_REF" ]]; then
96+
echo "⚠️ No version tag found for commit ${{ github.event.workflow_run.head_sha }}"
97+
echo "ℹ️ Using existing version from package.json."
98+
VERSION_FROM_TAG=$(node -p "require('./package.json').version")
99+
else
100+
echo "✅ Found tag: $TAG_REF"
101+
# Extract version from tag (remove 'v' prefix)
102+
VERSION_FROM_TAG="${TAG_REF#v}"
103+
fi
93104
VERSION_FROM_PACKAGE=$(node -p "require('./package.json').version")
94105
95106
if [[ "$VERSION_FROM_TAG" != "$VERSION_FROM_PACKAGE" ]]; then

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ local.properties
22
.idea
33
.gradle
44
.kotlin
5-
build
5+
build
6+
node_modules/

‎README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ The project is divided into several subprojects to keep development modular and
7575
- Temporary analysis of audio data without storing it, ensuring privacy.
7676
- Support for understanding and improving note bending techniques.
7777

78+
### 5. **NPM Package** ([npm](npm))
79+
80+
- A JavaScript package published on [npm](https://www.npmjs.com/package/bluesharp-pitch-detection) as `bluesharp-pitch-detection`.
81+
- Provides high-accuracy pitch detection algorithms for musical applications, with a focus on harmonica and other instruments.
82+
- Key features:
83+
- Multiple pitch detection algorithms:
84+
- **YIN**: Excellent for vocal and monophonic instrument detection
85+
- **MPM**: Modified Phase Matching for improved accuracy
86+
- **FFT**: Fast Fourier Transform-based detection
87+
- **Hybrid**: Combines multiple algorithms for optimal results
88+
- Chord detection capabilities
89+
- Note utilities for frequency-to-note conversion
90+
- Web Audio API integration with AudioWorklet support
91+
- Optimized for real-time applications
92+
- Used by the web version of the application and can be integrated into other web-based music applications.
93+
- Automatically published to npm after successful releases via GitHub Actions workflow.
94+
7895
---
7996

8097
## Build Instructions

‎android/app/build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ android {
3434
applicationId "de.schliweb.bluesharpbendingapp"
3535
minSdk 28
3636
targetSdk 35
37-
versionCode 68
37+
versionCode 69
3838
versionName project.version.toString()
3939

4040
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

‎build.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ allprojects {
4141
// Defines the group ID used for all projects
4242
group = 'de.schliweb.bluesharpbendingapp'
4343
// Sets the version of the project, matching ${revision}
44-
version = '3.4.2'
44+
version = '3.4.3'
4545

4646
repositories {
4747
google()

‎fastlane/report.xml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55

66

77

8-
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000134">
8+
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000146">
99

1010
</testcase>
1111

1212

13-
<testcase classname="fastlane.lanes" name="1: add_git_tag" time="0.054031">
13+
<testcase classname="fastlane.lanes" name="1: add_git_tag" time="0.033851">
1414

1515
</testcase>
1616

1717

18-
<testcase classname="fastlane.lanes" name="2: push_git_tags" time="1.50297">
18+
<testcase classname="fastlane.lanes" name="2: push_git_tags" time="1.584733">
1919

2020
</testcase>
2121

2222

23-
<testcase classname="fastlane.lanes" name="3: set_github_release" time="5.754063">
23+
<testcase classname="fastlane.lanes" name="3: set_github_release" time="5.550892">
2424

2525
</testcase>
2626

‎npm/README.md‎

Lines changed: 205 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,219 @@
1-
# bluesharp-pitch-detection
1+
# Bluesharp Pitch Detection
22

3-
High-accuracy pitch detection algorithms for musical applications.
3+
[![npm version](https://img.shields.io/npm/v/bluesharp-pitch-detection.svg)](https://www.npmjs.com/package/bluesharp-pitch-detection)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5+
6+
High-accuracy pitch detection algorithms for musical applications, with a focus on harmonica and other musical instruments.
7+
8+
## Features
9+
10+
- Multiple pitch detection algorithms:
11+
- **YIN**: Excellent for vocal and monophonic instrument detection
12+
- **MPM**: Modified Phase Matching for improved accuracy
13+
- **FFT**: Fast Fourier Transform-based detection
14+
- **Hybrid**: Combines multiple algorithms for optimal results
15+
- Chord detection capabilities
16+
- Note utilities for frequency-to-note conversion
17+
- Web Audio API integration with AudioWorklet support
18+
- Optimized for real-time applications
419

520
## Installation
621

722
```bash
823
npm install bluesharp-pitch-detection
924
```
1025

11-
## Usage
26+
## Basic Usage
1227

13-
```js
28+
```javascript
1429
import { YINPitchDetector } from 'bluesharp-pitch-detection';
30+
31+
// Configure the detector (optional)
32+
YINPitchDetector.setMinFrequency(80); // Set minimum frequency in Hz
33+
YINPitchDetector.setMaxFrequency(1000); // Set maximum frequency in Hz
34+
35+
// Detect pitch from audio data
36+
function processMicrophoneData(audioData, sampleRate) {
37+
const result = YINPitchDetector.detectPitch(audioData, sampleRate);
38+
39+
if (result.pitch !== YINPitchDetector.NO_DETECTED_PITCH) {
40+
console.log(`Detected pitch: ${result.pitch.toFixed(2)} Hz`);
41+
console.log(`Confidence: ${(result.confidence * 100).toFixed(2)}%`);
42+
} else {
43+
console.log('No pitch detected');
44+
}
45+
}
46+
```
47+
48+
## Module Structure
49+
50+
The package provides several modules that can be imported separately:
51+
52+
```javascript
53+
// Import everything
54+
import * as PitchDetection from 'bluesharp-pitch-detection';
55+
56+
// Import specific modules
57+
import { YINPitchDetector, MPMPitchDetector } from 'bluesharp-pitch-detection/pitch-detectors';
58+
import { NoteUtils, NoteLookup } from 'bluesharp-pitch-detection/utils';
59+
import { ChordDetector, ChordDetectionResult } from 'bluesharp-pitch-detection/chord-detection';
60+
import { PitchProcessor } from 'bluesharp-pitch-detection/audio-worklet';
61+
```
62+
63+
## API Documentation
64+
65+
### Pitch Detectors
66+
67+
#### YINPitchDetector
68+
69+
Implementation of the YIN algorithm for pitch detection.
70+
71+
```javascript
72+
import { YINPitchDetector } from 'bluesharp-pitch-detection/pitch-detectors';
73+
74+
// Configure frequency range
75+
YINPitchDetector.setMinFrequency(80); // Default: 80 Hz
76+
YINPitchDetector.setMaxFrequency(4835); // Default: 4835 Hz
77+
78+
// Detect pitch
79+
const result = YINPitchDetector.detectPitch(audioData, sampleRate);
80+
// result = { pitch: 440.0, confidence: 0.95 }
81+
```
82+
83+
#### MPMPitchDetector
84+
85+
Implementation of the McLeod Pitch Method (MPM) algorithm.
86+
87+
```javascript
88+
import { MPMPitchDetector } from 'bluesharp-pitch-detection/pitch-detectors';
89+
90+
// Configure frequency range
91+
MPMPitchDetector.setMinFrequency(80);
92+
MPMPitchDetector.setMaxFrequency(4835);
93+
94+
// Detect pitch
95+
const result = MPMPitchDetector.detectPitch(audioData, sampleRate);
96+
```
97+
98+
#### FFTDetector
99+
100+
Fast Fourier Transform-based pitch detection.
101+
102+
```javascript
103+
import { FFTDetector } from 'bluesharp-pitch-detection/pitch-detectors';
104+
105+
// Detect pitch
106+
const result = FFTDetector.detectPitch(audioData, sampleRate);
107+
```
108+
109+
#### HybridPitchDetector
110+
111+
Combines multiple algorithms for optimal results.
112+
113+
```javascript
114+
import { HybridPitchDetector } from 'bluesharp-pitch-detection/pitch-detectors';
115+
116+
// Detect pitch
117+
const result = HybridPitchDetector.detectPitch(audioData, sampleRate);
118+
```
119+
120+
### Utilities
121+
122+
#### NoteUtils
123+
124+
Utilities for working with musical notes and frequencies.
125+
126+
```javascript
127+
import { NoteUtils } from 'bluesharp-pitch-detection/utils';
128+
129+
// Calculate cents between two frequencies
130+
const cents = NoteUtils.getCents(440, 466.16); // ~100 cents (a semitone)
131+
132+
// Add cents to a frequency
133+
const newFreq = NoteUtils.addCentsToFrequency(50, 440); // 50 cents higher than A4
134+
135+
// Round a value to a specific decimal precision
136+
const roundedValue = NoteUtils.round(123.4567); // 123.456
137+
```
138+
139+
#### NoteLookup
140+
141+
Lookup table for note frequencies and names.
142+
143+
```javascript
144+
import { NoteLookup } from 'bluesharp-pitch-detection/utils';
145+
146+
// Get note name from frequency
147+
const noteName = NoteLookup.getNoteName(440); // "A4"
148+
149+
// Get frequency from note name
150+
const frequency = NoteLookup.getFrequency("A4"); // 440
151+
```
152+
153+
### Chord Detection
154+
155+
#### ChordDetector
156+
157+
Detects chords from frequency data.
158+
159+
```javascript
160+
import { ChordDetector } from 'bluesharp-pitch-detection/chord-detection';
161+
162+
// Detect chord from audio data
163+
const result = ChordDetector.detectChord(audioData, sampleRate);
164+
165+
// Get detected pitches
166+
if (result.hasPitches()) {
167+
console.log(`Detected ${result.getPitchCount()} pitches`);
168+
console.log(`First pitch: ${result.getPitch(0)} Hz`);
169+
console.log(`Confidence: ${result.confidence}`);
170+
}
171+
```
172+
173+
#### ChordDetectionResult
174+
175+
Represents the result of chord detection.
176+
177+
```javascript
178+
import { ChordDetectionResult } from 'bluesharp-pitch-detection/chord-detection';
179+
180+
// Create a chord detection result with an array of pitches and a confidence value
181+
const pitches = [261.63, 329.63, 392.00]; // C, E, G (C major chord)
182+
const confidence = 0.95;
183+
const result = new ChordDetectionResult(pitches, confidence);
184+
185+
// Alternative: use the static factory method
186+
const result2 = ChordDetectionResult.of(pitches, confidence);
187+
188+
// Convert from a single pitch detection result
189+
const pitchResult = { pitch: 440, confidence: 0.9 };
190+
const chordResult = ChordDetectionResult.fromPitchDetectionResult(pitchResult);
191+
```
192+
193+
### Audio Worklet
194+
195+
#### PitchProcessor
196+
197+
AudioWorklet processor for real-time pitch detection.
198+
199+
```javascript
200+
import { PitchProcessor } from 'bluesharp-pitch-detection/audio-worklet';
201+
202+
// Register the processor
203+
const audioContext = new AudioContext();
204+
await audioContext.audioWorklet.addModule('node_modules/bluesharp-pitch-detection/audio-worklet.js');
205+
206+
// Create and connect the processor
207+
const pitchNode = new AudioWorkletNode(audioContext, 'pitch-processor');
208+
pitchNode.port.onmessage = (event) => {
209+
const { pitch, confidence } = event.data;
210+
console.log(`Detected pitch: ${pitch} Hz with confidence ${confidence}`);
211+
};
212+
213+
// Connect to audio source
214+
microphoneSource.connect(pitchNode);
15215
```
16216

17217
## License
18218

19-
MIT
219+
MIT © Christian Kierdorf

0 commit comments

Comments
 (0)