react-native-simple-note-pitch-detector 0.1.6 → 0.1.8
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/build/index.d.ts +6 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +10 -16
- package/build/index.js.map +1 -1
- package/ios/ReactNativeSimpleNotePitchDetector.podspec +1 -0
- package/ios/ReactNativeSimpleNotePitchDetectorModule.swift +32 -31
- package/package.json +2 -2
- package/src/index.ts +26 -19
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.d.ts +0 -7
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.d.ts.map +0 -1
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.js +0 -12
- package/build/ReactNativeSimpleNotePitchDetectorModule.web.js.map +0 -1
- package/build/ReactNativeSimpleNotePitchDetectorView.web.d.ts +0 -4
- package/build/ReactNativeSimpleNotePitchDetectorView.web.d.ts.map +0 -1
- package/build/ReactNativeSimpleNotePitchDetectorView.web.js +0 -6
- package/build/ReactNativeSimpleNotePitchDetectorView.web.js.map +0 -1
- package/src/ReactNativeSimpleNotePitchDetectorModule.web.ts +0 -13
- package/src/ReactNativeSimpleNotePitchDetectorView.web.tsx +0 -11
package/build/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Subscription } from
|
|
2
|
-
import ReactNativeSimpleNotePitchDetectorView from
|
|
3
|
-
import { ChangeEventPayload, ReactNativeSimpleNotePitchDetectorViewProps } from
|
|
4
|
-
export declare
|
|
5
|
-
export declare function
|
|
6
|
-
export
|
|
7
|
-
export declare function addChangeListener(listener: (event: ChangeEventPayload) => void): Subscription;
|
|
8
|
-
export { ReactNativeSimpleNotePitchDetectorView, ReactNativeSimpleNotePitchDetectorViewProps, ChangeEventPayload };
|
|
1
|
+
import { Subscription } from "expo-modules-core";
|
|
2
|
+
import ReactNativeSimpleNotePitchDetectorView from "./ReactNativeSimpleNotePitchDetectorView";
|
|
3
|
+
import { ChangeEventPayload, ReactNativeSimpleNotePitchDetectorViewProps } from "./ReactNativeSimpleNotePitchDetector.types";
|
|
4
|
+
export declare function start(): any;
|
|
5
|
+
export declare function onChangePitch(listener: (event: ChangeEventPayload) => void): Subscription;
|
|
6
|
+
export { ReactNativeSimpleNotePitchDetectorView, ReactNativeSimpleNotePitchDetectorViewProps, ChangeEventPayload, };
|
|
9
7
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,sCAAsC,MAAM,0CAA0C,CAAC;AAC9F,OAAO,EACL,kBAAkB,EAClB,2CAA2C,EAC5C,MAAM,4CAA4C,CAAC;AAEpD,wBAAgB,KAAK,QAEpB;AAOD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAC5C,YAAY,CAEd;AAED,OAAO,EACL,sCAAsC,EACtC,2CAA2C,EAC3C,kBAAkB,GACnB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import { NativeModulesProxy, EventEmitter } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// Get the native constant value.
|
|
7
|
-
export const PI = ReactNativeSimpleNotePitchDetectorModule.PI;
|
|
8
|
-
export function hello() {
|
|
9
|
-
return ReactNativeSimpleNotePitchDetectorModule.hello();
|
|
1
|
+
import { NativeModulesProxy, EventEmitter, } from "expo-modules-core";
|
|
2
|
+
import ReactNativeSimpleNotePitchDetectorModule from "./ReactNativeSimpleNotePitchDetectorModule";
|
|
3
|
+
import ReactNativeSimpleNotePitchDetectorView from "./ReactNativeSimpleNotePitchDetectorView";
|
|
4
|
+
export function start() {
|
|
5
|
+
return ReactNativeSimpleNotePitchDetectorModule.start();
|
|
10
6
|
}
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const emitter = new EventEmitter(ReactNativeSimpleNotePitchDetectorModule ??
|
|
8
|
+
NativeModulesProxy.ReactNativeSimpleNotePitchDetector);
|
|
9
|
+
export function onChangePitch(listener) {
|
|
10
|
+
return emitter.addListener("onChangePitch", listener);
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
export function addChangeListener(listener) {
|
|
16
|
-
return emitter.addListener('onChange', listener);
|
|
17
|
-
}
|
|
18
|
-
export { ReactNativeSimpleNotePitchDetectorView };
|
|
12
|
+
export { ReactNativeSimpleNotePitchDetectorView, };
|
|
19
13
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,GAEb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,wCAAwC,MAAM,4CAA4C,CAAC;AAClG,OAAO,sCAAsC,MAAM,0CAA0C,CAAC;AAM9F,MAAM,UAAU,KAAK;IACnB,OAAO,wCAAwC,CAAC,KAAK,EAAE,CAAC;AAC1D,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,YAAY,CAC9B,wCAAwC;IACtC,kBAAkB,CAAC,kCAAkC,CACxD,CAAC;AAEF,MAAM,UAAU,aAAa,CAC3B,QAA6C;IAE7C,OAAO,OAAO,CAAC,WAAW,CAAqB,eAAe,EAAE,QAAQ,CAAC,CAAC;AAC5E,CAAC;AAED,OAAO,EACL,sCAAsC,GAGvC,CAAC","sourcesContent":["import {\n NativeModulesProxy,\n EventEmitter,\n Subscription,\n} from \"expo-modules-core\";\n\nimport ReactNativeSimpleNotePitchDetectorModule from \"./ReactNativeSimpleNotePitchDetectorModule\";\nimport ReactNativeSimpleNotePitchDetectorView from \"./ReactNativeSimpleNotePitchDetectorView\";\nimport {\n ChangeEventPayload,\n ReactNativeSimpleNotePitchDetectorViewProps,\n} from \"./ReactNativeSimpleNotePitchDetector.types\";\n\nexport function start() {\n return ReactNativeSimpleNotePitchDetectorModule.start();\n}\n\nconst emitter = new EventEmitter(\n ReactNativeSimpleNotePitchDetectorModule ??\n NativeModulesProxy.ReactNativeSimpleNotePitchDetector\n);\n\nexport function onChangePitch(\n listener: (event: ChangeEventPayload) => void\n): Subscription {\n return emitter.addListener<ChangeEventPayload>(\"onChangePitch\", listener);\n}\n\nexport {\n ReactNativeSimpleNotePitchDetectorView,\n ReactNativeSimpleNotePitchDetectorViewProps,\n ChangeEventPayload,\n};\n"]}
|
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
|
+
import Beethoven
|
|
3
|
+
import Pitchy
|
|
2
4
|
|
|
3
5
|
public class ReactNativeSimpleNotePitchDetectorModule: Module {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
lazy var pitchEngine: PitchEngine = { [weak self] in
|
|
8
|
+
let config = Config(estimationStrategy: .yin)
|
|
9
|
+
let pitchEngine = PitchEngine(config: config, delegate: self)
|
|
10
|
+
return pitchEngine
|
|
11
|
+
}()
|
|
12
|
+
|
|
7
13
|
public func definition() -> ModuleDefinition {
|
|
8
|
-
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
9
|
-
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
10
|
-
// The module will be accessible from `requireNativeModule('ReactNativeSimpleNotePitchDetector')` in JavaScript.
|
|
11
|
-
Name("ReactNativeSimpleNotePitchDetector")
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
Constants([
|
|
15
|
-
"PI": Double.pi
|
|
16
|
-
])
|
|
15
|
+
Name("ReactNativeSimpleNotePitchDetector")
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
Events("onChange")
|
|
17
|
+
Events("onChangePitch")
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return "Hello world! 👋"
|
|
19
|
+
Function("start") {
|
|
20
|
+
pitchEngine.start()
|
|
24
21
|
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"value": value
|
|
32
|
-
])
|
|
33
|
-
}
|
|
25
|
+
extension ReactNativeSimpleNotePitchDetectorModule: PitchEngineDelegate {
|
|
26
|
+
public func pitchEngine(_ pitchEngine: PitchEngine, didReceivePitch pitch: Pitch) {
|
|
27
|
+
|
|
28
|
+
let offsetPercentage = pitch.closestOffset.percentage
|
|
29
|
+
let absOffsetPercentage = abs(offsetPercentage)
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
View(ReactNativeSimpleNotePitchDetectorView.self) {
|
|
38
|
-
// Defines a setter for the `name` prop.
|
|
39
|
-
Prop("name") { (view: ReactNativeSimpleNotePitchDetectorView, prop: String) in
|
|
40
|
-
print(prop)
|
|
31
|
+
guard absOffsetPercentage > 1.0 else {
|
|
32
|
+
return
|
|
41
33
|
}
|
|
42
|
-
|
|
34
|
+
|
|
35
|
+
self.sendEvent("onChangePitch", ["note" : pitch.note.string, "frequency" : pitch.frequency, "wave" : pitch.wave.wavelength])
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public func pitchEngine(_ pitchEngine: PitchEngine, didReceiveError error: Error) {
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public func pitchEngineWentBelowLevelThreshold(_ pitchEngine: PitchEngine) {
|
|
43
|
+
|
|
43
44
|
}
|
|
44
45
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-simple-note-pitch-detector",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.8",
|
|
4
|
+
"description": "a simple react native library to detect the pitch of the input recording",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
7
7
|
"scripts": {
|
package/src/index.ts
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
NativeModulesProxy,
|
|
3
|
+
EventEmitter,
|
|
4
|
+
Subscription,
|
|
5
|
+
} from "expo-modules-core";
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
import ReactNativeSimpleNotePitchDetectorModule from "./ReactNativeSimpleNotePitchDetectorModule";
|
|
8
|
+
import ReactNativeSimpleNotePitchDetectorView from "./ReactNativeSimpleNotePitchDetectorView";
|
|
9
|
+
import {
|
|
10
|
+
ChangeEventPayload,
|
|
11
|
+
ReactNativeSimpleNotePitchDetectorViewProps,
|
|
12
|
+
} from "./ReactNativeSimpleNotePitchDetector.types";
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export function hello(): string {
|
|
13
|
-
return ReactNativeSimpleNotePitchDetectorModule.hello();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export async function setValueAsync(value: string) {
|
|
17
|
-
return await ReactNativeSimpleNotePitchDetectorModule.setValueAsync(value);
|
|
14
|
+
export function start() {
|
|
15
|
+
return ReactNativeSimpleNotePitchDetectorModule.start();
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
const emitter = new EventEmitter(
|
|
18
|
+
const emitter = new EventEmitter(
|
|
19
|
+
ReactNativeSimpleNotePitchDetectorModule ??
|
|
20
|
+
NativeModulesProxy.ReactNativeSimpleNotePitchDetector
|
|
21
|
+
);
|
|
21
22
|
|
|
22
|
-
export function
|
|
23
|
-
|
|
23
|
+
export function onChangePitch(
|
|
24
|
+
listener: (event: ChangeEventPayload) => void
|
|
25
|
+
): Subscription {
|
|
26
|
+
return emitter.addListener<ChangeEventPayload>("onChangePitch", listener);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
export {
|
|
29
|
+
export {
|
|
30
|
+
ReactNativeSimpleNotePitchDetectorView,
|
|
31
|
+
ReactNativeSimpleNotePitchDetectorViewProps,
|
|
32
|
+
ChangeEventPayload,
|
|
33
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeSimpleNotePitchDetectorModule.web.d.ts","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetectorModule.web.ts"],"names":[],"mappings":";;yBAM6B,MAAM,GAAG,QAAQ,IAAI,CAAC;;;AAFnD,wBAQE"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'expo-modules-core';
|
|
2
|
-
const emitter = new EventEmitter({});
|
|
3
|
-
export default {
|
|
4
|
-
PI: Math.PI,
|
|
5
|
-
async setValueAsync(value) {
|
|
6
|
-
emitter.emit('onChange', { value });
|
|
7
|
-
},
|
|
8
|
-
hello() {
|
|
9
|
-
return 'Hello world! 👋';
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=ReactNativeSimpleNotePitchDetectorModule.web.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeSimpleNotePitchDetectorModule.web.js","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetectorModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,EAAS,CAAC,CAAC;AAE5C,eAAe;IACb,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,KAAK,CAAC,aAAa,CAAC,KAAa;QAC/B,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,KAAK;QACH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF,CAAC","sourcesContent":["import { EventEmitter } from 'expo-modules-core';\n\nconst emitter = new EventEmitter({} as any);\n\nexport default {\n PI: Math.PI,\n async setValueAsync(value: string): Promise<void> {\n emitter.emit('onChange', { value });\n },\n hello() {\n return 'Hello world! 👋';\n },\n};\n"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ReactNativeSimpleNotePitchDetectorViewProps } from './ReactNativeSimpleNotePitchDetector.types';
|
|
3
|
-
export default function ReactNativeSimpleNotePitchDetectorView(props: ReactNativeSimpleNotePitchDetectorViewProps): React.JSX.Element;
|
|
4
|
-
//# sourceMappingURL=ReactNativeSimpleNotePitchDetectorView.web.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeSimpleNotePitchDetectorView.web.d.ts","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetectorView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,2CAA2C,EAAE,MAAM,4CAA4C,CAAC;AAEzG,MAAM,CAAC,OAAO,UAAU,sCAAsC,CAAC,KAAK,EAAE,2CAA2C,qBAMhH"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export default function ReactNativeSimpleNotePitchDetectorView(props) {
|
|
3
|
-
return (React.createElement("div", null,
|
|
4
|
-
React.createElement("span", null, props.name)));
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=ReactNativeSimpleNotePitchDetectorView.web.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeSimpleNotePitchDetectorView.web.js","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetectorView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,CAAC,OAAO,UAAU,sCAAsC,CAAC,KAAkD;IAC/G,OAAO,CACL;QACE,kCAAO,KAAK,CAAC,IAAI,CAAQ,CACrB,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { ReactNativeSimpleNotePitchDetectorViewProps } from './ReactNativeSimpleNotePitchDetector.types';\n\nexport default function ReactNativeSimpleNotePitchDetectorView(props: ReactNativeSimpleNotePitchDetectorViewProps) {\n return (\n <div>\n <span>{props.name}</span>\n </div>\n );\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'expo-modules-core';
|
|
2
|
-
|
|
3
|
-
const emitter = new EventEmitter({} as any);
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
PI: Math.PI,
|
|
7
|
-
async setValueAsync(value: string): Promise<void> {
|
|
8
|
-
emitter.emit('onChange', { value });
|
|
9
|
-
},
|
|
10
|
-
hello() {
|
|
11
|
-
return 'Hello world! 👋';
|
|
12
|
-
},
|
|
13
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { ReactNativeSimpleNotePitchDetectorViewProps } from './ReactNativeSimpleNotePitchDetector.types';
|
|
4
|
-
|
|
5
|
-
export default function ReactNativeSimpleNotePitchDetectorView(props: ReactNativeSimpleNotePitchDetectorViewProps) {
|
|
6
|
-
return (
|
|
7
|
-
<div>
|
|
8
|
-
<span>{props.name}</span>
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
11
|
-
}
|