コード例 #1
0
ファイル: krad_mixer.c プロジェクト: imclab/krad_radio
static int krad_mixer_process (uint32_t nframes, krad_mixer_t *krad_mixer) {
  
  int p, m;
  void *client;
  
  client = NULL;
  krad_mixer_portgroup_t *portgroup = NULL;
  krad_mixer_portgroup_t *mixbus = NULL;
  krad_mixer_crossfade_group_t *crossfade_group = NULL;

  krad_mixer_update_portgroups (krad_mixer);

  if (krad_mixer->push_tone != NULL) {
    krad_tone_add_preset (krad_mixer->tone_port->io_ptr, krad_mixer->push_tone);
    krad_mixer->push_tone = NULL;
  }
  
  // Gets input/output port buffers
  for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS; p++) {
    portgroup = krad_mixer->portgroup[p];
    if ((portgroup != NULL) && (portgroup->active == 2) && ((portgroup->direction == INPUT) || (portgroup->direction == OUTPUT))) {
      portgroup_update_samples (portgroup, nframes);
    }
  }
  
  for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS / 2; p++) {
    crossfade_group = &krad_mixer->crossfade_group[p];
    if ((crossfade_group != NULL) && ((crossfade_group->portgroup[0] != NULL) && (crossfade_group->portgroup[1] != NULL))) {
      if (crossfade_group->fade_easing.active) {
        portgroup_set_crossfade (crossfade_group->portgroup[0], krad_easing_process (&crossfade_group->fade_easing, crossfade_group->fade, &client));
        krad_radio_broadcast_subunit_control ( krad_mixer->broadcaster, &crossfade_group->portgroup[0]->address, KR_CROSSFADE,
                                               crossfade_group->fade, client );
      }
    }
  }

  for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS; p++) {
    portgroup = krad_mixer->portgroup[p];
    if ((portgroup != NULL) && (portgroup->active == 2) && (portgroup->volume_easing.active)) {
      portgroup_set_volume (portgroup, krad_easing_process (&portgroup->volume_easing, portgroup->volume[0], &client));
      krad_radio_broadcast_subunit_control ( krad_mixer->broadcaster, &portgroup->address, KR_VOLUME, 
                                             portgroup->volume[0], client );
    }
  }

  // apply volume, effects and calc peaks on inputs
  for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS; p++) {
    portgroup = krad_mixer->portgroup[p];
    if ((portgroup != NULL) && (portgroup->active == 2) && (portgroup->direction == INPUT)) {
      portgroup_apply_volume (portgroup, nframes);
      //experiment
      if (portgroup->volume_actual[0] != 0.0f) {
        portgroup_apply_effects (portgroup, nframes);
      }
      krad_mixer_portgroup_compute_meters (portgroup, nframes);
    }
  }
  
  // Clear Mixes  
  for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS; p++) {
    portgroup = krad_mixer->portgroup[p];
    if ((portgroup != NULL) && (portgroup->active == 2) && (portgroup->io_type == MIXBUS)) {
      portgroup_clear_samples (portgroup, nframes);
    }
  }

  // Mix
  for (m = 0; m < KRAD_MIXER_MAX_PORTGROUPS; m++) {
    mixbus = krad_mixer->portgroup[m];
    if ((mixbus != NULL) && (mixbus->active) && (mixbus->io_type == MIXBUS)) {
      for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS; p++) {
        portgroup = krad_mixer->portgroup[p];
        if ((portgroup != NULL) && (portgroup->active == 2) && (portgroup->mixbus == mixbus) && (portgroup->direction == INPUT)) {
          portgroup_mix_samples ( mixbus, portgroup, nframes );
        }
      }
    }
  }

  // copy to outputs, limit all outputs
  for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS; p++) {
    portgroup = krad_mixer->portgroup[p];
    if ((portgroup != NULL) && (portgroup->active == 2) && (portgroup->direction == OUTPUT)) {
      portgroup_copy_samples ( portgroup, portgroup->mixbus, nframes );
      if (portgroup->output_type == AUX) {
        portgroup_apply_volume (portgroup, nframes);
      }
      portgroup_limit ( portgroup, nframes );
    }
  }
  
  if (krad_mixer->master_mix != NULL) {
    krad_mixer_portgroup_compute_meters (krad_mixer->master_mix, nframes);
  }
  
  krad_mixer->frames_since_peak_read += nframes;

  if (krad_mixer->frames_since_peak_read >= krad_mixer->frames_per_peak_broadcast) {
    krad_mixer->frames_since_peak_read = 0;
    for (p = 0; p < KRAD_MIXER_MAX_PORTGROUPS; p++) {
      portgroup = krad_mixer->portgroup[p];
      if ((portgroup != NULL) && (portgroup->active == 2) && (portgroup->direction == INPUT)) {
        krad_mixer_portgroup_update_meter_readings (portgroup);
      }
    }
    if (krad_mixer->master_mix != NULL) {
      krad_mixer_portgroup_update_meter_readings (krad_mixer->master_mix);
    }
  }
  return 0;
}
コード例 #2
0
void krad_compositor_subunit_tick (krad_compositor_subunit_t *subunit) {
  if (subunit->x_easing.active) {
    subunit->x = krad_easing_process (&subunit->x_easing, subunit->x, NULL);
  }
  if (subunit->y_easing.active) {
    subunit->y = krad_easing_process (&subunit->y_easing, subunit->y, NULL);
  }
  if (subunit->width_easing.active) {
    subunit->width = krad_easing_process (&subunit->width_easing, subunit->width, NULL);
  }
  if (subunit->height_easing.active) {
    subunit->height = krad_easing_process (&subunit->height_easing, subunit->height, NULL);
  }
  if (subunit->xscale_easing.active) {
    subunit->xscale = krad_easing_process (&subunit->xscale_easing, subunit->xscale, NULL);
  }
  if (subunit->yscale_easing.active) {
    subunit->yscale = krad_easing_process (&subunit->yscale_easing, subunit->yscale, NULL);
  }
  if (subunit->opacity_easing.active) {
    subunit->opacity = krad_easing_process (&subunit->opacity_easing, subunit->opacity, NULL);
  }
  if (subunit->rotation_easing.active) {
    subunit->rotation = krad_easing_process (&subunit->rotation_easing, subunit->rotation, NULL);
  }
  if (subunit->red_easing.active) {
    subunit->red = krad_easing_process (&subunit->red_easing, subunit->red, NULL);
  }
  if (subunit->green_easing.active) {
    subunit->green = krad_easing_process (&subunit->green_easing, subunit->green, NULL);
  }
  if (subunit->blue_easing.active) {
    subunit->blue = krad_easing_process (&subunit->blue_easing, subunit->blue, NULL);
  }
  if (subunit->alpha_easing.active) {
    subunit->alpha = krad_easing_process (&subunit->alpha_easing, subunit->alpha, NULL);
  }
}