feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
BIN
Binary file not shown.
+34
@@ -0,0 +1,34 @@
|
||||
// Package vorbis decodes Ogg Vorbis files for package audio, with
|
||||
// github.com/jfreymuth/oggvorbis. Import it for its side effect:
|
||||
//
|
||||
// import _ "github.com/egoist/mygo/audio/vorbis"
|
||||
package vorbis
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/egoist/mygo/audio"
|
||||
"github.com/jfreymuth/oggvorbis"
|
||||
)
|
||||
|
||||
func init() {
|
||||
audio.RegisterFormat("vorbis", "OggS", func(r io.ReadSeeker) (audio.Decoder, error) { return NewDecoder(r) })
|
||||
}
|
||||
|
||||
// NewDecoder returns a decoder of the Ogg Vorbis file r.
|
||||
func NewDecoder(r io.ReadSeeker) (audio.Decoder, error) {
|
||||
v, err := oggvorbis.NewReader(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return decoder{v}, nil
|
||||
}
|
||||
|
||||
type decoder struct{ *oggvorbis.Reader }
|
||||
|
||||
func (d decoder) Len() int64 {
|
||||
if n := d.Length(); n > 0 {
|
||||
return n
|
||||
}
|
||||
return -1
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package vorbis
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/egoist/mygo/audio"
|
||||
)
|
||||
|
||||
// tone.ogg is 0.5 s of a 440 Hz sine at 22.05 kHz, in stereo.
|
||||
func TestDecode(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/tone.ogg")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
d, name, err := audio.NewDecoder(bytes.NewReader(data))
|
||||
if err != nil || name != "vorbis" {
|
||||
t.Fatal(name, err)
|
||||
}
|
||||
if d.SampleRate() != 22050 || d.Channels() != 2 || d.Len() < 11025 || d.Len() > 11025+128 {
|
||||
t.Fatalf("%d Hz, %d channels, %d frames", d.SampleRate(), d.Channels(), d.Len())
|
||||
}
|
||||
buf := make([]float32, 2*d.Len())
|
||||
n := 0
|
||||
for n < len(buf) {
|
||||
m, err := d.Read(buf[n:])
|
||||
n += m
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
if n != len(buf) {
|
||||
t.Fatalf("decoded %d samples", n)
|
||||
}
|
||||
// Zero crossings of the left channel, 2 a period.
|
||||
zc := 0
|
||||
for i := 2; i < n; i += 2 {
|
||||
if (buf[i-2] < 0) != (buf[i] < 0) {
|
||||
zc++
|
||||
}
|
||||
}
|
||||
if f := float64(zc) / 2 / (float64(n/2) / 22050); math.Abs(f-440) > 5 {
|
||||
t.Errorf("decoded %v Hz", f)
|
||||
}
|
||||
s, err := audio.DecodeSound(data)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := s.Duration(); got < 500*time.Millisecond || got > 510*time.Millisecond {
|
||||
t.Errorf("Duration = %v", got)
|
||||
}
|
||||
if err := d.SetPosition(5000); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user