react-native-simple-note-pitch-detector 0.3.9 → 0.4.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.
|
@@ -17,7 +17,7 @@ data class NoteAndDecibel(
|
|
|
17
17
|
class PitchAnalyzer {
|
|
18
18
|
|
|
19
19
|
private val notes = arrayOf("C","C#","D","D#","E","F","F#","G","G#","A","A#","B")
|
|
20
|
-
private val notesBuffer = Array(
|
|
20
|
+
private val notesBuffer = Array(6) { NoteAndDecibel() }
|
|
21
21
|
private var counter = 0
|
|
22
22
|
|
|
23
23
|
private lateinit var onChangeNote: (String) -> Unit
|
|
@@ -30,7 +30,9 @@ class PitchAnalyzer {
|
|
|
30
30
|
private val handler = PitchDetectionHandler { res, e ->
|
|
31
31
|
val pitchInHz = res.pitch
|
|
32
32
|
val decibel = e.getdBSPL().toFloat()
|
|
33
|
-
|
|
33
|
+
if (decibel > -85) {
|
|
34
|
+
process(pitchInHz, decibel)
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
private fun prepare() {
|
|
@@ -32,7 +32,7 @@ public class ReactNativeSimpleNotePitchDetectorModule: Module {
|
|
|
32
32
|
lazy var pitchEngine: PitchEngine = { [weak self] in
|
|
33
33
|
let config = Config(estimationStrategy: .yin)
|
|
34
34
|
let pitchEngine = PitchEngine(config: config, delegate: self)
|
|
35
|
-
pitchEngine.levelThreshold = -
|
|
35
|
+
pitchEngine.levelThreshold = -35
|
|
36
36
|
return pitchEngine
|
|
37
37
|
}()
|
|
38
38
|
|
package/package.json
CHANGED