33 lines
567 B
Go
33 lines
567 B
Go
|
package roflcopter
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
_ "embed"
|
||
|
"fmt"
|
||
|
"io"
|
||
|
"log"
|
||
|
"sync"
|
||
|
"time"
|
||
|
|
||
|
"github.com/faiface/beep/mp3"
|
||
|
"github.com/faiface/beep/speaker"
|
||
|
)
|
||
|
|
||
|
//go:embed embed\swah.mp3
|
||
|
var swah []byte
|
||
|
|
||
|
func Sound(wg *sync.WaitGroup) {
|
||
|
wg.Add(1)
|
||
|
fmt.Println("SWAH")
|
||
|
t := 1*time.Second + 390*time.Millisecond
|
||
|
streamer, format, err := mp3.Decode(io.NopCloser(bytes.NewReader(swah)))
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
defer streamer.Close()
|
||
|
speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
|
||
|
speaker.Play(streamer)
|
||
|
time.Sleep(t * 1)
|
||
|
wg.Done()
|
||
|
}
|