<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Boulay</id>
	<title>BCI2000 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Boulay"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Boulay"/>
	<updated>2026-06-09T07:59:14Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Howto:Quickstart_Guide&amp;diff=7340</id>
		<title>Programming Howto:Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Howto:Quickstart_Guide&amp;diff=7340"/>
		<updated>2014-04-01T16:20:21Z</updated>

		<summary type="html">&lt;p&gt;Boulay: /* Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial walks you through the process of obtaining the [[Programming_Reference:BCI2000_Source_Code|BCI2000 source distribution]], and using it to build and test your own custom [[BCI2000_Glossary#Filter|filters]], implemented in C++ inside your own custom [[BCI2000_Glossary#Core_Module|core module]]. It assumes that you have a good working knowledge of the C++ language,  and basic familiarity with the compiler/IDE that you are going to use.&lt;br /&gt;
&lt;br /&gt;
Many of the specific instructions below will assume that you are on a 32-bit Windows system, are using Microsoft&#039;s free &#039;&#039;&#039;Visual C++ 2010 Express&#039;&#039;&#039; compiler, and have checked out the BCI2000 distribution to a location &amp;lt;tt&amp;gt;C:\BCI2000\3.x&amp;lt;/tt&amp;gt; on your hard-drive. However, the same steps are valid for other supported setups, with the appropriate setup-specific changes.&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
===All Operating Systems===&lt;br /&gt;
# First, you need a complete BCI2000 distribution that includes the &amp;lt;tt&amp;gt;src&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt; directories. If you already have this, use SVN to make sure it is updated to a recent stable version (at least, for this tutorial to make sense, you will need revision 3279 or later / May 2011 or later).  If you do not already have the source distribution, here is how you obtain it:&lt;br /&gt;
## If you do not already have a [[Creating_a_User_Account|bci2000.org username]], get one [http://www.bci2000.org/GPL/ here].  Your password will be mailed to you.&lt;br /&gt;
## To download the BCI2000 source-code, you will need an SVN client. If you do not have one, for Windows we recommend TortoiseSVN, which can be downloaded [http://tortoisesvn.net/downloads.html here].  The BCI2000 wiki contains more documentation about how to [[Programming_Howto:SVN_Client_Setup|set up]] and [[Programming_Howto:Using_TortoiseSVN|use]] SVN.&lt;br /&gt;
## Use SVN, with your username and password, to check out the latest BCI2000 source-code-included distribution, the location of which is http://www.bci2000.org/svn/tags/releases/current (note this is the current release version, not the current source code -- for the current source code, check out from http://www.bci2000.org/svn/trunk). We will assume that you checked out to a location  &amp;lt;tt&amp;gt;C:\BCI2000\3.x&amp;lt;/tt&amp;gt;  on your hard-drive. Wherever you see this path below, adjust it so that it reflects the location you actually used. More information about the layout of the resulting distribution can be found [[Programming_Reference:BCI2000_Source_Code|here]].&lt;br /&gt;
# Next you will need to download and install CMake if you do not already have it (at least version 2.8.3 is recommended). CMake can be downloaded [http://www.cmake.org/cmake/resources/software.html here]. Make sure you select the option &#039;&#039;&#039;add to PATH for all users&#039;&#039;&#039; when installing.&lt;br /&gt;
# Finally you will need a C++ compiler. We will proceed on the assumption that you are on 32-bit Windows and using the free Visual C++ 2010 Express environment which can be downloaded [http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express here] (choose either the Visual C++ web-installer or, for something that can be installed offline, the option marked &amp;quot;Visual Studio 2010 Express All-in-One ISO&amp;quot; - this will give you an .iso file which can be mounted as a virtual drive using a tool like [http://www.slysoft.com/en/virtual-clonedrive.html Virtual Clone Drive]).  Consult the documentation for the [[Programming_Reference:Build_System|BCI2000 build system]] for information on other supported compilers, and more about CMake.&lt;br /&gt;
&lt;br /&gt;
You should now have everything you need in order to build and customize BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Prerequisites (Linux)===&lt;br /&gt;
# C++ compiler&lt;br /&gt;
# Subversion&lt;br /&gt;
# CMake&lt;br /&gt;
# Qt libraries and header files (Qt-dev)&lt;br /&gt;
Then follow the &amp;quot;unix command-line equivalent&amp;quot; instructions from a terminal.&lt;br /&gt;
&lt;br /&gt;
===Prerequisites (OS X)===&lt;br /&gt;
# Apple&#039;s Developer Tools (includes a C/C++ compiler and Subversion)&lt;br /&gt;
# A [http://www.cmake.org/cmake/resources/software.html CMake binary installer] (&amp;lt;tt&amp;gt;.dmg&amp;lt;/tt&amp;gt; file) appropriate to your platform, version 2.8.3 or later.&lt;br /&gt;
# Qt libraries (You only need the libraries, not the full SDK.   We have performed successful builds with [ftp://ftp.qt.nokia.com/qt/source/qt-mac-opensource-4.7.2.dmg v4.7.2]. Your mileage may vary according to the version you use.)&lt;br /&gt;
Then follow the &amp;quot;unix command-line equivalent&amp;quot; instructions from the Terminal.app command-line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; CMake may be used to create an XCode project file for BCI2000, using the appropriate generator option. However, it seems that XCode builds of BCI2000 do not always succeed, even if there is no problem with Unix makefile builds on the same machine. Thus, you should always try a command-line build when building fails under XCode.&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~  # or wherever&lt;br /&gt;
 $ svn checkout http://www.bci2000.org/svn/trunk  bci2000   # (or call it whatever you want)&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
# Use CMake to build a project file.  This is done by going to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;  (which is the main workbench from which all build operations occur) and launching one of the &amp;quot;&amp;lt;tt&amp;gt;Make ... .bat&amp;lt;/tt&amp;gt;&amp;quot;  batch-files.  If you are using Visual C++ 2010 Express,  the appropriate batch file is &amp;lt;tt&amp;gt;Make VS10 Project Files.bat&amp;lt;/tt&amp;gt; .  It may ask you several questions: feel free to answer &amp;quot;y&amp;quot; to building the &amp;quot;tools&amp;quot;, &amp;quot;contrib&amp;quot; and &amp;quot;BCPy2000&amp;quot; components.  For now, for simplicity, you may wish to say no to framework extensions. Also say no to modules that require MFC (unless you are using a commercial version of Visual C++ Studio that includes MFC).  If successful, you should see a long list of sub-projects being created, and after several seconds of this, &amp;quot;Configuring done&amp;quot; followed by &amp;quot;Generating done&amp;quot;.&lt;br /&gt;
# Open the resulting solution file,  &amp;lt;tt&amp;gt;BCI2000.sln&amp;lt;/tt&amp;gt; , in Visual C++ Express. The file should be located in &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt; .&lt;br /&gt;
# Ensure that you are in &amp;quot;Release&amp;quot; mode rather than &amp;quot;Debug&amp;quot; (in Visual C++, this is a drop-down menu in a toolbar near the top)&lt;br /&gt;
# You probably do not need to build all of BCI2000 at once.   To use BCI2000, the minimum you will need consists of the Operator, plus at least one SignalSource module, at least one SignalProcessing module, and at least one Application module. To build a single module in Visual C++ Express, right-click on the module&#039;s name in the list on the left, and select &amp;quot;Build&amp;quot;.   The initial build will typically take a few minutes per module.  If you do not intend to modify a given module, you can always skip building it by copying the corresponding ready-built binary (for example, &amp;lt;tt&amp;gt;Operator.exe&amp;lt;/tt&amp;gt;)  from the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; subdirectory of a BCI2000 v.2 or v.3 [[BCI2000_Binaries|binary distribution]], and paste it into the corresponding directory of the distribution in which you are working, i.e. &amp;lt;tt&amp;gt;C:\BCI2000\3.x\prog&amp;lt;/tt&amp;gt; .  (To [http://bci2000.org/downloads/bin/BCI2000Setup.exe download the latest binary distribution], you will need to supply the same username and password that you used for SVN download.) Let&#039;s assume you have built, or copied, the following modules: &#039;&#039;&#039;SignalGenerator&#039;&#039;&#039;, &#039;&#039;&#039;SpectralSignalProcessing&#039;&#039;&#039;, &#039;&#039;&#039;CursorTask&#039;&#039;&#039; and &#039;&#039;&#039;Operator&#039;&#039;&#039;, as well as the necessary &#039;&#039;&#039;OperatorLib&#039;&#039;&#039; shared library. Test the modules, i.e. run &amp;lt;tt&amp;gt;C:\BCI2000\3.x\batch\CursorTask_SignalGenerator.bat&amp;lt;/tt&amp;gt; .&lt;br /&gt;
# Build the &#039;&#039;&#039;NewBCI2000Module&#039;&#039;&#039;, &#039;&#039;&#039;NewBCI2000Filter&#039;&#039;&#039;  and &#039;&#039;&#039;NewBCI2000FilterTool&#039;&#039;&#039; targets for use in the subsequent steps.  The result will be new executables,  &amp;lt;tt&amp;gt;NewBCI2000Module.exe&amp;lt;/tt&amp;gt;,  &amp;lt;tt&amp;gt;NewBCI2000Filter.exe&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;NewBCI2000FilterTool.exe&amp;lt;/tt&amp;gt;,  in the &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make NewBCI2000Module NewBCI2000Filter NewBCI2000FilterTool&lt;br /&gt;
&lt;br /&gt;
==Creating a project for a new BCI2000 module, from a template==&lt;br /&gt;
&lt;br /&gt;
# Navigate to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Find &amp;lt;tt&amp;gt;NewBCI2000Module.exe&amp;lt;/tt&amp;gt; there, assuming you have already built it (see &amp;quot;Setup&amp;quot;, above).&lt;br /&gt;
# Launch it and answer the three questions it asks:&lt;br /&gt;
## What type of module are you creating? Enter &amp;quot;1&amp;quot; for a SignalSource module, &amp;quot;2&amp;quot; for a SignalProcessing module, or &amp;quot;3&amp;quot; for an Application module.&lt;br /&gt;
## What should be the name of the new module?  This should be single word, without spaces or punctuation (For example: &#039;&#039;&#039;VeryNiceSignalProcessing&#039;&#039;&#039;.  Or, at your option, something even more informative.) This name will be used as the name of a new directory that will contain the project source information, as well as for the resulting binary (&amp;lt;tt&amp;gt;.exe&amp;lt;/tt&amp;gt; file).&lt;br /&gt;
## Where (i.e. inside what parent directory) should the new project directory be created?   You can express this as a relative path, in which case it is interpreted relative to the &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt; directory where &amp;lt;tt&amp;gt;NewBCI2000Module.exe&amp;lt;/tt&amp;gt; itself is running.  To accept the default answer, which is &amp;lt;tt&amp;gt;..\src\custom&amp;lt;/tt&amp;gt;, just press return. This location (or some subdirectory of it) is a good choice: it maps to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\src\custom&amp;lt;/tt&amp;gt; which is an area reserved for your own projects.&lt;br /&gt;
# Now re-run CMake (see step 1 of &amp;quot;Setup&amp;quot;, above).  You should see your new project being added at the end of the long list of projects.  Re-open the project file (step 2 of &amp;quot;Setup&amp;quot;) and you should see it listed in the alphabetical list of projects.&lt;br /&gt;
# If you have just created a new SignalSource project,  a specialized source-acquisition filter (called an Analogue-to-Digital Converter or ADC) will already have been added to the project.  If your project was called &#039;&#039;&#039;Foo&#039;&#039;&#039;  or &#039;&#039;&#039;FooSource&#039;&#039;&#039;  this will be instantiated in files called &amp;lt;tt&amp;gt;FooADC.cpp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;FooADC.h&amp;lt;/tt&amp;gt;.  You can find this by expanding the tree (click on the plus sign) next to your project name in Visual C++.  Find the files under &amp;quot;Source&amp;quot; (or &amp;quot;Headers&amp;quot;) and then &amp;quot;Project&amp;quot;. Double-click them to edit.  You should already be able to compile the module: try it.&lt;br /&gt;
# If you have created a SignalProcessing or Application project,  you may be able to compile it, but it will not do anything until you add at least one filter to it (see next section).&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./NewBCI2000Module 2 VeryNiceSignalProcessing ../src/custom&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make VeryNiceSignalProcessing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Adding a new filter to a BCI2000 module, from a template==&lt;br /&gt;
&lt;br /&gt;
# Navigate to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Find &amp;lt;tt&amp;gt;NewBCI2000Filter.exe&amp;lt;/tt&amp;gt; there, assuming you have already built it (see &amp;quot;Setup&amp;quot;, above).&lt;br /&gt;
# Launch it and answer the three questions it asks:&lt;br /&gt;
## What type of filter are you creating?  Enter &amp;quot;1&amp;quot; for a subclass of [[Programming_Reference:BufferedADC_Class|BufferedADC]] (although if you created a SignalSource project with the NewBCI2000Module tool, an ADC of this kind will already have been created for you),  enter &amp;quot;2&amp;quot; for a subclass of [[Programming_Reference:GenericFilter_Class|GenericFilter]],  or &amp;quot;3&amp;quot; for a subclass of [[Programming_Reference:ApplicationBase_Class|ApplicationBase]].&lt;br /&gt;
## What should be the name of the filter class?  This should be a legal name for a new C++ class (no spaces or punctuation). If you enter, for example, &amp;quot;FooFilter&amp;quot;,  then a class of this name will be implemented in two new files, &amp;lt;tt&amp;gt;FooFilter.cpp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;FooFilter.h&amp;lt;/tt&amp;gt; .&lt;br /&gt;
## To which project (i.e. in which project directory, relative to &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt;) should the filter be added?  For example:  &amp;lt;tt&amp;gt;..\src\custom\VeryNiceSignalProcessing&amp;lt;/tt&amp;gt;  (as in all of the BCI2000 framework, directory slashes are allowed to go this / way or that \ way regardless of whether you are on Windows or not)&lt;br /&gt;
# Again, re-run CMake and re-open the master project file.&lt;br /&gt;
# Find your new files under the Source/Project  and Headers/Project  trees by clicking on the + sign next to the project name. Double-click them to edit. Read the comments in the file for help as to how to flesh out the various filter methods.&lt;br /&gt;
# Try building the project (right-click on the project and select &amp;quot;build&amp;quot;).  SignalSource and Application projects may already build successfully.  SignalProcessing projects, or any project to which you have added a new GenericFilter subclass, will have at least one deliberate &#039;&#039;&#039;#error&#039;&#039;&#039; in the code.  When the build attempt finishes, double-click on the error message to go to the offending line. Read the comments in the file, and you will see that the error is there to force you to think about the ordering of the filters in your module.  Once you have resolved this issue, simply remove the #error line and select &amp;quot;build&amp;quot; again (the process will be quicker this time: only previously unbuilt files or newly modified files will be compiled).&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./NewBCI2000Filter 2 FooFilter ../src/custom/VeryNiceSignalProcessing&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make VeryNiceSignalProcessing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running and testing the result==&lt;br /&gt;
&lt;br /&gt;
# Locate successfully built modules, which will appear as &amp;lt;tt&amp;gt;.exe&amp;lt;/tt&amp;gt; files inside the top-level &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory of the BCI2000 distribution,  for example &amp;lt;tt&amp;gt;C:\BCI2000\3.x\prog&amp;lt;/tt&amp;gt;&lt;br /&gt;
# The most basic way to launch BCI2000 is to double-click on each module in turn.  Start with &amp;lt;tt&amp;gt;Operator.exe&amp;lt;/tt&amp;gt;,  then launch one SignalSource module, one SignalProcessing module, and one Application module (your new module will fill one of these three roles, but all three are required).&lt;br /&gt;
# If you have a firewall running on your machine, dialogs may open for any modules that the firewall has never seen before. If so, click &amp;quot;unblock&amp;quot; to proceed, for each one. You should only ever need to do this once per newly-built module. (Check that your firewall is not configured to block network connections without telling you.)&lt;br /&gt;
# In the &#039;&#039;&#039;Config&#039;&#039;&#039; dialog, under the &#039;&#039;&#039;Visualize&#039;&#039;&#039; tab, you should see a check-box for visualizing the output of all the filters in the chain, including your newly created filter.  You may find it useful, whenever you are developing a new filter, to visualize your filter input and output simultaneously (i.e. visualize both the new filter and the filter that immediately precedes it in the chain).&lt;br /&gt;
&lt;br /&gt;
==Configuring your new filter for offline use==&lt;br /&gt;
&lt;br /&gt;
This is an optional step which many developers of new custom filters will find useful. Filters may be compiled singly as standalone executables to allow them to be tested and used for data analysis offline. The resulting &amp;quot;filter tools&amp;quot; can be used either [[User_Reference:Command_Line_Processing|from the DOS/Unix command-line]] or, more comfortably, [[User_Reference:Matlab_Tools|from the Matlab command-line]].&lt;br /&gt;
&lt;br /&gt;
# Navigate to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Find &amp;lt;tt&amp;gt;NewBCI2000FilterTool.exe&amp;lt;/tt&amp;gt; there, assuming you have already built it (see &amp;quot;Setup&amp;quot;, above).&lt;br /&gt;
# Launch it, and tell it which existing C++ file contains the filter definition (as always, specify the path relative to the &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt; directory—for example, &amp;lt;tt&amp;gt;..\src\custom\VeryNiceSignalProcessing\FooFilter.cpp&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# The tool will perform for you the necessary alterations to the CMakeLists files.  (The procedure, details of which can be found [[User_Reference:Command_Line_Processing#Compiling_an_existing_filter_as_a_command_line_tool|here]], involves creating a subdirectory called &amp;lt;tt&amp;gt;cmdline&amp;lt;/tt&amp;gt; inside your project directory, because specifying a new executable target in the same &amp;lt;tt&amp;gt;CMakeLists.txt&amp;lt;/tt&amp;gt; file as your module would cause a misconfiguration problems for either the module or the filter-tool. )&lt;br /&gt;
# Close &amp;lt;tt&amp;gt;BCI2000.sln&amp;lt;/tt&amp;gt;, re-run CMake, and re-open &amp;lt;tt&amp;gt;BCI2000.sln&amp;lt;/tt&amp;gt;.   You should now have a new target, whose name is simply the name of the filter (e.g. &amp;lt;tt&amp;gt;FooFilter&amp;lt;/tt&amp;gt;).&lt;br /&gt;
# Right-click on the new target and select &amp;quot;build&amp;quot;.  The resulting binary will appear as (for example) &amp;lt;tt&amp;gt;..\tools\cmdline\FooFilter.exe&amp;lt;/tt&amp;gt;&lt;br /&gt;
# If you have Matlab, consult  [[User_Reference:Matlab_Tools]] to see how to proceed.   Otherwise see [[User_Reference:Command_Line_Processing]].  (In the Matlab version, the &amp;quot;Hello World&amp;quot; messages of the default template filter, and any other &amp;lt;tt&amp;gt;bciout&amp;lt;/tt&amp;gt; debugging outputs you specify, will appear in the &amp;lt;tt&amp;gt;.ShellOutput&amp;lt;/tt&amp;gt; field.)&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./NewBCI2000FilterTool  ../src/custom/VeryNiceSignalProcessing/FooFilter.cpp&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make FooFilter&lt;br /&gt;
 $ ../tools/cmdline/FooFilter --help&lt;br /&gt;
 $ make bci_dat2stream bci_stream2mat  # you&#039;ll also need these&lt;br /&gt;
&lt;br /&gt;
==Exercises==&lt;br /&gt;
&lt;br /&gt;
===Exercise 1:  RMSFilter===&lt;br /&gt;
&lt;br /&gt;
# Use NewBCI2000Module to create a new SignalProcessing module.&lt;br /&gt;
# Use NewBCI2000Filter to create a new filter called RMSFilter in your new module.&lt;br /&gt;
# NewBCI2000Module and NewBCI2000Filter report that they are creating and altering various files and directories.  Write down what you think is the purpose of each new directory, new file, or alteration to an existing file.&lt;br /&gt;
# Write a filter called RMSFilter, which takes in multiple signal channels, and outputs a single channel containing the root-mean-square signal across all input channels.  (Advanced variant:  introduce a parameter which allows the user to specify groups of channels; then output one RMS signal per group.) Test the filter using the [[User_Reference:SignalGeneratorADC|SignalGenerator module]] as an input, configuring the SignalGenerator to respond to mouse movement as described in the documentation.  First visualize just the &#039;&#039;&#039;input&#039;&#039;&#039; of your new filter (the output of the previous filter, which will presumably be the [[User_Reference:TransmissionFilter|TransmissionFilter]]).  Then draw on paper what you would expect to see as an output of your filter in response to different mouse positions/actions. Finally, visualize your filter&#039;s output in order to verify that it matches your expectations.&lt;br /&gt;
# Visualization allows you to test your code&#039;s behaviour qualitatively to some extent. In what various different ways could you verify, in a more precise, quantitative way, that your implementation is correct?  Under what circumstances should you spend the extra time to do this? (hint: the answer rhymes with &amp;quot;hallways&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===Exercise 2:  Debugging===&lt;br /&gt;
&lt;br /&gt;
# Write a batch file to launch your combination of modules.  You may wish to use one of the existing files in the top-level &amp;lt;tt&amp;gt;batch&amp;lt;/tt&amp;gt; directory as a template. A batch file will allow  you to go around each edit-compile-debug cycle much faster and more reliably. It will also allow you to pass useful command-line flags to the modules as you start them. And finally, if you need to set parameters in a certain way on each launch,  we strongly recommended that you take advantage of [[User_Reference:Operator_Module_Scripting#2|operator scripting]] in your batch file to ensure that the required parameters are loaded automatically from a file on each launch. Inconsistent behaviour from one debug cycle to the next can often be attributed to having forgotten to perform the menial task of loading parameters manually. &lt;br /&gt;
#  You can also use the Visual C++ debugger as follows:&lt;br /&gt;
## In your batch file, comment out or remove the line that launches the module you want to debug.&lt;br /&gt;
## Again in your batch file, assuming you are using the [[User_Reference:SignalGeneratorADC|SignalGenerator]], [[Contributions:FilePlayback|FilePlayback]], or some other source module which does not have to run in real-time, add the flag &amp;lt;code&amp;gt;--EvaluateTiming=0&amp;lt;/code&amp;gt; to the call that launches the source module (see example snippet below).  Putting a debug breakpoint in your Process() method will slow the system to below real-time, and we do not want the framework&#039;s real-time check to terminate the debug session for this reason.   &lt;br /&gt;
## Launch the batch file, thereby launching all the necessary modules except one, and loading any parameters needed for the debug session.&lt;br /&gt;
## Note that there are different &amp;quot;build modes&amp;quot; for the BCI2000 solution, with names like &amp;quot;Release&amp;quot; and &amp;quot;Debug&amp;quot;.   In order to debug  a particular module, you will need to ensure that the module is built in either &amp;quot;Debug&amp;quot; mode or &amp;quot;RelWithDebInfo&amp;quot; mode. If you are in the wrong mode for debugging, select the correct build mode from the drop-down menu on Visual C++ Express&#039;s toolbar, then build your module again.  Note that the BCPy2000 modules (&#039;&#039;PythonSource&#039;&#039;, &#039;&#039;PythonSignalProcessing&#039;&#039; and &#039;&#039;PythonApplication&#039;&#039;) cannot be built in Debug mode.  Also, [http://www.flounder.com/debug_release.htm Debug mode can sometimes mask dangerous bugs], so you may experience the frustration of trying to investigate a crash only for it to stop happening when you switch from Release to Debug. Finally, a BCI2000 module built in Debug mode may exhibit poorer timing performance. For these reasons it is not generally advisable to use Debug mode as the default mode of your project, and RelWithDebInfo is often advisable when debugging (even though the compiler optimizations may lead to a less logical-seeming debugging experience).&lt;br /&gt;
## In Visual C++, set a breakpoint in the source file you want to debug.&lt;br /&gt;
## Although CMake directs Visual C++ to create the module in the correct directory, &amp;lt;tt&amp;gt;C:\BCI2000\3.x\prog&amp;lt;/tt&amp;gt;, it is [http://www.cmake.org/Wiki/CMake_FAQ#Can_CMake_set_the_Debugging.2FWorking_Directory_property_in_Visual_Studio_projects.3F unable to set the working directory in which the debug instance runs] to the same value. Therefore, if your module needs to load resources like image or sound files, and expects to find these at the end of a path that is expressed &#039;&#039;relative&#039;&#039; to &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt;, you will need to set the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory as the module&#039;s working directory by hand:  Right-click on the module -&amp;gt; Properties -&amp;gt; Configuration Properties -&amp;gt; Debugging -&amp;gt; Working Directory&lt;br /&gt;
## In Visual C++, right-click on the module, then select &amp;quot;Debug&amp;quot; followed by &amp;quot;Start New Instance&amp;quot; (if you find this too fiddly to do with the mouse, right-click, then press &amp;quot;g&amp;quot;, then press &amp;quot;s&amp;quot; ). If the build is not up-to-date, Visual Studio will prompt you:  in this case, allow it to build the module.&lt;br /&gt;
## You are now debugging BCI2000. Verify that the debugger stops your module at the breakpoint you specified and at the time that you expected.  Browse the available variables and their properties.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start SignalGenerator.exe --LogMouse=1 --EvaluateTiming=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Exercise 3:  Assembling a filter chain===&lt;br /&gt;
&lt;br /&gt;
# Write a filter called DiffFilter, in which each output channel contains the numerical derivative, with respect to time, of the corresponding input channel. Note that your Process() method only sees one discrete chunk (or SampleBlock) of signal at a time.  Is this a problem? Use private member variables of your filter instance as a &amp;quot;scratch-pad&amp;quot; where necessary. &lt;br /&gt;
# Assemble the pre-existing [[User_Reference:ExpressionFilter|ExpressionFilter]],  followed by your DiffFilter, followed by your RMSFilter (from exercise 1), in that order within one SignalProcessing module.  The ExpressionFilter implementation is already part of the framework, so all you need to do is uncomment the &amp;lt;tt&amp;gt;#include&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Filter()&amp;lt;/tt&amp;gt; statements that correspond to it in &amp;lt;tt&amp;gt;PipeDefinition.cpp&amp;lt;/tt&amp;gt;.  Read the comments in &amp;lt;tt&amp;gt;PipeDefinition.cpp&amp;lt;/tt&amp;gt;, and the [[Programming_Reference:Filter_Chain]] wiki page, for more information about linking filters in a chain.&lt;br /&gt;
# Make sure your SignalSource module is started with the &amp;lt;tt&amp;gt;--LogMouse=1&amp;lt;/tt&amp;gt; flag (see the code snippet above).&lt;br /&gt;
# Set the &#039;&#039;&#039;Expressions&#039;&#039;&#039; parameter (found in the &#039;&#039;&#039;Filtering&#039;&#039;&#039; tab of the &#039;&#039;&#039;Config&#039;&#039;&#039; dialog) such that it has two rows and one column, and contains the expressions &amp;quot;MousePosX&amp;quot; and &amp;quot;MousePosY&amp;quot;.&lt;br /&gt;
# Write down a full description of how you think the SignalProcessing module will process the signal, from start to finish, and exactly how you expect it to respond to different kinds of mouse movement.&lt;br /&gt;
# Verify that the module behaves the way you expect, under all relevant input conditions.&lt;br /&gt;
&lt;br /&gt;
===Exercise 4:  Offline filter-chain reconstruction in Matlab===&lt;br /&gt;
&lt;br /&gt;
# Take one or more of the filters you have written (RMSFilter, DiffFilter), or create a new one which also does something whose numerical output can be checked very easily (examples: squaring the input signal, or doubling it, or taking the absolute value).&lt;br /&gt;
# Use NewBCI2000FilterTool to create a command-line &amp;quot;filter tool&amp;quot; executable as described above.&lt;br /&gt;
# Also ensure that the &amp;lt;tt&amp;gt;bci_dat2stream&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;bci_stream2mat&amp;lt;/tt&amp;gt; targets have been built.&lt;br /&gt;
# Learn how to use the matlab function [[User_Reference:Matlab_Tools|bci2000chain]]  and the supporting Matlab tools.&lt;br /&gt;
# Use &amp;lt;tt&amp;gt;bci2000chain&amp;lt;/tt&amp;gt; to run your filter on some example data, or even on some toy data that you create using &amp;lt;tt&amp;gt;create_bcidat&amp;lt;/tt&amp;gt;.  Then, separately, write a Matlab function for performing the same numerical operation that you believe your filter performs.  Compare the two outputs and verify that your filter does exactly what it is intended to do, at least to within some very small numerical tolerance. The maximum absolute difference between the two outputs should be very small (say, 1e-10 or less, depending on the operations and on the magnitude of the input signal).&lt;br /&gt;
&lt;br /&gt;
==Further reading==&lt;br /&gt;
&lt;br /&gt;
Refer to the main [[Programming_Reference:Contents]] page here on http://doc.bci2000.org for a list of topics on which you can find more in-depth documentation. In particular, you may wish to work through the various [[Programming_Reference:Contents#Tutorials|tutorials]] at the bottom of the page.&lt;/div&gt;</summary>
		<author><name>Boulay</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Howto:Quickstart_Guide&amp;diff=7339</id>
		<title>Programming Howto:Quickstart Guide</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Howto:Quickstart_Guide&amp;diff=7339"/>
		<updated>2014-04-01T16:17:17Z</updated>

		<summary type="html">&lt;p&gt;Boulay: /* Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial walks you through the process of obtaining the [[Programming_Reference:BCI2000_Source_Code|BCI2000 source distribution]], and using it to build and test your own custom [[BCI2000_Glossary#Filter|filters]], implemented in C++ inside your own custom [[BCI2000_Glossary#Core_Module|core module]]. It assumes that you have a good working knowledge of the C++ language,  and basic familiarity with the compiler/IDE that you are going to use.&lt;br /&gt;
&lt;br /&gt;
Many of the specific instructions below will assume that you are on a 32-bit Windows system, are using Microsoft&#039;s free &#039;&#039;&#039;Visual C++ 2010 Express&#039;&#039;&#039; compiler, and have checked out the BCI2000 distribution to a location &amp;lt;tt&amp;gt;C:\BCI2000\3.x&amp;lt;/tt&amp;gt; on your hard-drive. However, the same steps are valid for other supported setups, with the appropriate setup-specific changes.&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
===All Operating Systems===&lt;br /&gt;
# First, you need a complete BCI2000 distribution that includes the &amp;lt;tt&amp;gt;src&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt; directories. If you already have this, use SVN to make sure it is updated to a recent stable version (at least, for this tutorial to make sense, you will need revision 3279 or later / May 2011 or later).  If you do not already have the source distribution, here is how you obtain it:&lt;br /&gt;
## If you do not already have a [[Creating_a_User_Account|bci2000.org username]], get one [http://www.bci2000.org/GPL/ here].  Your password will be mailed to you.&lt;br /&gt;
## To download the BCI2000 source-code, you will need an SVN client. If you do not have one, for Windows we recommend TortoiseSVN, which can be downloaded [http://tortoisesvn.net/downloads.html here].  The BCI2000 wiki contains more documentation about how to [[Programming_Howto:SVN_Client_Setup|set up]] and [[Programming_Howto:Using_TortoiseSVN|use]] SVN.&lt;br /&gt;
## Use SVN, with your username and password, to check out the latest BCI2000 source-code-included distribution, the location of which is http://www.bci2000.org/svn/tags/releases/current (note this is the current release version, not the current source code -- for the current source code, check out from http://www.bci2000.org/svn/trunk). We will assume that you checked out to a location  &amp;lt;tt&amp;gt;C:\BCI2000\3.x&amp;lt;/tt&amp;gt;  on your hard-drive. Wherever you see this path below, adjust it so that it reflects the location you actually used. More information about the layout of the resulting distribution can be found [[Programming_Reference:BCI2000_Source_Code|here]].&lt;br /&gt;
# Next you will need to download and install CMake if you do not already have it (at least version 2.8.3 is recommended). CMake can be downloaded [http://www.cmake.org/cmake/resources/software.html here]. Make sure you select the option &#039;&#039;&#039;add to PATH for all users&#039;&#039;&#039; when installing.&lt;br /&gt;
# Finally you will need a C++ compiler. We will proceed on the assumption that you are on 32-bit Windows and using the free Visual C++ 2010 Express environment which can be downloaded [http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express here] (choose either the Visual C++ web-installer or, for something that can be installed offline, the option marked &amp;quot;Visual Studio 2010 Express All-in-One ISO&amp;quot; - this will give you an .iso file which can be mounted as a virtual drive using a tool like [http://www.slysoft.com/en/virtual-clonedrive.html Virtual Clone Drive]).  Consult the documentation for the [[Programming_Reference:Build_System|BCI2000 build system]] for information on other supported compilers, and more about CMake.&lt;br /&gt;
&lt;br /&gt;
You should now have everything you need in order to build and customize BCI2000.&lt;br /&gt;
&lt;br /&gt;
===Prerequisites (Linux)===&lt;br /&gt;
# C++ compiler&lt;br /&gt;
# Subversion&lt;br /&gt;
# CMake&lt;br /&gt;
# Qt libraries and header files (Qt-dev)&lt;br /&gt;
Then follow the &amp;quot;unix command-line equivalent&amp;quot; instructions from a terminal.&lt;br /&gt;
&lt;br /&gt;
===Prerequisites (OS X)===&lt;br /&gt;
# Apple&#039;s Developer Tools (includes a C/C++ compiler and Subversion)&lt;br /&gt;
# A [http://www.cmake.org/cmake/resources/software.html CMake binary installer] (&amp;lt;tt&amp;gt;.dmg&amp;lt;/tt&amp;gt; file) appropriate to your platform, version 2.8.3 or later.&lt;br /&gt;
# Qt libraries (You only need the libraries, not the full SDK.   We have performed successful builds with [ftp://ftp.qt.nokia.com/qt/source/qt-mac-opensource-4.7.2.dmg v4.7.2]. Your mileage may vary according to the version you use.)&lt;br /&gt;
Then follow the &amp;quot;unix command-line equivalent&amp;quot; instructions from the Terminal.app command-line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; CMake may be used to create an XCode project file for BCI2000, using the appropriate generator option. However, it seems that XCode builds of BCI2000 do not always succeed, even if there is no problem with Unix makefile builds on the same machine. Thus, you should always try a command-line build when building fails under XCode.&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~  # or wherever&lt;br /&gt;
 $ svn checkout http://www.bci2000.org/svn/trunk  bci2000   # (or call it whatever you want)&lt;br /&gt;
&lt;br /&gt;
==Setup==&lt;br /&gt;
&lt;br /&gt;
# Use CMake to build a project file.  This is done by going to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;  (which is the main workbench from which all build operations occur) and launching one of the &amp;quot;&amp;lt;tt&amp;gt;Make ... .bat&amp;lt;/tt&amp;gt;&amp;quot;  batch-files.  If you are using Visual C++ 2010 Express,  the appropriate batch file is &amp;lt;tt&amp;gt;Make VS10 Project Files.bat&amp;lt;/tt&amp;gt; .  It may ask you several questions: feel free to answer &amp;quot;y&amp;quot; to building the &amp;quot;tools&amp;quot;, &amp;quot;contrib&amp;quot; and &amp;quot;BCPy2000&amp;quot; components.  For now, for simplicity, you may wish to say no to framework extensions. Also say no to modules that require MFC (unless you are using a commercial version of Visual C++ Studio that includes MFC).  If successful, you should see a long list of sub-projects being created, and after several seconds of this, &amp;quot;Configuring done&amp;quot; followed by &amp;quot;Generating done&amp;quot;.&lt;br /&gt;
# Open the resulting solution file,  &amp;lt;tt&amp;gt;BCI2000.sln&amp;lt;/tt&amp;gt; , in Visual C++ Express. The file should be located in &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt; .&lt;br /&gt;
# Ensure that you are in &amp;quot;Release&amp;quot; mode rather than &amp;quot;Debug&amp;quot; (in Visual C++, this is a drop-down menu in a toolbar near the top)&lt;br /&gt;
# You probably do not need to build all of BCI2000 at once.   To use BCI2000, the minimum you will need consists of the Operator, plus at least one SignalSource module, at least one SignalProcessing module, and at least one Application module. To build a single module in Visual C++ Express, right-click on the module&#039;s name in the list on the left, and select &amp;quot;Build&amp;quot;.   The initial build will typically take a few minutes per module.  If you do not intend to modify a given module, you can always skip building it by copying the corresponding ready-built binary (for example, &amp;lt;tt&amp;gt;Operator.exe&amp;lt;/tt&amp;gt;)  from the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; subdirectory of a BCI2000 v.2 or v.3 [[BCI2000_Binaries|binary distribution]], and paste it into the corresponding directory of the distribution in which you are working, i.e. &amp;lt;tt&amp;gt;C:\BCI2000\3.x\prog&amp;lt;/tt&amp;gt; .  (To [http://bci2000.org/downloads/bin/BCI2000Setup.exe download the latest binary distribution], you will need to supply the same username and password that you used for SVN download.) Let&#039;s assume you have built, or copied, the following modules: &#039;&#039;&#039;SignalGenerator&#039;&#039;&#039;, &#039;&#039;&#039;SpectralSignalProcessing&#039;&#039;&#039;, &#039;&#039;&#039;CursorTask&#039;&#039;&#039; and &#039;&#039;&#039;Operator&#039;&#039;&#039;, as well as the necessary &#039;&#039;&#039;OperatorLib&#039;&#039;&#039; shared library.&lt;br /&gt;
# Build the &#039;&#039;&#039;NewBCI2000Module&#039;&#039;&#039;, &#039;&#039;&#039;NewBCI2000Filter&#039;&#039;&#039;  and &#039;&#039;&#039;NewBCI2000FilterTool&#039;&#039;&#039; targets for use in the subsequent steps.  The result will be new executables,  &amp;lt;tt&amp;gt;NewBCI2000Module.exe&amp;lt;/tt&amp;gt;,  &amp;lt;tt&amp;gt;NewBCI2000Filter.exe&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;NewBCI2000FilterTool.exe&amp;lt;/tt&amp;gt;,  in the &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make NewBCI2000Module NewBCI2000Filter NewBCI2000FilterTool&lt;br /&gt;
&lt;br /&gt;
==Creating a project for a new BCI2000 module, from a template==&lt;br /&gt;
&lt;br /&gt;
# Navigate to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Find &amp;lt;tt&amp;gt;NewBCI2000Module.exe&amp;lt;/tt&amp;gt; there, assuming you have already built it (see &amp;quot;Setup&amp;quot;, above).&lt;br /&gt;
# Launch it and answer the three questions it asks:&lt;br /&gt;
## What type of module are you creating? Enter &amp;quot;1&amp;quot; for a SignalSource module, &amp;quot;2&amp;quot; for a SignalProcessing module, or &amp;quot;3&amp;quot; for an Application module.&lt;br /&gt;
## What should be the name of the new module?  This should be single word, without spaces or punctuation (For example: &#039;&#039;&#039;VeryNiceSignalProcessing&#039;&#039;&#039;.  Or, at your option, something even more informative.) This name will be used as the name of a new directory that will contain the project source information, as well as for the resulting binary (&amp;lt;tt&amp;gt;.exe&amp;lt;/tt&amp;gt; file).&lt;br /&gt;
## Where (i.e. inside what parent directory) should the new project directory be created?   You can express this as a relative path, in which case it is interpreted relative to the &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt; directory where &amp;lt;tt&amp;gt;NewBCI2000Module.exe&amp;lt;/tt&amp;gt; itself is running.  To accept the default answer, which is &amp;lt;tt&amp;gt;..\src\custom&amp;lt;/tt&amp;gt;, just press return. This location (or some subdirectory of it) is a good choice: it maps to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\src\custom&amp;lt;/tt&amp;gt; which is an area reserved for your own projects.&lt;br /&gt;
# Now re-run CMake (see step 1 of &amp;quot;Setup&amp;quot;, above).  You should see your new project being added at the end of the long list of projects.  Re-open the project file (step 2 of &amp;quot;Setup&amp;quot;) and you should see it listed in the alphabetical list of projects.&lt;br /&gt;
# If you have just created a new SignalSource project,  a specialized source-acquisition filter (called an Analogue-to-Digital Converter or ADC) will already have been added to the project.  If your project was called &#039;&#039;&#039;Foo&#039;&#039;&#039;  or &#039;&#039;&#039;FooSource&#039;&#039;&#039;  this will be instantiated in files called &amp;lt;tt&amp;gt;FooADC.cpp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;FooADC.h&amp;lt;/tt&amp;gt;.  You can find this by expanding the tree (click on the plus sign) next to your project name in Visual C++.  Find the files under &amp;quot;Source&amp;quot; (or &amp;quot;Headers&amp;quot;) and then &amp;quot;Project&amp;quot;. Double-click them to edit.  You should already be able to compile the module: try it.&lt;br /&gt;
# If you have created a SignalProcessing or Application project,  you may be able to compile it, but it will not do anything until you add at least one filter to it (see next section).&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./NewBCI2000Module 2 VeryNiceSignalProcessing ../src/custom&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make VeryNiceSignalProcessing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Adding a new filter to a BCI2000 module, from a template==&lt;br /&gt;
&lt;br /&gt;
# Navigate to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Find &amp;lt;tt&amp;gt;NewBCI2000Filter.exe&amp;lt;/tt&amp;gt; there, assuming you have already built it (see &amp;quot;Setup&amp;quot;, above).&lt;br /&gt;
# Launch it and answer the three questions it asks:&lt;br /&gt;
## What type of filter are you creating?  Enter &amp;quot;1&amp;quot; for a subclass of [[Programming_Reference:BufferedADC_Class|BufferedADC]] (although if you created a SignalSource project with the NewBCI2000Module tool, an ADC of this kind will already have been created for you),  enter &amp;quot;2&amp;quot; for a subclass of [[Programming_Reference:GenericFilter_Class|GenericFilter]],  or &amp;quot;3&amp;quot; for a subclass of [[Programming_Reference:ApplicationBase_Class|ApplicationBase]].&lt;br /&gt;
## What should be the name of the filter class?  This should be a legal name for a new C++ class (no spaces or punctuation). If you enter, for example, &amp;quot;FooFilter&amp;quot;,  then a class of this name will be implemented in two new files, &amp;lt;tt&amp;gt;FooFilter.cpp&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;FooFilter.h&amp;lt;/tt&amp;gt; .&lt;br /&gt;
## To which project (i.e. in which project directory, relative to &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt;) should the filter be added?  For example:  &amp;lt;tt&amp;gt;..\src\custom\VeryNiceSignalProcessing&amp;lt;/tt&amp;gt;  (as in all of the BCI2000 framework, directory slashes are allowed to go this / way or that \ way regardless of whether you are on Windows or not)&lt;br /&gt;
# Again, re-run CMake and re-open the master project file.&lt;br /&gt;
# Find your new files under the Source/Project  and Headers/Project  trees by clicking on the + sign next to the project name. Double-click them to edit. Read the comments in the file for help as to how to flesh out the various filter methods.&lt;br /&gt;
# Try building the project (right-click on the project and select &amp;quot;build&amp;quot;).  SignalSource and Application projects may already build successfully.  SignalProcessing projects, or any project to which you have added a new GenericFilter subclass, will have at least one deliberate &#039;&#039;&#039;#error&#039;&#039;&#039; in the code.  When the build attempt finishes, double-click on the error message to go to the offending line. Read the comments in the file, and you will see that the error is there to force you to think about the ordering of the filters in your module.  Once you have resolved this issue, simply remove the #error line and select &amp;quot;build&amp;quot; again (the process will be quicker this time: only previously unbuilt files or newly modified files will be compiled).&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./NewBCI2000Filter 2 FooFilter ../src/custom/VeryNiceSignalProcessing&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make VeryNiceSignalProcessing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Running and testing the result==&lt;br /&gt;
&lt;br /&gt;
# Locate successfully built modules, which will appear as &amp;lt;tt&amp;gt;.exe&amp;lt;/tt&amp;gt; files inside the top-level &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory of the BCI2000 distribution,  for example &amp;lt;tt&amp;gt;C:\BCI2000\3.x\prog&amp;lt;/tt&amp;gt;&lt;br /&gt;
# The most basic way to launch BCI2000 is to double-click on each module in turn.  Start with &amp;lt;tt&amp;gt;Operator.exe&amp;lt;/tt&amp;gt;,  then launch one SignalSource module, one SignalProcessing module, and one Application module (your new module will fill one of these three roles, but all three are required).&lt;br /&gt;
# If you have a firewall running on your machine, dialogs may open for any modules that the firewall has never seen before. If so, click &amp;quot;unblock&amp;quot; to proceed, for each one. You should only ever need to do this once per newly-built module. (Check that your firewall is not configured to block network connections without telling you.)&lt;br /&gt;
# In the &#039;&#039;&#039;Config&#039;&#039;&#039; dialog, under the &#039;&#039;&#039;Visualize&#039;&#039;&#039; tab, you should see a check-box for visualizing the output of all the filters in the chain, including your newly created filter.  You may find it useful, whenever you are developing a new filter, to visualize your filter input and output simultaneously (i.e. visualize both the new filter and the filter that immediately precedes it in the chain).&lt;br /&gt;
&lt;br /&gt;
==Configuring your new filter for offline use==&lt;br /&gt;
&lt;br /&gt;
This is an optional step which many developers of new custom filters will find useful. Filters may be compiled singly as standalone executables to allow them to be tested and used for data analysis offline. The resulting &amp;quot;filter tools&amp;quot; can be used either [[User_Reference:Command_Line_Processing|from the DOS/Unix command-line]] or, more comfortably, [[User_Reference:Matlab_Tools|from the Matlab command-line]].&lt;br /&gt;
&lt;br /&gt;
# Navigate to &amp;lt;tt&amp;gt;C:\BCI2000\3.x\build&amp;lt;/tt&amp;gt;&lt;br /&gt;
# Find &amp;lt;tt&amp;gt;NewBCI2000FilterTool.exe&amp;lt;/tt&amp;gt; there, assuming you have already built it (see &amp;quot;Setup&amp;quot;, above).&lt;br /&gt;
# Launch it, and tell it which existing C++ file contains the filter definition (as always, specify the path relative to the &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt; directory—for example, &amp;lt;tt&amp;gt;..\src\custom\VeryNiceSignalProcessing\FooFilter.cpp&amp;lt;/tt&amp;gt;)&lt;br /&gt;
# The tool will perform for you the necessary alterations to the CMakeLists files.  (The procedure, details of which can be found [[User_Reference:Command_Line_Processing#Compiling_an_existing_filter_as_a_command_line_tool|here]], involves creating a subdirectory called &amp;lt;tt&amp;gt;cmdline&amp;lt;/tt&amp;gt; inside your project directory, because specifying a new executable target in the same &amp;lt;tt&amp;gt;CMakeLists.txt&amp;lt;/tt&amp;gt; file as your module would cause a misconfiguration problems for either the module or the filter-tool. )&lt;br /&gt;
# Close &amp;lt;tt&amp;gt;BCI2000.sln&amp;lt;/tt&amp;gt;, re-run CMake, and re-open &amp;lt;tt&amp;gt;BCI2000.sln&amp;lt;/tt&amp;gt;.   You should now have a new target, whose name is simply the name of the filter (e.g. &amp;lt;tt&amp;gt;FooFilter&amp;lt;/tt&amp;gt;).&lt;br /&gt;
# Right-click on the new target and select &amp;quot;build&amp;quot;.  The resulting binary will appear as (for example) &amp;lt;tt&amp;gt;..\tools\cmdline\FooFilter.exe&amp;lt;/tt&amp;gt;&lt;br /&gt;
# If you have Matlab, consult  [[User_Reference:Matlab_Tools]] to see how to proceed.   Otherwise see [[User_Reference:Command_Line_Processing]].  (In the Matlab version, the &amp;quot;Hello World&amp;quot; messages of the default template filter, and any other &amp;lt;tt&amp;gt;bciout&amp;lt;/tt&amp;gt; debugging outputs you specify, will appear in the &amp;lt;tt&amp;gt;.ShellOutput&amp;lt;/tt&amp;gt; field.)&lt;br /&gt;
&lt;br /&gt;
 Unix command-line equivalent:&lt;br /&gt;
 &lt;br /&gt;
 $ cd ~/bci2000  # or wherever&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ ./NewBCI2000FilterTool  ../src/custom/VeryNiceSignalProcessing/FooFilter.cpp&lt;br /&gt;
 $ ./Make\ Unix\ Makefiles.sh&lt;br /&gt;
 $ make FooFilter&lt;br /&gt;
 $ ../tools/cmdline/FooFilter --help&lt;br /&gt;
 $ make bci_dat2stream bci_stream2mat  # you&#039;ll also need these&lt;br /&gt;
&lt;br /&gt;
==Exercises==&lt;br /&gt;
&lt;br /&gt;
===Exercise 1:  RMSFilter===&lt;br /&gt;
&lt;br /&gt;
# Use NewBCI2000Module to create a new SignalProcessing module.&lt;br /&gt;
# Use NewBCI2000Filter to create a new filter called RMSFilter in your new module.&lt;br /&gt;
# NewBCI2000Module and NewBCI2000Filter report that they are creating and altering various files and directories.  Write down what you think is the purpose of each new directory, new file, or alteration to an existing file.&lt;br /&gt;
# Write a filter called RMSFilter, which takes in multiple signal channels, and outputs a single channel containing the root-mean-square signal across all input channels.  (Advanced variant:  introduce a parameter which allows the user to specify groups of channels; then output one RMS signal per group.) Test the filter using the [[User_Reference:SignalGeneratorADC|SignalGenerator module]] as an input, configuring the SignalGenerator to respond to mouse movement as described in the documentation.  First visualize just the &#039;&#039;&#039;input&#039;&#039;&#039; of your new filter (the output of the previous filter, which will presumably be the [[User_Reference:TransmissionFilter|TransmissionFilter]]).  Then draw on paper what you would expect to see as an output of your filter in response to different mouse positions/actions. Finally, visualize your filter&#039;s output in order to verify that it matches your expectations.&lt;br /&gt;
# Visualization allows you to test your code&#039;s behaviour qualitatively to some extent. In what various different ways could you verify, in a more precise, quantitative way, that your implementation is correct?  Under what circumstances should you spend the extra time to do this? (hint: the answer rhymes with &amp;quot;hallways&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===Exercise 2:  Debugging===&lt;br /&gt;
&lt;br /&gt;
# Write a batch file to launch your combination of modules.  You may wish to use one of the existing files in the top-level &amp;lt;tt&amp;gt;batch&amp;lt;/tt&amp;gt; directory as a template. A batch file will allow  you to go around each edit-compile-debug cycle much faster and more reliably. It will also allow you to pass useful command-line flags to the modules as you start them. And finally, if you need to set parameters in a certain way on each launch,  we strongly recommended that you take advantage of [[User_Reference:Operator_Module_Scripting#2|operator scripting]] in your batch file to ensure that the required parameters are loaded automatically from a file on each launch. Inconsistent behaviour from one debug cycle to the next can often be attributed to having forgotten to perform the menial task of loading parameters manually. &lt;br /&gt;
#  You can also use the Visual C++ debugger as follows:&lt;br /&gt;
## In your batch file, comment out or remove the line that launches the module you want to debug.&lt;br /&gt;
## Again in your batch file, assuming you are using the [[User_Reference:SignalGeneratorADC|SignalGenerator]], [[Contributions:FilePlayback|FilePlayback]], or some other source module which does not have to run in real-time, add the flag &amp;lt;code&amp;gt;--EvaluateTiming=0&amp;lt;/code&amp;gt; to the call that launches the source module (see example snippet below).  Putting a debug breakpoint in your Process() method will slow the system to below real-time, and we do not want the framework&#039;s real-time check to terminate the debug session for this reason.   &lt;br /&gt;
## Launch the batch file, thereby launching all the necessary modules except one, and loading any parameters needed for the debug session.&lt;br /&gt;
## Note that there are different &amp;quot;build modes&amp;quot; for the BCI2000 solution, with names like &amp;quot;Release&amp;quot; and &amp;quot;Debug&amp;quot;.   In order to debug  a particular module, you will need to ensure that the module is built in either &amp;quot;Debug&amp;quot; mode or &amp;quot;RelWithDebInfo&amp;quot; mode. If you are in the wrong mode for debugging, select the correct build mode from the drop-down menu on Visual C++ Express&#039;s toolbar, then build your module again.  Note that the BCPy2000 modules (&#039;&#039;PythonSource&#039;&#039;, &#039;&#039;PythonSignalProcessing&#039;&#039; and &#039;&#039;PythonApplication&#039;&#039;) cannot be built in Debug mode.  Also, [http://www.flounder.com/debug_release.htm Debug mode can sometimes mask dangerous bugs], so you may experience the frustration of trying to investigate a crash only for it to stop happening when you switch from Release to Debug. Finally, a BCI2000 module built in Debug mode may exhibit poorer timing performance. For these reasons it is not generally advisable to use Debug mode as the default mode of your project, and RelWithDebInfo is often advisable when debugging (even though the compiler optimizations may lead to a less logical-seeming debugging experience).&lt;br /&gt;
## In Visual C++, set a breakpoint in the source file you want to debug.&lt;br /&gt;
## Although CMake directs Visual C++ to create the module in the correct directory, &amp;lt;tt&amp;gt;C:\BCI2000\3.x\prog&amp;lt;/tt&amp;gt;, it is [http://www.cmake.org/Wiki/CMake_FAQ#Can_CMake_set_the_Debugging.2FWorking_Directory_property_in_Visual_Studio_projects.3F unable to set the working directory in which the debug instance runs] to the same value. Therefore, if your module needs to load resources like image or sound files, and expects to find these at the end of a path that is expressed &#039;&#039;relative&#039;&#039; to &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt;, you will need to set the &amp;lt;tt&amp;gt;prog&amp;lt;/tt&amp;gt; directory as the module&#039;s working directory by hand:  Right-click on the module -&amp;gt; Properties -&amp;gt; Configuration Properties -&amp;gt; Debugging -&amp;gt; Working Directory&lt;br /&gt;
## In Visual C++, right-click on the module, then select &amp;quot;Debug&amp;quot; followed by &amp;quot;Start New Instance&amp;quot; (if you find this too fiddly to do with the mouse, right-click, then press &amp;quot;g&amp;quot;, then press &amp;quot;s&amp;quot; ). If the build is not up-to-date, Visual Studio will prompt you:  in this case, allow it to build the module.&lt;br /&gt;
## You are now debugging BCI2000. Verify that the debugger stops your module at the breakpoint you specified and at the time that you expected.  Browse the available variables and their properties.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
start SignalGenerator.exe --LogMouse=1 --EvaluateTiming=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Exercise 3:  Assembling a filter chain===&lt;br /&gt;
&lt;br /&gt;
# Write a filter called DiffFilter, in which each output channel contains the numerical derivative, with respect to time, of the corresponding input channel. Note that your Process() method only sees one discrete chunk (or SampleBlock) of signal at a time.  Is this a problem? Use private member variables of your filter instance as a &amp;quot;scratch-pad&amp;quot; where necessary. &lt;br /&gt;
# Assemble the pre-existing [[User_Reference:ExpressionFilter|ExpressionFilter]],  followed by your DiffFilter, followed by your RMSFilter (from exercise 1), in that order within one SignalProcessing module.  The ExpressionFilter implementation is already part of the framework, so all you need to do is uncomment the &amp;lt;tt&amp;gt;#include&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;Filter()&amp;lt;/tt&amp;gt; statements that correspond to it in &amp;lt;tt&amp;gt;PipeDefinition.cpp&amp;lt;/tt&amp;gt;.  Read the comments in &amp;lt;tt&amp;gt;PipeDefinition.cpp&amp;lt;/tt&amp;gt;, and the [[Programming_Reference:Filter_Chain]] wiki page, for more information about linking filters in a chain.&lt;br /&gt;
# Make sure your SignalSource module is started with the &amp;lt;tt&amp;gt;--LogMouse=1&amp;lt;/tt&amp;gt; flag (see the code snippet above).&lt;br /&gt;
# Set the &#039;&#039;&#039;Expressions&#039;&#039;&#039; parameter (found in the &#039;&#039;&#039;Filtering&#039;&#039;&#039; tab of the &#039;&#039;&#039;Config&#039;&#039;&#039; dialog) such that it has two rows and one column, and contains the expressions &amp;quot;MousePosX&amp;quot; and &amp;quot;MousePosY&amp;quot;.&lt;br /&gt;
# Write down a full description of how you think the SignalProcessing module will process the signal, from start to finish, and exactly how you expect it to respond to different kinds of mouse movement.&lt;br /&gt;
# Verify that the module behaves the way you expect, under all relevant input conditions.&lt;br /&gt;
&lt;br /&gt;
===Exercise 4:  Offline filter-chain reconstruction in Matlab===&lt;br /&gt;
&lt;br /&gt;
# Take one or more of the filters you have written (RMSFilter, DiffFilter), or create a new one which also does something whose numerical output can be checked very easily (examples: squaring the input signal, or doubling it, or taking the absolute value).&lt;br /&gt;
# Use NewBCI2000FilterTool to create a command-line &amp;quot;filter tool&amp;quot; executable as described above.&lt;br /&gt;
# Also ensure that the &amp;lt;tt&amp;gt;bci_dat2stream&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;bci_stream2mat&amp;lt;/tt&amp;gt; targets have been built.&lt;br /&gt;
# Learn how to use the matlab function [[User_Reference:Matlab_Tools|bci2000chain]]  and the supporting Matlab tools.&lt;br /&gt;
# Use &amp;lt;tt&amp;gt;bci2000chain&amp;lt;/tt&amp;gt; to run your filter on some example data, or even on some toy data that you create using &amp;lt;tt&amp;gt;create_bcidat&amp;lt;/tt&amp;gt;.  Then, separately, write a Matlab function for performing the same numerical operation that you believe your filter performs.  Compare the two outputs and verify that your filter does exactly what it is intended to do, at least to within some very small numerical tolerance. The maximum absolute difference between the two outputs should be very small (say, 1e-10 or less, depending on the operations and on the magnitude of the input signal).&lt;br /&gt;
&lt;br /&gt;
==Further reading==&lt;br /&gt;
&lt;br /&gt;
Refer to the main [[Programming_Reference:Contents]] page here on http://doc.bci2000.org for a list of topics on which you can find more in-depth documentation. In particular, you may wish to work through the various [[Programming_Reference:Contents#Tutorials|tutorials]] at the bottom of the page.&lt;/div&gt;</summary>
		<author><name>Boulay</name></author>
	</entry>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:Building_BCI2000_for_Win64_(obsolete)&amp;diff=7180</id>
		<title>Programming Reference:Building BCI2000 for Win64 (obsolete)</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:Building_BCI2000_for_Win64_(obsolete)&amp;diff=7180"/>
		<updated>2013-03-20T01:07:26Z</updated>

		<summary type="html">&lt;p&gt;Boulay: /* Limitations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This information applies if you intend to build 64-bit executables. Alternatively, you may build 32-bit executables and run them on 64-bit platforms as well. In oder to build BCI2000 for the Win64 target, you will need to manually perform a number of steps.&lt;br /&gt;
==Install Qt for x64==&lt;br /&gt;
Rather than building BCI2000 against the Qt distribution coming with its source code, you will need to install a separate version of Qt on your machine.&lt;br /&gt;
The following steps have been tested with Qt 4.6.3, and should generally work with Qt 4.7.x as well.&lt;br /&gt;
&lt;br /&gt;
1. Download and install a recent SDK version of Qt.&lt;br /&gt;
&lt;br /&gt;
2. Add your Qt installation&#039;s qt/bin directory to the system search path.&lt;br /&gt;
&lt;br /&gt;
3. In the file &amp;lt;tt&amp;gt;qt/mkspecs/win32-msvc2008/qmake.conf&amp;lt;/tt&amp;gt;, or the corresponding file for MSVC2010, apply these changes: In QMAKE_CFLAGS_RELEASE and QMAKE_CFLAGS_DEBUG, replace the -MD and -MDd switches with -MT and -MTd, respectively.&lt;br /&gt;
&lt;br /&gt;
4. From the Start menu, open the Visual Studio x64 Command Prompt.&lt;br /&gt;
&lt;br /&gt;
5. &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to your Qt installation&#039;s qt directory, and execute the following command:&lt;br /&gt;
 configure -static&lt;br /&gt;
 -no-sql-sqlite&lt;br /&gt;
 -no-qt3support&lt;br /&gt;
 -fast &lt;br /&gt;
 -qt-zlib&lt;br /&gt;
 -qt-gif &lt;br /&gt;
 -qt-libpng &lt;br /&gt;
 -qt-libmng &lt;br /&gt;
 -no-libtiff &lt;br /&gt;
 -no-libjpeg &lt;br /&gt;
 -no-phonon &lt;br /&gt;
 -no-webkit &lt;br /&gt;
 -no-scripttools &lt;br /&gt;
 -no-style-plastique &lt;br /&gt;
 -no-style-motif &lt;br /&gt;
 -no-style-cde &lt;br /&gt;
&lt;br /&gt;
6. Compile the required parts of Qt by executing &amp;lt;tt&amp;gt;nmake&amp;lt;/tt&amp;gt; in these directories:&lt;br /&gt;
*&amp;lt;tt&amp;gt;qt/src/corelib&amp;lt;/tt&amp;gt;,&lt;br /&gt;
*&amp;lt;tt&amp;gt;qt/src/gui&amp;lt;/tt&amp;gt;,&lt;br /&gt;
*&amp;lt;tt&amp;gt;qt/src/winmain&amp;lt;/tt&amp;gt;,&lt;br /&gt;
*&amp;lt;tt&amp;gt;qt/src/opengl&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Generate the Visual Studio Solution file==&lt;br /&gt;
Edit the file &amp;lt;tt&amp;gt;build/cmake/FindQt.cmake&amp;lt;/tt&amp;gt; to read SET( USE_STD_QT TRUE ) in line 10.&lt;br /&gt;
&lt;br /&gt;
Then, from your BCI2000 installation&#039;s &amp;lt;tt&amp;gt;build&amp;lt;/tt&amp;gt; directory, execute the &amp;quot;Make VS2008 Win64 Project Files&amp;quot; batch file.&lt;br /&gt;
After successful execution, you will have a Visual Studio solution file ready to compile BCI2000.&lt;br /&gt;
&lt;br /&gt;
==Limitations==&lt;br /&gt;
*You cannot build BCI2000 modules that depend on 32-bit libraries, as do most source modules. Consider building 32-bit executables instead--these will run fine on Win64.&lt;br /&gt;
*Note that the g.USBamp source module comes with a 64-bit library, so it is supported natively on Win64.&lt;br /&gt;
*You cannot build x64 targets using Visual C++ 2008 Express Edition except after considerable [http://wiki.blender.org/index.php/Dev:2.5/Doc/Building_Blender/Windows/Visual_C%2B%2B_2008_Express unsupported modifications].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Programming Reference:Build System]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Framework API]][[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Boulay</name></author>
	</entry>
</feed>