react-native-simple-note-pitch-detector 0.2.0 → 0.2.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.
@@ -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.1",
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",