package main import ( "log" "math" "github.com/gopxl/beep" "github.com/gopxl/beep/effects" discordspeaker "dndmusicbot/speaker" ) const ( volmin = -10.0 volmax = 0.0 ) var ( pl_volume *effects.Volume amb_volume *effects.Volume ambMixer beep.Mixer plMixer beep.Mixer ) func PercentToVolume(p float64) float64 { return (p * (volmax - volmin) / 100) + volmin } func VolumeToPercent(v float64) float64 { ratio := math.Pow(10, 2) return math.Round(((v-volmin)*100)/(volmax-volmin)*ratio) / ratio } func init() { log.Println("beep.go loading..") ambMixer = beep.Mixer{} amb_volume = &effects.Volume{ Streamer: &ambMixer, Base: 2, Volume: -2, Silent: false, } discordspeaker.Play(amb_volume) /* amb_stream, err := snapcast.New("127.0.0.1", config.GetInt("mpd.ambiance")) if err != nil { log.Fatal(err) } */ // ambMixer.Add(amb_stream) plMixer = beep.Mixer{} pl_volume = &effects.Volume{ Streamer: &plMixer, Base: 2, Volume: -2, Silent: false, } discordspeaker.Play(beep.Resample(4, beep.SampleRate(44100), beep.SampleRate(48000), pl_volume)) /* pl_stream, err := snapcast.New("127.0.0.1", config.GetInt("mpd.playlist")) if err != nil { log.Fatal(err) } plMixer.Add(pl_stream) */ discordspeaker.Lock() plMixer.Add(player) discordspeaker.Unlock() log.Println("beep.go done.") }