this is for holding javascript data
Bruno Ruviaro edited Pbind start and stop.tex
almost 10 years ago
Commit id: a82974db74a7d80f7781935aa98b6768fc543066
deletions | additions
diff --git a/Pbind start and stop.tex b/Pbind start and stop.tex
index 09675d9..767fb4d 100644
--- a/Pbind start and stop.tex
+++ b/Pbind start and stop.tex
...
Now let's look at a more complex example.
\lstinputlisting[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]{code-pbind-start-stop.scd}
\begin{figure}[h]
\centerline{\framebox{
\includegraphics[width=0.7\columnwidth]{code-pbind-start-stop-notation.pdf}}}
\caption{\texttt{Pbind} counterpoint with a Tchaikovsky melody}
\label{fig:counterpoint}
\end{figure}
Figure \ref{fig:counterpoint} shows these two melodies in musical notation.
First, notice \begin{lstlisting}
// Define 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 \texttt{$\sim$upperMelody} and \texttt{$\sim$lowerMelody}. They are not making sound yet---they are just the scores. The line \texttt{$\sim$player1 (
var myDurs =
$\sim$upperMelody.play} 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}
\item A \texttt{Pbind} is just a recipe for making sounds, like a musical score;
\item When you call the message \texttt{play} on a \texttt{Pbind}, an \texttt{EventStreamPlayer} object is created;
\item If you store this \texttt{EventStreamPlayer} into a variable, you can access it later to use commands like \texttt{stop} and \texttt{resume}.
\end{itemize} Pseq([Pn(1, 5), 3, Pn(1, 5), 3, Pn(1, 6), 1/2, 1/2, 1, 1, 3, 1, 3], inf) * 0.4;
~upperMelody = Pbind(
\midinote, Pseq([57, 62, 64, 65, 67, 69, Pseq([69, 67, 69, 70, 67, 69], 2), 70, 69, 67, 65, 64, 62, 62], inf),
\ctranspose, 12,
\dur, myDurs
);
~lowerMelody = Pbind(
\midinote, Pseq([57, 62, 61, 60, 59, 58, 57, 55, 53, 52, 50, 49, 50, 52, 50, 55, 53, 52, 53, 55, 57, 58, 61, 62, 62], inf),
\ctranspose, 12,
\dur, myDurs
);
)
\begin{center}
* * *
\end{center} // Play the two together:
(
~player1 = ~upperMelody.play;
~player2 = ~lowerMelody.play;
)
At this point you already know quite a lot about \texttt{Pbind}s // Stop and
you are able to build interesting patterns with many members of the Pattern family. However, you may be getting tired of the simple piano-like synth that \texttt{Pbind} uses out of the box. You naturally may want to try other sounds with your patterns. start melodies:
~player1.stop;
~player2.stop;
So let's now switch gears and enter the topic of Unit Generators (UGens). Most tutorials start with Unit Generators right away; in this intro to SC, however, we chose to emphasize the Pattern family first (\texttt{Pbind} and friends). The middle sections of this tutorial introduced you to quite a lot of nitty-gritty details about the language itself, from variables to enclosures and more. The next several sections will deal with sound synthesis and UGens. // Other available messages
~player1.resume;
~player1.reset;
~player1.play;
~player1.start; // same as .play
\end{lstlisting}
\lstinputlisting[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]{code-pbind-start-stop.scd}