Skip to content

Instantly share code, notes, and snippets.

@jfsantos
Created November 4, 2014 01:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfsantos/a39ed69a7894876f1e04 to your computer and use it in GitHub Desktop.
Save jfsantos/a39ed69a7894876f1e04 to your computer and use it in GitHub Desktop.
Rendering audio in IJulia notebooks
using WAV
function inline_audioplayer(filepath)
markup = """<audio controls="controls" {autoplay}>
<source src="$filepath" />
Your browser does not support the audio element.
</audio>"""
display(MIME("text/html") ,markup)
end
function inline_audioplayer(s, fs)
buf = IOBuffer()
wavwrite(s, buf; Fs=fs)
data = base64(bytestring(buf))
markup = """<audio controls="controls" {autoplay}>
<source src="data:audio/wav;base64,$data" type="audio/wav" />
Your browser does not support the audio element.
</audio>"""
display(MIME("text/html") ,markup)
end
@r9y9
Copy link

r9y9 commented Aug 22, 2015

This is really usefull, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment