react-native-simple-note-pitch-detector 0.1.5 → 0.1.7
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/src/main/java/expo/modules/simplenotepitchdetector/PitchAnalyzer.kt +5 -8
- package/android/src/main/java/expo/modules/simplenotepitchdetector/ReactNativeSimpleNotePitchDetectorModule.kt +24 -19
- 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/ReactNativeSimpleNotePitchDetectorModule.swift +2 -21
- package/package.json +1 -1
- 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
|
@@ -14,10 +14,10 @@ import kotlin.math.round
|
|
|
14
14
|
|
|
15
15
|
class PitchAnalyzer {
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var onChangePitch: (String, Double) -> Unit
|
|
18
18
|
|
|
19
|
-
constructor(callback: (String) -> Unit) {
|
|
20
|
-
this.
|
|
19
|
+
constructor(callback: (String, Double) -> Unit) {
|
|
20
|
+
this.onChangePitch = callback
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
private val tones = arrayOf("C","C#","D","D#","E","F","F#","G","G#","A","A#","B")
|
|
@@ -44,12 +44,9 @@ class PitchAnalyzer {
|
|
|
44
44
|
|
|
45
45
|
if (!index.isNaN() && pitchInHz > 0) {
|
|
46
46
|
val tone = tones[index.toInt()]
|
|
47
|
+
val frequency = pitchInHz.toDouble()
|
|
47
48
|
|
|
48
|
-
this.
|
|
49
|
-
// val data: WritableMap = WritableNativeMap()
|
|
50
|
-
//
|
|
51
|
-
// data.putDouble("frequency", pitchInHz.toDouble())
|
|
52
|
-
// data.putString("tone", tone)
|
|
49
|
+
this.onChangePitch(tone, frequency)
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
|
|
@@ -10,31 +10,36 @@ import androidx.core.os.bundleOf
|
|
|
10
10
|
|
|
11
11
|
class ReactNativeSimpleNotePitchDetectorModule : Module() {
|
|
12
12
|
|
|
13
|
-
private var permissions = arrayOf(Manifest.permission.RECORD_AUDIO)
|
|
14
|
-
|
|
15
13
|
override fun definition() = ModuleDefinition {
|
|
16
14
|
Name("ReactNativeSimpleNotePitchDetector")
|
|
17
15
|
|
|
18
|
-
Events("
|
|
19
|
-
|
|
20
|
-
Function("hello") {
|
|
16
|
+
Events("onChangePitch")
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
Function("start") {
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} else {
|
|
30
|
-
val pitchAnalyzer = PitchAnalyzer {
|
|
31
|
-
this@ReactNativeSimpleNotePitchDetectorModule.sendEvent(
|
|
32
|
-
"onChange",
|
|
33
|
-
bundleOf("tone" to it)
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
pitchAnalyzer.start()
|
|
20
|
+
val pitchAnalyzer = PitchAnalyzer { tone: String, frequency: Double ->
|
|
21
|
+
this@ReactNativeSimpleNotePitchDetectorModule.sendEvent(
|
|
22
|
+
"onChangePitch",
|
|
23
|
+
bundleOf("tone" to tone, "frequency" to frequency)
|
|
24
|
+
)
|
|
37
25
|
}
|
|
26
|
+
|
|
27
|
+
pitchAnalyzer.start()
|
|
28
|
+
|
|
29
|
+
// val context = appContext.reactContext!!
|
|
30
|
+
// var activity = appContext.currentActivity!!
|
|
31
|
+
// var permissionsGranted = ActivityCompat.checkSelfPermission(context, permissions[0]) == PackageManager.PERMISSION_GRANTED
|
|
32
|
+
// if (!permissionsGranted) {
|
|
33
|
+
// ActivityCompat.requestPermissions(activity, permissions, 200)
|
|
34
|
+
// } else {
|
|
35
|
+
// val pitchAnalyzer = PitchAnalyzer {
|
|
36
|
+
// this@ReactNativeSimpleNotePitchDetectorModule.sendEvent(
|
|
37
|
+
// "onChange",
|
|
38
|
+
// bundleOf("tone" to it)
|
|
39
|
+
// )
|
|
40
|
+
// }
|
|
41
|
+
// pitchAnalyzer.start()
|
|
42
|
+
// }
|
|
38
43
|
}
|
|
39
44
|
}
|
|
40
45
|
}
|
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,24 +1,13 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
|
|
3
3
|
public class ReactNativeSimpleNotePitchDetectorModule: Module {
|
|
4
|
-
|
|
5
|
-
// that describes the module's functionality and behavior.
|
|
6
|
-
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
4
|
+
|
|
7
5
|
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
6
|
|
|
13
|
-
|
|
14
|
-
Constants([
|
|
15
|
-
"PI": Double.pi
|
|
16
|
-
])
|
|
7
|
+
Name("ReactNativeSimpleNotePitchDetector")
|
|
17
8
|
|
|
18
|
-
// Defines event names that the module can send to JavaScript.
|
|
19
9
|
Events("onChange")
|
|
20
10
|
|
|
21
|
-
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
22
11
|
Function("hello") {
|
|
23
12
|
return "Hello world! 👋"
|
|
24
13
|
}
|
|
@@ -32,13 +21,5 @@ public class ReactNativeSimpleNotePitchDetectorModule: Module {
|
|
|
32
21
|
])
|
|
33
22
|
}
|
|
34
23
|
|
|
35
|
-
// Enables the module to be used as a native view. Definition components that are accepted as part of the
|
|
36
|
-
// view definition: Prop, Events.
|
|
37
|
-
View(ReactNativeSimpleNotePitchDetectorView.self) {
|
|
38
|
-
// Defines a setter for the `name` prop.
|
|
39
|
-
Prop("name") { (view: ReactNativeSimpleNotePitchDetectorView, prop: String) in
|
|
40
|
-
print(prop)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
24
|
}
|
|
44
25
|
}
|
package/package.json
CHANGED
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
|
-
}
|