mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/mp3: Bug fix: float32ArrayToSlice didn't work for Wasm
This commit is contained in:
parent
baee2ba4c9
commit
a8c27b4eb1
@ -188,7 +188,7 @@ func decode(context *audio.Context, buf []byte, try int) (*Stream, error) {
|
||||
oc := offlineAudioContextClass.New(2, 1, context.SampleRate())
|
||||
|
||||
u8 := js.ValueOf(buf)
|
||||
a := u8.Get("buffer").Call("slice", u8.Get("byteOffset"), u8.Get("byteOffset").Int()+len(buf))
|
||||
a := u8.Get("buffer").Call("slice", u8.Get("byteOffset"), u8.Get("byteOffset").Int()+u8.Get("byteLength").Int())
|
||||
|
||||
oc.Call("decodeAudioData", a, js.NewCallback(func(args []js.Value) {
|
||||
buf := args[0]
|
||||
|
@ -24,7 +24,8 @@ import (
|
||||
|
||||
func float32ArrayToSlice(arr js.Value) []float32 {
|
||||
bytes := make([]byte, arr.Length()*4)
|
||||
js.ValueOf(bytes).Call("set", arr.Get("buffer"))
|
||||
buf := arr.Get("buffer").Call("slice", arr.Get("byteOffset"), arr.Get("byteOffset").Int()+arr.Get("byteLength").Int())
|
||||
js.ValueOf(bytes).Call("set", js.Global.Get("Uint8Array").New(buf))
|
||||
|
||||
bh := (*reflect.SliceHeader)(unsafe.Pointer(&bytes))
|
||||
var f []float32
|
||||
|
Loading…
Reference in New Issue
Block a user