--- ../../denemocleaned/src/pitchentry.c 2007-09-13 15:00:47.000000000 +0100 +++ ./pitchentry.c 2007-09-15 08:06:28.000000000 +0100 @@ -19,6 +19,8 @@ We do not create one of these for each view (ie each DenemoGUI object, ie each score) because there is only one audio input source being used, so we would have to cope with resource contention issues, there is just no point. */ static DenemoGUI *PR_gui; /* the gui for which the pitch recognition has been set up */ static gboolean PR_insert; /* whether the notes should be inserted directly in the score or put in a list for controlled insertion */ +static gboolean PR_continuous; /* whether to go on to the next measure once overlay for current measure is full */ +gint PR_click;/*volume of a audible warning of next measure or extra tones in measure */ static GtkWidget *PR_notelabel = NULL; static GtkWidget *PR_deviation = NULL; static guint PR_timer;// timer id @@ -269,6 +271,10 @@ } +static void sound_click(void) { + if(PR_click) + gdk_beep(); +} static GList *get_tones(GList *tone_store, gint measurenum) { GList *g = g_list_nth(tone_store, measurenum); @@ -277,16 +283,20 @@ return NULL; } -/* apply the tones in the currentstaff to the notes of the currentstaff */ +/* apply the tones in the currentmeasure to the notes of the currentmeasure */ -static void apply_tones(DenemoScore *si) { +static gboolean apply_tones(DenemoScore *si) { + gboolean ret=FALSE; #define curstaff ((DenemoStaff*)si->currentstaff->data) GList *store; gint measurenum; store = (curstaff->tone_store); measurenode *curmeasure = curstaff->measures; - GList *store_el; - for (measurenum=0;curmeasure; curmeasure = curmeasure->next, measurenum++) { + GList *store_el = NULL; + + measurenum = si->currentmeasurenum - 1; + curmeasure = si->currentmeasure; + if(curmeasure) { store_el = get_tones(store, measurenum); objnode *curobj = curmeasure->data; for (; curobj && store_el; curobj = curobj->next) @@ -303,7 +313,7 @@ ((chord*)theobj->object)->tone_node = NULL; else { int dclef = curstaff->leftmost_clefcontext; - int mid_c_offset = thetone->step; //FIXME octave??? + int mid_c_offset = thetone->step; ((chord*)theobj->object)->tone_node = store_el; modify_note(((chord*)theobj->object)->notes->data, mid_c_offset, thetone->enshift, dclef); ((chord *) theobj->object)->sum_mid_c_offset = mid_c_offset;//Damned difficult to track this down - will not work if there are >1 notes in chord @@ -314,16 +324,17 @@ ((chord *) theobj->object)->lowesty = calculateheight (mid_c_offset, dclef); store_el = store_el->next; - } - } - } + }// tone available + }// note available + if(curobj->next==NULL && curmeasure->next) + ret = TRUE; + }// for objects in measure + if(store_el && !PR_continuous) + sound_click();//extra tones in measure showwhichaccidentals ((objnode *) si->currentmeasure->data, si->curmeasurekey, si->curmeasureaccs); } - g_print("the number of measures is %d\n", g_list_length(si->measurewidths)); - - - + return ret; } @@ -362,16 +373,22 @@ * enters the note FOUND as a tone in the tone store */ static void enter_tone_in_store (DenemoGUI *gui, notepitch * found, gint octave) { + gboolean nextmeasure; tone *thetone = (tone*)g_malloc0(sizeof(tone)); - g_print("tone %p\n", thetone); + //g_print("tone %p\n", thetone); thetone->enshift = found->spec.alteration; thetone->step = found->spec.step + 7*octave; thetone->octave = octave; thetone->valid = TRUE; #define store (((DenemoStaff*)gui->si->currentstaff->data)->tone_store) store = put_tone(store, gui->si->currentmeasurenum - 1, thetone); - apply_tones(gui->si); + nextmeasure = apply_tones(gui->si); displayhelper (gui); + if(PR_continuous && nextmeasure) { + sound_click(); + measureright(gui); + } + /* gtk_widget_draw(gui->scorearea, NULL); */ #undef store } @@ -419,7 +436,7 @@ if(tone_node) { ((tone*)tone_node->data)->valid = FALSE; thechord->tone_node = NULL; - apply_tones(si);// FIXME applies to whole of staff rather than measure + apply_tones(si); displayhelper (PR_gui); return TRUE; } else { @@ -428,13 +445,6 @@ } - - -static void apply_tone_store(GtkButton *button, DenemoGUI *gui ) { - apply_tones(gui->si); - displayhelper (gui); -} - /* return note for the passed pitch, or NULL if not a good note; * @param pitch, the pitch being enquired about * @temperament, the temperament to use to determine which pitch. @@ -537,6 +547,13 @@ } + + + // toggle PR_continuous advance to next measure or not +static void toggle_continuous(GtkButton *button, DenemoGUI *gui ) { + PR_continuous = !PR_continuous; +} + static void change_silence(GtkSpinButton *widget, gpointer data){ double silence = gtk_spin_button_get_value(widget); set_silence(silence); @@ -615,6 +632,14 @@ static void toggle_repeated_notes_allowed(){ repeated_notes_allowed = !repeated_notes_allowed; } + +static void change_click_volume(GtkSpinButton *widget, DenemoGUI *gui){ + PR_click = (guint)gtk_spin_button_get_value(widget); +gtk_window_present(GTK_WINDOW(gui->window)); + //eventually make this value control the loudness of a click +} + + static void change_timer_rate(GtkSpinButton *widget, DenemoGUI *gui){ PR_time = (guint)gtk_spin_button_get_value(widget); start_pitch_recognition(gui);//FIXME do not call the whole of start_pitch_recognition, just the timer setting bit??? @@ -652,11 +677,17 @@ gtk_container_add (GTK_CONTAINER (main_vbox), frame); hbox = gtk_hbox_new (FALSE, 1); gtk_container_add (GTK_CONTAINER (frame), hbox); + frame = gtk_frame_new( "Overlay Pitches"); gtk_container_add (GTK_CONTAINER (hbox), frame); + + GtkWidget *vbox2 = gtk_vbox_new (FALSE, 1); + gtk_container_add (GTK_CONTAINER (frame), vbox2); + hbox2 = gtk_hbox_new (FALSE, 1); - gtk_container_add (GTK_CONTAINER (frame), hbox2); + gtk_box_pack_start (GTK_BOX (vbox2), hbox2, + TRUE, TRUE, 0); GtkWidget *radio_button = gtk_radio_button_new_with_label(NULL, "Overlay Pitches"); gtk_box_pack_start (GTK_BOX (hbox2), radio_button, TRUE, TRUE, 0); @@ -668,6 +699,29 @@ TRUE, TRUE, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (clear_tone_store), gui); + hbox2 = gtk_hbox_new (FALSE, 1); + + gtk_box_pack_start (GTK_BOX (vbox2), hbox2, + TRUE, TRUE, 0); + button = gtk_check_button_new_with_label("Continuous"); + gtk_box_pack_start (GTK_BOX (hbox2), button, + TRUE, TRUE, 0); + PR_continuous = FALSE; + g_signal_connect (G_OBJECT (button), "clicked", + G_CALLBACK (toggle_continuous), gui); + + + label = gtk_label_new("Click Volume"); + gtk_box_pack_start (GTK_BOX (hbox2), label, TRUE, TRUE, 0); + GtkAdjustment *spinner_adj = + (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, + 1.0, 1.0, 1.0); + GtkWidget *spinner = gtk_spin_button_new (spinner_adj, 1.0, 1); + gtk_box_pack_start (GTK_BOX (hbox2), spinner, TRUE, TRUE, 0); + g_signal_connect (G_OBJECT (spinner), "value-changed", + G_CALLBACK (change_click_volume), gui); + + button = gtk_radio_button_new_with_label_from_widget(radio_button, "Insert Notes"); @@ -722,10 +776,10 @@ label = gtk_label_new("Silence"); gtk_box_pack_start (GTK_BOX (hbox2), label, TRUE, TRUE, 0); - GtkAdjustment *spinner_adj = + spinner_adj = (GtkAdjustment *) gtk_adjustment_new (-90.0, -1000.0, 100.0, 10.0, 1.0, 1.0); - GtkWidget *spinner = gtk_spin_button_new (spinner_adj, 100.0, 0); + spinner = gtk_spin_button_new (spinner_adj, 100.0, 0); gtk_box_pack_start (GTK_BOX (hbox), spinner, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (spinner), "value-changed", G_CALLBACK (change_silence), NULL);