react-native-simple-note-pitch-detector 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/.gradle/9.0-milestone-1/checksums/checksums.lock +0 -0
- package/android/.gradle/9.0-milestone-1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.0-milestone-1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.0-milestone-1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/caches/deviceStreaming.xml +1318 -0
- package/android/.idea/gradle.xml +13 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/local.properties +8 -0
- package/android/src/main/java/expo/modules/simplenotepitchdetector/PitchAnalyzer.kt +77 -8
- package/android/src/main/java/expo/modules/simplenotepitchdetector/ReactNativeSimpleNotePitchDetectorModule.kt +39 -1
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.d.ts +6 -1
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.d.ts.map +1 -1
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.js +6 -1
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.js.map +1 -1
- package/build/index.d.ts +65 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +71 -0
- package/build/index.js.map +1 -1
- package/ios/ReactNativeSimpleNotePitchDetectorModule.swift +102 -13
- package/package.json +2 -2
- package/src/ReactNativeSimpleNotePitchDetectorModule.web.ts +6 -1
- package/src/index.ts +83 -0
|
@@ -3,6 +3,11 @@ import { ChangeEventPayload } from "./ReactNativeSimpleNotePitchDetector.types";
|
|
|
3
3
|
export default {
|
|
4
4
|
start: () => {},
|
|
5
5
|
stop: () => {},
|
|
6
|
-
isRecording: () =>
|
|
6
|
+
isRecording: () => false,
|
|
7
7
|
onChangePitch: (_: ChangeEventPayload) => {},
|
|
8
|
+
setLevelThreshold: (_: number) => {},
|
|
9
|
+
setBufferSize: (_: number) => {},
|
|
10
|
+
getBufferSize: () => 8192,
|
|
11
|
+
setAlgorithm: (_: string) => {},
|
|
12
|
+
getAlgorithm: () => "yin",
|
|
8
13
|
};
|
package/src/index.ts
CHANGED
|
@@ -33,6 +33,73 @@ export function setLevelThreshold(threshold: number) {
|
|
|
33
33
|
return ReactNativeSimpleNotePitchDetectorModule.setLevelThreshold(threshold);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Set the buffer size for pitch detection.
|
|
38
|
+
* Must be called before start() or will restart the engine if already running.
|
|
39
|
+
*
|
|
40
|
+
* Buffer size affects the trade-off between frequency range and responsiveness:
|
|
41
|
+
* - Smaller buffer (2048-4096): Better for high frequencies, faster response, but less accurate for low notes
|
|
42
|
+
* - Larger buffer (8192-16384): Better for low frequencies, more accurate, but slightly more latency
|
|
43
|
+
*
|
|
44
|
+
* iOS defaults to 8192, Android defaults to 2048.
|
|
45
|
+
*
|
|
46
|
+
* Recommended values:
|
|
47
|
+
* - 4096: Good balance for most use cases
|
|
48
|
+
* - 8192: Better for bass instruments or full piano range (iOS default)
|
|
49
|
+
* - 2048: Better for high-pitched instruments, faster response (Android default)
|
|
50
|
+
*
|
|
51
|
+
* @param size - Buffer size (must be power of 2: 1024, 2048, 4096, 8192, 16384)
|
|
52
|
+
*/
|
|
53
|
+
export function setBufferSize(size: number) {
|
|
54
|
+
return ReactNativeSimpleNotePitchDetectorModule.setBufferSize(size);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the current buffer size.
|
|
59
|
+
* @returns Current buffer size
|
|
60
|
+
*/
|
|
61
|
+
export function getBufferSize(): number {
|
|
62
|
+
return ReactNativeSimpleNotePitchDetectorModule.getBufferSize();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Set the pitch estimation algorithm.
|
|
67
|
+
* Must be called before start() or will restart the engine if already running.
|
|
68
|
+
*
|
|
69
|
+
* Available algorithms differ by platform:
|
|
70
|
+
*
|
|
71
|
+
* **iOS (Beethoven library):**
|
|
72
|
+
* - "yin" (default) - YIN algorithm, good for monophonic instruments
|
|
73
|
+
* - "hps" - Harmonic Product Spectrum
|
|
74
|
+
* - "barycentric" - Barycentric interpolation
|
|
75
|
+
* - "quadradic" - Quadratic interpolation
|
|
76
|
+
* - "jains" - Jain's method
|
|
77
|
+
* - "quinnsFirst" - Quinn's first estimator
|
|
78
|
+
* - "quinnsSecond" - Quinn's second estimator
|
|
79
|
+
* - "maxValue" - Maximum value method
|
|
80
|
+
*
|
|
81
|
+
* **Android (TarsosDSP library):**
|
|
82
|
+
* - "fft_yin" (default) - FFT-based YIN, faster than pure YIN
|
|
83
|
+
* - "yin" - Pure YIN algorithm
|
|
84
|
+
* - "mpm" - McLeod Pitch Method, good for speech and music
|
|
85
|
+
* - "fft_pitch" - FFT bin with most energy
|
|
86
|
+
* - "dynamic_wavelet" - Dynamic wavelet algorithm
|
|
87
|
+
* - "amdf" - Average Magnitude Difference Function
|
|
88
|
+
*
|
|
89
|
+
* @param algorithm - Algorithm name (case-insensitive)
|
|
90
|
+
*/
|
|
91
|
+
export function setAlgorithm(algorithm: string) {
|
|
92
|
+
return ReactNativeSimpleNotePitchDetectorModule.setAlgorithm(algorithm);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get the current algorithm name.
|
|
97
|
+
* @returns Current algorithm name
|
|
98
|
+
*/
|
|
99
|
+
export function getAlgorithm(): string {
|
|
100
|
+
return ReactNativeSimpleNotePitchDetectorModule.getAlgorithm();
|
|
101
|
+
}
|
|
102
|
+
|
|
36
103
|
const emitter = new EventEmitter(
|
|
37
104
|
ReactNativeSimpleNotePitchDetectorModule ??
|
|
38
105
|
NativeModulesProxy.ReactNativeSimpleNotePitchDetector
|
|
@@ -44,4 +111,20 @@ export function onChangeNote(
|
|
|
44
111
|
return emitter.addListener<ChangeEventPayload>("onChangeNote", listener);
|
|
45
112
|
}
|
|
46
113
|
|
|
114
|
+
export interface StatusEventPayload {
|
|
115
|
+
level: "debug" | "error" | "verbose";
|
|
116
|
+
message: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Listen for status/debug messages from the native module.
|
|
121
|
+
* Useful for debugging audio initialization issues.
|
|
122
|
+
* @param listener - Callback that receives status events with level and message
|
|
123
|
+
*/
|
|
124
|
+
export function onStatus(
|
|
125
|
+
listener: (event: StatusEventPayload) => void
|
|
126
|
+
): Subscription {
|
|
127
|
+
return emitter.addListener<StatusEventPayload>("onStatus", listener);
|
|
128
|
+
}
|
|
129
|
+
|
|
47
130
|
export { ReactNativeSimpleNotePitchDetectorViewProps, ChangeEventPayload };
|