Пример #1
0
void MainWindow::OnMenuAbout()
{
	Gtk::Dialog *pDialog = NULL;
	builder->get_widget("zzz_about_dialog", pDialog);

	if(pDialog) {
		pDialog->set_transient_for(*this);
		pDialog->run();
		pDialog->hide();
	}
}
Пример #2
0
void View::show_dialog(const char *name)
{
  Gtk::Dialog *dialog;
  m_builder->get_widget (name, dialog);
  if (!dialog) {
    cerr << "no such dialog " << name << "\n";
    return;
  }
  dialog->signal_response().connect (sigc::bind(sigc::mem_fun(*this, &View::hide_on_response), dialog));
  dialog->show();
  dialog->set_transient_for (*this);
}
Пример #3
0
int main(int argc, char *argv[])
{
	memset(&last_refreshed, 0, sizeof(last_refreshed));
	for(int i = 1; i < argc; i++)
	{
		string tmp(argv[i]);
		if(tmp == "-s")display_spectrum = true;
		if(tmp == "-S")display_spectrogram = true;
	}
	Util.ChDir(Util.GetDirFromPath(Util.GetProgramPath()));
	//goto aaaaa;
	//fft=rfftw_create_plan(8192,
	for(UInt i = 0; i < CHANNELS; i++)
	{
		FFTFilter<jack_default_audio_sample_t>* trololo = new FFTFilter<jack_default_audio_sample_t>
		//bs, inbuffers,	outbuffers,	overlap,buffersperperiod,	paddingL,paddingR,	fftsize
		(1024, 12,			12,			2,		8,					0,		 0,			8192);

		//trololo->freq_scale=9./10.;
		setFilterParams(*trololo);
		filt[i] = trololo;
	}

	
	jack_set_error_function(error);
	JackStatus st;
	if((client = jack_client_open("jackfft", JackNoStartServer, &st)) == 0) {
		fprintf(stderr, "could not connect to server: status %i\n", st);
		return 1;
	}
	jack_set_process_callback(client, process, 0);
	jack_on_shutdown(client, jack_shutdown, 0);
	printf("engine sample rate: %u\n", srate = jack_get_sample_rate(client));
	/* create ports */
	int i;
	for(i = 0; i < CHANNELS; i++)
	{
		inputs.push_back(jack_port_register(client, CONCAT("input_" << i).c_str(),
						JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0));
		outputs.push_back(jack_port_register(client, CONCAT("output_" << i).c_str(),
						JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0));
#ifdef JACKFFT_USE_SOUNDTOUCH
		soundTouch[i].setSampleRate(srate);
		soundTouch[i].setChannels(1);
#endif
	}

//aaaaa:
	Gtk::Main kit(argc, argv);

	b = Gtk::Builder::create_from_file("main2.ui");
	
	Gtk::Window* window1;
	Gtk::Button* b_save;
	Gtk::Button* b_saveas;
	Gtk::Button* b_open;
	Gtk::Button* b_revert;
	Gtk::Button* b_apply;
	Gtk::Button* b_params;
	Gtk::Button* b_shift;
	Gtk::CheckButton* c_pitchshift;
	Gtk::CheckButton* c_spectrum;
	Gtk::CheckButton* c_spectrogram;
	Gtk::CheckButton* c_spectrogram1;
	Gtk::CheckButton* c_spectrum2;
	Gtk::CheckButton* c_mux;
	Gtk::Label* label8;
	Gtk::FileChooserDialog* filechooserdialog1;
	Gtk::Viewport* viewport1;
	Gtk::Viewport* viewport2;
	Gtk::Viewport* viewport4;
	Gtk::Scale* s_mux;
	
	//get controls
	JACKFFT_GETWIDGET(window1); JACKFFT_GETWIDGET(b_save); JACKFFT_GETWIDGET(b_saveas);
	JACKFFT_GETWIDGET(b_open); JACKFFT_GETWIDGET(b_revert); JACKFFT_GETWIDGET(b_apply);
	JACKFFT_GETWIDGET(c_pitchshift); JACKFFT_GETWIDGET(label8); JACKFFT_GETWIDGET(b_params);
	JACKFFT_GETWIDGET(b_shift); JACKFFT_GETWIDGET(filechooserdialog1); JACKFFT_GETWIDGET(viewport1);
	JACKFFT_GETWIDGET(viewport2); JACKFFT_GETWIDGET(c_spectrum); JACKFFT_GETWIDGET(c_spectrum2);
	JACKFFT_GETWIDGET(s_mux); JACKFFT_GETWIDGET(c_mux); JACKFFT_GETWIDGET(viewport4);
	JACKFFT_GETWIDGET(c_spectrogram); JACKFFT_GETWIDGET(c_spectrogram1);
	
	//initialize controls
	b_save->signal_clicked().connect(&save);
	b_saveas->signal_clicked().connect(&saveas);
	b_open->signal_clicked().connect(&loadfile);
	b_revert->signal_clicked().connect(&load);
	b_apply->signal_clicked().connect(&apply_pitchshift);
	c_pitchshift->signal_toggled().connect(&apply_pitchshift);
	
	
	c = new EQControl(EQ_POINTS);
	
	c->Change += EQControl::ChangeDelegate(&on_change, c);
	c->MouseMove += EQControl::MouseDelegate(&on_mousemove, c);
	
#ifdef CEPSTRUM
	c_eq2 = new EQControl(EQ_POINTS);
	c_eq2->Change += EQControl::ChangeDelegate(&on_change, c_eq2);
	c_eq2->MouseMove += EQControl::MouseDelegate(&on_mousemove, c_eq2);
#endif
	//UInt complexsize = (UInt)(((FFTFilter<jack_default_audio_sample_t>*)filt[0])->PeriodSize() / 2) + 1;


	apply_label_workaround(label8);

	b_params->signal_clicked().connect([]()
	{
		Gtk::Window* w1;
		Gtk::Dialog* d;
		b->get_widget("window1", w1);
		b->get_widget("dialog1", d);
		d->set_transient_for(*w1);
		if(d->run() != RESPONSE_APPLY)goto hhhhh;

		FFTFilter<jack_default_audio_sample_t>** tmp;
		tmp = new FFTFilter<jack_default_audio_sample_t>*[CHANNELS];
		Int bs, overlap, bpp, padding1, padding2, fftsize;
		Gtk::Entry* ent;
		b->get_widget("t_bs", ent);
		bs = atoi(ent->get_text().c_str());
		b->get_widget("t_overlap", ent);
		overlap = atoi(ent->get_text().c_str());
		b->get_widget("t_bpp", ent);
		bpp = atoi(ent->get_text().c_str());
		b->get_widget("t_padding1", ent);
		padding1 = atoi(ent->get_text().c_str());
		b->get_widget("t_padding2", ent);
		padding2 = atoi(ent->get_text().c_str());
		b->get_widget("t_fftsize", ent);
		fftsize = atoi(ent->get_text().c_str());
		Int buffers;
		buffers = (bpp + padding1 + padding2) + 4;
		for(int i = 0; i < CHANNELS; i++)
		{
			tmp[i] = new FFTFilter<jack_default_audio_sample_t>
			//bs, inbuffers,	outbuffers,	overlap,buffersperperiod,	padding1,padding2	fftsize
			(bs,  buffers,		buffers,	overlap,bpp,				padding1,padding2,	fftsize);
			setFilterParams(*(tmp[i]));
		}
		update_fft(tmp);
		apply_pitchshift1(tmp);
		filt2 = tmp; //assumed to be atomic on all cpus, otherwise the cpu sucks and is not supported
hhhhh:
		d->hide();
	});

	b_shift->signal_clicked().connect([]()
	{
		Gtk::Window* w1;
		Gtk::Dialog* d;
		b->get_widget("window1", w1);
		b->get_widget("dialog_shift", d);
		d->set_transient_for(*w1);
		if(d->run() != RESPONSE_OK)goto hhhhh;
		Gtk::Entry* ent;
		b->get_widget("t_x", ent);
		double x;
		x = atof(ent->get_text().c_str());
		for(Int i=0;i<EQ_POINTS;i++)
		{
			c->data[i]=scale_value_r(scale_value(c->data[i])*pow(2,x));
		}
		c->do_draw();
		update_fft();
	hhhhh:
		d->hide();
	});
	//d->signal_response().connect(&on_response);
	filechooserdialog1->add_button(Stock::CANCEL, RESPONSE_CANCEL);
	viewport1->add(*c);

	//c->set_hexpand(true);
	//c->set_vexpand(true);
	c->show();
	
#ifdef CEPSTRUM
	Gtk::Viewport* vp_eq2;
	b->get_widget("vp_eq2", vp_eq2);
	vp_eq2->add(*c_eq2);
	c_eq2->show();
#endif
	

	//if(display_spectrum)
	//{
	c2 = new EQControl(EQ_POINTS);
	viewport2->add(*c2);
	c2->show();
	c2->MouseMove += EQControl::MouseDelegate(&on_mousemove, c2);
	
	c3 = new HistoryControl(SPECTROGRAM_LEN,EQ_POINTS);
	c3->show();
	viewport4->add(*c3);
	/*}
	else
	{
		Gtk::Table* t1;
		b->get_widget("table1",t1);
		t1->remove(*v);
	}*/

	//spectrum display
	c_spectrum->set_active(display_spectrum);
	viewport2->set_visible(display_spectrum);
	c_spectrum->signal_toggled().connect([c_spectrum]()
	{
		Gtk::Window* w1;
		Gtk::Viewport* v;
		b->get_widget("window1", w1);
		b->get_widget("viewport1", v);
		
		gint ww,wh; w1->get_size(ww,wh);
		if(display_spectrum && !c_spectrum->get_active()) {
			w1->resize(ww,wh-v->get_allocation().get_height());
		} else if(!display_spectrum && c_spectrum->get_active()) {
			w1->resize(ww,wh+v->get_allocation().get_height());
		}
		display_spectrum = c_spectrum->get_active();
		Gtk::Viewport* vp;
		b->get_widget("viewport2", vp);
		vp->set_visible(display_spectrum);
	});
	
	//spectrogram display
	c_spectrogram->set_active(display_spectrogram);
	viewport4->set_visible(display_spectrogram);
	c_spectrogram->signal_toggled().connect([c_spectrogram]()
	{
		Gtk::Window* w1;
		Gtk::Viewport* v;
		b->get_widget("window1", w1);
		b->get_widget("viewport1", v);
		
		gint ww,wh; w1->get_size(ww,wh);
		if(display_spectrogram && !c_spectrogram->get_active()) {
			w1->resize(ww,wh-v->get_allocation().get_height());
		} else if(!display_spectrogram && c_spectrogram->get_active()) {
			w1->resize(ww,wh+v->get_allocation().get_height());
		}
		display_spectrogram = c_spectrogram->get_active();
		Gtk::Viewport* vp;
		b->get_widget("viewport4", vp);
		vp->set_visible(display_spectrogram);
	});
	
	//spectrogram output
	c_spectrogram1->set_active(output_spectrogram);
	c_spectrogram1->signal_toggled().connect([c_spectrogram1]()
	{
		if(output_spectrogram && !c_spectrogram1->get_active()) {
			disableSpectrogramOutput();
		} else if(!output_spectrogram && c_spectrogram1->get_active()) {
			enableSpectrogramOutput();
		}
		wmb();
		output_spectrogram=c_spectrogram1->get_active();
	});
	
	c_spectrum2->set_active(spectrum2);
	c_spectrum2->signal_toggled().connect([c_spectrum2]()
	{
		spectrum2 = c_spectrum2->get_active();
	});
	
	c_mux->set_active(do_mux);
	Gtk::Adjustment adj_mux(v_mux,0,1,0.01);
	s_mux->set_adjustment(adj_mux);
	
	auto update_mux=[&]() {
		do_mux=c_mux->get_active();
		v_mux=adj_mux.get_value();
	};
	
	s_mux->signal_value_changed().connect(update_mux);
	c_mux->signal_toggled().connect(update_mux);
	
	load();
	if(jack_activate(client)) {
		fprintf(stderr, "cannot activate client");
		return 1;
	}
	g_thread_init (NULL);
	gdk_threads_init();
	//glib_threads_init();
	
	pthread_t thr;
	pthread_create(&thr,NULL,&thread1,NULL);
	gdk_threads_enter();
	kit.run(*window1);
	gdk_threads_leave();
	jack_client_close(client);
	return 0;
}