Created
November 4, 2014 01:10
-
-
Save jfsantos/a39ed69a7894876f1e04 to your computer and use it in GitHub Desktop.
Rendering audio in IJulia notebooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is really usefull, thanks!