new analyzer
This commit is contained in:
1 parent
4b1fc0835a
commit
98d9fa24cf
110 files changed
+1749
-52
No files matched your search
@@ -27,6 +27,8 @@ enum State {
|
||||
var current_state: State = State.IDLE
|
||||
var _silence_timer: float = 0.0
|
||||
var _current_rms: float = 0.0
|
||||
var _current_genre: String = ""
|
||||
var _current_genre_conf: float = 0.0
|
||||
|
||||
# BPM dinamico: parte da 0 finché la canzone non viene agganciata
|
||||
var _current_bpm: float = 0.0
|
||||
@@ -48,6 +50,7 @@ func _ready() -> void:
|
||||
audio_analyzer.volume_updated.connect(_on_volume_updated)
|
||||
audio_analyzer.bpm_updated.connect(_on_bpm_updated)
|
||||
audio_analyzer.applications_updated.connect(_on_applications_updated)
|
||||
audio_analyzer.genre_updated.connect(_on_genre_updated)
|
||||
|
||||
if app_selector:
|
||||
app_selector.item_selected.connect(_on_app_selected)
|
||||
@@ -56,18 +59,22 @@ func _ready() -> void:
|
||||
|
||||
_set_state(State.IDLE)
|
||||
|
||||
func _on_genre_updated(genre: String, confidence: float, _probs: Dictionary) -> void:
|
||||
_current_genre = genre
|
||||
_current_genre_conf = confidence
|
||||
|
||||
func _on_applications_updated(apps: Array[Dictionary]) -> void:
|
||||
if not app_selector:
|
||||
return
|
||||
|
||||
# Evita di ricreare la lista se gli elementi sono identici (previene glitch della UI)
|
||||
var is_same = (apps.size() == _known_apps.size())
|
||||
if is_same:
|
||||
var issame = (apps.size() == _known_apps.size())
|
||||
if issame:
|
||||
for i in range(apps.size()):
|
||||
if apps[i]["pid"] != _known_apps[i]["pid"] or apps[i]["name"] != _known_apps[i]["name"]:
|
||||
is_same = false
|
||||
issame = false
|
||||
break
|
||||
if is_same:
|
||||
if issame:
|
||||
return
|
||||
|
||||
_known_apps = apps
|
||||
@@ -207,8 +214,12 @@ func _update_debug_ui() -> void:
|
||||
if _current_bpm > 50.0:
|
||||
bpm_str = "%d BPM" % round(_current_bpm)
|
||||
|
||||
debug_label.text = "Stato: %s | Volume: %.2f | %s" % [
|
||||
var genre_str: String = "Genere: --"
|
||||
if not _current_genre.is_empty() and _current_genre != "unknown":
|
||||
genre_str = "%s (%d%%)" % [_current_genre, roundi(_current_genre_conf * 100.0)]
|
||||
debug_label.text = "Stato: %s | Volume: %.2f | %s | %s" % [
|
||||
State.keys()[current_state],
|
||||
_current_rms,
|
||||
bpm_str
|
||||
bpm_str,
|
||||
genre_str
|
||||
]
|
||||
Reference in new issue
Block a user