Tutorial 4
F-tables and oscillators
In this tutorial we'll start moving
the objects we create on the openGL window. We will do this by means
of an oscillator. An oscillator is a 'device' that repeats a pattern
repeatedly. In synths oscillators repeat some kind of wave shape
(sine, square, saw, etc.). In Csound, oscillators can repeat any kind
of shape, whether a mathematical function, a sound file, or curves
connecting points. This shape an oscillator uses, is stored within
Csound in an f-table (or function table). As you'll see below, an
oscillator will use the f-table to 'oscillate' at a given frequency,
but let's start to make it more clear...
<CsoundSynthesizer>
<CsOptions>
-+Y
</CsOptions>
<CsInstruments>
#include "OpenGL.h"
sr=100
kr =100
ksmps=1
nchnls=1
GLfps 30
GLpanel "OpenGL panel",
512, 512
GLpanel_end
FLrun
glMatrixMode $GL_PROJECTION
glLoadIdentity
gluPerspective 60,0.1,100
glMatrixMode $GL_MODELVIEW
GLinsert_i $GL_NOT_VALID
glClear $GL_COLOR_BUFFER_BIT
+ $GL_DEPTH_BUFFER_BIT
GLinsert_i 1.1
gisine ftgen 1,0,1024,10,1
instr 1
iframes = p4
irotate = p5
glLoadIdentity
trot GLoscil 1,iframes,1
glRotate irotate,0,0,1
glTranslate 0,trot+1,-5
glBegin $GL_QUADS
glColor 0,0,1,1
glVertex3 0,0,0
glVertex3 0,1,0
glColor 1,0,1,1
glVertex3 1,1,0
glColor 0,1,1,1
glVertex3 1,0,0
glEnd
GLinsert 1.5
endin
</CsInstruments>
<CsScore>
i 1 2 14 60 0
i 1 4 12 90 90
i 1 6 10 120 180
i 1 8 8 150 270
i 1 18 12 60 45
i 1 18 12 90 135
i 1 18 12 120 225
i 1 18 12 150 315
</CsScore>
</CsoundSynthesizer>
This
is tutorial 4. Experiment with different colours, shapes and rotation
values. Read about f-tables and GEN routines on the csound manual.
NOTES:
Apart
from the instruction ftgen, you can also create f-tables from
the score using the 'f' command. The latter is the more traditional
one, but I've chosen ftgen for the tutorial because it seems
more logical to see the creation of the f-table above the use of the
oscillator.
As
in GLoscil and ftgen, most csound opcodes use
parameters on the right and results on the left.
Back
to OpenGL Tutorials Index