Esempio n. 1
0
void voice_update(struct Voice *v) {
  if (v->volume > 0) {//voice is on
    v->ticks++;
    switch (v->adsr_phase) {
      case 1:
        if (v->volume >= v->velocity) {
          v->adsr_phase = 2;
        } else {
          handle_increase(v->attack, v);
        }
        break;
      case 2:
        if (v->volume <= v->velocity * v->decay / 0xFF) {
          v->adsr_phase = 3;
        } else {
          handle_decrease(v->attack, v);
        }
        break;
      case 3: //sustain
        handle_decrease(v->sustain, v);
        break;
      case 4: //release
        handle_decrease(v->rel, v);
        break;
    }

    if (v->volume > UINT16_MAX) {
      v->volume = UINT16_MAX;
    }
    if (v->volume < 0) {
      v->volume = 0;
    }
  }
}
Esempio n. 2
0
void spicker::handle_left(image *screen, InputManager *inm)
{
  if (!vert)
    handle_decrease(screen, inm);
}