react-native-simple-note-pitch-detector 0.2.1 → 0.2.3

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.
@@ -6,6 +6,7 @@ import be.tarsos.dsp.io.android.AudioDispatcherFactory
6
6
  import be.tarsos.dsp.pitch.PitchDetectionHandler
7
7
  import be.tarsos.dsp.pitch.PitchProcessor
8
8
  import be.tarsos.dsp.pitch.PitchProcessor.PitchEstimationAlgorithm
9
+ import kotlin.math.floor
9
10
  import kotlin.math.log2
10
11
  import kotlin.math.round
11
12
 
@@ -35,7 +36,7 @@ class PitchAnalyzer {
35
36
 
36
37
  private fun process(pitchInHz: Float) {
37
38
  val freq = round(12 * (log2(pitchInHz / 440) / log2(2f)) + 69)
38
- val octave = freq / 12
39
+ val octave = (floor(freq / 12) - 1).toInt()
39
40
  val index = freq % 12
40
41
 
41
42
  if (!index.isNaN() && pitchInHz > 0) {
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"]}
@@ -7,6 +7,7 @@ public class ReactNativeSimpleNotePitchDetectorModule: Module {
7
7
  lazy var pitchEngine: PitchEngine = { [weak self] in
8
8
  let config = Config(estimationStrategy: .yin)
9
9
  let pitchEngine = PitchEngine(config: config, delegate: self)
10
+ pitchEngine.levelThreshold = -30
10
11
  return pitchEngine
11
12
  }()
12
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-simple-note-pitch-detector",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
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