octaveShift

octave shifter
Author: Johannes Taelman
License: BSD
Github: hug/math/octaveShift.axo

Inlets

bool32 up

bool32 down

Outlets

bool32 trig

frac32 a+1

Declaration
int _state;
bool _busy;
int _highthres = 6;
int _lowthres = -4;
int _delay;
bool _trig;
Init
_state = 0;
_busy = 0;
_delay = 0;
_trig = 0;
Control Rate
if (_busy == 0 && _delay > 1000) {
  if ((inlet_up == 1) && (_state + 1 < _highthres)) {
    if (inlet_down == 1) {
      _trig = 1;
    } else {
      _state = _state + 1;
      _busy = 1;
      _delay = 0;

      LogTextMessage("%d", _state);
    }
  }
  if ((inlet_down == 1) && (_state - 1 > _lowthres)) {
    _state = _state - 1;
    _busy = 1;
    _delay = 0;

    LogTextMessage("%d", _state);
  }

} else {
  if ((inlet_up == 0) && (inlet_down == 0)) {
    _busy = 0;
    _trig = 0;
  }
}
_delay++;
// outlet_result= inlet_a+((12*_state)<<21);
outlet_result = ((12 * _state) << 21);
outlet_trig = _trig;

Privacy

© 2024 Zrna Research