%  edit_net.tex from ObjectProDSP 0.2
%  Copyright (C) 1994 1995, Mountain Math Software. All rights reserved.
%  
%  This file is part of ObjectProDSP, a tool for Digital Signal
%  Processing design, development and implementation. It is free
%  software provided you use and distribute it under the terms of
%  version 2 of the GNU General Public License as published
%  by the Free Software Foundation. You may NOT distribute it or
%  works derived from it or code that it generates under ANY
%  OTHER terms.  In particular NONE of the ObjectProDSP system is
%  licensed for use under the GNU General Public LIBRARY License.
%  Mountain Math Software plans to offer a commercial version of
%  ObjectProDSP for a fee. That version will allow redistribution
%  of generated code under standard commercial terms.
%  
%  This program is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%  GNU General Public License for more details.
%  
%  You should have received a copy of version 2 of the GNU General
%  Public License along with this program. See file COPYING. If not
%  or if you wish information on commercial versions and licensing
%  write Mountain Math Software, P. O. Box 2124, Saratoga, CA 95070,
%  USA, or send us e-mail at: support@mtnmath.com.
%  
%  You may also obtain the GNU General Public License by writing the
%  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
%  USA.  However if you received a copy of this program without the
%  file COPYING or without a copyright notice attached to all text
%  files, libraries and executables please inform Mountain Math Software.
%  
%  ObjectProDSP is a trademark of Mountain Math Software.
%  
\clearpage
\SectionIndex{Constructing and editing DSP networks}
\markright{\headtitle}

\begin{figure}
\centerline{\psfig{figure=../psfig/edit_net_1.ps}}
\caption{Editing a CxFir node into FFT\_Net.}
\label{fig:edit_net_1}
\end{figure}


You can add additional nodes to any of the example networks.
Assume you want to add a thread to the \verb"FFT_Net" example that
\index{edit network}
filters the output of the \verb"FFT_Sum" node with the filter
response in the \verb"Fir_resp" example. First execute the
\verb"fft" example to get a display of \verb"FFT_Net". 
Click the left mouse button with the cursor over the \verb"Edit" push button
at the upper left corner of this display. A check mark should appear.
Now select \DppNm{objects} and \DppNm{dsp processing} from the first and second
lines in the menu database. The FIR filter we want uses the default
coefficients. To get an instance of the filter with the default parameters
\index{node create}
\index{node edit}
click the left mouse button with the \verb"shift" key depressed and the
cursor over \verb"CxFir" in the third line of the menu data base.
A \verb"CxFir" node should appear in the \verb"Fir_net" window as
in figure~\ref{fig:edit_net_1}. This node is not connected yet.

To complete the network and get useful output we need
an FFT and a plotting node. We can add all these to
the network display before connecting them. The default FFT size
is only 16 points so we want to change this parameter
from its default value.
To add an FFT node and set its parameters
hold the \verb"shift" key down while clicking the {\it right} mouse
button with the cursor over the \verb"CxFFT" button in the third row
of the menu data base. You will be prompted for a series of parameters.
\index{node parameters}
We only want to change the size of the FFT or the second parameter.
You can type return to select the default value of the others.
For the second parameter you must specify the log base 2 of the
FFT size. To make this comparable to the FFT already in this example
select 9 for an FFT size of 512. Now you should have two disconnected
\index{FFT size}
nodes in the \verb"Fir_net" display. To add a plotting node select
\verb"plot" from the second line of the menu data base and and then
hold the \verb"shift" key down and click the left mouse button with
the cursor over the \verb"Plot" button in the third line of the menu
data base.

To link these nodes in the network you need to understand how to reference
\index{node connections}
the three points where a node can be connected. Input channels are referenced
with the left mouse button, output channels are referenced with the middle
mouse button and output buffers are reference with the right mouse button.
The distinction between output buffers and output channels is important.
\index{node buffers}\index{node channels}\index{output buffers}
\index{output channels}Nodes have a fixed number of output channels,
they can however have
any number of connection from the output buffer associated with
\index{buffer}\index{output buffer} {\it each} output channel.
The outputs of the different output
channels of a node are usually different data streams. For example
the \verb"Demux" node demultiplexes a single data stream into multiple
\index{Demux}
\index{demultiplex}
data streams that each contain different samples from the input.
The multiple outputs from a single buffer all get the same data.

\begin{figure}
\centerline{\psfig{figure=../psfig/edit_net_2.ps}}
\caption{Selecting FFT\_Sum to connect to.}
\label{fig:edit_net_2}
\end{figure}

\begin{figure}
\centerline{\psfig{figure=../psfig/edit_net_3.ps}}
\caption{Completed edit of FFT\_Net.}
\label{fig:edit_net_3}
\end{figure}


In editing a network, selecting an output channel selects the next
\index{channel selection}
\index{node channel selection}
available channel. If all the output channels of a node are connected you
cannot select an output channel from it. This is always true if
we are linking a new thread into an existing network as we are
in this example. However you can always connect a new node to any
buffer in a network. To link our FIR filter node into the network
hold the \verb"shift" key down and click the right mouse button on the
\verb"FFT_Sum" node. This node should be highlighted as in
figure~\ref{fig:edit_net_2}. To connect to the filter node hold
the \verb"shift" key down and click the left mouse button (to select the input)
on the \verb"CxFir_1" node. This node will be briefly highlighted and then
the network will be redrawn with this connection. To complete your
additions to the network hold the \verb"shift" key down for all operations.
(The \verb"shift" key is the modifier that denotes network editing operations.)
\index{shift}
\index{edit network operation}
Click the middle mouse button on \verb"CxFir_1" and then the
left button on \verb"CxFFT_2". Finally click the the middle button
on the \verb"CxFFT_2" node and the right left button on the
\verb"Plot_4" node. Your network is complete and should look like
figure~\ref{fig:edit_net_3}

\begin{figure}
\centerline{\psfig{figure=../psfig/edit_net_menu.ps}}
\caption{Menu to execute edited network.}
\label{fig:edit_net_menu}
\end{figure}

\begin{figure}
\centerline{\psfig{figure=../psfig/edit_net_plt_1.ps}}
\caption{New complex plot from edited network.}
\label{fig:edit_net_plt_1}
\end{figure}

\begin{figure}
\centerline{\psfig{figure=../psfig/edit_net_plt_2.ps}}
\caption{Decibel power view of plot.}
\label{fig:edit_net_plt_2}
\end{figure}



To execute the network hold the \verb"ctrl" key down and click mouse
\index{execute network}
\index{network execution}
button one over the gray area at the top of the \verb"FFT_Net" window.
A menu of commands for \verb"FFT_net" should appear. Select \verb"exec"
\index{network menu}
from this menu and then \verb"Execute" from the second line as
in figure~\ref{fig:edit_net_menu}. You will be prompted for the number
of times to execute the input nodes of the network. Make
sure you select a value to generate enough data for your FFT such
as 1024. Execution will produce a new complex plot as in
figure~\ref{fig:edit_net_plt_1}. To get a decibel power view of this
data position the cursor over the plot and type \verb"ctrl-b".
A window like that in figure~\ref{fig:edit_net_plt_2} will
appear.

You do not need to start with an existing network. If you have not
\index{creating a network}
\index{network creation}
checked the edit box of a displayed network (or you check it again
to turn editing off) you can select a node to
edit in a new network.
Hold the \verb"shift"
key down while clicking the left (default parameters) or right mouse
button on the selection for any DSP node in the menu data base.
An instance of this node will appear in a new window. You can
add additional nodes and connect them as just described and
execute the network.
