Пример #1
0
void gdEditor::__cb_setChanPos() {
	glue_setBeginEndChannel(
		this,
		ch,
		atoi(chanStart->value())*2,  // glue halves printed values
		atoi(chanEnd->value())*2,
		true
	);
}
Пример #2
0
void gdEditor::__cb_reload()
{
  if (!gdConfirmWin("Warning", "Reload sample: are you sure?"))
    return;

  /* no need for glue_loadChan, there's no gui to refresh */

  ch->load(ch->wave->pathfile.c_str(), G_Conf.samplerate, G_Conf.rsmpQuality);

  glue_setBoost(this, ch, DEFAULT_BOOST, true);
  glue_setPitch(this, ch, gDEFAULT_PITCH, true);
  glue_setPanning(this, ch, 1.0f);
  pan->value(1.0f);  // glue_setPanning doesn't do it
  pan->redraw();     // glue_setPanning doesn't do it

  waveTools->waveform->stretchToWindow();
  waveTools->updateWaveform();

  glue_setBeginEndChannel(this, ch, 0, ch->wave->size, true);

  redraw();
}
Пример #3
0
void gdEditor::__cb_reload() {

	if (!gdConfirmWin("Warning", "Reload sample: are you sure?"))
		return;

	/* no need for glue_loadChan, there's no gui to refresh */

	mh_loadChan(G_Mixer.chan[chan]->pathfile.c_str(), chan);

	glue_setBoost(this, chan, DEFAULT_BOOST, true);
	glue_setPitch(this, chan, gDEFAULT_PITCH, true);
	glue_setPanning(this, chan, 1.0f);
	pan->value(1.0f);  // glue_setPanning doesn't do it
	pan->redraw();     // glue_setPanning doesn't do it

	wt->wave->calcZoom();
	wt->wave->alloc();
	wt->wave->redraw();

	glue_setBeginEndChannel(this, chan, 0, G_Mixer.chan[chan]->size, true);

	redraw();
}
Пример #4
0
void gdEditor::__cb_resetStartEnd()
{
  glue_setBeginEndChannel(this, ch, 0, ch->wave->size, true);
}
Пример #5
0
void gWaveform::openEditMenu() {

	if (selectionA == selectionB)
		return;

	menuOpen = true;

	Fl_Menu_Item menu[] = {
		{"Cut"},
		{"Trim"},
		{"Silence"},
		{"Fade in"},
		{"Fade out"},
		{"Smooth edges"},
		{"Set start/end here"},
		{0}
	};

	if (chan->status == STATUS_PLAY) {
		menu[0].deactivate();
		menu[1].deactivate();
	}

	Fl_Menu_Button *b = new Fl_Menu_Button(0, 0, 100, 50);
	b->box(G_BOX);
	b->textsize(11);
	b->textcolor(COLOR_TEXT_0);
	b->color(COLOR_BG_0);

	const Fl_Menu_Item *m = menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, b);
	if (!m) {
		menuOpen = false;
		return;
	}

	/* straightSel() to ensure that point A is always lower than B */

	straightSel();

	if (strcmp(m->label(), "Silence") == 0) {
		wfx_silence(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));

		selectionA = 0;
		selectionB = 0;

		stretchToWindow();
		redraw();
		menuOpen = false;
		return;
	}

	if (strcmp(m->label(), "Set start/end here") == 0) {

		glue_setBeginEndChannel(
				(gdEditor *) window(), // parent
				chan,
				absolutePoint(selectionA) * 2,  // stereo!
				absolutePoint(selectionB) * 2,  // stereo!
				false, // no recalc (we do it here)
				false  // don't check
				);

		selectionA     = 0;
		selectionB     = 0;
		selectionA_abs = 0;
		selectionB_abs = 0;

		recalcPoints();
		redraw();
		menuOpen = false;
		return;
	}

	if (strcmp(m->label(), "Cut") == 0) {
		wfx_cut(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));

		/* for convenience reset start/end points */

		glue_setBeginEndChannel(
			(gdEditor *) window(),
			chan,
			0,
			chan->wave->size,
			false);

		selectionA     = 0;
		selectionB     = 0;
		selectionA_abs = 0;
		selectionB_abs = 0;

		setZoom(0);

		menuOpen = false;
		return;
	}

	if (strcmp(m->label(), "Trim") == 0) {
		wfx_trim(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));

		glue_setBeginEndChannel(
			(gdEditor *) window(),
			chan,
			0,
			chan->wave->size,
			false);

		selectionA     = 0;
		selectionB     = 0;
		selectionA_abs = 0;
		selectionB_abs = 0;

		stretchToWindow();
		menuOpen = false;
		redraw();
		return;
	}

	if (!strcmp(m->label(), "Fade in") || !strcmp(m->label(), "Fade out")) {

		int type = !strcmp(m->label(), "Fade in") ? 0 : 1;
		wfx_fade(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB), type);

		selectionA = 0;
		selectionB = 0;

		stretchToWindow();
		redraw();
		menuOpen = false;
		return;
	}

	if (!strcmp(m->label(), "Smooth edges")) {

		wfx_smooth(chan->wave, absolutePoint(selectionA), absolutePoint(selectionB));

		selectionA = 0;
		selectionB = 0;

		stretchToWindow();
		redraw();
		menuOpen = false;
		return;
	}
}
Пример #6
0
int gWaveform::handle(int e) {

	int ret = 0;

	switch (e) {

		case FL_PUSH: {

			mouseX = Fl::event_x();
			pushed = true;

			if (!mouseOnEnd() && !mouseOnStart()) {

				/* right button? show the menu. Don't set selectionA,B,etc */

				if (Fl::event_button3()) {
					openEditMenu();
				}
				else
				if (mouseOnSelectionA() || mouseOnSelectionB()) {
					resized = true;
				}
				else {
					dragged = true;
					selectionA = Fl::event_x() - x();

					if (selectionA >= data.size) selectionA = data.size;

					selectionB = selectionA;
					selectionA_abs = absolutePoint(selectionA);
					selectionB_abs = selectionA_abs;
				}
			}

			ret = 1;
			break;
		}

		case FL_RELEASE: {

			/* don't recompute points if something is selected */

			if (selectionA != selectionB) {
				pushed  = false;
				dragged = false;
				ret = 1;
				break;
			}

			///int realChanStart = chan->beginTrue;
			///int realChanEnd   = chan->endTrue;
			int realChanStart = chan->begin;
			int realChanEnd   = chan->end;

			if (chanStartLit)
				realChanStart = absolutePoint(chanStart)*2;
			else
			if (chanEndLit)
				realChanEnd = absolutePoint(chanEnd)*2;

			glue_setBeginEndChannel((gdEditor *) window(), chan, realChanStart, realChanEnd, false);

			pushed  = false;
			dragged = false;

			redraw();
			ret = 1;
			break;
		}

		case FL_ENTER: {  // enables FL_DRAG
			ret = 1;
			break;
		}

		case FL_LEAVE: {
			if (chanStartLit || chanEndLit) {
				chanStartLit = false;
				chanEndLit   = false;
				redraw();
			}
			ret = 1;
			break;
		}

		case FL_MOVE: {
			mouseX = Fl::event_x();
			mouseY = Fl::event_y();

			if (mouseOnStart()) {
				chanStartLit = true;
				redraw();
			}
			else
			if (chanStartLit) {
				chanStartLit = false;
				redraw();
			}


			if (mouseOnEnd()) {
				chanEndLit = true;
				redraw();
			}
			else
			if (chanEndLit) {
				chanEndLit = false;
				redraw();
			}

			if (mouseOnSelectionA()) {
				fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK);
			}
			else
			if (mouseOnSelectionB()) {
				fl_cursor(FL_CURSOR_WE, FL_WHITE, FL_BLACK);
			}
			else {
				fl_cursor(FL_CURSOR_DEFAULT, FL_WHITE, FL_BLACK);
			}

			ret = 1;
			break;
		}

		case FL_DRAG: {

			if (chanStartLit && pushed)	{

				chanStart += Fl::event_x() - mouseX;

				if (chanStart < 0)
					chanStart = 0;

				if (chanStart >= chanEnd)
					chanStart = chanEnd-2;

				redraw();
			}
			else
			if (chanEndLit && pushed) {

				chanEnd += Fl::event_x() - mouseX;

				if (chanEnd >= data.size - 2)
					chanEnd = data.size - 2;

				if (chanEnd <= chanStart)
					chanEnd = chanStart + 2;

				redraw();
			}

			/* here the mouse is on the waveform, i.e. a selection */

			else
			if (dragged) {

				selectionB = Fl::event_x() - x();

				if (selectionB >= data.size)
					selectionB = data.size;

				if (selectionB <= 0)
					selectionB = 0;

				selectionB_abs = absolutePoint(selectionB);
				redraw();
			}
			else
			if (resized) {
				if (mouseOnSelectionA()) {
					selectionA     = Fl::event_x() - x();
					selectionA_abs = absolutePoint(selectionA);
				}
				else {
					selectionB     = Fl::event_x() - x();
					selectionB_abs = absolutePoint(selectionB);
				}
				redraw();
			}
			mouseX = Fl::event_x();
			ret = 1;
			break;
		}
	}
	return ret;
}
Пример #7
0
void gdEditor::__cb_resetStartEnd() {
	glue_setBeginEndChannel(this, chan, 0, G_Mixer.chan[chan]->size, true);
}