diff --git a/tracker/files.go b/tracker/files.go index 1e8acda..35894dd 100644 --- a/tracker/files.go +++ b/tracker/files.go @@ -75,7 +75,7 @@ func (m *Model) WriteSong(w io.WriteCloser) { m.completeAction(false) } -func (m *Model) WriteWav(w io.WriteCloser, pcm16 bool, execChan chan<- func()) { +func (m *Model) WriteWav(w io.WriteCloser, pcm16 bool) { m.dialog = NoDialog song := m.d.Song.Copy() go func() { @@ -83,21 +83,18 @@ func (m *Model) WriteWav(w io.WriteCloser, pcm16 bool, execChan chan<- func()) { rand.Read(b) name := fmt.Sprintf("%x", b)[2 : 32+2] data, err := sointu.Play(m.synther, song, func(p float32) { - execChan <- func() { - m.Alerts().AddNamed(name, fmt.Sprintf("Exporting song: %.0f%%", p*100), Info) - } + txt := fmt.Sprintf("Exporting song: %.0f%%", p*100) + trySend(m.broker.ToModel, MsgToModel{Data: Alert{Message: txt, Priority: Info, Name: name, Duration: defaultAlertDuration}}) }) // render the song to calculate its length if err != nil { - execChan <- func() { - m.Alerts().Add(fmt.Sprintf("Error rendering the song during export: %v", err), Error) - } + txt := fmt.Sprintf("Error rendering the song during export: %v", err) + trySend(m.broker.ToModel, MsgToModel{Data: Alert{Message: txt, Priority: Error, Name: name, Duration: defaultAlertDuration}}) return } buffer, err := data.Wav(pcm16) if err != nil { - execChan <- func() { - m.Alerts().Add(fmt.Sprintf("Error converting to .wav: %v", err), Error) - } + txt := fmt.Sprintf("Error converting to .wav: %v", err) + trySend(m.broker.ToModel, MsgToModel{Data: Alert{Message: txt, Priority: Error, Name: name, Duration: defaultAlertDuration}}) return } w.Write(buffer) diff --git a/tracker/gioui/tracker.go b/tracker/gioui/tracker.go index b80dab8..7bed2ac 100644 --- a/tracker/gioui/tracker.go +++ b/tracker/gioui/tracker.go @@ -253,7 +253,7 @@ func (t *Tracker) showDialog(gtx C) { filename = p[:len(p)-len(filepath.Ext(p))] + ".wav" } t.explorerCreateFile(func(wc io.WriteCloser) { - t.WriteWav(wc, t.Dialog() == tracker.ExportInt16Explorer, t.execChan) + t.WriteWav(wc, t.Dialog() == tracker.ExportInt16Explorer) }, filename) } }