audio: Remove audio.Tick

This commit is contained in:
Hajime Hoshi 2016-02-08 03:26:58 +09:00
parent d1f46a92df
commit 4b4802419b
2 changed files with 4 additions and 17 deletions

View File

@ -24,7 +24,6 @@ const SampleRate = 44100
type channel struct { type channel struct {
buffer []byte buffer []byte
nextInsertionPosition int
} }
const MaxChannel = 32 const MaxChannel = 32
@ -53,7 +52,7 @@ func withChannels(f func()) {
func isPlaying(channel int) bool { func isPlaying(channel int) bool {
ch := channels[channel] ch := channels[channel]
return ch.nextInsertionPosition < len(ch.buffer) return 0 < len(ch.buffer)
} }
func channelAt(i int) *channel { func channelAt(i int) *channel {
@ -88,12 +87,6 @@ func Queue(channel int, data []byte) bool {
return result return result
} }
func Tick() {
for _, ch := range channels {
ch.nextInsertionPosition += SampleRate * 4 / 60
}
}
func min(a, b int) int { func min(a, b int) int {
if a < b { if a < b {
return a return a
@ -132,11 +125,6 @@ func loadChannelBuffer(channel int, bufferSize int) []byte {
input := ch.buffer[:length] input := ch.buffer[:length]
ch.buffer = ch.buffer[length:] ch.buffer = ch.buffer[length:]
ch.nextInsertionPosition -= bufferSize
if ch.nextInsertionPosition < 0 {
ch.nextInsertionPosition = 0
}
r = input r = input
}) })
return r return r

5
run.go
View File

@ -15,9 +15,9 @@
package ebiten package ebiten
import ( import (
"github.com/hajimehoshi/ebiten/internal/audio"
"github.com/hajimehoshi/ebiten/internal/ui"
"time" "time"
"github.com/hajimehoshi/ebiten/internal/ui"
) )
var runContext = &struct { var runContext = &struct {
@ -112,7 +112,6 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
if err := f(graphicsContext.screen); err != nil { if err := f(graphicsContext.screen); err != nil {
return err return err
} }
audio.Tick()
} }
if err := graphicsContext.postUpdate(); err != nil { if err := graphicsContext.postUpdate(); err != nil {
return err return err