Exemple #1
0
static LV2_Handle
instantiate(const LV2_Descriptor* descriptor,
            double rate,
            const char* bundle_path,
            const LV2_Feature* const* features)
{
	int i;
	ADelay* adelay = (ADelay*)calloc(1, sizeof(ADelay));
	if (!adelay) return NULL;

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

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

	map_uris(adelay->map, &adelay->uris);
	lv2_atom_forge_init(&adelay->forge, adelay->map);

	adelay->srate = rate;
	adelay->bpmvalid = 0;

	return (LV2_Handle)adelay;
}
Exemple #2
0
static LV2UI_Handle
instantiate(
		void* const               ui_toplevel,
		const LV2UI_Descriptor*   descriptor,
		const char*               plugin_uri,
		const char*               bundle_path,
		LV2UI_Write_Function      write_function,
		LV2UI_Controller          controller,
		RobWidget**               widget,
		const LV2_Feature* const* features)
{
	SFSUI* ui = (SFSUI*) calloc(1,sizeof(SFSUI));
	*widget = NULL;
	ui->map = NULL;

	if      (!strcmp(plugin_uri, MTR_URI "stereoscope")) { ; }
	else if (!strcmp(plugin_uri, MTR_URI "stereoscope_gtk")) { ; }
	else {
		free(ui);
		return NULL;
	}

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

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

	map_xfer_uris(ui->map, &ui->uris);
	lv2_atom_forge_init(&ui->forge, ui->map);

	ui->write      = write_function;
	ui->controller = controller;

	ui->rate = 48000;
	ui->disable_signals = false;
	ui->update_grid = false;
	ui->clear_persistence = false;
	ui->fft_bins = 512;
	ui->freq_band = NULL;
	ui->freq_bins = 0;

	ui->width  = SS_SIZE + 2 * SS_BORDER;
	ui->height = SS_SIZE + 2 * SS_BORDER;

	pthread_mutex_init(&ui->fft_lock, NULL);
	*widget = toplevel(ui, ui_toplevel);
	reinitialize_fft(ui, ui->fft_bins);
	ui_enable(ui);
	return ui;
}
Exemple #3
0
/** ==== 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;
}
Exemple #4
0
static LV2_Handle
instantiate(const LV2_Descriptor*     descriptor,
            double                    rate,
            const char*               bundle_path,
            const LV2_Feature* const* features)
{
	int i;
	BalanceControl* self = (BalanceControl*) calloc(1, sizeof(BalanceControl));
	if (!self) return NULL;

  for (int 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, "BLClv2 error: Host does not support urid:map\n");
		free(self);
		return NULL;
	}

  map_balance_uris(self->map, &self->uris);
  lv2_atom_forge_init(&self->forge, self->map);

	self->peak_integrate_max = PEAK_INTEGRATION_MAX * rate;
	self->peak_integrate_pref = PEAK_INTEGRATION_TIME * rate;
	self->phase_integrate_max = PHASE_INTEGRATION_TIME * rate;
	self->meter_falloff = METER_FALLOFF / UPDATE_FREQ;
	self->peak_hold = PEAK_HOLD_TIME * UPDATE_FREQ;

	assert(self->peak_integrate_max >= 0);
	assert(self->phase_integrate_max > 0);
	assert(self->peak_integrate_max <= self->phase_integrate_max);

	for (i=0; i < CHANNELS; ++i) {
		self->c_amp[i] = 1.0;
		self->c_dly[i] = 0;
		self->r_ptr[i] = self->w_ptr[i] = 0;
		memset(self->buffer[i], 0, sizeof(float) * MAXDELAY);
		self->p_peak_inPi[i]  = (double*) malloc(self->peak_integrate_max * sizeof(double));
		self->p_peak_outPi[i] = (double*) malloc(self->peak_integrate_max * sizeof(double));
	}
	self->p_phase_outPi = (double*) malloc(self->phase_integrate_max * sizeof(double));
	self->p_phase_outNi = (double*) malloc(self->phase_integrate_max * sizeof(double));

	self->uicom_active = 0;
	self->c_monomode = 0;
	self->samplerate = rate;
	self->queue_stateswitch = 0;

	reset_uicom(self);

	return (LV2_Handle)self;
}
Exemple #5
0
AtomWriter::AtomWriter(URIMap& map, URIs& uris, AtomSink& sink)
	: _map(map)
	, _uris(uris)
	, _sink(sink)
	, _id(0)
{
	_out.buf = NULL;
	_out.len = 0;
	lv2_atom_forge_init(&_forge, &map.urid_map_feature()->urid_map);
	lv2_atom_forge_set_sink(&_forge, forge_sink, forge_deref, &_out);
}
Exemple #6
0
Lv2World *lv2_init(uint32_t sample_rate) {
    Lv2World *world = malloc(sizeof(Lv2World));
    world->sample_rate = sample_rate;
    urid_table = NULL;
    world->lv2_features[0] = &map_feature;
    world->lv2_features[1] = &unmap_feature;
    world->lv2_features[2] = NULL ;
	lv2_atom_forge_init(&forge, &lv2_urid_map);
    load_lv2_descriptors(world);
    return world;
}
Exemple #7
0
/** ==== 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;
}
static LV2UI_Handle
instantiate(const LV2UI_Descriptor*   descriptor,
            const char*               plugin_uri,
            const char*               bundle_path,
            LV2UI_Write_Function      write_function,
            LV2UI_Controller          controller,
            LV2UI_Widget*             widget,
            const LV2_Feature* const* features)
{
	FeedbackSuppressorUI* ui = (FeedbackSuppressorUI*)malloc(sizeof(FeedbackSuppressorUI));
	ui->map        = NULL;
	ui->write      = write_function;
	ui->controller = controller;
	ui->box        = NULL;
	ui->button     = NULL;
	ui->label      = NULL;

	*widget = NULL;

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

	if (!ui->map) {
		fprintf(stderr, "feedback_suppressor_ui: Host does not support urid:Map\n");
		free(ui);
		return NULL;
	}

	map_sampler_uris(ui->map, &ui->uris);

	lv2_atom_forge_init(&ui->forge, ui->map);

	ui->box = gtk_vbox_new(FALSE, 4);
	ui->label = gtk_label_new("Select Filter List");
	ui->button = gtk_button_new_with_label("Load Filter List");
	gtk_box_pack_start(GTK_BOX(ui->box), ui->label, TRUE, TRUE, 4);
	gtk_box_pack_start(GTK_BOX(ui->box), ui->button, FALSE, FALSE, 4);
	g_signal_connect(ui->button, "clicked",
	                 G_CALLBACK(on_load_clicked),
	                 ui);

	*widget = ui->box;

	return ui;
}
Exemple #9
0
SRATOM_API
Sratom*
sratom_new(LV2_URID_Map* map)
{
	Sratom* sratom = (Sratom*)malloc(sizeof(Sratom));
	sratom->map            = map;
	sratom->atom_Event     = map->map(map->handle, LV2_ATOM__Event);
	sratom->midi_MidiEvent = map->map(map->handle, LV2_MIDI__MidiEvent);
	sratom->next_id        = 0;
	sratom->base_uri       = SERD_NODE_NULL;
	sratom->object_mode    = SRATOM_OBJECT_MODE_BLANK;
	sratom->pretty_numbers = false;
	memset(&sratom->nodes, 0, sizeof(sratom->nodes));
	lv2_atom_forge_init(&sratom->forge, map);
	return sratom;
}
/**
   Instantiate the user interface
*/
static LV2UI_Handle instantiate(const LV2UI_Descriptor *descriptor,
                                const char *plugin_uri,
                                const char *bundle_path,
                                LV2UI_Write_Function write_function,
                                LV2UI_Controller controller,
                                LV2UI_Widget *widget,
                                const LV2_Feature *const *features)
{
    /* Create object data */
    FluidUI *self = malloc(sizeof(FluidUI));

    self->write = write_function;
    self->controller = controller;

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

    /* Create GUI */
    self->box = gtk_hbox_new(FALSE, 4);
    self->label = gtk_label_new("Preset");
    self->combo_box  = gtk_combo_box_text_new();

    get_presets(self);

    gtk_box_pack_start(GTK_BOX(self->box), self->label, TRUE, TRUE, 4);
    gtk_box_pack_start(GTK_BOX(self->box), self->combo_box, FALSE, TRUE, 4);

    g_signal_connect(self->combo_box, "changed", G_CALLBACK(on_changed), self);

    *widget = self->box;

    /* Send patch get to synth plug to get current preset setting */
    uint8_t obj_buf[OBJ_BUF_SIZE];
    lv2_atom_forge_set_buffer(&self->forge, obj_buf, OBJ_BUF_SIZE);

    LV2_Atom *patch_get = write_patch_get(&self->forge, &self->uris);

    self->write(self->controller, INPUT_PORT, lv2_atom_total_size(patch_get),
                self->uris.atom_event_transfer, patch_get);

    return self;
}
Exemple #11
0
static LV2UI_Handle instantiate (
		void* const               ui_toplevel,
		const LV2UI_Descriptor*   descriptor,
		const char*               plugin_uri,
		const char*               bundle_path,
		LV2UI_Write_Function      write_function,
		LV2UI_Controller          controller,
		RobWidget**               widget,
		const LV2_Feature* const* features)
{
	BITui* ui = (BITui*)calloc (1,sizeof (BITui));
	if (!ui) { return NULL; }

	ui->write      = write_function;
	ui->controller = controller;

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

	if (!ui->map) {
		fprintf (stderr, "UI: Host does not support urid:map\n");
		free (ui);
		return NULL;
	}

	ui->nfo = robtk_info(ui_toplevel);
	ui->rate = 48000;
	ui->integration_spl = 0;
	ui->stats[0] = ui->stats[1] = ui->stats[2] = -1;
	ui->sig[0] = ui->sig[1] = -1;

	map_eburlv2_uris (ui->map, &ui->uris);
	lv2_atom_forge_init (&ui->forge, ui->map);

	*widget = toplevel (ui, ui_toplevel);

	ui_enable (ui);
	return ui;
}
Exemple #12
0
static LV2_Handle
bim_instantiate(
		const LV2_Descriptor*     descriptor,
		double                    rate,
		const char*               bundle_path,
		const LV2_Feature* const* features)
{
	LV2meter* self = (LV2meter*)calloc (1, sizeof (LV2meter));
	if (!self) return NULL;

	if (strcmp (descriptor->URI, MTR_URI "bitmeter") && strcmp (descriptor->URI, MTR_URI "bitmeter_gtk")) {
		free(self);
		return NULL;
	}

	for (int 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, "Bitmeter error: Host does not support urid:map\n");
		free (self);
		return NULL;
	}

	map_eburlv2_uris(self->map, &self->uris);
	lv2_atom_forge_init(&self->forge, self->map);

	self->rate = rate;
	self->ui_active = false;
	self->send_state_to_ui = false;
	self->ebu_integrating = true;
	self->bim_average = false;

	bim_reset (self);
	return (LV2_Handle)self;
}
Exemple #13
0
static LV2_Handle
instantiate (const LV2_Descriptor*     descriptor,
             double                    rate,
             const char*               bundle_path,
             const LV2_Feature* const* features)
{
	MidiMap* self = (MidiMap*)calloc (1, sizeof (MidiMap));

	int i;
	for (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_WORKER__schedule)) {
			self->schedule = (LV2_Worker_Schedule*)features[i]->data;
		} else if (!strcmp (features[i]->URI, LV2_LOG__log)) {
			self->log = (LV2_Log_Log*)features[i]->data;
		}
	}

	lv2_log_logger_init (&self->logger, self->map, self->log);

	if (!self->map) {
		lv2_log_error (&self->logger, "MidiMap.lv2 error: Host does not support urid:map\n");
		free (self);
		return NULL;
	}
	if (!self->schedule) {
		lv2_log_error (&self->logger, "MidiMap.lv2 error: Host does not support worker:schedule\n");
		free (self);
		return NULL;
	}

	self->sample_rate = rate;
	lv2_atom_forge_init (&self->forge, self->map);
	map_mem_uris (self->map, &self->uris);
	return (LV2_Handle)self;
}
Exemple #14
0
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;
}
Exemple #15
0
static LV2UI_Handle
instantiate(
		void* const               ui_toplevel,
		const LV2UI_Descriptor*   descriptor,
		const char*               plugin_uri,
		const char*               bundle_path,
		LV2UI_Write_Function      write_function,
		LV2UI_Controller          controller,
		RobWidget**               widget,
		const LV2_Feature* const* features)
{
	MF2UI* ui = (MF2UI*) calloc(1,sizeof(MF2UI));
	*widget = NULL;
	ui->map = NULL;

	if (!strcmp(plugin_uri, MTR_URI "phasewheel")) { ; }
	else {
		free(ui);
		return NULL;
	}

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

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

	ui->nfo = robtk_info(ui_toplevel);
	map_xfer_uris(ui->map, &ui->uris);
	lv2_atom_forge_init(&ui->forge, ui->map);

	ui->write      = write_function;
	ui->controller = controller;

	ui->rate = 48000;
	ui->db_cutoff = -60;
	ui->db_thresh = 0.000001; // (-60dB)^2 // XXX
	ui->drag_cutoff_x = -1;
	ui->prelight_cutoff = false;
	ui->cor = 0.5;
	ui->disable_signals = false;
	ui->update_annotations = false;
	ui->update_grid = false;
	ui->fft_bins = 512;
	ui->freq_band = NULL;
	ui->freq_bins = 0;
	ui->pgain = -100;
	ui->peak = 0;
	ui->scale = 0.0;
	ui->pscale = 1.0;

	ui->width  = 2 * (PH_RAD + XOFF);
	ui->height = 2 * (PH_RAD + YOFF);

	pthread_mutex_init(&ui->fft_lock, NULL);
	*widget = toplevel(ui, ui_toplevel);
	reinitialize_fft(ui, ui->fft_bins);
	ui_enable(ui);
	return ui;
}
Exemple #16
0
static LV2_Handle
instantiate(const LV2_Descriptor*     descriptor,
            double                    rate,
            const char*               bundle_path,
            const LV2_Feature* const* features)
{
  B3S* b3s = (B3S*)malloc(sizeof(B3S));
  if(!b3s) {
    return NULL;
  }
  memset(b3s, 0, sizeof(B3S));

  SampleRateD = rate;

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

  if (!b3s->map || !b3s->schedule) {
    fprintf(stderr, "B3Lv2 error: Host does not support urid:map or work:schedule\n");
    free(b3s);
    return NULL;
  }

  map_setbfree_uris(b3s->map, &b3s->uris);
  lv2_atom_forge_init(&b3s->forge, b3s->map);

  srand ((unsigned int) time (NULL));
  b3s->suspend_ui_msg = 1;
  b3s->boffset = BUFFER_SIZE_SAMPLES;

  b3s->swap_instances = 0;
  b3s->update_gui_now = 0;
  b3s->update_pgm_now = 0;
  b3s->queue_panic = 0;

  b3s->inst = (b_instance*) calloc(1, sizeof(struct b_instance));
  b3s->inst_offline = NULL;

  allocSynth(b3s->inst);

#ifdef JACK_DESCRIPT
  // CODE DUP src/main.c
  char * defaultConfigFile = NULL;
  char * defaultProgrammeFile = NULL;

#ifdef _WIN32
  char wintmp[1024] = "";
  if (ExpandEnvironmentStrings("%localappdata%\\setBfree\\default.cfg", wintmp, 1024)) {
    defaultConfigFile = strdup (wintmp);
  }
  wintmp[0] = '\0';
  if (ExpandEnvironmentStrings("%localappdata%\\setBfree\\default.pgm", wintmp, 1024)) {
    defaultProgrammeFile = strdup (wintmp);
  }
#else // unices: prefer XDG_CONFIG_HOME
  if (getenv("XDG_CONFIG_HOME")) {
    size_t hl = strlen(getenv("XDG_CONFIG_HOME"));
    defaultConfigFile=(char*) malloc(hl+22);
    defaultProgrammeFile=(char*) malloc(hl+22);
    sprintf(defaultConfigFile,    "%s/setBfree/default.cfg", getenv("XDG_CONFIG_HOME"));
    sprintf(defaultProgrammeFile, "%s/setBfree/default.pgm", getenv("XDG_CONFIG_HOME"));
  }
  else if (getenv("HOME")) {
    size_t hl = strlen(getenv("HOME"));
# ifdef __APPLE__
    defaultConfigFile=(char*) malloc(hl+42);
    defaultProgrammeFile=(char*) malloc(hl+42);
    sprintf(defaultConfigFile,    "%s/Library/Preferences/setBfree/default.cfg", getenv("HOME"));
    sprintf(defaultProgrammeFile, "%s/Library/Preferences/setBfree/default.pgm", getenv("HOME"));
# else // linux, BSD, etc
    defaultConfigFile=(char*) malloc(hl+30);
    defaultProgrammeFile=(char*) malloc(hl+30);
    sprintf(defaultConfigFile,    "%s/.config/setBfree/default.cfg", getenv("HOME"));
    sprintf(defaultProgrammeFile, "%s/.config/setBfree/default.pgm", getenv("HOME"));
# endif
  }
#endif

  if (access (defaultConfigFile, R_OK) == 0) {
    parseConfigurationFile (b3s->inst, defaultConfigFile);
  }
#endif

  setControlFunctionCallback(b3s->inst->midicfg, mctl_cb, b3s);
  initSynth(b3s->inst, rate);

#ifdef JACK_DESCRIPT
  if (access (defaultProgrammeFile, R_OK) == 0) {
    loadProgrammeFile (b3s->inst->progs, defaultProgrammeFile);
  }
  free(defaultConfigFile);
  free(defaultProgrammeFile);
#endif

  strcpy(b3s->lv2nfo, "v" VERSION);
  b3s->thirtysec = 0;
#ifdef WITH_SIGNATURE
  {
    b3s->thirtysec = 30 * rate;
    b3s->counter = 0;
    b3s->sin_phase = 0;

    gp3_initialize ();
    load_master_key (); // in header WITH_SIGNATURE
    gp3_loglevel (GP3L_SILENT);
    int rc = -1;
    char signature_file0[1024] = "";
    char signature_file1[1024] = "";
#ifdef _WIN32
	ExpandEnvironmentStrings("%localappdata%\\"SIGFILE, signature_file0, 1024);
	ExpandEnvironmentStrings("%localappdata%\\x42_license.txt", signature_file1, 1024);
#else
	const char * home = getenv("HOME");
	if (home && (strlen(home) + strlen(SIGFILE) + 3) < 1024) {
		sprintf(signature_file0, "%s/.%s", home, SIGFILE);
	}
	if (home && (strlen(home) + 18) < 1024) {
		sprintf(signature_file1, "%s/.x42_license.txt", home);
	}
#endif
	if (!access(signature_file0, R_OK)) {
	  rc = gp3_checksigfile (signature_file0);
	} else if (!access(signature_file1, R_OK)) {
	  rc = gp3_checksigfile (signature_file1);
	}
	if (rc == 0) {
	  bool ok = false;
	  char data[8192];
	  char *tmp=NULL;
	  uint32_t len = gp3_get_text(data, sizeof(data));
	  if (len == sizeof(data)) data[sizeof(data)-1] = '\0';
	  else data[len] = '\0';
	  if ((tmp = strchr(data, '\n'))) *tmp = 0;
	  b3s->lv2nfo[sizeof(b3s->lv2nfo) - 1] = 0;
	  if (tmp++ && *tmp) {
	    if ((tmp = strstr(tmp, SB3_URI))) {
	      char *t1, *t2;
	      ok = true;
	      t1 = tmp + 1 + strlen(SB3_URI);
	      t2 = strchr(t1, '\n');
	      if (t2) { *t2 = 0; }
	      if (strlen(t1) > 0 && strncmp(t1, VERSION, strlen(t1))) {
	      ok = false;
	      }
	    }
	  }
	  if (ok) {
	    b3s->thirtysec = 0;
	    strncat(b3s->lv2nfo, " ", sizeof(b3s->lv2nfo) - strlen(b3s->lv2nfo));
	    strncat(b3s->lv2nfo, data, sizeof(b3s->lv2nfo) - strlen(b3s->lv2nfo));
	  }
	}
	gp3_cleanup ();
  }
#endif
  return (LV2_Handle)b3s;
}
Exemple #17
0
EAPI_MAIN int
elm_main(int argc, char **argv)
{
	static prog_t handle;
	bin_t *bin = &handle.bin;

	handle.server_name = NULL;
	handle.session_id = NULL;
	handle.seq_size = SEQ_SIZE;

	bin->has_gui = true;

	fprintf(stderr,
		"Synthpod "SYNTHPOD_VERSION"\n"
		"Copyright (c) 2015 Hanspeter Portner ([email protected])\n"
		"Released under Artistic License 2.0 by Open Music Kontrollers\n");
	
	int c;
	while((c = getopt(argc, argv, "vhgGn:u:s:")) != -1)
	{
		switch(c)
		{
			case 'v':
				fprintf(stderr,
					"--------------------------------------------------------------------\n"
					"This is free software: you can redistribute it and/or modify\n"
					"it under the terms of the Artistic License 2.0 as published by\n"
					"The Perl Foundation.\n"
					"\n"
					"This source is distributed in the hope that it will be useful,\n"
					"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
					"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
					"Artistic License 2.0 for more details.\n"
					"\n"
					"You should have received a copy of the Artistic License 2.0\n"
					"along the source as a COPYING file. If not, obtain it from\n"
					"http://www.perlfoundation.org/artistic_license_2_0.\n\n");
				return 0;
			case 'h':
				fprintf(stderr,
					"--------------------------------------------------------------------\n"
					"USAGE\n"
					"   %s [OPTIONS] [BUNDLE_PATH]\n"
					"\n"
					"OPTIONS\n"
					"   [-v]                 print version and full license information\n"
					"   [-h]                 print usage information\n"
					"   [-g]                 enable GUI (default)\n"
					"   [-G]                 disable GUI\n"
					"   [-n] server-name     connect to named JACK daemon\n"
					"   [-u] client-uuid     client UUID for JACK session management\n"
					"   [-s] sequence-size   minimum sequence size (8192)\n\n"
					, argv[0]);
				return 0;
			case 'g':
				bin->has_gui = true;
				break;
			case 'G':
				bin->has_gui = false;
				break;
			case 'n':
				handle.server_name = optarg;
				break;
			case 'u':
				handle.session_id = optarg;
				break;
			case 's':
				handle.seq_size = MAX(SEQ_SIZE, atoi(optarg));
				break;
			case '?':
				if( (optopt == 'n') || (optopt == 'u') || (optopt == 's') )
					fprintf(stderr, "Option `-%c' requires an argument.\n", optopt);
				else if(isprint(optopt))
					fprintf(stderr, "Unknown option `-%c'.\n", optopt);
				else
					fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
				return -1;
			default:
				return -1;
		}
	}

	bin_init(bin);

	LV2_URID_Map *map = ext_urid_map_get(bin->ext_urid);

	lv2_atom_forge_init(&handle.forge, map);
	osc_forge_init(&handle.oforge, map);
	
	handle.midi_MidiEvent = map->map(map->handle, LV2_MIDI__MidiEvent);

	handle.time_position = map->map(map->handle, LV2_TIME__Position);
	handle.time_barBeat = map->map(map->handle, LV2_TIME__barBeat);
	handle.time_bar = map->map(map->handle, LV2_TIME__bar);
	handle.time_beatUnit = map->map(map->handle, LV2_TIME__beatUnit);
	handle.time_beatsPerBar = map->map(map->handle, LV2_TIME__beatsPerBar);
	handle.time_beatsPerMinute = map->map(map->handle, LV2_TIME__beatsPerMinute);
	handle.time_frame = map->map(map->handle, LV2_TIME__frame);
	handle.time_framesPerSecond = map->map(map->handle, LV2_TIME__framesPerSecond);
	handle.time_speed = map->map(map->handle, LV2_TIME__speed);

	bin->app_driver.system_port_add = _system_port_add;
	bin->app_driver.system_port_del = _system_port_del;

#if defined(JACK_HAS_CYCLE_TIMES)
	handle.osc_sched.osc2frames = _osc_schedule_osc2frames;
	handle.osc_sched.frames2osc = _osc_schedule_frames2osc;
	handle.osc_sched.handle = &handle;
	bin->app_driver.osc_sched = &handle.osc_sched;
#else
	bin->app_driver.osc_sched = NULL;
#endif
	bin->app_driver.features = SP_APP_FEATURE_POWER_OF_2_BLOCK_LENGTH; // always true for JACK

	bin->ui_driver.saved = _ui_saved;

	bin->ui_driver.features = SP_UI_FEATURE_NEW | SP_UI_FEATURE_SAVE | SP_UI_FEATURE_CLOSE;
	if(synthpod_nsm_managed() || handle.session_id)
		bin->ui_driver.features |= SP_UI_FEATURE_IMPORT_FROM | SP_UI_FEATURE_EXPORT_TO;
	else
		bin->ui_driver.features |= SP_UI_FEATURE_OPEN | SP_UI_FEATURE_SAVE_AS;

	// run
	bin_run(bin, argv, &nsm_driver);

	// stop
	bin_stop(bin);

	// deinit JACK
	_jack_deinit(&handle);

	// deinit
	bin_deinit(bin);

	return 0;
}
void
gst_lv2_host_init (void)
{
  lv2_atom_forge_init (&forge, &lv2_map);
}
Exemple #19
0
static LilvState*
new_state_from_model(LilvWorld*       world,
                     LV2_URID_Map*    map,
                     SordModel*       model,
                     const SordNode*  node,
                     const char*      dir)
{
	LilvState* const state = (LilvState*)malloc(sizeof(LilvState));
	memset(state, '\0', sizeof(LilvState));
	state->dir       = lilv_strdup(dir);
	state->atom_Path = map->map(map->handle, LV2_ATOM__Path);

	// Get the plugin URI this state applies to
	SordIter* i = sord_search(model, node, world->uris.lv2_appliesTo, 0, 0);
	if (i) {
		const SordNode* object = sord_iter_get_node(i, SORD_OBJECT);
		const SordNode* graph  = sord_iter_get_node(i, SORD_GRAPH);
		state->plugin_uri = lilv_node_new_from_node(world, object);
		if (!state->dir && graph) {
			state->dir = lilv_strdup((const char*)sord_node_get_string(graph));
		}
		sord_iter_free(i);
	} else if (sord_ask(model,
	                    node,
	                    world->uris.rdf_a,
	                    world->uris.lv2_Plugin, 0)) {
		// Loading plugin description as state (default state)
		state->plugin_uri = lilv_node_new_from_node(world, node);
	} else {
		LILV_ERRORF("State %s missing lv2:appliesTo property\n",
		            sord_node_get_string(node));
	}

	// Get the state label
	i = sord_search(model, node, world->uris.rdfs_label, NULL, NULL);
	if (i) {
		const SordNode* object = sord_iter_get_node(i, SORD_OBJECT);
		const SordNode* graph  = sord_iter_get_node(i, SORD_GRAPH);
		state->label = lilv_strdup((const char*)sord_node_get_string(object));
		if (!state->dir) {
			state->dir = lilv_strdup((const char*)sord_node_get_string(graph));
		}
		sord_iter_free(i);
	}

	Sratom*        sratom = sratom_new(map);
	SerdChunk      chunk  = { NULL, 0 };
	LV2_Atom_Forge forge;
	lv2_atom_forge_init(&forge, map);
	lv2_atom_forge_set_sink(
		&forge, sratom_forge_sink, sratom_forge_deref, &chunk);

	// Get port values
	SordIter* ports = sord_search(model, node, world->uris.lv2_port, 0, 0);
	FOREACH_MATCH(ports) {
		const SordNode* port = sord_iter_get_node(ports, SORD_OBJECT);

		SordNode* label  = sord_get(model, port, world->uris.rdfs_label, 0, 0);
		SordNode* symbol = sord_get(model, port, world->uris.lv2_symbol, 0, 0);
		SordNode* value  = sord_get(model, port, world->uris.pset_value, 0, 0);
		if (!value) {
			value = sord_get(model, port, world->uris.lv2_default, 0, 0);
		}
		if (!symbol) {
			LILV_ERRORF("State `%s' port missing symbol.\n",
			            sord_node_get_string(node));
		} else if (value) {
			chunk.len = 0;
			sratom_read(sratom, &forge, world->world, model, value);
			LV2_Atom* atom = (LV2_Atom*)chunk.buf;

			append_port_value(state,
			                  (const char*)sord_node_get_string(symbol),
			                  LV2_ATOM_BODY(atom), atom->size, atom->type);

			if (label) {
				lilv_state_set_label(state,
				                     (const char*)sord_node_get_string(label));
			}
		}
		sord_node_free(world->world, value);
		sord_node_free(world->world, symbol);
		sord_node_free(world->world, label);
	}
	sord_iter_free(ports);

	// Get properties
	SordNode* statep     = sord_new_uri(world->world, USTR(LV2_STATE__state));
	SordNode* state_node = sord_get(model, node, statep, NULL, NULL);
	if (state_node) {
		SordIter* props = sord_search(model, state_node, 0, 0, 0);
		FOREACH_MATCH(props) {
			const SordNode* p = sord_iter_get_node(props, SORD_PREDICATE);
			const SordNode* o = sord_iter_get_node(props, SORD_OBJECT);

			chunk.len = 0;
			lv2_atom_forge_set_sink(
				&forge, sratom_forge_sink, sratom_forge_deref, &chunk);

			sratom_read(sratom, &forge, world->world, model, o);
			LV2_Atom* atom  = (LV2_Atom*)chunk.buf;
			uint32_t  flags = LV2_STATE_IS_POD|LV2_STATE_IS_PORTABLE;
			Property  prop  = { NULL, 0, 0, 0, flags };

			prop.key   = map->map(map->handle, (const char*)sord_node_get_string(p));
			prop.type  = atom->type;
			prop.size  = atom->size;
			prop.value = malloc(atom->size);
			memcpy(prop.value, LV2_ATOM_BODY(atom), atom->size);
			if (atom->type == forge.Path) {
				prop.flags = LV2_STATE_IS_PORTABLE;
			}

			if (prop.value) {
				state->props = (Property*)realloc(
					state->props, (++state->num_props) * sizeof(Property));
				state->props[state->num_props - 1] = prop;
			}
		}
		sord_iter_free(props);
	}
	sord_node_free(world->world, state_node);
	sord_node_free(world->world, statep);

	free((void*)chunk.buf);
	sratom_free(sratom);

	qsort(state->props, state->num_props, sizeof(Property), property_cmp);
	qsort(state->values, state->num_values, sizeof(PortValue), value_cmp);

	return state;
}
Exemple #20
0
 /** Initialize the underlying atom forge
     @param map The mapping function needed for init
  */
 inline void
 init (LV2_URID_Map* map)
 {
    lv2_atom_forge_init (this, map);
 }
Exemple #21
0
Forge::Forge(URIMap& map)
	: _map(map)
{
	lv2_atom_forge_init(this, &map.urid_map_feature()->urid_map);
}