Bruno Ruviaro edited Pbind counterpoint.tex  almost 10 years ago

Commit id: 9ab19b5abc6d832adc92ca6fbfb4d33aa18fd3a8

deletions | additions      

       

First, notice the use of variables. One of them, \texttt{myDurs}, is a local variable. You can tell it's a local variable because it doesn't start with a tilde ($\sim$) and it's declared at the top with the reserved keyword \texttt{\textbf{var}}. This variable holds an entire \texttt{Pseq} that will be used as \texttt{\textbackslash dur} in both of the \texttt{Pbind}s. \texttt{myDurs} is really only needed at the moment of defining the score, so it makes sense to use a local variable for that (though an environment variable would work just fine too). The other variables you see in the example are environment variables---once declared, they are valid anywhere in your SuperCollider patches.  Second, notice the separation between score and players, as discussed earlier. When the \texttt{Pbind}s are defined, they are not played right away---there is no \texttt{.play} immediately after their closing parenthesis. After you evaluate the first code block, all you have is two \texttt{Pbind} definitions stored into the variables $\sim$upperMelody and $\sim$lowerMelody. They are not making sound yet---they are just the scores. The line \begin{lstlisting}$\sim$player1 \begin{lstlisting}~player1  = $\sim$upperMelody.play\end{lstlisting} ~upperMelody.play\end{lstlisting}  creates an \texttt{EventStreamPlayer} to do the job of playing the upper melody, and that player is given the name $\sim$player1. Same idea for $\sim$player2. Thanks to this, we can talk to each player and request it to stop, start, resume, etc. At the risk of being tedious, let's reiterate this one last time:  \begin{itemize}