Bruno Ruviaro edited Order of execution.tex  almost 10 years ago

Commit id: ea360856a52055697efe1e6c05a7fb8d13f7a06e

deletions | additions      

       

Watch the Node Tree as you run the synths in order.  \begin{figure}[h]  \centerline{  \includegraphics[scale=0.5]{fig-node-tree.png}}  \caption{Synth nodes in the Node Tree window}  \label{fig:node-tree}  \end{figure}  Synth nodes in the Node Tree window run from \emph{top to bottom}. The most recent synths get added to the top by default. In figure \ref{fig:node-tree}, you can see that \texttt{"noise"} is on top, so it's the first to be calculated. Then \texttt{"filter"} comes second, and \texttt{"masterOut"} comes last. This is the right order we want. If you now try running the example again, but evaluating the lines \texttt{m}, \texttt{f}, and \texttt{n} in reverse order, you will hear nothing, because the signals are being calculated in the wrong order.  Evaluating the right lines in the right order is fine, but it might get tricky as your code becomes more complex. In order to make this job easier, SuperCollider allows you to explicitly define where to place synth in the Node Tree. For this we use the \texttt{addAction} argument.  \begin{lstlisting}[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]  n = Synth("noise", addAction: 'addToHead');  m = Synth("masterOut", addAction: 'addToTail');  f = Synth("filter", target: n, addAction: 'addAfter');  \end{lstlisting}  Now, no matter in what order you execute the lines above, you can be sure that nodes will fall in the right places. The \texttt{"noise"} synth is explicitly told to be added to the head of the Node Tree; \texttt{"masterOut"} is added to the tail; and \texttt{filter} is explicitly added right after target \texttt{n} (the noise synth).  \subsection{Groups}  When you start to have lots of synths---some of them for source sounds, other for effects, or whatever you need---it may be a good idea to organize them into groups. Here's a basic example:  \lstinputlisting[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]{code-groups.scd}  For more information about order of execution, look up the Help files ``Synth,'' ``Order of Execution,'' and ``Group.''