Created
April 29, 2012 14:02
-
-
Save jacobjoaquin/2550583 to your computer and use it in GitHub Desktop.
first Csound opcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "csdl.h" | |
#include "jakesine.h" | |
int jakesine_init (CSOUND *csound, JAKESINE *p) | |
{ | |
p->inc = *p->freq_in * csound->tpidsr; | |
p->phase = *p->phase_in * TWOPI; | |
return OK; | |
} | |
int jakesine_perf (CSOUND *csound, JAKESINE *p) | |
{ | |
int n = csound->ksmps; | |
MYFLT *audio = p->audio_out; | |
MYFLT amp = *p->amp_in; | |
MYFLT *phase = &p->phase; | |
MYFLT inc = p->inc; | |
do { | |
*audio++ = amp * sin(*phase); | |
*phase += inc; | |
} while (--n); | |
return OK; | |
} | |
static OENTRY localops[] = { | |
{"jakesine", sizeof(JAKESINE), 5, "a", "iii", (SUBR)jakesine_init, (SUBR)NULL, (SUBR)jakesine_perf}, | |
}; | |
LINKAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "csdl.h" | |
typedef struct | |
{ | |
OPDS h; | |
MYFLT *audio_out, *amp_in, *freq_in, *phase_in; | |
MYFLT inc, phase; | |
} JAKESINE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment