next up previous contents
Next: ox_desc: giving text feedback Up: ox_update: when parameter values Previous: ox_update: when parameter values

Great. But now what do I do with the data?

You might want to change the state of your machine. For instance, when you recieve a noteoff value in a note column, you may need to update a variable somewhere that says ``I'm no longer playing any notes on track x.''1.5

You might also want to scale1.6 the parameter data. For instance, OCTAL will display small tracker columns as two-digit hexadecimal numbers; while this makes it easy for the user to enter and edit the data, it's not likely that you'll be using a value from scaled 0x00 - 0xFE directly in DSP tasks. More often you'll need +/- 1.0 or something like that. You can use ox_update() to perform the scaling when a parameter changes1.7, storing the result in your state object if neccessary.

Here is the ox_update() function taken from the example square-wave plugin:

void ox_update(machine* m, int track, 
               int param_index, param value) 
{
  my_state *s = (my_state*)m->state; 
     
  switch(param_index) {

  case ix_note:
    s->pitch = m->pkg->note2freq(value); 
    if (value = noteoff) s->play = 0; 
    else s->play = 1; 

  case ix_vol:
    s->vol = ((float)value) / 255.0;    /* scale to 1.0 */   
  }
}



David O'Toole
2000-07-19