Introduction

Fra 8BitWiki

Skift til: Navigation, Søgning

Indholdsfortegnelse

Introduction

Csound

The following paragraph is a brief introduction to Csound. Further documentation can be found at csounds.com and wikipedia. If you don´t know Csound we recommend you reading the Wikipedia page as an introduction.

When programming Csound you write code, which is then interpreted by a compiler (Csound) and rendered either as live audio or to a sound file. A simple Csound code might look like this:

 <CsoundSynthesizer>;

   <CsOptions>
     csound -W -d -o tone.wav 
   </CsOptions>

   <CsInstruments>
     sr     = 44100           ; Sample rate.
     kr     = 4410            ; Control signal rate.
     ksmps  = 10              ; Samples pr. control signal.
     nchnls = 1               ; Number of output channels.

           instr 1  ;untitled
     iamp  = 	     10000            ; Amplitude
     ifreq = 	     440              ; Frequency
     kenv  linseg   0, 1, iamp, 1, 0  ; Amplitude envelope
     aout  vco2     kenv, ifreq       ; Oscillator
           out      aout              ; Output
           endin
   
   </CsInstruments>
   
   <CsScore>
     f1 0 8192 10 1           ; Table containing a sine wave.
     i1 0 1 20000 1000        ; Play one second of one kHz tone.
     e
   </CsScore>
  
 </CsoundSynthesizer>

The root element of a Csound file is <CsoundSynthesizer>, which marks the beginning of a complete csound synthesizer with all its instruments, its musical score and the compiler arguments. </CsoundSynthesizer> marks the end of the root element.

The <CsOptions> element contains the command-line arguments given to the Csound compiler. A complete alphabetic list of arguments can be found in the Csound Manual. Here is a direct link.

The <CsScore> element contains the musical score associated with the instruments given in <CsInstruments>.

The <CsInstruments> element contains a list of instruments. This program will mainly (if not only) be concerned about the creation of instruments.

; Semi-colon marks the beginning of a comment

Now let´s look at the above instrument. If we were to create this by visual means, it might look like this:Billede:Eksempel csound.gif
Each box represents a Csound opcode, where the opcode name is written at the top, its unique name in the bottom, its input arguments to the left and output arguments to the right.

Programming language and libraries

A few words about the language and library

The programming language choosen for this project is C++. Since Csound is an open-source platform independent program, this program should strive to accomodate the same properties. That means it is important for this project to be as platform independent as possible while still providing a consistent graphical user interface on the supported platforms. Therefore WxWidgets has been choosen as the GUI library for the project, since this library supports Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more. However, testing the program on all platforms will become a problem. I personally will be developing in a windows environment and will also be running tests in a Linux environment (Ubuntu).

Style guide

I think it might be a good idea to start out with a style guide. I don´t really know how other people work so this will be developed as needed. So for now, this is the style guide :D

1. Use indentation which can be altered to suit your style in most IDEs
2. Always use curly brackets, even for 1 line conditions.

IDE and library setup

I´m using Visual Studio 2008. I´m hoping to be using some other free program soon. Unfortunately I have not found one that I really liked working with. Anyway, as long as wxWidgets has been setup correctly its no problem using different IDEs.

This paragraph is written from memory and should not be seen as a setup walkthrough. There may well be errors, but in time (hopefully) this will become correct through editing by me and other people setting up their IDE.

Visual Studio 2008 setup

Visual Studio -> project -> properties -> configuration properties -> linker -> input -> Additional Dependencies:

Release:
wxmsw28_aui.lib
comctl32.lib
uuid.lib
rpcrt4.lib
advapi32.lib
wxbase28.lib
wxmsw28_core.lib
wxpng.lib
wxzlib.lib

Debug:
wxmsw28d_core.lib
wxbase28d.lib
wxmsw28d_adv.lib
wxmsw28d_aui.lib
wxtiffd.lib
wxjpegd.lib
wxpngd.lib
wxzlibd.lib
wxregexd.lib
wxexpatd.lib
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib

Visual Studio -> project -> properties -> configuration properties -> linker -> input -> System -> SubSystem:
Windows (/SUBSYSTEM:WINDOWS)

In Debug:
Visual Studio -> project -> properties -> configuration properties -> C++ -> preprocessor:
__WXDEBUG__

In Debug:
Visual Studio -> project -> properties -> configuration properties -> C++ -> Code generation -> Runtime Library:
Multi-threaded debug (Note: not DLL)

In Release:
Visual Studio -> project -> properties -> configuration properties -> C++ -> Code generation -> Runtime Library:
Multi-threaded (Note: not DLL)

WxWidgets Setup

Generally you should follow one of the setup tutorials found in the wxWidgets wiki. Other than that a few special setup parameters needs to be set before compiling the library.

In setup.h: Set wxUSE_MEMORY_TRACING to 1
Set wxUSE_DEBUG_CONTEXT to 1