Esempio n. 1
0
SampleChannel *mh_startInputRec()
{
	

	SampleChannel *chan = NULL;
	for (unsigned i=0; i<G_Mixer.channels.size(); i++) {
		if (G_Mixer.channels.at(i)->type == CHANNEL_SAMPLE)
			if (((SampleChannel*) G_Mixer.channels.at(i))->canInputRec()) {
			chan = (SampleChannel*) G_Mixer.channels.at(i);
			break;
		}
	}

	

	if (chan == NULL)
		return NULL;

	Wave *w = new Wave();
	if (!w->allocEmpty(G_Mixer.totalFrames, G_Conf.samplerate))
		return NULL;

	

	char name[32];
	sprintf(name, "TAKE-%d", G_Patch_DEPR_.lastTakeId);
	while (!mh_uniqueSamplename(chan, name)) {
		G_Patch_DEPR_.lastTakeId++;
		G_Patch.lastTakeId++;
		sprintf(name, "TAKE-%d", G_Patch_DEPR_.lastTakeId);
	}

	chan->allocEmpty(G_Mixer.totalFrames, G_Patch_DEPR_.lastTakeId);
	G_Mixer.chanInput = chan;

	
	

	G_Mixer.inputTracker = G_Mixer.actualFrame;

	gLog(
		"[mh] start input recs using chan %d with size %d, frame=%d\n",
		chan->index, G_Mixer.totalFrames, G_Mixer.inputTracker
	);

	return chan;
}
Esempio n. 2
0
SampleChannel *mh_startInputRec()
{
	/* search for the next available channel */

	SampleChannel *chan = NULL;
	for (unsigned i=0; i<G_Mixer.channels.size; i++) {
		if (G_Mixer.channels.at(i)->type == CHANNEL_SAMPLE)
			if (((SampleChannel*) G_Mixer.channels.at(i))->canInputRec()) {
			chan = (SampleChannel*) G_Mixer.channels.at(i);
			break;
		}
	}

	/* no chans available? */

	if (chan == NULL)
		return NULL;

	Wave *w = new Wave();
	if (!w->allocEmpty(G_Mixer.totalFrames))
		return NULL;

	/* increase lastTakeId until the sample name TAKE-[n] is unique */

	char name[32];
	sprintf(name, "TAKE-%d", G_Patch.lastTakeId);
	while (!mh_uniqueSamplename(chan, name)) {
		G_Patch.lastTakeId++;
		sprintf(name, "TAKE-%d", G_Patch.lastTakeId);
	}

	chan->allocEmpty(G_Mixer.totalFrames, G_Patch.lastTakeId);
	G_Mixer.chanInput = chan;

	/* start to write from the actualFrame, not the beginning */
	/** FIXME: move this before wave allocation*/

	G_Mixer.inputTracker = G_Mixer.actualFrame;

	gLog(
		"[mh] start input recs using chan %d with size %d, frame=%d\n",
		chan->index, G_Mixer.totalFrames, G_Mixer.inputTracker
	);

	return chan;
}
Esempio n. 3
0
bool mh_startInputRec()
{
	int channelsReady = 0;

	for (unsigned i=0; i<G_Mixer.channels.size(); i++) {

		if (!G_Mixer.channels.at(i)->canInputRec())
			continue;

		SampleChannel *ch = (SampleChannel*) G_Mixer.channels.at(i);

		/* Allocate empty sample for the current channel. */

		if (!ch->allocEmpty(G_Mixer.totalFrames, G_Conf.samplerate, G_Patch.lastTakeId))
		{
			gu_log("[mh_startInputRec] unable to allocate new Wave in chan %d!\n",
				ch->index);
			continue;
		}

		/* Increase lastTakeId until the sample name TAKE-[n] is unique */

		while (!mh_uniqueSampleName(ch, ch->wave->name)) {
			G_Patch_DEPR_.lastTakeId++;
			G_Patch.lastTakeId++;
			ch->wave->name = "TAKE-" + gu_itoa(G_Patch.lastTakeId);
		}

		gu_log("[mh_startInputRec] start input recs using chan %d with size %d "
			"frame=%d\n", ch->index, G_Mixer.totalFrames, G_Mixer.inputTracker);

		channelsReady++;
	}

	if (channelsReady > 0) {
		G_Mixer.recording = true;
		/* start to write from the currentFrame, not the beginning */
		/** FIXME: this should be done before wave allocation */
		G_Mixer.inputTracker = G_Mixer.currentFrame;
		return true;
	}
	return false;
}