Skip to content

Commit

Permalink
common: figureSoundGraph: Use LaTeX conditionals
Browse files Browse the repository at this point in the history
* src/common/figureAnalogSignalExample.tex: Use LaTeX conditionals to select the
proper translation for the figure caption.
* src/en/sections/music-and-technology-synthesis-sound.tex,
src/ru/sections/music-and-technology-synthesis-sound.tex: Update.
  • Loading branch information
artyom-poptsov committed Jan 17, 2025
1 parent a92652b commit 8f4b6a7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
17 changes: 16 additions & 1 deletion src/common/figureSoundGraph.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
\newcommand{\figureSoundGraph}[1]{
\def\lang{\detokenize{#1}}
\def\langRu{\detokenize{ru}}
\def\langEn{en}
\def\figureCaption{XXX: No translation.}
\def\figureUnit{$\mu\mbox{s}$}
\ifx \lang\langRu
\def\figureCaption{
Графическое отображение процесса генерации звука.
}
\fi
\if \lang\langEn
\def\figureCaption{
Graphical representation of the sound generation process.
}
\fi
\begin{figure}[H]
\begin{tikzpicture}
\draw[thick, ->] (0, 0) -- (12, 0) node[anchor=north west] {t};
Expand All @@ -22,7 +37,7 @@
\draw[thick, orange, <->] (0, -1.5)
-- (10, -1.5) node[midway, below, red] {t=?};
\end{tikzpicture}
\caption{#1}
\caption{\figureCaption}
\label{fig:sound-graph}
\end{figure}
}
4 changes: 1 addition & 3 deletions src/en/sections/music-and-technology-synthesis-sound.tex
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ \section{Sound}
divide 1 second (in microseconds) by the wavelength and by that we will get the
frequency (in Hertz). That's easy.

\figureSoundGraph{
Graphical representation of the sound generation process.
}
\figureSoundGraph{en}

The method of sound generation is similar to \gls{PWM}. The main difference is
that now we must change the wavelength, keeping the duty cycle constant, equal
Expand Down
4 changes: 1 addition & 3 deletions src/ru/sections/music-and-technology-synthesis-sound.tex
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ \section{Звук}
секунду (в микросекундах) на длину волны -- таким образом, получим частоту в
Герцах. Всё просто.

\figureSoundGraph{
Графическое отображение процесса генерации звука.
}
\figureSoundGraph{ru}

Метод генерации звука похож на \gls{ШИМ}. Основные отличия заключаются в том,
что теперь мы должны изменять длину волны \texttt{len}, оставляя коэффициент
Expand Down

0 comments on commit 8f4b6a7

Please sign in to comment.