Logo Search packages:      
Sourcecode: csound version File versions  Download package

PUBLIC int csoundSetControlChannelParams ( CSOUND *  csound,
const char *  name,
int  type,
MYFLT  dflt,
MYFLT  min,
MYFLT  max 
)

Sets special parameters for a control channel. The parameters are: type: must be one of CSOUND_CONTROL_CHANNEL_INT, CSOUND_CONTROL_CHANNEL_LIN, or CSOUND_CONTROL_CHANNEL_EXP for integer, linear, or exponential channel data, respectively, or zero to delete any previously assigned parameter information dflt: the control value that is assumed to be the default, should be greater than or equal to 'min', and less than or equal to 'max' min: the minimum value expected; if the control type is exponential, it must be non-zero max: the maximum value expected, should be greater than 'min'; if the control type is exponential, it must be non-zero and match the sign of 'min' Returns zero on success, or a non-zero error code on failure: CSOUND_ERROR: the channel does not exist, is not a control channel, or the specified parameters are invalid CSOUND_MEMORY: could not allocate memory

Definition at line 719 of file bus.c.

References CSOUND_CONTROL_CHANNEL, and csoundSetControlChannelParams().

Referenced by csoundSetControlChannelParams().

{
    channelEntry_t  *pp;

    if (UNLIKELY(name == NULL))
      return CSOUND_ERROR;
    pp = find_channel(csound, name);
    if (UNLIKELY(pp == NULL))
      return CSOUND_ERROR;
    if (UNLIKELY((pp->type & CSOUND_CHANNEL_TYPE_MASK) != CSOUND_CONTROL_CHANNEL))
      return CSOUND_ERROR;
    if (!type) {
      if (pp->info != NULL) {
        free((void*) pp->info);
        pp->info = NULL;
      }
      return CSOUND_SUCCESS;
    }
    switch (type) {
    case CSOUND_CONTROL_CHANNEL_INT:
      dflt = (MYFLT) ((int32) MYFLT2LRND(dflt));
      min  = (MYFLT) ((int32) MYFLT2LRND(min));
      max  = (MYFLT) ((int32) MYFLT2LRND(max));
      break;
    case CSOUND_CONTROL_CHANNEL_LIN:
    case CSOUND_CONTROL_CHANNEL_EXP:
      break;
    default:
      return CSOUND_ERROR;
    }
    if (UNLIKELY(min >= max || dflt < min || dflt > max ||
                 (type == CSOUND_CONTROL_CHANNEL_EXP && ((min * max) <= FL(0.0)))))
      return CSOUND_ERROR;
    if (pp->info == NULL) {
      pp->info = (controlChannelInfo_t*) malloc(sizeof(controlChannelInfo_t));
      if (UNLIKELY(pp->info == NULL))
        return CSOUND_MEMORY;
    }
    pp->info->type = type;
    pp->info->dflt = dflt;
    pp->info->min  = min;
    pp->info->max  = max;
    return CSOUND_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index