react-native-simple-note-pitch-detector 0.7.2 → 0.7.4

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.
@@ -38,7 +38,8 @@ class ReactNativeSimpleNotePitchDetectorModule : Module() {
38
38
  "note" to pitchData.note,
39
39
  "octave" to pitchData.octave,
40
40
  "frequency" to pitchData.frequency.toDouble(),
41
- "offset" to pitchData.offset.toDouble()
41
+ "offset" to pitchData.offset.toDouble(),
42
+ "amplitude" to pitchData.amplitude.toDouble()
42
43
  )
43
44
  )
44
45
  }
@@ -7,5 +7,7 @@ export type ChangeEventPayload = {
7
7
  frequency: number;
8
8
  /** Offset from perfect pitch as percentage (-50 to +50, negative = flat, positive = sharp) */
9
9
  offset: number;
10
+ /** Signal amplitude in dB SPL (approximate) */
11
+ amplitude: number;
10
12
  };
11
13
  //# sourceMappingURL=ReactNativeSimpleNotePitchDetector.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeSimpleNotePitchDetector.types.d.ts","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetector.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
1
+ {"version":3,"file":"ReactNativeSimpleNotePitchDetector.types.d.ts","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetector.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeSimpleNotePitchDetector.types.js","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetector.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ChangeEventPayload = {\n /** Note name without octave (e.g., \"C#\", \"D\", \"Eb\") */\n note: string;\n /** Octave number (e.g., 4 for middle C) */\n octave: number;\n /** Raw frequency in Hz */\n frequency: number;\n /** Offset from perfect pitch as percentage (-50 to +50, negative = flat, positive = sharp) */\n offset: number;\n};\n"]}
1
+ {"version":3,"file":"ReactNativeSimpleNotePitchDetector.types.js","sourceRoot":"","sources":["../src/ReactNativeSimpleNotePitchDetector.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ChangeEventPayload = {\n /** Note name without octave (e.g., \"C#\", \"D\", \"Eb\") */\n note: string;\n /** Octave number (e.g., 4 for middle C) */\n octave: number;\n /** Raw frequency in Hz */\n frequency: number;\n /** Offset from perfect pitch as percentage (-50 to +50, negative = flat, positive = sharp) */\n offset: number;\n /** Signal amplitude in dB SPL (approximate) */\n amplitude: number;\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  import ExpoModulesCore
2
2
  import Beethoven
3
3
  import Pitchy
4
+ import AVFoundation
4
5
 
5
6
 
6
7
  public class ReactNativeSimpleNotePitchDetectorModule: Module {
@@ -19,6 +20,21 @@ public class ReactNativeSimpleNotePitchDetectorModule: Module {
19
20
  ])
20
21
  }
21
22
 
23
+ private func configureAudioSession() {
24
+ let session = AVAudioSession.sharedInstance()
25
+ do {
26
+ try session.setCategory(
27
+ .playAndRecord,
28
+ mode: .measurement,
29
+ options: [.defaultToSpeaker, .allowBluetooth]
30
+ )
31
+ try session.setActive(true, options: .notifyOthersOnDeactivation)
32
+ self.sendStatus("debug", "AVAudioSession configured: category=playAndRecord, mode=measurement")
33
+ } catch {
34
+ self.sendStatus("error", "Failed to configure AVAudioSession: \(error.localizedDescription)")
35
+ }
36
+ }
37
+
22
38
  public func definition() -> ModuleDefinition {
23
39
 
24
40
  Name("ReactNativeSimpleNotePitchDetector")
@@ -27,6 +43,7 @@ public class ReactNativeSimpleNotePitchDetectorModule: Module {
27
43
 
28
44
  Function("start") {
29
45
  self.sendStatus("debug", "start() called with bufferSize=\(self.bufferSize), algorithm=\(self.estimationStrategy)")
46
+ self.configureAudioSession()
30
47
  self.pitchEngine.start()
31
48
  self.sendStatus("debug", "Recording started successfully")
32
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-simple-note-pitch-detector",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
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",
@@ -7,4 +7,6 @@ export type ChangeEventPayload = {
7
7
  frequency: number;
8
8
  /** Offset from perfect pitch as percentage (-50 to +50, negative = flat, positive = sharp) */
9
9
  offset: number;
10
+ /** Signal amplitude in dB SPL (approximate) */
11
+ amplitude: number;
10
12
  };