mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
audio: Remove audio.Tick
This commit is contained in:
parent
d1f46a92df
commit
4b4802419b
@ -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
5
run.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user