react-native-simple-note-pitch-detector 0.3.8 → 0.4.0
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(8) { NoteAndDecibel() }
|
|
21
21
|
private var counter = 0
|
|
22
22
|
|
|
23
23
|
private lateinit var onChangeNote: (String) -> Unit
|
|
@@ -45,20 +45,21 @@ class PitchAnalyzer {
|
|
|
45
45
|
|
|
46
46
|
if (!index.isNaN() && pitchInHz > 0) {
|
|
47
47
|
val note = notes[index.toInt()]
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
counter
|
|
48
|
+
onChangeNote("$note $decibel")
|
|
49
|
+
// var noteAndDecibel = NoteAndDecibel(note, decibel)
|
|
50
|
+
//
|
|
51
|
+
// if (counter == notesBuffer.size) {
|
|
52
|
+
// var mostFrequentNote = getMostFrequentNote(notesBuffer)
|
|
53
|
+
//
|
|
54
|
+
// if (mostFrequentNote != null) {
|
|
55
|
+
// onChangeNote(mostFrequentNote)
|
|
56
|
+
// }
|
|
57
|
+
//
|
|
58
|
+
// counter = 0
|
|
59
|
+
// }
|
|
60
|
+
//
|
|
61
|
+
// notesBuffer[counter] = noteAndDecibel
|
|
62
|
+
// counter += 1
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
package/package.json
CHANGED