コード例 #1
0
ファイル: examploscope.c プロジェクト: AkiraShirase/audacity
/** ==== Instantiate Method ==== */
static LV2_Handle
instantiate(const LV2_Descriptor*     descriptor,
            double                    rate,
            const char*               bundle_path,
            const LV2_Feature* const* features)
{
	(void)descriptor;   // Unused variable
	(void)bundle_path;  // Unused variable

	// Allocate and initialise instance structure.
	EgScope* self = (EgScope*)calloc(1, sizeof(EgScope));
	if (!self) {
		return NULL;
	}

	// Get host features
	for (int i = 0; features[i]; ++i) {
		if (!strcmp(features[i]->URI, LV2_URID__map)) {
			self->map = (LV2_URID_Map*)features[i]->data;
		} else if (!strcmp(features[i]->URI, LV2_LOG__log)) {
			self->log = (LV2_Log_Log*)features[i]->data;
		}
	}

	if (!self->map) {
		fprintf(stderr, "EgScope.lv2 error: Host does not support urid:map\n");
		free(self);
		return NULL;
	}

	// Decide which variant to use depending on the plugin URI
	if (!strcmp(descriptor->URI, SCO_URI "#Stereo")) {
		self->n_channels = 2;
	} else if (!strcmp(descriptor->URI, SCO_URI "#Mono")) {
		self->n_channels = 1;
	} else {
		free(self);
		return NULL;
	}

	// Initialise local variables
	self->ui_active           = false;
	self->send_settings_to_ui = false;
	self->rate                = rate;

	// Set default UI settings
	self->ui_spp = 50;
	self->ui_amp = 1.0;

	// Map URIs and initialise forge/logger
	map_sco_uris(self->map, &self->uris);
	lv2_atom_forge_init(&self->forge, self->map);
	lv2_log_logger_init(&self->logger, self->map, self->log);

	return (LV2_Handle)self;
}
コード例 #2
0
ファイル: examploscope.c プロジェクト: drobilla/lv2
/** ==== Instantiate Method ==== */
static LV2_Handle
instantiate(const LV2_Descriptor*     descriptor,
            double                    rate,
            const char*               bundle_path,
            const LV2_Feature* const* features)
{
	(void)descriptor;   // Unused variable
	(void)bundle_path;  // Unused variable

	// Allocate and initialise instance structure.
	EgScope* self = (EgScope*)calloc(1, sizeof(EgScope));
	if (!self) {
		return NULL;
	}

	// Get host features
	const char* missing = lv2_features_query(
		features,
		LV2_LOG__log,  &self->logger.log, false,
		LV2_URID__map, &self->map,        true,
		NULL);
	lv2_log_logger_set_map(&self->logger, self->map);
	if (missing) {
		lv2_log_error(&self->logger, "Missing feature <%s>\n", missing);
		free(self);
		return NULL;
	}

	// Decide which variant to use depending on the plugin URI
	if (!strcmp(descriptor->URI, SCO_URI "#Stereo")) {
		self->n_channels = 2;
	} else if (!strcmp(descriptor->URI, SCO_URI "#Mono")) {
		self->n_channels = 1;
	} else {
		free(self);
		return NULL;
	}

	// Initialise local variables
	self->ui_active           = false;
	self->send_settings_to_ui = false;
	self->rate                = rate;

	// Set default UI settings
	self->ui_spp = 50;
	self->ui_amp = 1.0;

	// Map URIs and initialise forge/logger
	map_sco_uris(self->map, &self->uris);
	lv2_atom_forge_init(&self->forge, self->map);

	return (LV2_Handle)self;
}
コード例 #3
0
ファイル: sisco.c プロジェクト: felipebetancur/sisco.lv2
static LV2_Handle
instantiate(const LV2_Descriptor*     descriptor,
            double                    rate,
            const char*               bundle_path,
            const LV2_Feature* const* features)
{
  (void) descriptor; /* unused variable */
  (void) bundle_path; /* unused variable */

  SiSco* self = (SiSco*)calloc(1, sizeof(SiSco));
  if(!self) {
    return NULL;
  }

  int i;
  for (i=0; features[i]; ++i) {
    if (!strcmp(features[i]->URI, LV2_URID__map)) {
      self->map = (LV2_URID_Map*)features[i]->data;
    }
  }

  if (!self->map) {
    fprintf(stderr, "SiSco.lv2 error: Host does not support urid:map\n");
    free(self);
    return NULL;
  }

  if (!strncmp(descriptor->URI, SCO_URI "#Mono", 31 + 5)) {
    self->n_channels = 1;
  } else if (!strncmp(descriptor->URI, SCO_URI "#Stereo", 31 + 7)) {
    self->n_channels = 2;
  } else if (!strncmp(descriptor->URI, SCO_URI "#3chan", 31 + 6)) {
    self->n_channels = 3;
  } else if (!strncmp(descriptor->URI, SCO_URI "#4chan", 31 + 6)) {
    self->n_channels = 4;
  } else {
    free(self);
    return NULL;
  }

  assert(self->n_channels <= MAX_CHANNELS);

  self->ui_active = false;
  self->send_settings_to_ui = false;
  self->printed_capacity_warning = false;
  self->rate = rate;

  /* default settings */
  self->ui_grid = 10;
  self->triggerstate.mode = 0;
  self->triggerstate.type = 0;
  self->triggerstate.xpos = 50;
  self->triggerstate.hold = 0.5;
  self->triggerstate.level = 0.0;

  self->cursorstate.xpos[0] = 640 * .25;
  self->cursorstate.xpos[1] = 640 * .75;
  self->cursorstate.chn[0] = 1;
  self->cursorstate.chn[1] = 1;

  for (uint32_t c = 0; c < self->n_channels; ++c) {
    self->channelstate[c].gain = 1.0;
    self->channelstate[c].xoff = 0.0;
    self->channelstate[c].yoff = 0.0;
    self->channelstate[c].opts = 3.0;
  }

  lv2_atom_forge_init(&self->forge, self->map);
  map_sco_uris(self->map, &self->uris);
  return (LV2_Handle)self;
}