Exemple #1
0
void gBrowser::init(const char *init_path) {

	gLog("[gBrowser] init path = '%s'\n", init_path);

	if (init_path == NULL || !gIsDir(init_path)) {
#if defined(__linux__) || defined(__APPLE__)
		path_obj->value("/home");
#elif defined(_WIN32)

		/* SHGetFolderPath is deprecated. We should use SHGetKnownFolderPath
		 * but that would break compatibility with XP. On Vista, GetFolderPath
		 * is a wrapper of GetKnownFolderPath, so no problem. */

		char winRoot[1024];
		SHGetFolderPath(NULL, CSIDL_COMMON_DESKTOPDIRECTORY, NULL, 0, winRoot); // si parte dal Desktop
		path_obj->value(winRoot);
#endif
		gLog("[gBrowser] init_path null or invalid, using default\n");
	}
	else
		path_obj->value(init_path);

	refresh();
	sort();
}
Exemple #2
0
int Wave::resample(int quality, int newRate)
{
	float ratio = newRate / (float) inHeader.samplerate;
	int newSize = ceil(size * ratio);
	if (newSize % 2 != 0)   // libsndfile goes crazy with odd size in case of saving
		newSize++;

	float *tmp = (float *) malloc(newSize * sizeof(float));
	if (!tmp) {
		gLog("[wave] unable to allocate memory for resampling\n");
		return -1;
	}

	SRC_DATA src_data;
	src_data.data_in       = data;
	src_data.input_frames  = size/2;     // in frames, i.e. /2 (stereo)
	src_data.data_out      = tmp;
	src_data.output_frames = newSize/2;  // in frames, i.e. /2 (stereo)
	src_data.src_ratio     = ratio;

	gLog("[wave] resampling: new size=%d (%d frames)\n", newSize, newSize/2);

	int ret = src_simple(&src_data, quality, 2);
	if (ret != 0) {
		gLog("[wave] resampling error: %s\n", src_strerror(ret));
		return 0;
	}

	free(data);
	data = tmp;
	size = newSize;
	inHeader.samplerate = newRate;
	return 1;
}
Exemple #3
0
int Plugin::unload() {

	if (module == NULL)
		return 1;

#if defined(_WIN32)

	FreeLibrary((HMODULE)module); // FIXME - error checking
	return 1;

#elif defined(__linux__)

	return dlclose(module) == 0 ? 1 : 0;

#elif defined(__APPLE__)

	/* we must unload bundles but because bundles may be in use for other
	plug-in types it is important (and mandatory on certain plug-ins,
	e.g. Korg) to do a check on the retain count. */

	CFIndex retainCount = CFGetRetainCount(module);

	if (retainCount == 1) {
		gLog("[plugin] retainCount == 1, can unload dlyb\n");
		CFBundleUnloadExecutable(module);
		CFRelease(module);
	}
	else
		gLog("[plugin] retainCount > 1 (%d), leave dlyb alone\n", (int) retainCount);

	return 1;

#endif
}
Exemple #4
0
int Wave::writeData(const char *f)
{
	/* prepare the header for output file */

	outHeader.samplerate = inHeader.samplerate;
	outHeader.channels   = inHeader.channels;
	outHeader.format     = inHeader.format;

	fileOut = sf_open(f, SFM_WRITE, &outHeader);
	if (fileOut == NULL) {
		gLog("[wave] unable to open %s for exporting\n", f);
		return 0;
	}

	int out = sf_write_float(fileOut, data, size);
	if (out != (int) size) {
		gLog("[wave] error while exporting %s! %s\n", f, sf_strerror(fileOut));
		return 0;
	}

	isLogical = false;
	isEdited  = false;
	sf_close(fileOut);
	return 1;
}
Exemple #5
0
void PluginHost::freePlugin(int id, int stackType, Channel *ch) {

	gVector <Plugin *> *pStack;
	pStack = getStack(stackType, ch);

	/* try to delete the plugin until succeed. G_Mixer has priority. */

	for (unsigned i=0; i<pStack->size; i++)
		if (pStack->at(i)->getId() == id) {

			if (pStack->at(i)->status == 0) { // no frills if plugin is missing
				delete pStack->at(i);
				pStack->del(i);
				return;
			}
			else {
				int lockStatus;
				while (true) {
					lockStatus = pthread_mutex_trylock(&G_Mixer.mutex_plugins);
					if (lockStatus == 0) {
						pStack->at(i)->suspend();
						pStack->at(i)->close();
						delete pStack->at(i);
						pStack->del(i);
						pthread_mutex_unlock(&G_Mixer.mutex_plugins);
						gLog("[pluginHost] plugin id=%d removed\n", id);
						return;
					}
					//else
						//gLog("[pluginHost] waiting for mutex...\n");
				}
			}
		}
	gLog("[pluginHost] plugin id=%d not found\n", id);
}
Exemple #6
0
int wfx_trim(Wave *w, int a, int b) {
	a = a * 2;
	b = b * 2;

	if (a < 0) a = 0;
	if (b > w->size) b = w->size;

	int newSize = b - a;
	float *temp = (float *) malloc(newSize * sizeof(float));
	if (temp == NULL) {
		gLog("[wfx] unable to allocate memory for trimming\n");
		return 0;
	}

	gLog("[wfx] trimming from %d to %d (area = %d)\n", a, b, b-a);

	for (int i=a, k=0; i<b; i++, k++)
		temp[k] = w->data[i];

	free(w->data);
	w->data = temp;
	w->size = newSize;
	//w->inHeader.frames = b-a;
	w->frames(b - a);
 	w->isEdited = true;

	return 1;
}
Exemple #7
0
void updateSamplerate(int systemRate, int patchRate) 
{
	/* diff ratio: systemRate / patchRate
	 * e.g.  44100 / 96000 = 0.4... */

	if (systemRate == patchRate)
		return;

	gLog("[REC] systemRate (%d) != patchRate (%d), converting...\n", systemRate, patchRate);

	float ratio = systemRate / (float) patchRate;
	for (unsigned i=0; i<frames.size; i++) {

		gLog("[REC]    oldFrame = %d", frames.at(i));

		float newFrame = frames.at(i);
		newFrame = floorf(newFrame * ratio);

		frames.at(i) = (int) newFrame;

		if (frames.at(i) % 2 != 0)
			frames.at(i)++;

		gLog(", newFrame = %d\n", frames.at(i));
	}

	/* update structs */

	for (unsigned i=0; i<frames.size; i++) {
		for (unsigned j=0; j<global.at(i).size; j++) {
			action *a = global.at(i).at(j);
			a->frame = frames.at(i);
		}
	}
}
Exemple #8
0
void AppidManager::UpdateAppidMeta(const Config& config) {
  int ret = 0;
  unsigned int appid = 0; 
  std::string interval_value; //60, 3600, 86400

  unsigned char new_index = (index_ + 1) % 2;
  AppidMapVecAppidMeta& tmp_appid  = appid_map_[new_index];
  tmp_appid.clear();

  std::vector<std::string> keys;
  config.GetKeysBySection("appid", keys);

  for (std::vector<std::string>::iterator it = keys.begin();
      it != keys.end(); ++it) {
    appid = atoi(it->c_str());
    ret = config.ReadItem("appid", *it, "", interval_value);
    if (ret != 0 || appid == 0) {
      gLog("[%s][%d]: read %s appid %d failed %d\n", __FILE__, __LINE__,
          it->c_str(), appid, ret);
      continue;
    }

    int32_t min = 0, mid = 0, max = 0;
    char *save_ptr = NULL;
    char *p = NULL;
    char buf[128];
    snprintf(buf, sizeof(buf), "%s", interval_value.c_str());
    p = strtok_r(buf, ",", &save_ptr);
    if (p != NULL) {
      min = atoi(p);
      if (min > 0 && min <= 86400) {
        tmp_appid[appid].set_min_interval(min);
      }
    }

    p = strtok_r(NULL, ",", &save_ptr);
    if (p != NULL) {
      mid = atoi(p);
      if (mid > 0 && mid <= 86400) {
        tmp_appid[appid].set_mid_interval(mid);
      }
    }

    p = strtok_r(NULL, ",", &save_ptr);
    if (p != NULL) {
      max = atoi(p);
      if (max > 0 && max <= 86400) {
        tmp_appid[appid].set_max_interval(max);
      }
    }
  }

  index_ = new_index;
  gLog("[%s][%d]: index = %d\n", __FILE__, __LINE__, index_);
  for (AppidMapVecAppidMeta::iterator it = appid_map_[index_].begin();
      it != appid_map_[index_].end(); ++it) {
    gLog("[%s][%d]: appid = %u, meta = %s\n", __FILE__, __LINE__,
        it->first, it->second.DebugString().c_str());
  }
}
Exemple #9
0
int jackSyncCb(jack_transport_state_t state, jack_position_t *pos,
		void *arg)
{
	switch (state) {
		case JackTransportStopped:
			gLog("[KA] Jack transport stopped, frame=%d\n", pos->frame);
			glue_stopSeq(false);  // false = not from GUI
			if (pos->frame == 0)
				glue_rewindSeq();
			break;

		case JackTransportRolling:
			gLog("[KA] Jack transport rolling\n");
			break;

		case JackTransportStarting:
			gLog("[KA] Jack transport starting, frame=%d\n", pos->frame);
			glue_startSeq(false);  // false = not from GUI
			if (pos->frame == 0)
				glue_rewindSeq();
			break;

		default:
			gLog("[KA] Jack transport [unknown]\n");
	}
	return 1;
}
int checkConfig()
{
	FILE* EditorPTR;

	EditorPTR = fopen(CONFIG_FILE, "r");

	if(EditorPTR) // If open Editor
	{
		gLog("[World of Warcraft Studio - Editor] - Config exist\n##############################################################\n");

		if(EditorPTR == NULL) // If conf is empty
		{
			gLog("[World of Warcraft Studio - Editor] - Config is empty\n##############################################################\n");
			exit(1);
		}
		else
			gLog("[World of Warcraft Studio - Editor] - Config have content\n##############################################################\n"); // Config isn't empty
	}
	else
	{
		gLog("[World of Warcraft Studio - Editor] - Config doesn't exist\n##############################################################\n"); // Config doesn't exist
		exit(1);
	}

	return 0;
}
bool PlainExpression::ParseItem(const std::string& item) {
  const char *ptr = NULL;
  ptr = strstr(item.c_str(), ">");
  if (ptr == NULL) return false;
  Slice keyword(item.c_str(), ptr);
  keyword.StrTrim(" ");
  if (keyword == "min_interval") {
    key_index_ = 0;
  } else if (keyword == "mid_interval") {
    key_index_ = 1;
  } else if (keyword == "max_interval") {
    key_index_ = 2;
  } else {
    gLog("[%s][%d]: wrong keyword %s, item %s\n",
        __FILE__, __LINE__, keyword.ToStr().c_str(), item.c_str());
    return false;
  }
  ptr++;
  if (*ptr == '=') {
    ptr++;
    cmp_ = GreaterOrEqual;
  } else {
    cmp_ = Greater;
  }

  if (*ptr == '\0') {
    gLog("[%s][%d]: wrong syntax item %s\n", __FILE__, __LINE__, item.c_str());
    return false;
  }
  threshold_ = strtoul(ptr, NULL, 10);
  return threshold_ > 0;
}
GLuint TextureManager::add(string name)
{
	bool ext;
	GLuint id;
	transform (name.begin(), name.end(), name.begin(), ToLower());
	if (names.find(name) != names.end())
	{
		id = names[name];
		items[id]->addref();
		return id;
	}
	
	glGenTextures(1, &id);

	Texture* tex = new Texture(name);
	tex->id = id;
	ext=LoadBLP(id, tex);

	if(!ext)
		gLog("[World of Warcraft Studio - Editor] - Loading Texture from MPQ %s\n", name.c_str());
	else
		gLog("[World of Warcraft Studio - Editor] - Loading Texture from File %s\n", name.c_str());

	do_add(name, id, tex);

	return id;
}
int gdKeyGrabber::handle(int e)
{
	int ret = Fl_Group::handle(e);
	switch(e) {
		case FL_KEYUP: {
			int x = Fl::event_key();
			if (strlen(Fl::event_text()) != 0
			    && x != FL_BackSpace
			    && x != FL_Enter
			    && x != FL_Delete
			    && x != FL_Tab
			    && x != FL_End
			    && x != ' ')
			{
				gLog("set key '%c' (%d) for channel %d\n", x, x, ch->index);
				setButtonLabel(x);
				updateText(x);
				break;
			}
			else
				gLog("invalid key\n");
		}
	}
	return(ret);
}
Exemple #14
0
void print() 
{
	gLog("[REC] ** print debug **\n");
	for (unsigned i=0; i<global.size; i++) {
		gLog("  frame %d\n", frames.at(i));
		for (unsigned j=0; j<global.at(i).size; j++) {
			gLog("    action %d | chan %d | frame %d\n", global.at(i).at(j)->type, global.at(i).at(j)->chan, global.at(i).at(j)->frame);
		}
	}
}
Exemple #15
0
int startStream() {
	try {
		system->startStream();
		gLog("[KA] latency = %lu\n", system->getStreamLatency());
		return 1;
	}
	catch (RtAudioError &e) {
		gLog("[KA] Start stream error: %s\n", e.getMessage().c_str());
		return 0;
	}
}
Exemple #16
0
Model::Model(std::string name, bool forceAnim) : ManagedItem(name), forceAnim(forceAnim)
{
	// replace .MDX with .M2
	char tempname[256];
	strcpy(tempname,name.c_str());
	tempname[name.length()-2] = '2';
	tempname[name.length()-1] = 0;

	MPQFile f(tempname);
	ok = !f.isEof();

	if (!ok) {
		gLog("Error loading model [%s]\n", tempname);
		return;
	}

	memcpy(&header, f.getBuffer(), sizeof(ModelHeader));

	// HACK: these particle systems are way too active and cause horrible horrible slowdowns
	// I'm removing them until I can fix emission speed so it doesn't get this crazy
	if (false
	|| name=="World\\Kalimdor\\Orgrimmar\\Passivedoodads\\Orgrimmarbonfire\\Orgrimmarsmokeemitter.Mdx"	
	//|| name=="World\\Kalimdor\\Orgrimmar\\Passivedoodads\\Orgrimmarbonfire\\Orgrimmarbonfire01.Mdx"	
	) {
        header.nParticleEmitters = 0;
	}

	animated = isAnimated(f) || forceAnim;  // isAnimated will set animGeometry and animTextures

	gLog("Loading model %s%s\n", tempname, animated ? " (animated)" : "");

	trans = 1.0f;

	vbuf = nbuf = tbuf = 0;

	globalSequences = 0;
	animtime = 0;
	anim = 0;
	colors = 0;
	lights = 0;
	transparency = 0;
	particleSystems = 0;
	ribbons = 0;
	if (header.nGlobalSequences) {
		globalSequences = new int[header.nGlobalSequences];
		memcpy(globalSequences, (f.getBuffer() + header.ofsGlobalSequences), header.nGlobalSequences * 4);
	}

	if (animated) initAnimated(f);
	else initStatic(f);

	f.close();
}
Exemple #17
0
int SampleChannel::load(const char *file)
{
	if (strcmp(file, "") == 0 || gIsDir(file)) {
		gLog("[SampleChannel] file not specified\n");
		return SAMPLE_LEFT_EMPTY;
	}

	if (strlen(file) > FILENAME_MAX)
		return SAMPLE_PATH_TOO_LONG;

	Wave *w = new Wave();

	if (!w->open(file)) {
		gLog("[SampleChannel] %s: read error\n", file);
		delete w;
		return SAMPLE_READ_ERROR;
	}

	if (w->channels() > 2) {
		gLog("[SampleChannel] %s: unsupported multichannel wave\n", file);
		delete w;
		return SAMPLE_MULTICHANNEL;
	}

	if (!w->readData()) {
		delete w;
		return SAMPLE_READ_ERROR;
	}

	if (w->channels() == 1) /** FIXME: error checking  */
		wfx_monoToStereo(w);

	if (w->rate() != G_Conf.samplerate) {
		gLog("[SampleChannel] input rate (%d) != system rate (%d), conversion needed\n",
				w->rate(), G_Conf.samplerate);
		w->resample(G_Conf.rsmpQuality, G_Conf.samplerate);
	}

	pushWave(w);

	/* sample name must be unique. Start from k = 1, zero is too nerdy */

	std::string oldName = wave->name;
	int k = 1;
	while (!mh_uniqueSamplename(this, wave->name.c_str())) {
		wave->updateName((oldName + "-" + gItoa(k)).c_str());
		k++;
	}

	gLog("[SampleChannel] %s loaded in channel %d\n", file, index);
	return SAMPLE_LOADED_OK;
}
Exemple #18
0
void deleteAction(int chan, int frame, char type, bool checkValues, uint32_t iValue, float fValue) 
{
	/* find the frame 'frame' */

	bool found = false;
	for (unsigned i=0; i<frames.size && !found; i++) {
		if (frames.at(i) == frame) {

			/* find the action in frame i */

			for (unsigned j=0; j<global.at(i).size; j++) {
				action *a = global.at(i).at(j);

				/* action comparison logic */

				bool doit = (a->chan == chan && a->type == (type & a->type));
				if (checkValues)
					doit &= (a->iValue == iValue && a->fValue == fValue);

				if (doit) {
					int lockStatus = 0;
					while (lockStatus == 0) {
						lockStatus = pthread_mutex_trylock(&G_Mixer.mutex_recs);
						if (lockStatus == 0) {
#ifdef WITH_VST
							if (type == ACTION_MIDI)
								free(a->event);
#endif
							free(a);
							global.at(i).del(j);
							pthread_mutex_unlock(&G_Mixer.mutex_recs);
							found = true;
							break;
						}
						else
							gLog("[REC] delete action: waiting for mutex...\n");
					}
				}
			}
		}
	}
	if (found) {
		optimize();
		chanHasActions(chan);
		gLog("[REC] action deleted, type=%d frame=%d chan=%d iValue=%d (%X) fValue=%f\n",
			type, frame, chan, iValue, iValue, fValue);
	}
	else
		gLog("[REC] unable to find action! type=%d frame=%d chan=%d iValue=%d (%X) fValue=%f\n",
			type, frame, chan, iValue, iValue, fValue);
}
Exemple #19
0
int Wave::readData() {
	size = inHeader.frames * inHeader.channels;
	data = (float *) malloc(size * sizeof(float));
	if (data == NULL) {
		gLog("[wave] unable to allocate memory\n");
		return 0;
	}

	if (sf_read_float(fileIn, data, size) != size)
		gLog("[wave] warning: incomplete read!\n");

	sf_close(fileIn);
	return 1;
}
Exemple #20
0
void expand(int old_fpb, int new_fpb) 
{
	/* this algorithm requires multiple passages if we expand from e.g. 2
	 * to 16 beats, precisely 16 / 2 - 1 = 7 times (-1 is the first group,
	 * which exists yet). If we expand by a non-multiple, the result is zero,
	 * due to float->int implicit cast */

	unsigned pass = (int) (new_fpb / old_fpb) - 1;
	if (pass == 0) pass = 1;

	unsigned init_fs = frames.size;

	for (unsigned z=1; z<=pass; z++) {
		for (unsigned i=0; i<init_fs; i++) {
			unsigned newframe = frames.at(i) + (old_fpb*z);
			frames.add(newframe);
			global.add(actions);
			for (unsigned k=0; k<global.at(i).size; k++) {
				action *a = global.at(i).at(k);
				rec(a->chan, a->type, newframe, a->iValue, a->fValue);
			}
		}
	}
	gLog("[REC] expanded recs\n");
	//print();
}
Exemple #21
0
Channel::Channel(int type, int status, char side, int bufferSize)
	: bufferSize(bufferSize),
	  type      (type),
		status    (status),
		side      (side),
	  volume    (DEFAULT_VOL),
	  volume_i  (1.0f),
	  volume_d  (0.0f),
	  panLeft   (1.0f),
	  panRight  (1.0f),
	  mute_i    (false),
	  mute_s    (false),
	  mute      (false),
	  solo      (false),
	  hasActions(false),
	  recStatus (REC_STOPPED),
	  vChan     (NULL),
	  guiChannel(NULL),
	  midiIn        (true),
	  midiInKeyPress(0x0),
	  midiInKeyRel  (0x0),
	  midiInKill    (0x0),
	  midiInVolume  (0x0),
	  midiInMute    (0x0),
	  midiInSolo    (0x0)
{
	vChan = (float *) malloc(bufferSize * sizeof(float));
	if (!vChan)
		gLog("[Channel] unable to alloc memory for vChan\n");
	memset(vChan, 0, bufferSize * sizeof(float));
}
Exemple #22
0
void gKeyboard::__cb_addColumn()
{
	int colx;
	int colxw;
	int colw = 380;
	if (columns.size == 0) {
		colx  = x() - xposition();  // mind the offset with xposition()
		colxw = colx + colw;
	}
	else {
		gColumn *prev = columns.last();
		colx  = prev->x()+prev->w() + 16;
		colxw = colx + colw;
	}

	/* add gColumn to gKeyboard and to columns vector */

	gColumn *gc = new gColumn(colx, y(), colw-20, 2000, indexColumn, this);
  add(gc);
	columns.add(gc);
	indexColumn++;

	/* move addColumn button */

	addColumnBtn->position(colxw-4, y());
	redraw();

	gLog("[gKeyboard::__cb_addColumn] new column added (index = %d), total count=%d, addColumn(x)=%d\n",
		gc->getIndex(), columns.size, addColumnBtn->x());
}
Exemple #23
0
void Skies::initSky(Vec3D pos, int t)
{
	if (numSkies==0) 
		return;

	findSkyWeights(pos);

	for (int i=0; i<18; i++) colorSet[i] = Vec3D(1,1,1);

	// interpolation
	for (size_t j=0; j<skies.size(); j++) {
		if (skies[j].weight>0) {
			// now calculate the color rows
			for (int i=0; i<18; i++) {
				if((skies[j].colorFor(i,t).x>1.0f)||(skies[j].colorFor(i,t).y>1.0f)||(skies[j].colorFor(i,t).z>1.0f))
				{
					gLog("Sky %d %d is out of bounds!\n",j,i);
					continue;
				}
				colorSet[i] += skies[j].colorFor(i,t) * skies[j].weight;
			}
		}
	}
	for (int i=0; i<18; i++) 
	{
		colorSet[i] -= Vec3D( 1, 1, 1 );
	}
}
Exemple #24
0
Skies::Skies( int mapid )
{
	gLog( "Skies::Skies( %i );\n", mapid );

	numSkies = 0;
	cs = -1;
	stars = 0;

	for( DBCFile::Iterator i = gLightDB.begin(); i != gLightDB.end(); ++i )
	{
		if( mapid == i->getUInt( LightDB::Map ) )
		{
			Sky s( i );
			skies.push_back( s );
			numSkies++;
		}
	}

	// sort skies from smallest to largest; global last.
	// smaller skies will have precedence when calculating weights to achieve smooth transitions etc.
	std::sort( skies.begin( ), skies.end( ) );

	stars = new Model( "Environments\\Stars\\Stars.mdx", true );

}
Exemple #25
0
std::string gGetHomePath()
{
	char path[PATH_MAX];

#if   defined(__linux__)

	snprintf(path, PATH_MAX, "%s/.giada", getenv("HOME"));

#elif defined(_WIN32)

	snprintf(path, PATH_MAX, ".");

#elif defined(__APPLE__)

	struct passwd *p = getpwuid(getuid());
	if (p == NULL) {
		gLog("[gGetHomePath] unable to fetch user infos\n");
		return "";
	}
	else {
		const char *home = p->pw_dir;
		snprintf(path, PATH_MAX, "%s/Library/Application Support/Giada", home);
	}

#endif

	return std::string(path);
}
Exemple #26
0
void clearChan(int index) 
{
	gLog("[REC] clearing chan %d...\n", index);

	for (unsigned i=0; i<global.size; i++) {	// for each frame i
		unsigned j=0;
		while (true) {
			if (j == global.at(i).size) break; 	  // for each action j of frame i
			action *a = global.at(i).at(j);
			if (a->chan == index)	{
#ifdef WITH_VST
				if (a->type == ACTION_MIDI)
					free(a->event);
#endif
				free(a);
				global.at(i).del(j);
			}
			else
				j++;
		}
	}

	Channel *ch = G_Mixer.getChannelByIndex(index);
	ch->hasActions = false;
	optimize();
	//print();
}
Exemple #27
0
std::string DataStorageIni::getValue(const char *in) 
{
	/* on each call reset the pointe to the beginning of the file. Not so
	 * good but necessary if you want to pick up random values from the
	 * file. */

	fseek(fp, 0L, SEEK_SET);
	std::string out = "";

	while (!feof(fp)) {

		char buffer[MAX_LINE_LEN];
		if (fgets(buffer, MAX_LINE_LEN, fp) == NULL) {
			gLog("[PATCH] get_value error (key=%s)\n", in);
			return "";
		}

		if (buffer[0] == '#')
			continue;

		unsigned len = strlen(in);
		if (strncmp(buffer, in, len) == 0) {

			for (unsigned i=len+1; i<MAX_LINE_LEN; i++) {
				if (buffer[i] == '\0' || buffer[i] == '\n' || buffer[i] == '\r')
					break;
				out += buffer[i];
			}

			break; // string found
		}
	}
	return out;
}
Exemple #28
0
int PluginHost::allocBuffers() {

	/** FIXME - ERROR CHECKING! */

	/* never, ever use G_Conf.buffersize to alloc these chunks of memory.
	 * If you use JACK, that value would be meaningless. Always refer to
	 * kernelAudio::realBufsize. */

	int bufSize = kernelAudio::realBufsize*sizeof(float);

	bufferI    = (float **) malloc(2 * sizeof(float*));
	bufferI[0] =  (float *) malloc(bufSize);
	bufferI[1] =  (float *) malloc(bufSize);

	bufferO    = (float **) malloc(2 * sizeof(float*));
	bufferO[0] =  (float *) malloc(bufSize);
	bufferO[1] =  (float *) malloc(bufSize);

	memset(bufferI[0], 0, bufSize);
	memset(bufferI[1], 0, bufSize);
	memset(bufferO[0], 0, bufSize);
	memset(bufferO[1], 0, bufSize);

	gLog("[pluginHost] buffers allocated, buffersize = %d\n", 2*kernelAudio::realBufsize);

	//printOpcodes();

	return 1;
}
Exemple #29
0
int Plugin::setProgram(int index) {
	plugin->dispatcher(plugin, effBeginSetProgram, 0, 0, 0, 0);
	plugin->dispatcher(plugin, effSetProgram, 0, index, 0, 0);
	gLog("[plugin] program changed, index %d\n", index);
	program = index;
	return plugin->dispatcher(plugin, effEndSetProgram, 0, 0, 0, 0);
}
Exemple #30
0
int PluginHost::addPlugin(const char *fname, int stackType, Channel *ch) {

	Plugin *p    = new Plugin();
	bool success = true;

	gVector <Plugin *> *pStack;
	pStack = getStack(stackType, ch);

	if (!p->load(fname)) {
		//delete p;
		//return 0;
		success = false;
	}

	/* if the load failed we add a 'dead' plugin into the stack. This is
	 * useful to report a missing plugin. */

	if (!success) {
		pStack->add(p);
		return 0;
	}

	/* otherwise let's try to initialize it. */

	else {

		/* try to init the plugin. If fails, delete it and return error. */

		if (!p->init(&PluginHost::HostCallback)) {
			delete p;
			return 0;
		}

		/* plugin setup */

		p->setup(G_Conf.samplerate, kernelAudio::realBufsize);

		/* try to add the new plugin until succeed */

		int lockStatus;
		while (true) {
			lockStatus = pthread_mutex_trylock(&G_Mixer.mutex_plugins);
			if (lockStatus == 0) {
				pStack->add(p);
				pthread_mutex_unlock(&G_Mixer.mutex_plugins);
				break;
			}
		}

		char name[256]; p->getName(name);
		gLog("[pluginHost] plugin id=%d loaded (%s), stack type=%d, stack size=%d\n", p->getId(), name, stackType, pStack->size);

		/* p->resume() is suggested. Who knows... */

		p->resume();

		return 1;
	}
}