Changeset 39
- Timestamp:
- 05/12/07 13:14:04 (2 years ago)
- Files:
-
- nekostring/trunk/gui/Makefile (modified) (5 diffs)
- nekostring/trunk/gui/Makefile.am (modified) (1 diff)
- nekostring/trunk/gui/callbacks.c (modified) (5 diffs)
- nekostring/trunk/gui/callbacks.h (modified) (1 diff)
- nekostring/trunk/gui/interface.c (modified) (5 diffs)
- nekostring/trunk/gui/main.c (modified) (4 diffs)
- nekostring/trunk/src/Makefile (modified) (1 diff)
- nekostring/trunk/src/neko-dssi.c (modified) (1 diff)
- nekostring/trunk/src/neko_synth.c (modified) (1 diff)
- nekostring/trunk/src/neko_voice_render.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nekostring/trunk/gui/Makefile
r29 r39 53 53 nekostring_gtk-support.$(OBJEXT) \ 54 54 nekostring_gtk-interface.$(OBJEXT) \ 55 nekostring_gtk-callbacks.$(OBJEXT) 55 nekostring_gtk-callbacks.$(OBJEXT) \ 56 nekostring_gtk-neko_ports.$(OBJEXT) 56 57 nekostring_gtk_OBJECTS = $(am_nekostring_gtk_OBJECTS) 57 58 nekostring_gtk_DEPENDENCIES = … … 85 86 CC = gcc 86 87 CCDEPMODE = depmode=gcc3 87 CFLAGS = - Werror -Wall88 CFLAGS = -g -O2 88 89 CPP = gcc -E 89 90 CPPFLAGS = … … 190 191 interface.c interface.h \ 191 192 callbacks.c callbacks.h \ 193 neko_ports.c \ 192 194 widgets.h 193 195 194 196 nekostring_gtk_LDADD = -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lm -llo -lpthread 197 _SOURCES = osc.c 195 198 all: all-am 196 199 … … 267 270 include ./$(DEPDIR)/nekostring_gtk-interface.Po 268 271 include ./$(DEPDIR)/nekostring_gtk-main.Po 272 include ./$(DEPDIR)/nekostring_gtk-neko_ports.Po 269 273 include ./$(DEPDIR)/nekostring_gtk-support.Po 270 274 … … 345 349 # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 346 350 # $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nekostring_gtk_CFLAGS) $(CFLAGS) -c -o nekostring_gtk-callbacks.obj `if test -f 'callbacks.c'; then $(CYGPATH_W) 'callbacks.c'; else $(CYGPATH_W) '$(srcdir)/callbacks.c'; fi` 351 352 nekostring_gtk-neko_ports.o: neko_ports.c 353 if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nekostring_gtk_CFLAGS) $(CFLAGS) -MT nekostring_gtk-neko_ports.o -MD -MP -MF "$(DEPDIR)/nekostring_gtk-neko_ports.Tpo" -c -o nekostring_gtk-neko_ports.o `test -f 'neko_ports.c' || echo '$(srcdir)/'`neko_ports.c; \ 354 then mv -f "$(DEPDIR)/nekostring_gtk-neko_ports.Tpo" "$(DEPDIR)/nekostring_gtk-neko_ports.Po"; else rm -f "$(DEPDIR)/nekostring_gtk-neko_ports.Tpo"; exit 1; fi 355 # source='neko_ports.c' object='nekostring_gtk-neko_ports.o' libtool=no \ 356 # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 357 # $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nekostring_gtk_CFLAGS) $(CFLAGS) -c -o nekostring_gtk-neko_ports.o `test -f 'neko_ports.c' || echo '$(srcdir)/'`neko_ports.c 358 359 nekostring_gtk-neko_ports.obj: neko_ports.c 360 if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nekostring_gtk_CFLAGS) $(CFLAGS) -MT nekostring_gtk-neko_ports.obj -MD -MP -MF "$(DEPDIR)/nekostring_gtk-neko_ports.Tpo" -c -o nekostring_gtk-neko_ports.obj `if test -f 'neko_ports.c'; then $(CYGPATH_W) 'neko_ports.c'; else $(CYGPATH_W) '$(srcdir)/neko_ports.c'; fi`; \ 361 then mv -f "$(DEPDIR)/nekostring_gtk-neko_ports.Tpo" "$(DEPDIR)/nekostring_gtk-neko_ports.Po"; else rm -f "$(DEPDIR)/nekostring_gtk-neko_ports.Tpo"; exit 1; fi 362 # source='neko_ports.c' object='nekostring_gtk-neko_ports.obj' libtool=no \ 363 # DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ 364 # $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(nekostring_gtk_CFLAGS) $(CFLAGS) -c -o nekostring_gtk-neko_ports.obj `if test -f 'neko_ports.c'; then $(CYGPATH_W) 'neko_ports.c'; else $(CYGPATH_W) '$(srcdir)/neko_ports.c'; fi` 347 365 348 366 mostlyclean-libtool: nekostring/trunk/gui/Makefile.am
r9 r39 21 21 interface.c interface.h \ 22 22 callbacks.c callbacks.h \ 23 neko_ports.c \ 23 24 widgets.h 24 25 25 26 nekostring_gtk_LDADD = @PACKAGE_LIBS@ -lm -llo -lpthread 26 27 28 _SOURCES = osc.c nekostring/trunk/gui/callbacks.c
r29 r39 15 15 16 16 #include 17 #include 18 #include 17 19 18 20 #include "callbacks.h" … … 20 22 #include "support.h" 21 23 #include "widgets.h" 24 #include "../src/neko_types.h" 25 #include "../src/neko_ports.h" 26 27 28 29 30 31 void update_voice_widget(int port, float value) 32 { 33 struct neko_port_descriptor *xpd; 34 GtkAdjustment *adj; 35 float cval, a, b, c, d; 36 37 38 //i if (port < XSYNTH_PORT_WAVEFORM || port >= XSYNTH_PORTS_COUNT) { 39 // return; 40 // } 41 42 xpd = &neko_port_description[port]; 43 44 if (value < xpd->lower_bound) 45 value = xpd->lower_bound; 46 else if (value > xpd->upper_bound) 47 value = xpd->upper_bound; 48 49 //internal_gui_update_only = 1; 50 51 // switch (xpd->type) { 52 53 // case XSYNTH_PORT_TYPE_LINEAR: 54 a=xpd->a; b=xpd->b; c=xpd->c; 55 // used in "on_voice_slider_change" value = (xpd->a * cval + xpd->b) * cval + xpd->c; 56 d = sqrt(b*b - 4*a*(c-value)); 57 cval=(-b+d)/(2*a); 58 //cval = (value - xpd->c) / xpd->b; // assume xpd->a == 0, which was always true for nekobee 59 printf(" update_voice_widget: change of %s to %f => %f\n", xpd->name, value, cval); 60 61 adj = (GtkAdjustment *)voice_widget[port]; 62 adj->value = cval * 10.0f; 63 // gtk_signal_emit_by_name (GTK_OBJECT (adj), "changed"); does not cause call to on_voice_slider_change callback 64 gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed"); // causes call to on_voice_slider_change callback 65 // break; 66 /* 67 case XSYNTH_PORT_TYPE_LOGARITHMIC: 68 cval = log(value / xpd->a) / (xpd->c * log(xpd->b)); 69 if (port == XSYNTH_PORT_TUNING) { 70 if (cval < -1.2f) cval = -1.2f; 71 if (cval > 1.2f) cval = 1.2f; 72 } 73 else { 74 if (cval > 1.0f - 1.0e-6f) 75 cval = 1.0f; 76 } 77 printf(" update_voice_widget: change of %s to %f => %f\n", xpd->name, value, cval); 78 adj = (GtkAdjustment *)voice_widget[port]; 79 adj->value = cval * 10.0f; 80 gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed"); // causes call to on_voice_slider_change callback 81 break; 82 default: 83 printf(" update_voice_widget: don't know what this is...\n"); 84 break; 85 86 87 } 88 // internal_gui_update_only = 0; 89 90 */ 91 } 92 93 94 22 95 23 96 void on_voice_slider_change( GtkWidget *widget, gpointer data ) … … 32 105 float value; 33 106 34 index=0; 35 value=0; 36 printf("from slider: %f\n",cval); 107 //printf("from slider: %d -> %f\n",index, cval); 37 108 38 adj= gtk_range_get_adjustment(GTK_RANGE(vs_viola));39 adj->value=cval;40 gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");109 // adj= gtk_range_get_adjustment(GTK_RANGE(vs_viola)); 110 // adj->value=cval; 111 // gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed"); 41 112 42 113 … … 52 123 // } else { /* XSYNTH_PORT_TYPE_LOGARITHMIC */ 53 124 54 //value = xpd->a * exp(xpd->c * cval * log(xpd->b));125 // value = xpd->a * exp(xpd->c * cval * log(xpd->b)); 55 126 56 127 // } … … 59 130 // index, GTK_ADJUSTMENT(widget)->value, value); 60 131 61 // lo_send(osc_host_address, osc_control_path, "if", index, value);132 lo_send(osc_host_address, osc_control_path, "if", index, cval); 62 133 } nekostring/trunk/gui/callbacks.h
r9 r39 11 11 12 12 #include 13 #include 13 14 void on_voice_slider_change( GtkWidget *widget, gpointer data ); 15 16 extern lo_address osc_host_address; 17 extern char * osc_control_path; nekostring/trunk/gui/interface.c
r29 r39 80 80 gtk_widget_set_size_request (vb_contrabass, 50, 135); 81 81 82 voice_widget[NEKO_PORT_BASS_LEVEL] = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new ( 1.706, 0, 2, 0, 0, 0)));82 voice_widget[NEKO_PORT_BASS_LEVEL] = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 0, 0, 0, 0))); 83 83 gtk_widget_show (voice_widget[NEKO_PORT_BASS_LEVEL]); 84 84 gtk_box_pack_start (GTK_BOX (vb_contrabass), voice_widget[NEKO_PORT_BASS_LEVEL], TRUE, FALSE, 0); … … 97 97 gtk_widget_set_size_request (vbox4, 50, 135); 98 98 99 vs_cello = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new ( 0, 0, 1, 0, 0, 0)));99 vs_cello = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (1, 0, 1, 0, 0, 0))); 100 100 gtk_widget_show (vs_cello); 101 101 gtk_box_pack_start (GTK_BOX (vbox4), vs_cello, TRUE, FALSE, 0); … … 114 114 gtk_widget_set_size_request (vbox5, 50, 135); 115 115 116 vs_viola = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new ( 0, 0, 1, 0, 0, 0)));116 vs_viola = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (1, 0, 1, 0, 0, 0))); 117 117 gtk_widget_show (vs_viola); 118 118 gtk_box_pack_start (GTK_BOX (vbox5), vs_viola, TRUE, FALSE, 0); … … 131 131 gtk_widget_set_size_request (vbox6, 50, 135); 132 132 133 vs_violin = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new ( 0, 0, 1, 0, 0, 0)));133 vs_violin = gtk_vscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (1, 0, 1, 0, 0, 0))); 134 134 gtk_widget_show (vs_violin); 135 135 gtk_box_pack_start (GTK_BOX (vbox6), vs_violin, TRUE, FALSE, 0); … … 490 490 491 491 492 492 gtk_signal_connect (GTK_OBJECT (voice_widget[NEKO_PORT_BASS_LEVEL]), 493 493 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change), 494 494 (gpointer)NEKO_PORT_BASS_LEVEL); 495 495 gtk_signal_connect (GTK_OBJECT (vs_cello), 496 496 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change), 497 497 (gpointer)NEKO_PORT_CELLO_LEVEL); 498 gtk_signal_connect (GTK_OBJECT (vs_viola), 499 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change), 500 (gpointer)NEKO_PORT_VIOLA_LEVEL); 501 gtk_signal_connect (GTK_OBJECT (vs_violin), 502 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change), 503 (gpointer)NEKO_PORT_VIOLIN_LEVEL); 498 504 499 505 return window1; nekostring/trunk/gui/main.c
r9 r39 7 7 * For further information on contributors and the history of nekostring, 8 8 * please see the README 9 * this file contains elements from Sean Bolton's Xsynth-DSSI 9 10 * 10 11 */ … … 14 15 #endif 15 16 17 #include 18 #include 19 20 16 21 #include 22 #include 17 23 18 24 #include "interface.h" … … 20 26 #include "widgets.h" 21 27 22 int 23 main (int argc, char *argv[]) 28 // define a few globals 29 lo_address osc_host_address; 30 char * osc_host_url; 31 char * osc_quit_path; 32 char * osc_control_path; 33 34 static void osc_error(int num, const char *msg, const char *path) { 35 printf(" error: liblo server error %d in path \"%s\": %s\n", num, (path ? path : "(null)"), msg); 36 } 37 static char *osc_build_path(char *base_path, char *method) { 38 char buffer[256]; 39 char *full_path; 40 41 snprintf(buffer, 256, "%s%s", base_path, method); 42 if (!(full_path = strdup(buffer))) { 43 printf(": out of memory!\n"); 44 exit(1); 45 } 46 return strdup(buffer); 47 } 48 49 osc_action_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { 50 51 printf("%s\n",user_data); 52 53 } 54 55 osc_control_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) { 56 57 int port; 58 float value; 59 60 if (argc < 2) { 61 printf("error: too few arguments to osc_control_handler\n"); 62 return 1; 63 } 64 65 port = argv[0]->i; 66 value = argv[1]->f; 67 printf(" osc_control_handler: control %d now %f\n", port, value); 68 69 update_voice_widget(port, value); 70 71 return 0; 72 73 74 75 } 76 77 // Here's where the fun starts 78 79 int main (int argc, char *argv[]) 24 80 { 81 // first we'll define the necessary OSC things 82 char *host, *port, *path, *tmp_url; // FIXME - tmp_url? 83 lo_server osc_server; 84 25 85 GtkWidget *window1; 26 GtkAdjustment *adj;86 // GtkAdjustment *adj; 27 87 28 88 gtk_set_locale (); 29 89 gtk_init (&argc, &argv); 90 91 if (argc != 5) { 92 fprintf(stderr, "usage: %s \n", argv[0]); 93 exit(1); 94 } 95 96 // sort out the OSC addresses 97 osc_host_url = argv[1]; 98 host = lo_url_get_hostname(osc_host_url); 99 port = lo_url_get_port(osc_host_url); 100 path = lo_url_get_path(osc_host_url); 101 osc_host_address = lo_address_new(host, port); 102 // now we define the handlers 103 osc_quit_path = osc_build_path(path, "/quit"); 104 osc_control_path = osc_build_path(path, "/control"); 105 106 // start the OSC server 107 osc_server = lo_server_new(NULL, osc_error); 108 109 // add the callbacks 110 lo_server_add_method(osc_server, osc_quit_path, "", osc_action_handler, "quit"); 111 lo_server_add_method(osc_server, osc_control_path, "if", osc_control_handler, NULL); 112 113 114 int i; 115 30 116 31 117 add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps"); … … 38 124 window1 = create_window1 (); 39 125 gtk_widget_show (window1); 126 127 128 129 130 printf("%d\n",argc); 131 for (i=0; i 132 printf("%s\n",argv[i]); 133 } 134 135 gtk_main (); 40 136 41 // adj = (GtkAdjustment *)vs_viola;42 adj= gtk_range_get_adjustment(GTK_RANGE(vs_viola));43 adj->value = 0.5f;44 /* gtk_signal_emit_by_name (GTK_OBJECT (adj), "changed"); does not cause call to on_voice_slider_change callback */45 gtk_signal_emit_by_name (GTK_OBJECT (adj), "value_changed");46 137 47 48 gtk_main (); 138 lo_server_free(osc_server); 139 free(host); 140 free(port); 141 free(path); 142 free(osc_quit_path); 49 143 return 0; 50 144 } nekostring/trunk/src/Makefile
r29 r39 89 89 CC = gcc 90 90 CCDEPMODE = depmode=gcc3 91 CFLAGS = - Werror -Wall91 CFLAGS = -g -O2 92 92 CPP = gcc -E 93 93 CPPFLAGS = nekostring/trunk/src/neko-dssi.c
r37 r39 161 161 synth->note_id = 0; 162 162 neko_synth_all_voices_off(synth); 163 printf("called activate\n"); 163 164 } 164 165 nekostring/trunk/src/neko_synth.c
r36 r39 647 647 for(i = 0; i<12; i++) { 648 648 p= synth->bog_pos[i]; 649 // p += ((float)sample_count*neko_pitch[24+i] *440 * synth->deltat);650 649 p += (f * neko_pitch[24+i]); 651 652 650 if (p>1.0f) p -= 1.0f; 653 651 synth->bog_pos[i]=p; 654 //printf("%d:%f\t", i, synth->bog_pos[i]);655 652 } 656 // printf("\n"); 657 } 653 } nekostring/trunk/src/neko_voice_render.c
r37 r39 193 193 if (pos >= 1.0f) { 194 194 pos -= 1.0f; 195 blosc_place_step_dd(voice->osc_audio, index, pos, w, lowpass*gain);195 //blosc_place_step_dd(voice->osc_audio, index, pos, w, lowpass*gain); 196 196 } 197 197