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

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

5
run.go
View File

@ -15,9 +15,9 @@
package ebiten
import (
"github.com/hajimehoshi/ebiten/internal/audio"
"github.com/hajimehoshi/ebiten/internal/ui"
"time"
"github.com/hajimehoshi/ebiten/internal/ui"
)
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 {
return err
}
audio.Tick()
}
if err := graphicsContext.postUpdate(); err != nil {
return err