Great you feel more comfortable and familiar with Brython, her cousin
javascript and how they relate in the playground!!!
:-P
2015-10-09 20:34 GMT+02:00, SoundMUD <
soun...@gmail.com>:
> Thank you! No need to spend time: since I'm growing more familiar with
> Javascript and Brython, I have translated the loadBuffer() part, so the
> entire code is in Brython. Here is a short version. I hope indentation will
>
> be kept.
>
>
http://jlpo.free.fr/webaudio/webaudio7.htm
>
http://jlpo.free.fr/webaudio/
>
> from browser import document, timer, windowfrom javascript import
> JSConstructortry: context_constructor =
> window.AudioContextexcept: context_constructor =
> window.webkitAudioContextcontext = JSConstructor(context_constructor)()def
> load_buffer(context, url, callback): request =
> JSConstructor(window.XMLHttpRequest)() request.open("GET", url,
> True) request.responseType = "arraybuffer" def on_load(): def
> on_error(): window.console.error('decodeAudioData error',
> error) print(request) context.decodeAudioData(request.response,
> callback, on_error) request.onload = on_load def
> on_error(): window.alert('BufferLoader: XHR error') request.onerror =
> on_error request.send()def load_sounds(urls,
> function_to_call_when_done): global buffers buffers = {} for key, value in
> urls.items(): # Because of late binding, it is necessary to force early
> binding with "key=key", # or else "key" will have the last value of the
> loop. #
>
http://stackoverflow.com/questions/3431676/creating-functions-in-a-loop def
> callback(buffer, key=key): buffers[key] = buffer if len(buffers) ==
> len(urls): function_to_call_when_done() load_buffer(context, value,
> callback)
>
>
> def start():
> ...
>
>
> urls = {"techno": 'techno.wav', "open": 'open.wav', "close":
> 'close.wav'}load_sounds(urls, start)
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
brython+u...@googlegroups.com.
> To post to this group, send email to
bry...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/brython/fb6b05fc-2fc5-415b-bd28-7e05ecc2bb2a%40googlegroups.com.