atarivox preferences (festival binary) definable by prefs window

fixed keyboard input for imgui widgets - didn't interact well with playmode
This commit is contained in:
JetSetIlly 2022-03-17 08:34:53 +00:00
parent a8d506f92a
commit a168681996
5 changed files with 60 additions and 14 deletions

View file

@ -451,8 +451,6 @@ func (img *SdlImgui) serviceKeyboard(ev *sdl.KeyboardEvent) {
logger.Log("sdlimgui", "dropped keyboard event")
}
}
return
}
// remaining keypresses forwarded to imgui io system

View file

@ -352,6 +352,27 @@ func (win *winPrefs) drawVCS() {
win.drawTIARev()
}
imgui.Spacing()
if imgui.CollapsingHeader("AtariVox") {
imgui.Spacing()
imgui.Text("AtariVox output is currently only available")
imgui.Text("via the Festival voice synthsizer. The path")
imgui.Text("to the binary is specified below:")
imgui.Spacing()
binary := win.img.vcs.Instance.Prefs.AtariVox.FestivalBinary.Get().(string)
if imgui.InputTextV("##festivalbinary", &binary, imgui.InputTextFlagsEnterReturnsTrue, nil) {
win.img.vcs.Instance.Prefs.AtariVox.FestivalBinary.Set(binary)
win.img.vcs.RIOT.Ports.ResetPeripherals()
}
imgui.Spacing()
enabled := win.img.vcs.Instance.Prefs.AtariVox.FestivalEnabled.Get().(bool)
if imgui.Checkbox("Enable Festival Output", &enabled) {
win.img.vcs.Instance.Prefs.AtariVox.FestivalEnabled.Set(enabled)
win.img.vcs.RIOT.Ports.ResetPeripherals()
}
}
}
func (win *winPrefs) drawARM() {
@ -467,6 +488,10 @@ func (win *winPrefs) drawDiskButtons() {
if err != nil {
logger.Logf("sdlimgui", "could not save (arm) preferences: %v", err)
}
err = win.img.vcs.Instance.Prefs.AtariVox.Save()
if err != nil {
logger.Logf("sdlimgui", "could not save (atarivox) preferences: %v", err)
}
err = win.img.vcs.Instance.Prefs.PlusROM.Save()
if err != nil {
logger.Logf("sdlimgui", "could not save (plusrom) preferences: %v", err)
@ -512,6 +537,10 @@ func (win *winPrefs) drawDiskButtons() {
if err != nil {
logger.Logf("sdlimgui", "could not restore (arm) preferences: %v", err)
}
err = win.img.vcs.Instance.Prefs.AtariVox.Load()
if err != nil {
logger.Logf("sdlimgui", "could not restore (atarivox) preferences: %v", err)
}
err = win.img.vcs.Instance.Prefs.PlusROM.Load()
if err != nil {
logger.Logf("sdlimgui", "could not restore (plusrom) preferences: %v", err)

View file

@ -94,16 +94,7 @@ func NewAtariVox(inst *instance.Instance, port plugging.PortID, bus ports.Periph
SpeakJetREADY: i2c.NewTrace(),
}
var err error
// only start festival engine if this a "Main" emulation instance
if vox.instance.Label == instance.Main {
vox.Engine, err = atarivoxengines.NewFestival(vox.instance.Prefs.AtariVox.FestivalBinary.Get().(string))
if err != nil {
logger.Logf("atarivox", err.Error())
}
}
vox.activateFestival()
logger.Logf("atarivox", "attached [%v]", vox.port)
// attach savekey to same port
@ -112,11 +103,31 @@ func NewAtariVox(inst *instance.Instance, port plugging.PortID, bus ports.Periph
return vox
}
func (vox *AtariVox) activateFestival() {
if vox.Engine != nil {
vox.Engine.Quit()
vox.Engine = nil
}
// only start festival engine if this a "Main" emulation instance
if vox.instance.Label == instance.Main {
if vox.instance.Prefs.AtariVox.FestivalEnabled.Get().(bool) {
var err error
vox.Engine, err = atarivoxengines.NewFestival(vox.instance.Prefs.AtariVox.FestivalBinary.Get().(string))
if err != nil {
logger.Logf("atarivox", err.Error())
}
}
}
}
// Periperhal is to be removed
func (vox *AtariVox) Unplug() {
vox.SaveKey.Unplug()
if vox.Engine != nil {
vox.Engine.Quit()
vox.Engine = nil
}
}
@ -151,6 +162,7 @@ func (vox *AtariVox) ID() plugging.PeripheralID {
// reset state of peripheral. this has nothing to do with the reset switch
// on the VCS panel
func (vox *AtariVox) Reset() {
vox.activateFestival()
vox.SaveKey.Reset()
}

View file

@ -96,7 +96,7 @@ func NewFestival(executablePath string) (AtariVoxEngine, error) {
fest.stdin.Write([]byte(sayphones))
case command := <-fest.cmd:
// logger.Logf("festival", command)
// https://www.cstr.ed.ac.uk/projects/festival/manual/festival_34.html#SEC141
fest.stdin.Write([]byte(command))
}
}

View file

@ -23,7 +23,8 @@ import (
type AtariVoxPreferences struct {
dsk *prefs.Disk
FestivalBinary prefs.String
FestivalEnabled prefs.Bool
FestivalBinary prefs.String
}
// NewPreferences is the preferred method of initialisation for the Preferences type.
@ -41,6 +42,11 @@ func newAtariVoxPreferences() (*AtariVoxPreferences, error) {
return nil, err
}
err = p.dsk.Add("peripherals.atarivox.festival.enabled", &p.FestivalEnabled)
if err != nil {
return nil, err
}
err = p.dsk.Add("peripherals.atarivox.festival.binary", &p.FestivalBinary)
if err != nil {
return nil, err
@ -56,6 +62,7 @@ func newAtariVoxPreferences() (*AtariVoxPreferences, error) {
// SetDefaults reverts all settings to default values.
func (p *AtariVoxPreferences) SetDefaults() {
p.FestivalEnabled.Set(true)
p.FestivalBinary.Set(p.binary())
}