react-native-simple-note-pitch-detector 0.2.0 → 0.2.2

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 CHANGED
@@ -2,6 +2,8 @@ import { Subscription } from "expo-modules-core";
2
2
  import ReactNativeSimpleNotePitchDetectorView from "./ReactNativeSimpleNotePitchDetectorView";
3
3
  import { ChangeEventPayload, ReactNativeSimpleNotePitchDetectorViewProps } from "./ReactNativeSimpleNotePitchDetector.types";
4
4
  export declare function start(): any;
5
+ export declare function stop(): any;
6
+ export declare function isRecording(): any;
5
7
  export declare function onChangePitch(listener: (event: ChangeEventPayload) => void): Subscription;
6
8
  export { ReactNativeSimpleNotePitchDetectorView, ReactNativeSimpleNotePitchDetectorViewProps, ChangeEventPayload, };
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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"}
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;AAED,wBAAgB,IAAI,QAEnB;AAED,wBAAgB,WAAW,QAE1B;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
@@ -4,6 +4,12 @@ import ReactNativeSimpleNotePitchDetectorView from "./ReactNativeSimpleNotePitch
4
4
  export function start() {
5
5
  return ReactNativeSimpleNotePitchDetectorModule.start();
6
6
  }
7
+ export function stop() {
8
+ return ReactNativeSimpleNotePitchDetectorModule.stop();
9
+ }
10
+ export function isRecording() {
11
+ return ReactNativeSimpleNotePitchDetectorModule.isRecording();
12
+ }
7
13
  const emitter = new EventEmitter(ReactNativeSimpleNotePitchDetectorModule ??
8
14
  NativeModulesProxy.ReactNativeSimpleNotePitchDetector);
9
15
  export function onChangePitch(listener) {
@@ -1 +1 @@
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
+ {"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,UAAU,IAAI;IAClB,OAAO,wCAAwC,CAAC,IAAI,EAAE,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,wCAAwC,CAAC,WAAW,EAAE,CAAC;AAChE,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\nexport function stop() {\n return ReactNativeSimpleNotePitchDetectorModule.stop();\n}\n\nexport function isRecording() {\n return ReactNativeSimpleNotePitchDetectorModule.isRecording();\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"]}
@@ -9,37 +9,50 @@ public class ReactNativeSimpleNotePitchDetectorModule: Module {
9
9
  let pitchEngine = PitchEngine(config: config, delegate: self)
10
10
  return pitchEngine
11
11
  }()
12
+
13
+ var isRecording = false
14
+
15
+ public func definition() -> ModuleDefinition {
12
16
 
13
- public func definition() -> ModuleDefinition {
17
+ Name("ReactNativeSimpleNotePitchDetector")
14
18
 
15
- Name("ReactNativeSimpleNotePitchDetector")
19
+ Events("onChangePitch")
16
20
 
17
- Events("onChangePitch")
21
+ Function("start") {
22
+ pitchEngine.start()
23
+ isRecording = true
24
+ }
18
25
 
19
- Function("start") {
20
- pitchEngine.start()
26
+ Function("stop") {
27
+ pitchEngine.stop()
28
+ isRecording = false
29
+ }
30
+
31
+ Function("isRecording") {
32
+ return isRecording
33
+ }
21
34
  }
22
- }
23
35
  }
24
36
 
25
37
  extension ReactNativeSimpleNotePitchDetectorModule: PitchEngineDelegate {
26
- public func pitchEngine(_ pitchEngine: PitchEngine, didReceivePitch pitch: Pitch) {
38
+
39
+ public func pitchEngine(_ pitchEngine: PitchEngine, didReceivePitch pitch: Pitch) {
27
40
 
28
- let offsetPercentage = pitch.closestOffset.percentage
29
- let absOffsetPercentage = abs(offsetPercentage)
41
+ let offsetPercentage = pitch.closestOffset.percentage
42
+ let absOffsetPercentage = abs(offsetPercentage)
30
43
 
31
- guard absOffsetPercentage > 1.0 else {
32
- return
33
- }
44
+ guard absOffsetPercentage > 1.0 else {
45
+ return
46
+ }
34
47
 
35
- self.sendEvent("onChangePitch", ["note" : pitch.note.string, "frequency" : pitch.frequency])
36
- }
48
+ self.sendEvent("onChangePitch", ["note" : pitch.note.string, "frequency" : pitch.frequency])
49
+ }
37
50
 
38
- public func pitchEngine(_ pitchEngine: PitchEngine, didReceiveError error: Error) {
39
-
40
- }
51
+ public func pitchEngine(_ pitchEngine: PitchEngine, didReceiveError error: Error) {
41
52
 
42
- public func pitchEngineWentBelowLevelThreshold(_ pitchEngine: PitchEngine) {
43
-
44
- }
53
+ }
54
+
55
+ public func pitchEngineWentBelowLevelThreshold(_ pitchEngine: PitchEngine) {
56
+
57
+ }
45
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-simple-note-pitch-detector",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
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",
package/src/index.ts CHANGED
@@ -15,6 +15,14 @@ export function start() {
15
15
  return ReactNativeSimpleNotePitchDetectorModule.start();
16
16
  }
17
17
 
18
+ export function stop() {
19
+ return ReactNativeSimpleNotePitchDetectorModule.stop();
20
+ }
21
+
22
+ export function isRecording() {
23
+ return ReactNativeSimpleNotePitchDetectorModule.isRecording();
24
+ }
25
+
18
26
  const emitter = new EventEmitter(
19
27
  ReactNativeSimpleNotePitchDetectorModule ??
20
28
  NativeModulesProxy.ReactNativeSimpleNotePitchDetector