usynth

simple midi synth for sndio
git clone git://nsmpr.xyz/usynth.git
Log | Files | Refs

operator.c (266B)


      1 #include <stdio.h>
      2 #include <stdint.h>
      3 #include "operator.h"
      4 
      5 int16_t
      6 op_fetch(struct op_state *op, size_t dp, int16_t mod)
      7 {
      8 	uint8_t pos;
      9 	op->p += dp * op->conf.freq_multiplier;
     10 	pos = (mod + op->p) >> 8;
     11 	return op->conf.waveform[pos] * op->conf.gain / 0xff;
     12 }
     13