BasicSynth Library

The complete source code to the BasicSynth library and example programs is available on sourceforge.net under the project name 'basicsynth.'

BasicSynth is a set of C++ libraries for sound generation and sequencing. The source distribution contains the source code to the libraries, example programs, summary documentation for the classes in each library, and a reference manual for the Notelist score language. Detailed description of the library is contained in the BasicSynth book.

Directory Structure


Directory structure

Directory

Usage

Bin

Executable images

Lib

Object file libraries

Include

Source include files. Much of the BasicSynth sound generation code is contained in these files

Documents

Various documents.

Doxygen Script to produce detailed documentation with Doxygen

Src

Source code

Src/Common

Common source, mostly implementation of sequencers and file I/O

Src/Instruments

Source to the BasicSynth instruments collection library.

Src/Notelist

Source to the notelist parser and interpreter library.

Src/Examples

Source to the example programs. Each sub-directory contains one example program. The theory and algorithm of each program is explained in the associated book chapter.

Src/Utilities

Source to the utility programs. Each sub-directory contains one utility program. These are Windows-only GUI programs that use the BasicSynth library and demonstrate various synthesis techniques.

BSynth

Command line version of the synthesizer.

To build your own synthesis program with BasicSynth you need at a minimum the Include files and the Common library (Lib/Common.lib). The Include directory and the Common library provide the sound generation, wave file and sequencer code. The header file BasicSynth.h includes all of the library.

If you want to use the BasicSynth instruments collection in your program, you must also include the header file Src/Instruments/Instruments.h and link the Lib/Instruments.lib library.

To include the Notelist score processor, you must include the header file NLConvert.h from the Src/Notelist directory and link the Lib/Notelist.lib library.

Note: Libraries on Linux have the .a extension instead of .lib

Reference documentation on the libraries is conatined in the Documents directory.

Building on MS-Windows

There are several solution files that can be built depending on what you want to do. All solution files are for Visual Studio 2008 (i.e. version 9). If you have a different version of the compiler, you will have to reproduce the project and/or solution files.

To build everything, use the solution file Src/BasicSynth.sln

To build just the libraries, use the solution files in Src/Common, Src/Instruments, and Src/Notelist directories.

To build the Example programs, use the solution file in Src/Examples. This builds all the example programs and libraries.

To build the utilities, use the solution file in Src/Utilities.

To build the stand-alone command line synthesizer, build the project in Src/BSynth.

Each project provides four targets:

  1. Release Win32 - 32-bit version without debug info.
  2. Debug Win32 - 32-bit version with debugging.
  3. Release x64 - 64-bit version without debug info.
  4. Debug x64 - 64-bit version with debug info.

Output of the 32-bit release version is in Bin and Lib. The 64-bit version produces output in Bin64 and Lib64


Building on Linux

There is a master Makefile located in the Src directory. This will build all of the system. There is also a Makefile in each directory that can be used if you only want to build part of the system. The file BasicSynth.cfg in the Src directory contains the settings for the compiler and linker. Edit this file to point to the appropriate places. Usually you will only need to change the location of BSDIR in case you put the source in a directory other than your home directory. By default, BasicSynth is built with XML support using the libxml2 library. You should install the libxml2-dev package first before building BasicSynth. If you do not need to use the project/instrument file loading code, there is a null implementation of the XmlWrapper class that can be used instead. The file is Src/Common/XmlWrapN.cpp and should be compiled and added to the Common library in place of XmlWrapU.cpp

Output is to the directories Bin and Lib under the BasicSynth install directory. (Note the capitalization!)

Note:I have noticed a problem with the GNU make that causes make to halt when descending three directory levels. Running make with the command line argument --no-print-directory fixes this.


Example Programs


Example01 (Chapter 5)

This example program shows a basic oscillator. It produces one second of a sin wave and writes the sound into the file Example01.wav

Example02 (Chapter 6)

These examples demonstrate envelope generators. Example02 has in-line code, Example02a uses the BasicSynth Library, Example02b uses a graphics line algorithm.

Example03 (Chapter 7)

Program to calculate complex waveforms.

  • summation of first 8 partials
  • sawtooth wave
  • inverse sawtooth wave
  • triangle wave
  • square wave
  • 25% pulse wave
  • frequency modulation
  • phase modulation
  • amplitude modulation
  • ring modulation
  • white noise

Example04 (Chapter 8)

Program to calculate complex waveforms using wavetable oscillators.

Example05 (Chapter 10)

Various filters, LP, HP, BP, Reson, using bi-quad filter; FIR and IIR averaging and convolution.

Example06 (Chapter 9)

Program to demonstrate mixing and panning.

Example07 (Chapter 11)

Using delay lines to implement echo.

Example07a (Chapter 12)

Using delay lines to implement reverb.

Examle07b (Chapter 13)

Using delay lines to implement Flanger/Chorus.

Example08 (Chapter 15)

BasicSynth sequencer.

Example09 (Chapter 16)

MIDI Sequencer.

Example10 (Chapters 19-25)

Synthesizer Instruments

  • Tone Generator
  • Additive Synthesis
  • Subtractive Synthesis
  • FM Synthesis (3 oscillators)
  • Matrix Synthesizer (8 oscillators, FM or Add)
  • Wavefile Playback

Utility Programs


Waveform Explorer

This program allows setting each of 16 partials to construct a complex waveform using the inverse Fourier transform (sum of sine waves). The resulting waveform can be saved to disk as a WAV file and as a graphic (EMF). Settings can be copied to the clipboard.

FM Explorer

This program implements a three oscillator FM synthesizer. Each oscillator is combined with an ADSR envelope generator. Several presets are available as examples. The program can save the sound to a WAV file. The settings can also be copied to the clipboard.

Reverb Explorer

This program implements a Schroeder reverb. The loop times and reverb time can be set from the program to hear how they affect the sound. Sounds can be internally generated or loaded from a WAV file. The processed sound can be saved to disk.

Flanger Explorer

This program implements a Flanger/Chorus effect. The delay times, modulation depth, and amplitudes can be set to hear how they affect the sound. Sounds can be internally generated or loaded from a WAV file. The processed sound can be saved to disk.


BSynth

This program is a complete synthesizer that runs from a command line. It takes one argument, the name of the project file to process.

BSynth project.xml

The documentation on this program gives the specification for the project file and other related files.


© 2008, Daniel R. Mitchell, All rights reserved except as noted below.

See more synthesis stuff at the BasicSynth Website

CC-GNU GPL
The BasicSynth library, instrument library, example and utility programs are licensed under the CC-GNU GPL.

Links:

Dan Mitchell's Personal Website