8 #define GOAL (0.95 * (1 << 28))
11 #define BIGGER (1.5819767 * (1 << 28))
15 #define NOT_TOO_SMALL(x) MAX(x, 0.01)
17 #define KEYDOWN_HYSTERESIS 10
46 return -2.0 + 0.01 * (rand() % 400);
54 uint32_t
t = tune[tune_pointer++];
59 uint32_t type = tune[tune_pointer++];
60 uint32_t param = tune[tune_pointer++];
61 uint32_t value = tune[tune_pointer++];
87 const char *file,
const int line)
92 "%s(%d) ASSERTION FAILED: %s\n",
101 if (
empty())
return 1;
108 if (
full())
return 1;
116 for (i = 0; i < 100; i++)
132 v->
setfreq(261.6255653
f * pow(1.059463094359
f, pitch));
166 return (x + 0x800) & 0xFFF;
170 uint32_t i, j, found;
181 if (++i == num_voices) i = 0;
198 for (n = -50; n < 50; n++) {
200 if (pitch != n && old_voice == v) {
217 if (next_value >
GOAL) {
275 if (
phase < 0x80000000)
return (((int32_t)
phase) >> 20);
276 else return (((int32_t) phase) >> 20) - 4096;
280 switch (phase >> 30) {
282 return (phase >> 19);
284 return -(phase >> 19) + 4096;
286 return -(phase >> 19) + 4096;
288 return (phase >> 19) - 8192;
293 if (phase == 0)
return 0;
294 if (phase < 0x80000000)
return 0x7ff;
306 const int32_t m = 6 * 3.1415926 * (1 << 20) *
DT;
313 const float kmin = 0.1;
316 if (_fk < kmin) _fk = kmin;
317 _k = _fk * (1 << 16);
326 integrator1 =
clip(integrator1 + ((
w0dt *
u) >> 20));
361 if (_synth != NULL) {
367 if (_synth != NULL) {
IVoice * get_next_available_voice(int8_t pitch)
void compute_sample(void)
uint8_t read(uint32_t *x)
virtual bool idle(void)=0
virtual void keyup(int8_t pitch)=0
void assertion(int cond, const char *strcond, const char *file, const int line)
virtual void keydown(int8_t pitch)=0
uint32_t next_voice_to_assign
void use_synth_array(ISynth **s, uint8_t _num_synths)
#define KEYDOWN_HYSTERESIS
virtual void keydown(void)=0
uint32_t get_12_bit_value(void)
IVoice * assignments[100]
uint8_t play_tune(uint32_t *tune, uint32_t msecs)
virtual void step(void)=0
virtual void setfreq(float f)=0
virtual int32_t output(void)=0
uint8_t write(uint32_t x)
void use_read_key(uint8_t(*rk)(uint32_t))
void use_synth(uint8_t i)
uint8_t(* _read_key)(uint32_t)
void keydown(int8_t pitch)
Synthesizer modules and supporting functions.
virtual void keyup(void)=0
virtual void ioctl(uint32_t, uint32_t)=0