TEMPO: play a sound in animated GIF/PDF/SVGHow to include audio file in PDFHow to define the default vertical distance between nodes?Play animated graphic when “next slide” is clickedbeamer: How to play movies in their original size?Numerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?standalone mode=image with animated pdfLine up nested tikz enviroments or how to get rid of themHow to animate SVG paths as an animated PDF with animate?
Is this n-speak?
Not going forward with internship interview process
How to create events observer that only call when REST api dispatch events?
Is it okay for a ticket seller in the USA to refuse to give you your change, keep it for themselves and claim it's a tip?
If clocks themselves are based on light signals, wouldn't we expect the measured speed of light to always be the same constant?
Can sampling rate be a floating point number?
Why is the result of ('b'+'a'+ + 'a' + 'a').toLowerCase() 'banana'?
is this F 6'9 chord a figured bass or a chord extension?
Why command hierarchy, if the chain of command is standing next to each other?
When does Tiana, Ship's Caretaker check card type?
Is God unknowable?
How to take the beginning and end parts of a list with simpler syntax?
Can anybody explain why using multicolumn changes the width of the four-column tabular environment?
The cat ate your input again!
Why did Gandalf use a sword against the Balrog?
TEMPO: play a sound in animated GIF/PDF/SVG
How does "Te vas a cansar" mean "You're going to get tired"?
Is it feasible to get a hash collision for CRC32, MD-5 and SHA-1 on one file?
How to describe accents?
How are you supposed to know the strumming pattern for a song from the "chord sheet music"?
Enigma between Collegues (Part1)
Why is there a large performance impact when looping over an array over 240 elements?
On math looking obvious in retrospect
Are differences between uniformly distributed numbers uniformly distributed?
TEMPO: play a sound in animated GIF/PDF/SVG
How to include audio file in PDFHow to define the default vertical distance between nodes?Play animated graphic when “next slide” is clickedbeamer: How to play movies in their original size?Numerical conditional within tikz keys?TikZ: Drawing an arc from an intersection to an intersectionHow to prevent rounded and duplicated tick labels in pgfplots with fixed precision?standalone mode=image with animated pdfLine up nested tikz enviroments or how to get rid of themHow to animate SVG paths as an animated PDF with animate?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
When practicing piano, TEMPO (an app on iOS, CHplay) is a metronome that often be used to beat on time.
I can make animated GIF/PDF/SVG/frame (in beamer
) for TEMPO, but don't know how to play a sound (for example beep 8, mp3
or wav
in here) at each beat.
Can anyone help (with full code and clear explanation)? Thank you!
The following code are my MWEs. (these are good examples on animated things)
% TEMPO for piano tempo.tex
% for animated GIF, run on command line (require ImageMagick installed)
% magick -density 200 -delay 100 tempo.pdf tempo.gif
% -delay 100 >>> each frame is 100/100 = 1 second
documentclass[tikz]standalone
begindocument
foreach n in 1,...,4
pagecolorwhite
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.5);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
enddocument
With minor changes, we can get animated PDF (open in Acrobat Reader).
% animated PDF standalone tempopdf.tex
% multiframe4n=1+1 >>> starting frame is with n=1,
% then plus 1 each frame, so we have 4 frames
% [loop,controls]1 >>> number 1 means 1 second each frame
documentclassstandalone
usepackagetikz
usepackageanimate
begindocument
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.6);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Animated PDF frame in beamer (open with Acrobat Reader)
% animated PDF frame in beamer (open with Acrobat Reader)
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemultimedia
begindocument
beginframeTEMPO for piano
begincenter
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
tikz-pgf asymptote animate media9 multimedia
add a comment |
When practicing piano, TEMPO (an app on iOS, CHplay) is a metronome that often be used to beat on time.
I can make animated GIF/PDF/SVG/frame (in beamer
) for TEMPO, but don't know how to play a sound (for example beep 8, mp3
or wav
in here) at each beat.
Can anyone help (with full code and clear explanation)? Thank you!
The following code are my MWEs. (these are good examples on animated things)
% TEMPO for piano tempo.tex
% for animated GIF, run on command line (require ImageMagick installed)
% magick -density 200 -delay 100 tempo.pdf tempo.gif
% -delay 100 >>> each frame is 100/100 = 1 second
documentclass[tikz]standalone
begindocument
foreach n in 1,...,4
pagecolorwhite
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.5);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
enddocument
With minor changes, we can get animated PDF (open in Acrobat Reader).
% animated PDF standalone tempopdf.tex
% multiframe4n=1+1 >>> starting frame is with n=1,
% then plus 1 each frame, so we have 4 frames
% [loop,controls]1 >>> number 1 means 1 second each frame
documentclassstandalone
usepackagetikz
usepackageanimate
begindocument
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.6);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Animated PDF frame in beamer (open with Acrobat Reader)
% animated PDF frame in beamer (open with Acrobat Reader)
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemultimedia
begindocument
beginframeTEMPO for piano
begincenter
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
tikz-pgf asymptote animate media9 multimedia
add a comment |
When practicing piano, TEMPO (an app on iOS, CHplay) is a metronome that often be used to beat on time.
I can make animated GIF/PDF/SVG/frame (in beamer
) for TEMPO, but don't know how to play a sound (for example beep 8, mp3
or wav
in here) at each beat.
Can anyone help (with full code and clear explanation)? Thank you!
The following code are my MWEs. (these are good examples on animated things)
% TEMPO for piano tempo.tex
% for animated GIF, run on command line (require ImageMagick installed)
% magick -density 200 -delay 100 tempo.pdf tempo.gif
% -delay 100 >>> each frame is 100/100 = 1 second
documentclass[tikz]standalone
begindocument
foreach n in 1,...,4
pagecolorwhite
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.5);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
enddocument
With minor changes, we can get animated PDF (open in Acrobat Reader).
% animated PDF standalone tempopdf.tex
% multiframe4n=1+1 >>> starting frame is with n=1,
% then plus 1 each frame, so we have 4 frames
% [loop,controls]1 >>> number 1 means 1 second each frame
documentclassstandalone
usepackagetikz
usepackageanimate
begindocument
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.6);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Animated PDF frame in beamer (open with Acrobat Reader)
% animated PDF frame in beamer (open with Acrobat Reader)
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemultimedia
begindocument
beginframeTEMPO for piano
begincenter
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
tikz-pgf asymptote animate media9 multimedia
When practicing piano, TEMPO (an app on iOS, CHplay) is a metronome that often be used to beat on time.
I can make animated GIF/PDF/SVG/frame (in beamer
) for TEMPO, but don't know how to play a sound (for example beep 8, mp3
or wav
in here) at each beat.
Can anyone help (with full code and clear explanation)? Thank you!
The following code are my MWEs. (these are good examples on animated things)
% TEMPO for piano tempo.tex
% for animated GIF, run on command line (require ImageMagick installed)
% magick -density 200 -delay 100 tempo.pdf tempo.gif
% -delay 100 >>> each frame is 100/100 = 1 second
documentclass[tikz]standalone
begindocument
foreach n in 1,...,4
pagecolorwhite
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.5);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
enddocument
With minor changes, we can get animated PDF (open in Acrobat Reader).
% animated PDF standalone tempopdf.tex
% multiframe4n=1+1 >>> starting frame is with n=1,
% then plus 1 each frame, so we have 4 frames
% [loop,controls]1 >>> number 1 means 1 second each frame
documentclassstandalone
usepackagetikz
usepackageanimate
begindocument
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10]
(n,0) circle(.6);
foreach i in 1,...,4
fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Animated PDF frame in beamer (open with Acrobat Reader)
% animated PDF frame in beamer (open with Acrobat Reader)
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemultimedia
begindocument
beginframeTEMPO for piano
begincenter
beginanimateinline[loop,controls]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
tikz-pgf asymptote animate media9 multimedia
tikz-pgf asymptote animate media9 multimedia
edited 1 hour ago
Black Mild
asked 12 hours ago
Black MildBlack Mild
1,7748 silver badges14 bronze badges
1,7748 silver badges14 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Click on the image below to see the ticking metronome (SVG version) in action:
The animate
-based example comes in two versions.
The PDF version requires Acrobat Reader and is thus restricted to Windows and OSX platforms for desktop PCs. (Mobile devices are not supported.)
The PDF version uses media9
for playing the embedded sound file click.mp3
, taken from the animate
package which already provides a ticking metronome example in its manual.
The standalone SVG version runs in most contemporary Web browsers (Firefox, Chrome, Opera ...), even on mobile devices. Here the sound is "embedded" using the <audio>
tag, but the sound file itself is separate, not physically embedded, and must be bundled with the SVG file.
In either case, playback of the sound is started by JavaScript on every frame change of the running animation. The "timeline" feature of animate
is used to associate the JS code with each frame.
PDF version, to be compiled with pdflatex
, latex+dvips+ps2pdf
, or xelatex
:
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemedia9
usepackagefilecontents
beginfilecontents*frames.txt
::0: annotRM['click'].callAS('play');
::1: annotRM['click'].callAS('play');
::2: annotRM['click'].callAS('play');
::3: annotRM['click'].callAS('play');
endfilecontents*
begindocument
beginframeTEMPO for piano
begincenter
%the sound player
makebox[0pt][r]includemedia[
width=1ex,height=1ex,
label=click,
addresource=click.mp3,
activate=pageopen,transparent,noplaybutton,
flashvars=source=click.mp3&hideBar=true
]APlayer.swf%
% animation provided by OP
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
SVG version, to be compiled with
latex tempoForWeb.tex
latex tempoForWeb.tex
dvisvgm --font-format=woff --exact --zoom=-1 tempoForWeb.dvi
The SVG can be viewed standalone in a Web browser, or embedded by means of the <object>
HTML tag.
documentclass[dvisvgm,preview]standalone
usepackagetikz
usepackageanimate
usepackagefilecontents
beginfilecontents*frames.txt
::0: myClick.play();
::1: myClick.play();
::2: myClick.play();
::3: myClick.play();
endfilecontents*
begindocument
specialdvisvgm:rawdef
<audio xmlns="http://www.w3.org/1999/xhtml" id='click'>
<source src="click.mp3" type="audio/mpeg"/>
</audio>
<script type="text/javascript">
<![CDATA[
var myClick = document.getElementById('click');
function playClick ()
try myClick.play(); catch (e) console.log(e);
]]>
</script>
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Standalone, animated GIF is dumb and deaf, afaik, and there does not seem to exist an easily accessible method to synchronize an embedded Gif (in a Web page) with a sound. But SVG is much superior, since it is vectorial and thus freely scalable.
1
Wow, it is very beautiful. :-) +1
– Sebastiano
9 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
8 hours ago
Done now for all the users :-)
– Sebastiano
8 hours ago
@AlexG: When I open animated PDF in Acrobat Reader, it requires Flash Player. I have just installed Flash Player, but still can not hear the sound
– Black Mild
7 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
7 hours ago
add a comment |
You can alternatively do the animation elsewhere with sound and add that to the Beamer Files. Beamer seems to have an multimedia package. Also movie15 seems to be promising.
Look at this thread about Multimedia/sound How to include audio file in PDF, maybe thats a valid startingpoint.
New contributor
Could you provide full code with some explanation?
– Black Mild
12 hours ago
Sorry, can't do that right now. But the movie15 package has it online. I can't open it as it is not allowed by my company network. ctan.org/tex-archive/macros/latex/contrib/movie15/doc
– Sango
11 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f503886%2ftempo-play-a-sound-in-animated-gif-pdf-svg%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Click on the image below to see the ticking metronome (SVG version) in action:
The animate
-based example comes in two versions.
The PDF version requires Acrobat Reader and is thus restricted to Windows and OSX platforms for desktop PCs. (Mobile devices are not supported.)
The PDF version uses media9
for playing the embedded sound file click.mp3
, taken from the animate
package which already provides a ticking metronome example in its manual.
The standalone SVG version runs in most contemporary Web browsers (Firefox, Chrome, Opera ...), even on mobile devices. Here the sound is "embedded" using the <audio>
tag, but the sound file itself is separate, not physically embedded, and must be bundled with the SVG file.
In either case, playback of the sound is started by JavaScript on every frame change of the running animation. The "timeline" feature of animate
is used to associate the JS code with each frame.
PDF version, to be compiled with pdflatex
, latex+dvips+ps2pdf
, or xelatex
:
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemedia9
usepackagefilecontents
beginfilecontents*frames.txt
::0: annotRM['click'].callAS('play');
::1: annotRM['click'].callAS('play');
::2: annotRM['click'].callAS('play');
::3: annotRM['click'].callAS('play');
endfilecontents*
begindocument
beginframeTEMPO for piano
begincenter
%the sound player
makebox[0pt][r]includemedia[
width=1ex,height=1ex,
label=click,
addresource=click.mp3,
activate=pageopen,transparent,noplaybutton,
flashvars=source=click.mp3&hideBar=true
]APlayer.swf%
% animation provided by OP
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
SVG version, to be compiled with
latex tempoForWeb.tex
latex tempoForWeb.tex
dvisvgm --font-format=woff --exact --zoom=-1 tempoForWeb.dvi
The SVG can be viewed standalone in a Web browser, or embedded by means of the <object>
HTML tag.
documentclass[dvisvgm,preview]standalone
usepackagetikz
usepackageanimate
usepackagefilecontents
beginfilecontents*frames.txt
::0: myClick.play();
::1: myClick.play();
::2: myClick.play();
::3: myClick.play();
endfilecontents*
begindocument
specialdvisvgm:rawdef
<audio xmlns="http://www.w3.org/1999/xhtml" id='click'>
<source src="click.mp3" type="audio/mpeg"/>
</audio>
<script type="text/javascript">
<![CDATA[
var myClick = document.getElementById('click');
function playClick ()
try myClick.play(); catch (e) console.log(e);
]]>
</script>
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Standalone, animated GIF is dumb and deaf, afaik, and there does not seem to exist an easily accessible method to synchronize an embedded Gif (in a Web page) with a sound. But SVG is much superior, since it is vectorial and thus freely scalable.
1
Wow, it is very beautiful. :-) +1
– Sebastiano
9 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
8 hours ago
Done now for all the users :-)
– Sebastiano
8 hours ago
@AlexG: When I open animated PDF in Acrobat Reader, it requires Flash Player. I have just installed Flash Player, but still can not hear the sound
– Black Mild
7 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
7 hours ago
add a comment |
Click on the image below to see the ticking metronome (SVG version) in action:
The animate
-based example comes in two versions.
The PDF version requires Acrobat Reader and is thus restricted to Windows and OSX platforms for desktop PCs. (Mobile devices are not supported.)
The PDF version uses media9
for playing the embedded sound file click.mp3
, taken from the animate
package which already provides a ticking metronome example in its manual.
The standalone SVG version runs in most contemporary Web browsers (Firefox, Chrome, Opera ...), even on mobile devices. Here the sound is "embedded" using the <audio>
tag, but the sound file itself is separate, not physically embedded, and must be bundled with the SVG file.
In either case, playback of the sound is started by JavaScript on every frame change of the running animation. The "timeline" feature of animate
is used to associate the JS code with each frame.
PDF version, to be compiled with pdflatex
, latex+dvips+ps2pdf
, or xelatex
:
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemedia9
usepackagefilecontents
beginfilecontents*frames.txt
::0: annotRM['click'].callAS('play');
::1: annotRM['click'].callAS('play');
::2: annotRM['click'].callAS('play');
::3: annotRM['click'].callAS('play');
endfilecontents*
begindocument
beginframeTEMPO for piano
begincenter
%the sound player
makebox[0pt][r]includemedia[
width=1ex,height=1ex,
label=click,
addresource=click.mp3,
activate=pageopen,transparent,noplaybutton,
flashvars=source=click.mp3&hideBar=true
]APlayer.swf%
% animation provided by OP
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
SVG version, to be compiled with
latex tempoForWeb.tex
latex tempoForWeb.tex
dvisvgm --font-format=woff --exact --zoom=-1 tempoForWeb.dvi
The SVG can be viewed standalone in a Web browser, or embedded by means of the <object>
HTML tag.
documentclass[dvisvgm,preview]standalone
usepackagetikz
usepackageanimate
usepackagefilecontents
beginfilecontents*frames.txt
::0: myClick.play();
::1: myClick.play();
::2: myClick.play();
::3: myClick.play();
endfilecontents*
begindocument
specialdvisvgm:rawdef
<audio xmlns="http://www.w3.org/1999/xhtml" id='click'>
<source src="click.mp3" type="audio/mpeg"/>
</audio>
<script type="text/javascript">
<![CDATA[
var myClick = document.getElementById('click');
function playClick ()
try myClick.play(); catch (e) console.log(e);
]]>
</script>
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Standalone, animated GIF is dumb and deaf, afaik, and there does not seem to exist an easily accessible method to synchronize an embedded Gif (in a Web page) with a sound. But SVG is much superior, since it is vectorial and thus freely scalable.
1
Wow, it is very beautiful. :-) +1
– Sebastiano
9 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
8 hours ago
Done now for all the users :-)
– Sebastiano
8 hours ago
@AlexG: When I open animated PDF in Acrobat Reader, it requires Flash Player. I have just installed Flash Player, but still can not hear the sound
– Black Mild
7 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
7 hours ago
add a comment |
Click on the image below to see the ticking metronome (SVG version) in action:
The animate
-based example comes in two versions.
The PDF version requires Acrobat Reader and is thus restricted to Windows and OSX platforms for desktop PCs. (Mobile devices are not supported.)
The PDF version uses media9
for playing the embedded sound file click.mp3
, taken from the animate
package which already provides a ticking metronome example in its manual.
The standalone SVG version runs in most contemporary Web browsers (Firefox, Chrome, Opera ...), even on mobile devices. Here the sound is "embedded" using the <audio>
tag, but the sound file itself is separate, not physically embedded, and must be bundled with the SVG file.
In either case, playback of the sound is started by JavaScript on every frame change of the running animation. The "timeline" feature of animate
is used to associate the JS code with each frame.
PDF version, to be compiled with pdflatex
, latex+dvips+ps2pdf
, or xelatex
:
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemedia9
usepackagefilecontents
beginfilecontents*frames.txt
::0: annotRM['click'].callAS('play');
::1: annotRM['click'].callAS('play');
::2: annotRM['click'].callAS('play');
::3: annotRM['click'].callAS('play');
endfilecontents*
begindocument
beginframeTEMPO for piano
begincenter
%the sound player
makebox[0pt][r]includemedia[
width=1ex,height=1ex,
label=click,
addresource=click.mp3,
activate=pageopen,transparent,noplaybutton,
flashvars=source=click.mp3&hideBar=true
]APlayer.swf%
% animation provided by OP
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
SVG version, to be compiled with
latex tempoForWeb.tex
latex tempoForWeb.tex
dvisvgm --font-format=woff --exact --zoom=-1 tempoForWeb.dvi
The SVG can be viewed standalone in a Web browser, or embedded by means of the <object>
HTML tag.
documentclass[dvisvgm,preview]standalone
usepackagetikz
usepackageanimate
usepackagefilecontents
beginfilecontents*frames.txt
::0: myClick.play();
::1: myClick.play();
::2: myClick.play();
::3: myClick.play();
endfilecontents*
begindocument
specialdvisvgm:rawdef
<audio xmlns="http://www.w3.org/1999/xhtml" id='click'>
<source src="click.mp3" type="audio/mpeg"/>
</audio>
<script type="text/javascript">
<![CDATA[
var myClick = document.getElementById('click');
function playClick ()
try myClick.play(); catch (e) console.log(e);
]]>
</script>
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Standalone, animated GIF is dumb and deaf, afaik, and there does not seem to exist an easily accessible method to synchronize an embedded Gif (in a Web page) with a sound. But SVG is much superior, since it is vectorial and thus freely scalable.
Click on the image below to see the ticking metronome (SVG version) in action:
The animate
-based example comes in two versions.
The PDF version requires Acrobat Reader and is thus restricted to Windows and OSX platforms for desktop PCs. (Mobile devices are not supported.)
The PDF version uses media9
for playing the embedded sound file click.mp3
, taken from the animate
package which already provides a ticking metronome example in its manual.
The standalone SVG version runs in most contemporary Web browsers (Firefox, Chrome, Opera ...), even on mobile devices. Here the sound is "embedded" using the <audio>
tag, but the sound file itself is separate, not physically embedded, and must be bundled with the SVG file.
In either case, playback of the sound is started by JavaScript on every frame change of the running animation. The "timeline" feature of animate
is used to associate the JS code with each frame.
PDF version, to be compiled with pdflatex
, latex+dvips+ps2pdf
, or xelatex
:
documentclassbeamer
usepackagetikz
usepackageanimate
usepackagemedia9
usepackagefilecontents
beginfilecontents*frames.txt
::0: annotRM['click'].callAS('play');
::1: annotRM['click'].callAS('play');
::2: annotRM['click'].callAS('play');
::3: annotRM['click'].callAS('play');
endfilecontents*
begindocument
beginframeTEMPO for piano
begincenter
%the sound player
makebox[0pt][r]includemedia[
width=1ex,height=1ex,
label=click,
addresource=click.mp3,
activate=pageopen,transparent,noplaybutton,
flashvars=source=click.mp3&hideBar=true
]APlayer.swf%
% animation provided by OP
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
endcenter
endframe
enddocument
SVG version, to be compiled with
latex tempoForWeb.tex
latex tempoForWeb.tex
dvisvgm --font-format=woff --exact --zoom=-1 tempoForWeb.dvi
The SVG can be viewed standalone in a Web browser, or embedded by means of the <object>
HTML tag.
documentclass[dvisvgm,preview]standalone
usepackagetikz
usepackageanimate
usepackagefilecontents
beginfilecontents*frames.txt
::0: myClick.play();
::1: myClick.play();
::2: myClick.play();
::3: myClick.play();
endfilecontents*
begindocument
specialdvisvgm:rawdef
<audio xmlns="http://www.w3.org/1999/xhtml" id='click'>
<source src="click.mp3" type="audio/mpeg"/>
</audio>
<script type="text/javascript">
<![CDATA[
var myClick = document.getElementById('click');
function playClick ()
try myClick.play(); catch (e) console.log(e);
]]>
</script>
beginanimateinline[loop,controls,timeline=frames.txt]1
multiframe4n=1+1
begintikzpicture
path (0,-1) rectangle (5,1);
shade[inner color=green,outer color=green!10] (n,0) circle(.6);
foreach i in 1,...,4 fill[cyan] (i,0) circle(.3);
endtikzpicture
endanimateinline
enddocument
Standalone, animated GIF is dumb and deaf, afaik, and there does not seem to exist an easily accessible method to synchronize an embedded Gif (in a Web page) with a sound. But SVG is much superior, since it is vectorial and thus freely scalable.
edited 9 hours ago
answered 12 hours ago
AlexGAlexG
36.4k4 gold badges86 silver badges155 bronze badges
36.4k4 gold badges86 silver badges155 bronze badges
1
Wow, it is very beautiful. :-) +1
– Sebastiano
9 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
8 hours ago
Done now for all the users :-)
– Sebastiano
8 hours ago
@AlexG: When I open animated PDF in Acrobat Reader, it requires Flash Player. I have just installed Flash Player, but still can not hear the sound
– Black Mild
7 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
7 hours ago
add a comment |
1
Wow, it is very beautiful. :-) +1
– Sebastiano
9 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
8 hours ago
Done now for all the users :-)
– Sebastiano
8 hours ago
@AlexG: When I open animated PDF in Acrobat Reader, it requires Flash Player. I have just installed Flash Player, but still can not hear the sound
– Black Mild
7 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
7 hours ago
1
1
Wow, it is very beautiful. :-) +1
– Sebastiano
9 hours ago
Wow, it is very beautiful. :-) +1
– Sebastiano
9 hours ago
2
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
8 hours ago
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
8 hours ago
Done now for all the users :-)
– Sebastiano
8 hours ago
Done now for all the users :-)
– Sebastiano
8 hours ago
@AlexG: When I open animated PDF in Acrobat Reader, it requires Flash Player. I have just installed Flash Player, but still can not hear the sound
– Black Mild
7 hours ago
@AlexG: When I open animated PDF in Acrobat Reader, it requires Flash Player. I have just installed Flash Player, but still can not hear the sound
– Black Mild
7 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
7 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
7 hours ago
add a comment |
You can alternatively do the animation elsewhere with sound and add that to the Beamer Files. Beamer seems to have an multimedia package. Also movie15 seems to be promising.
Look at this thread about Multimedia/sound How to include audio file in PDF, maybe thats a valid startingpoint.
New contributor
Could you provide full code with some explanation?
– Black Mild
12 hours ago
Sorry, can't do that right now. But the movie15 package has it online. I can't open it as it is not allowed by my company network. ctan.org/tex-archive/macros/latex/contrib/movie15/doc
– Sango
11 hours ago
add a comment |
You can alternatively do the animation elsewhere with sound and add that to the Beamer Files. Beamer seems to have an multimedia package. Also movie15 seems to be promising.
Look at this thread about Multimedia/sound How to include audio file in PDF, maybe thats a valid startingpoint.
New contributor
Could you provide full code with some explanation?
– Black Mild
12 hours ago
Sorry, can't do that right now. But the movie15 package has it online. I can't open it as it is not allowed by my company network. ctan.org/tex-archive/macros/latex/contrib/movie15/doc
– Sango
11 hours ago
add a comment |
You can alternatively do the animation elsewhere with sound and add that to the Beamer Files. Beamer seems to have an multimedia package. Also movie15 seems to be promising.
Look at this thread about Multimedia/sound How to include audio file in PDF, maybe thats a valid startingpoint.
New contributor
You can alternatively do the animation elsewhere with sound and add that to the Beamer Files. Beamer seems to have an multimedia package. Also movie15 seems to be promising.
Look at this thread about Multimedia/sound How to include audio file in PDF, maybe thats a valid startingpoint.
New contributor
New contributor
answered 12 hours ago
SangoSango
815 bronze badges
815 bronze badges
New contributor
New contributor
Could you provide full code with some explanation?
– Black Mild
12 hours ago
Sorry, can't do that right now. But the movie15 package has it online. I can't open it as it is not allowed by my company network. ctan.org/tex-archive/macros/latex/contrib/movie15/doc
– Sango
11 hours ago
add a comment |
Could you provide full code with some explanation?
– Black Mild
12 hours ago
Sorry, can't do that right now. But the movie15 package has it online. I can't open it as it is not allowed by my company network. ctan.org/tex-archive/macros/latex/contrib/movie15/doc
– Sango
11 hours ago
Could you provide full code with some explanation?
– Black Mild
12 hours ago
Could you provide full code with some explanation?
– Black Mild
12 hours ago
Sorry, can't do that right now. But the movie15 package has it online. I can't open it as it is not allowed by my company network. ctan.org/tex-archive/macros/latex/contrib/movie15/doc
– Sango
11 hours ago
Sorry, can't do that right now. But the movie15 package has it online. I can't open it as it is not allowed by my company network. ctan.org/tex-archive/macros/latex/contrib/movie15/doc
– Sango
11 hours ago
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f503886%2ftempo-play-a-sound-in-animated-gif-pdf-svg%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown