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?
Submitting a new paper just after another was accepted by the same journal
Lengthened voiced stops and the airstream through the nose
Word for an event that will likely never happen again
Simplification of numbers
Heat equation: Squiggly lines
Why command hierarchy, if the chain of command is standing next to each other?
If clocks themselves are based on light signals, wouldn't we expect the measured speed of light to always be the same constant?
When does Tiana, Ship's Caretaker check card type?
Why are Tucker and Malcolm not dead?
Plotting octahedron inside the sphere and sphere inside the cube
Is there a command to install basic applications on Ubuntu 16.04?
How does "Te vas a cansar" mean "You're going to get tired"?
Generate Brainfuck for the numbers 1–255
Prove without writing all cases that there are more odd numbers from 1 to 199 than even numbers from 1 to 199
Normalization constant of a planar wave
Why does the standard fingering / strumming for a D maj chord leave out the 5th string?
Can the government force you to change your license plate?
Understanding the point of a kölsche Witz
80's/90's superhero cartoon with a man on fire and a man who made ice runways like Frozone
How to disable "Completion time:..." in SQL Server Messages window
Why is there a large performance impact when looping over an array over 240 elements?
how do companies get money from being listed publicly
Is it legal for a company to enter an agreement not to hire employees from another company?
How to assign many blockers at the same time?
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 3 hours ago
Black Mild
asked 14 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
11 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
10 hours ago
Done now for all the users :-)
– Sebastiano
10 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
9 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
9 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
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Could you provide full code with some explanation?
– Black Mild
13 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
13 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
11 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
10 hours ago
Done now for all the users :-)
– Sebastiano
10 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
9 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
9 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
11 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
10 hours ago
Done now for all the users :-)
– Sebastiano
10 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
9 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
9 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 11 hours ago
answered 14 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
11 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
10 hours ago
Done now for all the users :-)
– Sebastiano
10 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
9 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
9 hours ago
add a comment |
1
Wow, it is very beautiful. :-) +1
– Sebastiano
11 hours ago
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
10 hours ago
Done now for all the users :-)
– Sebastiano
10 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
9 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
9 hours ago
1
1
Wow, it is very beautiful. :-) +1
– Sebastiano
11 hours ago
Wow, it is very beautiful. :-) +1
– Sebastiano
11 hours ago
2
2
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
10 hours ago
@Sebastiano Oh, thank you! As for beauty, all credits go to Black Mild :-). Upvote his question too, please.
– AlexG
10 hours ago
Done now for all the users :-)
– Sebastiano
10 hours ago
Done now for all the users :-)
– Sebastiano
10 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
9 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
9 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
9 hours ago
You need the version for Firefox , not the one for IExplorer (ActiveX component), @BlackMild.
– AlexG
9 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
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Could you provide full code with some explanation?
– Black Mild
13 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
13 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
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Could you provide full code with some explanation?
– Black Mild
13 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
13 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
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 14 hours ago
SangoSango
815 bronze badges
815 bronze badges
New contributor
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sango is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Could you provide full code with some explanation?
– Black Mild
13 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
13 hours ago
add a comment |
Could you provide full code with some explanation?
– Black Mild
13 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
13 hours ago
Could you provide full code with some explanation?
– Black Mild
13 hours ago
Could you provide full code with some explanation?
– Black Mild
13 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
13 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
13 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