feat(audio): T-0.3 spike lolos — engine oto v3.5.1 async + fallback anggun (F-024 awal)

This commit is contained in:
oxpoe committed 2026-10-15 06:59:48 +07:00
1 parent 3b4bbf09bc
commit b8d2595ca9
20 files changed
+497 -10

No files matched your search

+18 -8
View File
@@ -5,19 +5,25 @@ import (
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"github.com/oxpoe/tia/internal/audio"
)
// Model root sementara (T-0.2, Phase 0).
// Tujuannya membuktikan Bubble Tea v2 (View struct, mouse, resize) sebelum
// layout penuh Phase 1 menggantikannya.
// Model root sementara (T-0.2/T-0.3, Phase 0).
// Membuktikan Bubble Tea v2 (View struct, mouse, resize) + audio engine
// sebelum layout penuh Phase 1 menggantikannya.
type Model struct {
width, height int
clicks int
lastClick string
sound *audio.Engine
}
func New() Model {
return Model{lastClick: "belum ada klik"}
return Model{
lastClick: "belum ada klik",
sound: audio.New(audio.Options{Enabled: true, Volume: 70, MuteOnSSH: true}),
}
}
func (m Model) Init() tea.Cmd { return nil }
@@ -30,13 +36,17 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.KeyPressMsg:
switch msg.String() {
case "q", "ctrl+c", "esc":
m.sound.Play(audio.ModalClose)
return m, tea.Quit
case "j", "down", "k", "up":
m.sound.Play(audio.Navigate)
}
case tea.MouseClickMsg:
if msg.Button == tea.MouseLeft {
m.clicks++
m.lastClick = fmt.Sprintf("klik #%d di (%d, %d)", m.clicks, msg.X, msg.Y)
m.sound.Play(audio.Click)
}
}
return m, nil
@@ -49,15 +59,15 @@ func (m Model) View() tea.View {
Render("tia — Terminal Is A My Way")
tagline := lipgloss.NewStyle().
Foreground(lipgloss.Color("#a6adc8")).
Render("Just Work · Phase 0 · skeleton TUI")
Render("Just Work · Phase 0 · skeleton TUI + audio")
box := lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.Color("#6c7086")).
Padding(0, 2).
Render(m.lastClick + "\n\nklik mouse di mana saja · tekan q untuk keluar")
Render(m.lastClick + "\n\nklik / j / k = bunyi · q = keluar")
content := fmt.Sprintf("%s\n%s\n\n%s\n\nukuran jendela: %dx%d",
title, tagline, box, m.width, m.height)
content := fmt.Sprintf("%s\n%s\n\n%s\n\nukuran jendela: %dx%d · audio: %s",
title, tagline, box, m.width, m.height, m.sound.Status())
v := tea.NewView(content)
v.AltScreen = true