pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
mainpage.h
00001 /*
00002  -------------------------------------------------------------------------------
00003  This file is part of the Plink, Plonk, Plank libraries
00004  by Martin Robinson
00005  
00006  http://code.google.com/p/pl-nk/
00007  
00008  Copyright University of the West of England, Bristol 2011-14
00009  All rights reserved.
00010  
00011  Redistribution and use in source and binary forms, with or without
00012  modification, are permitted provided that the following conditions are met:
00013  
00014  * Redistributions of source code must retain the above copyright
00015    notice, this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright
00017    notice, this list of conditions and the following disclaimer in the
00018    documentation and/or other materials provided with the distribution.
00019  * Neither the name of University of the West of England, Bristol nor 
00020    the names of its contributors may be used to endorse or promote products
00021    derived from this software without specific prior written permission.
00022  
00023  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00026  DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF THE WEST OF ENGLAND, BRISTOL BE 
00027  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00028  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
00029  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00030  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00031  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
00032  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00033  
00034  This software makes use of third party libraries. For more information see:
00035  doc/license.txt included in the distribution.
00036  -------------------------------------------------------------------------------
00037  */
00038 
00086  /*
00087  The following assume the use of standard 32-bit floating point processing.
00088   
00089  The following class should act as pseudocode for the required operations needed to get
00090  basic synthesis working.
00091  
00092  @code
00093  #include "plonk/plonk.h"
00094  
00095  class TestPlonk
00096  {
00097  public:
00098     TestPlonk()
00099     {
00100     }
00101  
00102     // set up sample rate and block size and construct process graph
00103     void init (const double sampleRate, const int blockSize)
00104     {
00105         SampleRate::getDefault().setValue (sampleRate);
00106         BlockSize::getDefault().setValue (blockSize);
00107  
00108         graph = constructGraph();
00109     }
00110  
00111     // construct the graph of processing objects
00112     Unit constructGraph()
00113     {
00114         // just a 1kHz test tone at amplitude 0.25 (-12dB)
00115         return Sine::ar (1000, 0.25);
00116     }
00117  
00118     // assumes outputs is an array of pointers to output channel buffers
00119     void render (float** outputs, int numOutputs, int blockSize)
00120     {
00121         // update block size just in case it changed
00122         BlockSize::getDefault().setValue (blockSize);
00123  
00124         // process the graph 
00125         graph.process (info);
00126         
00127         // pull the data out of the root of the graph 
00128         for (i = 0; i < numOutputs; ++i)
00129         {
00130             float* const output = outputs[i];
00131             const float* const graphOutput = graph.getOutputSamples (i);
00132             Float1D::copyData (output, graphOutput, blockSize);            
00133         }
00134     }
00135  
00136  private:
00137     Unit graph;
00138     ProcessInfo info;
00139  };
00140  @endcode
00141  
00142  The following assumes you then have an instance of this @c TestPlonk class accessible
00143  to your code i.e., 
00144  
00145  @code
00146  ...
00147  TestPlonk testPlonk;
00148  ...
00149  @endcode
00150  
00151  Once you know the sample rate and processing block size for the system you're using you
00152  need to set these as the defaults in Plonk. E.g., if the sample rate is 44.1kHz using
00153  a block size of 512 samples you would need to use something like the following code
00154  before audio rendering starts (this is commonly available before starting an audio
00155  device driver running).
00156  
00157  @code
00158  ...
00159  testPlonk.init (44100.0, 512);
00160  ...
00161  @endcode
00162  
00163  Then you'd need to call the @c render() function for each block of audio requested
00164  by the audio device.
00165  
00166  @code
00167  ...
00168  testPlonk.render (outputs, numOutputs, blockSize);
00169  ...
00170  @endcode
00171  
00172  This assumes @c outputs is an array of pointers to floating point arrays of samples
00173  that are all @c blockSize in length. There should be @c numOutputs pointers in the
00174  @c outputs array.
00175 
00176 */
00177 
00178 
00179 /*
00180  cd libogg-1.3.0 
00181  
00182  ./configure 
00183  make clean
00184  make
00185  sudo make install
00186  
00187  cp /usr/local/lib/libogg.a libogg-x86_64.a
00188  cp /usr/local/lib/libogg.0.dylib libogg-x86_64.dylib 
00189  
00190  make clean
00191  make CC="gcc -m32"
00192  sudo make install
00193  
00194  cp /usr/local/lib/libogg.a libogg-i386.a
00195  cp /usr/local/lib/libogg.0.dylib libogg-i386.dylib 
00196  
00197  sudo rm /usr/local/lib/libogg.a
00198  sudo rm /usr/local/lib/libogg.0.dylib
00199  sudo lipo -create libogg-i386.a libogg-x86_64.a -output /usr/local/lib/libogg.a
00200  sudo lipo -create libogg-i386.dylib libogg-x86_64.dylib -output /usr/local/lib/libogg.0.dylib
00201  */
00202 
00203 /*
00204  cd libvorbis-1.3.3 
00205  ./configure
00206  make clean
00207  make CC="clang -arch x86_64"
00208  sudo make install
00209  
00210  cp /usr/local/lib/libvorbisenc.2.dylib libvorbisenc-x86_64.dylib 
00211  cp /usr/local/lib/libvorbisfile.3.dylib libvorbisfile-x86_64.dylib 
00212  cp /usr/local/lib/libvorbis.0.dylib libvorbis-x86_64.dylib 
00213  
00214  make clean
00215  make CC="clang -arch i386"
00216  sudo make install
00217  
00218  cp /usr/local/lib/libvorbisenc.2.dylib libvorbisenc-i386.dylib 
00219  cp /usr/local/lib/libvorbisfile.3.dylib libvorbisfile-i386.dylib 
00220  cp /usr/local/lib/libvorbis.0.dylib libvorbis-i386.dylib 
00221  
00222  sudo rm /usr/local/lib/libvorbisenc.2.dylib
00223  sudo rm /usr/local/lib/libvorbisfile.3.dylib
00224  sudo rm /usr/local/lib/libvorbis.0.dylib
00225  
00226  sudo lipo -create libvorbisenc-i386.dylib libvorbisenc-x86_64.dylib -output /usr/local/lib/libvorbisenc.2.dylib
00227  sudo lipo -create libvorbisfile-i386.dylib libvorbisfile-x86_64.dylib -output /usr/local/lib/libvorbisfile.3.dylib
00228  sudo lipo -create libvorbis-i386.dylib libvorbis-x86_64.dylib -output /usr/local/lib/libvorbis.0.dylib
00229 */
 All Classes Functions Typedefs Enumerations Enumerator Properties