forked from localhost/bloopsaphone
/
bloopsaphone.h
126 lines (112 loc) · 3 KB
/
bloopsaphone.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//
// bloopsaphone.h
// the chiptune maker for portaudio
//
#ifndef BLOOPSAPHONE_H
#define BLOOPSAPHONE_H
#define BLOOPSAPHONE_VERSION "1.0"
#define BLOOPS_STOP 0
#define BLOOPS_PLAY 1
#define BLOOPS_MUTE 2
#define BLOOPS_SQUARE 0
#define BLOOPS_SAWTOOTH 1
#define BLOOPS_SINE 2
#define BLOOPS_NOISE 3
#define BLOOPS_FX_VOLUME 0
#define BLOOPS_FX_PUNCH 1
#define BLOOPS_FX_ATTACK 2
#define BLOOPS_FX_SUSTAIN 3
#define BLOOPS_FX_DECAY 4
#define BLOOPS_FX_SWEEP 5
#define BLOOPS_FX_SQUARE 6
#define BLOOPS_FX_VIBE 7
#define BLOOPS_FX_VSPEED 8
#define BLOOPS_FX_VDELAY 9
#define BLOOPS_FX_LPF 10
#define BLOOPS_FX_LSWEEP 11
#define BLOOPS_FX_RESONANCE 12
#define BLOOPS_FX_HPF 13
#define BLOOPS_FX_HSWEEP 14
#define BLOOPS_FX_ARP 15
#define BLOOPS_FX_ASPEED 16
#define BLOOPS_FX_PHASE 17
#define BLOOPS_FX_PSWEEP 18
#define BLOOPS_FX_REPEAT 19
#define BLOOPS_MAX_FX 19
typedef struct {
unsigned char type, pan;
float volume;
float punch;
float attack;
float sustain;
float decay;
float freq, limit, slide, dslide; // pitch
float square, sweep; // square wave
float vibe, vspeed, vdelay; // vibrato
float lpf, lsweep, resonance, hpf, hsweep;
// hi-pass, lo-pass
float arp, aspeed; // arpeggiator
float phase, psweep; // phaser
float repeat; // repeats?
} bloopsaphone;
#define BLOOPS_HI_OCTAVE 8
typedef struct {
unsigned char cmd;
unsigned char inc;
unsigned char dec;
float val;
struct bloopsafx *next;
} bloopsafx;
typedef struct {
char tone, octave, duration;
struct bloopsafx *FX;
} bloopsanote;
typedef struct {
bloopsaphone *P;
int nlen, capa;
bloopsanote *notes;
int frames, nextnote[2];
float volume, freq;
unsigned char playing;
int stage, time, length[3];
double period, maxperiod, slide, dslide;
float square, sweep;
int phase, iphase, phasex;
float fphase, dphase;
float phaser[1024];
float noise[32];
float filter[8];
float vibe, vspeed, vdelay;
int repeat, limit;
double arp;
int atime, alimit;
} bloopsatrack;
#define BLOOPS_MAX_TRACKS 64
typedef struct {
void *stream;
int tempo;
float volume;
bloopsatrack *tracks[BLOOPS_MAX_TRACKS];
unsigned char play;
} bloops;
//
// the api
//
bloops *bloops_new();
void bloops_destroy(bloops *);
bloopsaphone *bloops_square();
bloopsaphone *bloops_load(char *);
void bloops_clear(bloops *);
void bloops_tempo(bloops *, int tempo);
void bloops_track_at(bloops *, bloopsatrack *, int);
void bloops_track_destroy(bloopsatrack *);
void bloops_play(bloops *);
int bloops_is_done(bloops *);
bloopsatrack *bloops_track(bloops *, bloopsaphone *, char *, int);
bloopsatrack *bloops_track2(bloops *, bloopsaphone *, char *);
char *bloops_track_str(bloopsatrack *);
char *bloops_fxcmd_name(int);
float bloops_note_freq(char, int);
bloopsaphone *bloops_sound_file(bloops *, char *);
char *bloops_sound_str(bloops *, bloopsaphone *);
#endif