示例#1
0
static void op_midi_note_handler(op_midi_t* op_midi, u32 data) {
  static u8 com;
  static u8 ch, num, vel;
  op_midi_note_t* op = (op_midi_note_t*)(op_midi->sub);

  // check status byte  
  com = (data & 0xf0000000) >> 28; 
  if (com == 0x9) {
    if(op->chan < 0) {
      num = (data & 0xff0000) >> 16;
      vel = (data & 0xff00) >> 8;
      net_activate(op->outs[0], op_from_int(num), op);
      net_activate(op->outs[1], op_from_int(vel), op);
    } else {
示例#2
0
/// initialize
void op_metro_init(void* op) {
  op_metro_t* metro = (op_metro_t*)op;
  // operator superclass
  metro->super.numInputs = 3;
  metro->super.numOutputs = 1;
  metro->outs[0] = -1;
  // polled operator superclass
  metro->op_poll.handler = (poll_handler_t)(&op_metro_poll_handler);
  metro->op_poll.op = metro;
  metro->super.in_fn = op_metro_in_fn;
  // input value array
  metro->super.in_val = metro->in_val;
  metro->in_val[0] = &(metro->enable);
  metro->in_val[1] = &(metro->period);
  metro->in_val[2] = &(metro->value);

  // pickles
  metro->super.pickle = (op_pickle_fn)(&op_metro_pickle);
  metro->super.unpickle = (op_unpickle_fn)(&op_metro_unpickle);
  // output array
  metro->super.out = metro->outs;
  // strings
  metro->super.opString = op_metro_opstring;
  metro->super.inString = op_metro_instring;
  metro->super.outString = op_metro_outstring;
  // type
  metro->super.type = eOpMetro;
  /// state
  metro->period = op_from_int(125);
  metro->enable = 0;
  metro->value = OP_ONE;
  // timer (unlinked)
  metro->timer.next = NULL;
}
示例#3
0
/// initialize
void op_delay_init(void* op) {
  op_delay_t* delay = (op_delay_t*)op;
  // operator superclass
  delay->super.numInputs = 3;
  delay->super.numOutputs = 1;
  delay->outs[0] = -1;
  // polled operator superclass
  delay->op_poll.handler = (poll_handler_t)(&op_delay_poll_handler);
  delay->op_poll.op = delay;
  delay->super.in_fn = op_delay_in_fn;
  // input value array
  delay->super.in_val = delay->in_val;
  delay->in_val[0] = &(delay->val);
  delay->in_val[1] = &(delay->ms);
  delay->in_val[2] = &(delay->clear);

  // pickles
  delay->super.pickle = (op_pickle_fn)(&op_delay_pickle);
  delay->super.unpickle = (op_unpickle_fn)(&op_delay_unpickle);
  // output array
  delay->super.out = delay->outs;
  // strings
  delay->super.opString = op_delay_opstring;
  delay->super.inString = op_delay_instring;
  delay->super.outString = op_delay_outstring;
  // type
  delay->super.type = eOpDelay;
  /// state
  delay->ms = op_from_int(125);
  delay->clear = 0;
  delay->val = 0;
  // timer (unlinked)
  delay->timer.next = NULL;
}
示例#4
0
文件: op_enc.c 项目: botstein/aleph
void op_enc_sys_input(op_enc_t* enc, s8 v) {
  /* print_dbg("\r\n enc sys input, address: 0x"); */
  /* print_dbg_hex((u32)enc); */
  /* print_dbg(" , input value: 0x"); */
  /* print_dbg_hex((u32)v); */

  enc->val = op_add(enc->val, op_mul(enc->step, op_from_int(v)));
  op_enc_perform(enc);  
}
示例#5
0
文件: op_enc.c 项目: Someone101/aleph
void op_enc_sys_input(op_enc_t* enc, s8 v) {
  /* print_dbg("\r\n enc sys input, address: 0x"); */
  /* print_dbg_hex((u32)enc); */
  /* print_dbg(" , input value: 0x"); */
  /* print_dbg_hex((u32)v); */
  // use saturating add. have to explicitly check for "would-be overflow" in wrap mode with max val.
  //  enc->val = op_sadd(enc->val, op_mul(enc->step, op_from_int(v)));
  /// HACK: assuming the io_t is small enough t
  /// that we can void overflow by casting to 4 bytes.
  enc->val32 = (s32)(enc->val) + (s32)(op_mul(enc->step, op_from_int(v)));
  op_enc_perform(enc);  
}
示例#6
0
/// initialize
void op_screen_init(void* op) {
  op_screen_t* screen = (op_screen_t*)op;

  // superclass functions
  screen->super.in_fn = op_screen_in;
  screen->super.pickle = (op_pickle_fn) (&op_screen_pickle);
  screen->super.unpickle = (op_unpickle_fn) (&op_screen_unpickle);
    // polled operator superclass
  screen->op_poll.handler = (poll_handler_t)(&op_screen_poll_handler);
  screen->op_poll.op = screen;

  // superclass val
  screen->super.numInputs = 6;
  screen->super.numOutputs = 0;
 
  screen->super.in_val = screen->in_val;
  screen->in_val[0] = &(screen->enable);
  screen->in_val[1] = &(screen->period);
  screen->in_val[2] = &(screen->val);
  screen->in_val[3] = &(screen->fill);
  screen->in_val[4] = &(screen->x);
  screen->in_val[5] = &(screen->y);

  screen->super.out = screen->outs;
  screen->super.opString = op_screen_opstring;
  screen->super.inString = op_screen_instring;
  screen->super.outString = op_screen_outstring;
  screen->super.type = eOpScreen;

  // class val
  screen->enable = 0;
  screen->period = op_from_int(50);
  screen->val = 0xf;
  screen->fill = 0;
  screen->x = 0;
  screen->y = 0;

  // init graphics
  /*.. this is sort of retarded, 
  doing stuff normally accomplished in region_alloc() or in static init,
  but doing a dumb memory hack on it to share a tmp data space between instances.
  */  
  screen->reg.dirty = 0;
  screen->reg.x = 0;
  screen->reg.y = 0;
  screen->reg.w = OP_SCREEN_PX_W;
  screen->reg.h = OP_SCREEN_PX_H;
  screen->reg.len = OP_SCREEN_GFX_BYTES;
  screen->reg.data = (u8*) (screen->regData);

  region_fill(&(screen->reg), 0);
}
示例#7
0
/// initialize
void op_bignum_init(void* op) {
  op_bignum_t* bignum = (op_bignum_t*)op;

  // superclass functions
  bignum->super.in_fn = op_bignum_in;
  bignum->super.pickle = (op_pickle_fn) (&op_bignum_pickle);
  bignum->super.unpickle = (op_unpickle_fn) (&op_bignum_unpickle);
    // polled operator superclass
  bignum->op_poll.handler = (poll_handler_t)(&op_bignum_poll_handler);
  bignum->op_poll.op = bignum;

  // superclass val
  bignum->super.numInputs = 5;
  bignum->super.numOutputs = 0;
 
  bignum->super.in_val = bignum->in_val;
  bignum->in_val[0] = &(bignum->enable);
  bignum->in_val[1] = &(bignum->period);
  bignum->in_val[2] = &(bignum->val);
  bignum->in_val[3] = &(bignum->x);
  bignum->in_val[4] = &(bignum->y);

  bignum->super.out = bignum->outs;
  bignum->super.opString = op_bignum_opstring;
  bignum->super.inString = op_bignum_instring;
  bignum->super.outString = op_bignum_outstring;
  bignum->super.type = eOpBignum;

  // class val
  bignum->enable = 0;
  bignum->period = op_from_int(50);
  bignum->val = 0;
  bignum->x = 0;
  bignum->y = 0;

  // init graphics
  /*.. this is sort of retarded, 
  doing stuff normally accomplished in region_alloc() or in static init,
  but doing a dumb memory hack on it to share a tmp data space between instances.
  */  
  bignum->reg.dirty = 0;
  bignum->reg.x = 0;
  bignum->reg.y = 0;
  bignum->reg.w = OP_BIGNUM_PX_W;
  bignum->reg.h = OP_BIGNUM_PX_H;
  bignum->reg.len = OP_BIGNUM_GFX_BYTES;
  bignum->reg.data = (u8*) (bignum->regData);

  region_fill(&(bignum->reg), 0);
}
示例#8
0
//-------------------------------------------------
//----- extern function definition
void op_midi_cc_init(void* mem) {
  //  print_dbg("\r\n op_midi_cc_init ");
  op_midi_cc_t* op = (op_midi_cc_t*)mem;

  // superclass functions
  //--- op
  //  op->super.inc_fn = (op_inc_fn)op_midi_cc_inc_fn;
  op->super.in_fn = op_midi_cc_in_fn;
  op->super.pickle = (op_pickle_fn) (&op_midi_cc_pickle);
  op->super.unpickle = (op_unpickle_fn) (&op_midi_cc_unpickle);

  //--- midi
  op->midi.handler = (midi_handler_t)&op_midi_cc_handler;
  op->midi.sub = op;

  // superclass state

  op->super.type = eOpMidiCC;
  op->super.flags |= (1 << eOpFlagMidiIn);

  op->super.numInputs = 2;
  op->super.numOutputs = 1;

  op->super.in_val = op->in_val;
  op->super.out = op->outs;

  op->super.opString = op_midi_cc_opstring;
  op->super.inString = op_midi_cc_instring;
  op->super.outString = op_midi_cc_outstring;

  op->in_val[0] = &(op->chan);
  op->in_val[1] = &(op->num);
  op->outs[0] = -1;

  op->chan = op_from_int(-1);
  op->num = 0;

  net_midi_list_push(&(op->midi));
}
示例#9
0
文件: op_adc.c 项目: botstein/aleph
/// initialize
void op_adc_init(void* op) {
  op_adc_t* adc = (op_adc_t*)op;
  adc->super.numInputs = 2;
  adc->super.numOutputs = 4;

  adc->outs[0] = -1;
  adc->outs[1] = -1;
  adc->outs[2] = -1;
  adc->outs[3] = -1;
  // ui increment function
  adc->super.inc_fn = (op_inc_fn)op_adc_inc_fn;
  adc->super.in_fn = op_adc_in_fn;
  // input value array
  adc->super.in_val = adc->in_val;
  adc->in_val[0] = &(adc->enable);
  adc->in_val[1] = &(adc->period);

  // pickles
  adc->super.pickle = (op_pickle_fn)(&op_adc_pickle);
  adc->super.unpickle = (op_unpickle_fn)(&op_adc_unpickle);
  // output array
  adc->super.out = adc->outs;
  // strings
  adc->super.opString = op_adc_opstring;
  adc->super.inString = op_adc_instring;
  adc->super.outString = op_adc_outstring;
  // type
  adc->super.type = eOpAdc;
  adc->super.flags |= (1 << eOpFlagSys);

  /// state
  adc->val[0] = 0;
  adc->val[1] = 0;
  adc->val[2] = 0;
  adc->val[3] = 0;
  adc->period = op_from_int(20);
  adc->enable = 0;
}
示例#10
0
文件: op_enc.c 项目: Someone101/aleph
// perform wrapping and output
static void op_enc_perform(op_enc_t* enc) { 
  s32 wrap = 0;
  s32 dif = 0;

  /// FIXME: this 32-bit business is pretty foul stuff.
  s32 min32;
  s32 max32;
  if(enc->min < 0) {
    min32 = (s32)(enc->min) | 0xffff0000;
  } else {
    min32 = (s32)(enc->min);
  }
  if(enc->max < 0) {
    max32 = (s32)(enc->max) | 0xffff0000;
  } else {
    max32 = (s32)(enc->max);
  }
  
  /* /\* print_dbg("\r\n calculating enc output... min: 0x"); *\/ */
  /* /\* print_dbg_hex(min32); *\/ */
  /* /\* print_dbg(" , max: "); *\/ */
  /* /\* print_dbg_hex(max32); *\/ */
  /* /\* print_dbg(" , val: "); *\/ */
  /* /\* print_dbg_hex(enc->val32); *\/ */

  if (enc->wrap) { // wrapping...
    // if value needs wrapping, output the applied difference
    while (enc->val32 > max32) {

      print_dbg(" ... wrapping high... ");

      dif = min32 - max32;

      if(dif == 0) { dif = -1; }
      /* print_dbg(" , dif: "); */
      /* print_dbg_hex(dif); */

      wrap += dif;
      enc->val32 = enc->val32 + dif;

      /* print_dbg(" , new val: "); */
      /* print_dbg_hex(enc->val32); */

    }
    while (enc->val32 < min32) { 
      /* print_dbg(" ... wrapping low... "); */
      
      dif = max32 - min32;
      if(dif == 0) { dif = 1; }

      /* print_dbg(" , dif: "); */
      /* print_dbg_hex(dif); */


      wrap += dif;
      enc->val32 = enc->val32 + dif;

  /* print_dbg(" , new val: "); */
  /* print_dbg_hex(enc->val32); */

    }
    enc->val = op_from_int(enc->val32);
  } else { // saturating...
    if (enc->val32 > (s32)(enc->max)) {
      enc->val = enc->max;
      dif = 1; // force wrap output
    }
    else if (enc->val32 < (s32)(enc->min)) {
      enc->val = enc->min;
      dif = -1; // force wrap output
    } else {
      enc->val = op_from_int(enc->val32);
    }
  }

  // output the value
  net_activate(enc->outs[0], enc->val, enc);

  // output the wrap amount
  if (dif != 0) {
    net_activate(enc->outs[1], op_from_int(wrap), enc);  
  }
}
示例#11
0
/// initialize
void op_bars8_init(void* op) {
  op_bars8_t* bars8 = (op_bars8_t*)op;

  // superclass functions
  bars8->super.in_fn = op_bars8_in;
  bars8->super.pickle = (op_pickle_fn) (&op_bars8_pickle);
  bars8->super.unpickle = (op_unpickle_fn) (&op_bars8_unpickle);
    // polled operator superclass
  bars8->op_poll.handler = (poll_handler_t)(&op_bars8_poll_handler);
  bars8->op_poll.op = bars8;

  // superclass val
  bars8->super.numInputs = 11;
  bars8->super.numOutputs = 0;
 
  bars8->super.in_val = bars8->in_val;
  bars8->in_val[0] = &(bars8->enable);
  bars8->in_val[1] = &(bars8->period);
  bars8->in_val[2] = &(bars8->mode);
  bars8->in_val[3] = &(bars8->a);
  bars8->in_val[4] = &(bars8->b);
  bars8->in_val[5] = &(bars8->c);
  bars8->in_val[6] = &(bars8->d);
  bars8->in_val[7] = &(bars8->e);
  bars8->in_val[8] = &(bars8->f);
  bars8->in_val[9] = &(bars8->g);
  bars8->in_val[10] = &(bars8->h);

  bars8->super.out = bars8->outs;
  bars8->super.opString = op_bars8_opstring;
  bars8->super.inString = op_bars8_instring;
  bars8->super.outString = op_bars8_outstring;
  bars8->super.type = eOpBars8;

  // class val
  bars8->enable = 0;
  bars8->period = op_from_int(100);
  bars8->mode = 0;
  bars8->a = 0;
  bars8->b = 0;
  bars8->c = 0;
  bars8->d = 0;
  bars8->e = 0;
  bars8->f = 0;
  bars8->g = 0;
  bars8->h = 0;

  // init graphics
  /*.. this is sort of retarded, 
  doing stuff normally accomplished in region_alloc() or in static init,
  but doing a dumb memory hack on it to share a tmp data space between instances.
  */  
  bars8->reg.dirty = 0;
  bars8->reg.x = 0;
  bars8->reg.y = 0;
  bars8->reg.w = OP_BARS8_PX_W;
  bars8->reg.h = OP_BARS8_PX_H;
  bars8->reg.len = OP_BARS8_GFX_BYTES;
  bars8->reg.data = (u8*) (bars8->regData);

  region_fill(&(bars8->reg), 0);
}