Presentation is loading. Please wait.

Presentation is loading. Please wait.

Csound. a language for describing sound. General History. Developed by Barry Vercoe at MIT. Extended by too many people to mention. Based initially on.

Similar presentations


Presentation on theme: "Csound. a language for describing sound. General History. Developed by Barry Vercoe at MIT. Extended by too many people to mention. Based initially on."— Presentation transcript:

1 Csound. a language for describing sound

2 General History. Developed by Barry Vercoe at MIT. Extended by too many people to mention. Based initially on work done by Vercoe and Max Matthews for creating music on IBM 7094 and 360 machines. –These first programs were written in assembler, and CSound has retained the overall flavor of assembler code in its style. The name CSound comes from the ‘rendterpreter’ being implemented in the C programming language.

3 Rendterpreter? CSound source files are interpreted, then rendered. –The language utilizes variables and function definitions that can only be evaluated at runtime, and also allows real-time interaction through MIDI; thus it is interpreted. –However, the output of CSound source files is always sound; after variables and functions are bound, the source is carried to an intermediate form, from which it is written into pulse code modulation audio data (either directly to a file or into system- specific audio API)

4 General Structure Every CSound program can be broken down into the orchestra file and the score file. –by convention, these use.orc and.sco extensions –the orchestra file contains all the instruments; the score file contains how and when to play them. Each file type has a fairly well-defined structure using opcode-type primitives and methods. –For example, the orchestra header ALWAYS begins with something of the form: sr = 44100 kr = 4410 ksmps = 10 nchnls = 2 sr => sampling rate for audio kr => control rate ksmps => sr / kr nchlns => number of audio channels

5 Opcodes. CSound modules, or opcodes, are just like assembler opcodes: a base function with white-space delimited arguments. e.g. foscil1000044011.581 CSound also uses ‘GEN functions’ to create datatables for opcodes; these routines generate everything from simple sines/cosines to Blackman-Harris windows, used in spectrum analysis e.g. f3 0 4097 20 2 1 generates a Hanning window of with max value 1.

6 Binding, Scoping, Parameters, Oh my... Binding is really irrelevant in Csound; there are no procedures Scoping: variables can be scoped either: – within a single instrument An instrument has a block structure: instr 107 a1 oscil p4, p5, p6 out a1 endin –within a score/orchestra file combination (referred to as ‘global’) All parameters are passed by value; the mechanism is by simply placing a numeric value or variable name in the appropriate ‘p- field’ (analogous to a register argument in assembler), e.g. p4 through p6 above. All variables in CSound must begin with one of the letters a, d, k, i, w, x, or z. (making them feel even more like registers....)

7 So why the hell would anyone want to go to all that trouble? It’s free. It’s limitless in terms of the noises one can make. It’s available for almost every platform. Many, many development environments are available (e.g., integration into MAX/MSP) Online documentation is exhaustive (think: the Java API on the Sun site) The language has had excellent longevity and keeps getting better, with a richer set of built-in features and opcodes. Highly efficient; speed is directly related to complexity.

8 However... Code is not very readable / maintainable compared to most ‘real’ programming languages (it’s a lot less like spoken English) The learning curve is pretty steep Its control flow is fairly limited; conditionals have to be implemented in a manner somewhat akin to gates on a circuit Aside from blatant syntax errors, debugging messages occur entirely between ears and brain.

9 A small example. ; me999.orc ; simple buzz instrument— sr = 44100 kr = 4410 ksmps = 10 nchnls = 1 instr 109 a1 buzz p4, p5, p6, p7 out a1 endin

10 A small example, cont. ; me999.sco – score for buzz instrument ;FUNCTION 1 USES THE GEN10 SUBROUTINE TO COMPUTE A SINE WAVE ;FUNCTION 2 USES THE GEN10 SUBROUTINE BUT SPECIFIES AMPLITUDES ;OF THE FIRST 12 PARTIALS f1 0 4096 10 1 f2 0 4096 10 1.5.323.25.3.189.142.125.111.1.09.107 ;bass i10900.971600440251 i109111600330221 i109211600256201 i109311600329.6181 ;alto i10900.216001245101 i1090.20.2160062781 i1090.40.2160056851 i1090.60.2160066071 i1090.80.21600124551 i10910.216001345101 i1091.20.2160072781 i1091.40.2160066851 i1091.60.2160066071 i1091.80.21600124551...

11 Demos and Resources me999.orcand me999.sco render to: me999.wav A much bigger example: –shortyorc.txt and shortyscore.txt render to: shorty.wavshortyorc.txt shortyscore.txt shorty.wav using a MIDI keyboard and controller: ambientsong.mp3 The Csound website: www.csound.orgwww.csound.org The Online Csound Manual: –http://www.lakewoodsound.com/csound/hypertext/manual.htmhttp://www.lakewoodsound.com/csound/hypertext/manual.htm


Download ppt "Csound. a language for describing sound. General History. Developed by Barry Vercoe at MIT. Extended by too many people to mention. Based initially on."

Similar presentations


Ads by Google