next up previous contents
Next: ox_track: when the user Up: Setting up your callbacks Previous: Great. But now what

ox_desc: giving text feedback

void ox_desc(char* dest, int which_param, param value)

The user needs to know something about how a machine interprets numbers. So, in addition to the simple naming and description of parameters discussed in 1.3, the OX_API supports ``live'' parameter feedback from the machines. When the musician tweaks a slider or spin button on your machine, Octal calls ox_desc()1.8 with the location of the buffer where you should write the string, the index number of the parameter being tweaked, and the new value. Your job is to make up a string describing the ``interpreted version'' of the new value; for instance, if the range 0x00 - 0xFE is interpreted as a percentage, the following code will write a string describing the new value into the location pointed to by dest. OCTAL might then display this string onscreen.

float x;
int percent;
...
switch(which_param) {
  
  case ix_feedback:
    x = ((float)value) / 255.0; 
    percent = (int)(x*100);
    sprintf(dest, "%d%%", percent);
    break;

  case ix_vol: 
    
    ...

It isn't safe to assume that the host's calls to ox_desc() will ``pair up'' with parameter changes. While this will often be true, sometimes there will be no connection between calls. For instance, to fill a ``listbox'' style control with five or six options, OCTAL will query ox_desc() for each choice and retrieve a string to display for each item in the box.

You can use C's enum facility to create a set of unique indices, and then switch on the value passed to you during ox_desc(), in each case returning the string you would like to have appear in the interface. This indexing strategy is like the one used for parameters themselves.


next up previous contents
Next: ox_track: when the user Up: Setting up your callbacks Previous: Great. But now what
David O'Toole
2000-07-19