66 lines · 1.3 KB · Text
RawDownload
#+TITLE: GEN routines* OverviewThis document outlines a set of useful GEN routines.* What exactly is a GEN routine?A GEN routine is used to describe a function that workson table (a =SKFLT= array in C). These are usually used togenerate wavetables. The term "GEN routine" (yes, all caps), is borrowed fromCsound and MUSIC-N languages as[[http://www.csounds.com/manual/html/ScoreGenRef.html][GENerators for function tables]],affectionately referred to as "f-tables", which areessentially just "tables" in the sndkit world.* Tangled Files=gen.c= and =gen.h=. #+NAME: gen.h#+BEGIN_SRC c :tangle gen.h#ifndef SK_GEN_SINE#define SK_GEN_SINE #ifndef SKFLT#define SKFLT float#endif <<funcdefs>>#endif#+END_SRC #+NAME: gen.c#+BEGIN_SRC c :tangle gen.c#include <math.h>#include <stddef.h>#include "gen.h" #ifndef M_PI#define M_PI 3.14159265358979323846#endif <<funcs>>#+END_SRC* sine wave tableThe function =sk_gen_sine= generates a sampled periodof a sine wave. #+NAME: funcdefs#+BEGIN_SRC cvoid sk_gen_sine(SKFLT *tab, unsigned long sz);#+END_SRC #+NAME: funcs#+BEGIN_SRC cvoid sk_gen_sine(SKFLT *tab, unsigned long sz){    int i;    SKFLT step;     if (sz <= 0) return;     step = 2 * M_PI / sz;     for (i = 0; i < sz; i++) {        tab[i] = sin(i * step);    }}#+END_SRC

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t