-
-
Save faiface/0fdded5fde4c4fe3c054145cce8cca46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math" | |
"os" | |
"time" | |
"github.com/faiface/beep" | |
"github.com/faiface/beep/mp3" | |
"github.com/faiface/beep/speaker" | |
) | |
func main() { | |
f, _ := os.Open("04 Harder, Better, Faster, Stronger.mp3") | |
s, format, _ := mp3.Decode(f) | |
sr := format.SampleRate | |
speaker.Init(sr, sr.N(time.Second/30)) | |
start := time.Now() | |
speaker.Play(beep.Iterate(func() beep.Streamer { | |
speedChange := (math.Sin(time.Since(start).Seconds()/2)+1)*1.5 + 0.5 | |
newSampleRate := beep.SampleRate(float64(sr) / speedChange) | |
return beep.Resample(4, sr, newSampleRate, beep.Take(sr.N(time.Second/5), s)) | |
})) | |
select {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment