mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
audio: Change audio.SampleRate to be a const
This commit is contained in:
parent
b63911e6f7
commit
60c4990555
@ -57,7 +57,7 @@ func square(out []int16, volume float64, freq float64, sequence float64) {
|
||||
}
|
||||
return
|
||||
}
|
||||
length := int(float64(audio.SampleRate()) / freq)
|
||||
length := int(float64(audio.SampleRate) / freq)
|
||||
if length == 0 {
|
||||
panic("invalid freq")
|
||||
}
|
||||
@ -85,7 +85,7 @@ func toBytes(l, r []int16) []byte {
|
||||
}
|
||||
|
||||
func addNote() {
|
||||
size := audio.SampleRate() / 60
|
||||
size := audio.SampleRate / 60
|
||||
notes := []float64{freqC, freqD, freqE, freqF, freqG, freqA * 2, freqB * 2}
|
||||
|
||||
defer func() {
|
||||
|
@ -31,12 +31,12 @@ const (
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
var pcm = make([]float64, 4*audio.SampleRate())
|
||||
var pcm = make([]float64, 4*audio.SampleRate)
|
||||
|
||||
const baseFreq = 220
|
||||
|
||||
func init() {
|
||||
s := float64(audio.SampleRate())
|
||||
s := float64(audio.SampleRate)
|
||||
amp := []float64{1.0, 0.8, 0.6, 0.4, 0.2}
|
||||
x := []float64{4.0, 2.0, 1.0, 0.5, 0.25}
|
||||
for i := 0; i < len(pcm); i++ {
|
||||
|
@ -19,12 +19,10 @@ import (
|
||||
)
|
||||
|
||||
// SampleRate returns the sampling frequency (e.g. 44100).
|
||||
func SampleRate() int {
|
||||
return audio.SampleRate
|
||||
}
|
||||
const SampleRate = audio.SampleRate
|
||||
|
||||
// MaxChannel is a max number of channels.
|
||||
var MaxChannel = audio.MaxChannel
|
||||
const MaxChannel = audio.MaxChannel
|
||||
|
||||
// Queue queues the given data to the given channel.
|
||||
// The given data is queued to the end of the buffer and not played immediately.
|
||||
@ -32,7 +30,7 @@ var MaxChannel = audio.MaxChannel
|
||||
// channel must be -1 or a channel index. If channel is -1, an empty channel is automatically selected.
|
||||
// If the channel is not empty, this function does nothing and returns false. This returns true otherwise.
|
||||
//
|
||||
// data's format must be linear PCM (44100Hz, 16bits, 2 channel stereo, little endian).
|
||||
// data's format must be linear PCM (44100Hz, 16bits, 2 channel stereo, little endian) without a header (e.g. RIFF header).
|
||||
func Queue(channel int, data []byte) bool {
|
||||
return audio.Queue(channel, data)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ type channel struct {
|
||||
nextInsertionPosition int
|
||||
}
|
||||
|
||||
var MaxChannel = 32
|
||||
const MaxChannel = 32
|
||||
|
||||
var channels = make([]*channel, MaxChannel)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user