diff --git a/example/audio/main.go b/example/audio/main.go index feae6992c..d1ebcf7d6 100644 --- a/example/audio/main.go +++ b/example/audio/main.go @@ -27,6 +27,7 @@ import ( const ( screenWidth = 320 screenHeight = 240 + sampleRate = 44100 ) var frames = 0 @@ -57,7 +58,7 @@ func square(out []int16, volume float64, freq float64, sequence float64) { } return } - length := int(float64(audio.SampleRate) / freq) + length := int(float64(sampleRate) / freq) if length == 0 { panic("invalid freq") } @@ -85,7 +86,7 @@ func toBytes(l, r []int16) []byte { } func addNote() { - size := audio.SampleRate / 60 + size := sampleRate / 60 notes := []float64{freqC, freqD, freqE, freqF, freqG, freqA * 2, freqB * 2} defer func() { diff --git a/example/piano/main.go b/example/piano/main.go index 1c7ef1102..1e0edf460 100644 --- a/example/piano/main.go +++ b/example/piano/main.go @@ -29,14 +29,15 @@ import ( const ( screenWidth = 320 screenHeight = 240 + sampleRate = 44100 ) -var pcm = make([]float64, 4*audio.SampleRate) +var pcm = make([]float64, 4*sampleRate) const baseFreq = 220 func init() { - s := float64(audio.SampleRate) + s := float64(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++ { diff --git a/exp/audio/audio.go b/exp/audio/audio.go index 798254a28..04aa703d0 100644 --- a/exp/audio/audio.go +++ b/exp/audio/audio.go @@ -18,25 +18,16 @@ import ( "github.com/hajimehoshi/ebiten/internal/audio" ) -// SampleRate returns the sampling frequency (e.g. 44100). -const SampleRate = audio.SampleRate - -// MaxChannel is a max number of channels. -const MaxChannel = audio.MaxChannel - // Queue queues the given data to the given channel. // The given data is queued to the end of the buffer. // This may not be played immediately when data already exists in the buffer. // // data's format must be linear PCM (44100Hz, 16bits, 2 channel stereo, little endian) // without a header (e.g. RIFF header). +// +// TODO: Pass sample rate and num of channels. func Queue(data []byte) bool { return audio.Queue(data) } -// IsPlaying returns a boolean value which indicates if the channel buffer has data to play. -func IsPlaying(channel int) bool { - return audio.IsPlaying(channel) -} - // TODO: Add Clear function