Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffy-melli committed Dec 31, 2024
1 parent 0a8a98d commit 6e774c7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sclat/gui/addon/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

def run(audio_data):
audio_index = int(screen.vid.get_pos() / screen.vid.duration * len(audio_data))
if audio_index >= len(audio_data):
audio_index = len(audio_data)
if audio_index + buffer_size < len(audio_data):
audio_chunk = audio_data[audio_index:audio_index + buffer_size]
else:
audio_chunk = audio_data[audio_index:]
fft_data = np.fft.fft(audio_chunk)
audio_index += buffer_size
if audio_index >= len(audio_data):
audio_index = 0
plot_spectrum(fft_data, audio_chunk)

def plot_spectrum(fft_data, audio_chunk):
Expand Down
9 changes: 8 additions & 1 deletion sclat/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from typing import Optional
from gui import screen, cache
from gui.addon import ascii, subtitle, with_play, fft
from gui.addon.control import gesture, stt
import gui.font
from download import download, subtitles
from sockets import client, server
from sockets import setting as socket_setting
from setting import setting as user_setting
import discord_rpc.client
if user_setting.stt:
from gui.addon.control import stt
if user_setting.Gesture or user_setting.Gesture_show:
from gui.addon.control import gesture

# Global state
@dataclass
Expand Down Expand Up @@ -82,6 +85,10 @@ def handle_key_event(key: str) -> None:
case "l":
cache.loop = not cache.loop
state.msg_text = f"Loop: {'On' if cache.loop else 'Off'}"
case "f":
user_setting.FFT = not user_setting.FFT
user_setting.change_setting_data('FFT', user_setting.FFT)
state.msg_text = f"FFT: {user_setting.FFT}"
case "up" | "down":
volume_delta = 10 if key == "up" else -10
if 0 <= user_setting.volume + volume_delta <= 100:
Expand Down
1 change: 0 additions & 1 deletion sclat/sclat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sys,time
from gui import gui, nogui, screen, cache
from gui.addon import with_play
from gui.addon.control import stt
from pypresence.exceptions import DiscordNotFound
from setting import setting as user_setting
import discord_rpc.client
Expand Down

0 comments on commit 6e774c7

Please sign in to comment.