mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-19 05:24:48 -04:00
feat: upgrade oto and output float audio
This commit is contained in:
parent
890ebe3294
commit
81a6d1acea
@ -43,6 +43,7 @@ func main() {
|
||||
*play = true // if the user gives nothing to output, then the default behaviour is just to play the file
|
||||
}
|
||||
var audioContext sointu.AudioContext
|
||||
var playWaiter sointu.CloserWaiter
|
||||
if *play {
|
||||
var err error
|
||||
audioContext, err = oto.NewContext()
|
||||
@ -50,7 +51,6 @@ func main() {
|
||||
fmt.Fprintf(os.Stderr, "could not acquire oto AudioContext: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer audioContext.Close()
|
||||
}
|
||||
process := func(filename string) error {
|
||||
output := func(extension string, contents []byte) error {
|
||||
@ -98,11 +98,7 @@ func main() {
|
||||
return fmt.Errorf("sointu.Play failed: %v", err)
|
||||
}
|
||||
if *play {
|
||||
output := audioContext.Output()
|
||||
defer output.Close()
|
||||
if err := output.WriteAudio(buffer); err != nil {
|
||||
return fmt.Errorf("error playing: %v", err)
|
||||
}
|
||||
playWaiter = audioContext.Play(buffer.Source())
|
||||
}
|
||||
if *rawOut {
|
||||
raw, err := buffer.Raw(*pcm)
|
||||
@ -122,6 +118,9 @@ func main() {
|
||||
return fmt.Errorf("error outputting .wav file: %v", err)
|
||||
}
|
||||
}
|
||||
if *play {
|
||||
playWaiter.Wait()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
retval := 0
|
||||
|
Reference in New Issue
Block a user