3 various software synths and samples
5 Copyright (C) 2009 Evan Rinehart
7 This software comes with no warranty.
8 1. This software can be used for any purpose, good or evil.
9 2. Modifications must retain this license, at least in spirit.
15 #include <audio.h> /* to have SAMPLE_RATE */
19 instrument
make_cool() {
28 float note2f(int note
){
29 return 440*3.14159*2*pow(2, note
/12.0)/SAMPLE_RATE
;
38 void foo_mix(void* data
, float out
[], int count
){
39 struct foo
* foo
= data
;
42 if(foo
->on
== 0) return;
44 for(i
=0; i
<count
; i
++){
45 out
[i
] += sin(foo
->t
);
47 while(foo
->t
> 2*3.14159){
53 void foo_control(void* data
, int type
, int val1
, int val2
, int val
){
54 struct foo
* foo
= data
;
56 case 0: foo
->on
= 1; break;
57 case 2: foo
->on
= 0; break;
58 case 1: foo
->f
= note2f(val1
); break;
62 void foo_cleanup(void* data
){ free(data
); }
64 instrument
make_foo(){
67 ins
.control
= foo_control
;
68 ins
.cleanup
= foo_cleanup
;
69 ins
.data
= malloc(sizeof(struct foo
));
73 instrument
load_instrument(enum instrument_name name
){
75 case ORG_FOO
: return make_foo();
76 case ORG_COOL
: return make_cool();
77 default: return make_foo();