audio: Move to exa/audio

This commit is contained in:
Hajime Hoshi 2015-01-23 23:04:56 +09:00
parent 88ac129dd6
commit d020824b3a
2 changed files with 11 additions and 10 deletions

View File

@ -18,6 +18,7 @@ import (
"fmt"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/ebitenutil"
"github.com/hajimehoshi/ebiten/exp/audio"
"log"
)
@ -54,7 +55,7 @@ func square(out []float32, volume float64, freq float64, sequence float64) {
}
return
}
length := int(float64(ebiten.AudioSampleRate()) / freq)
length := int(float64(audio.SampleRate()) / freq)
if length == 0 {
panic("invalid freq")
}
@ -68,7 +69,7 @@ func square(out []float32, volume float64, freq float64, sequence float64) {
}
func addNote() {
size := ebiten.AudioSampleRate() / 60
size := audio.SampleRate() / 60
notes := []float64{freqC, freqD, freqE, freqF, freqG, freqA * 2, freqB * 2}
defer func() {
@ -92,10 +93,10 @@ func addNote() {
default:
freq = notes[note-'C']
}
vol := 1.0 / 32.0
square(l, vol, freq, 0.5)
square(r, vol, freq, 0.5)
ebiten.AppendToAudioBuffer(0, l, r)
vol := 1.0 / 16.0
square(l, vol, freq, 0.25)
square(r, vol, freq, 0.25)
audio.AppendToBuffer(0, l, r)
}
func update(screen *ebiten.Image) error {

View File

@ -12,21 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package ebiten
package audio
import (
"github.com/hajimehoshi/ebiten/internal/audio"
)
func AudioSampleRate() int {
func SampleRate() int {
return audio.SampleRate
}
func AppendToAudioBuffer(channel int, l []float32, r []float32) bool {
func AppendToBuffer(channel int, l []float32, r []float32) bool {
return audio.Append(channel, l, r)
}
// TODO: better name
func CurrentAudioTime() int {
func CurrentTime() int {
return audio.CurrentBytes()
}