/* change the MIDI output tuning */ void change_tuning (gdouble * cents) { guchar buffer[] = { 0xF0, 0x7F, // Universal Real-Time SysEx header 0x7F, //<device ID> ID of target device (7F = all devices) 0x08, // sub-ID#1 = "MIDI Tuning Standard" 0x08, // sub-ID#2 = "scale/octave tuning 1-byte form (Real-Time)" 0x03, /* channel/options byte 1 bits 0 to 1 = channel 15 to 16 bit 2 to 6 = reserved for future expansion */ 0x7F, // channel byte 2 - bits 0 to 6 = channel 8 to 14 0x7F, // channel byte 3 - bits 0 to 6 = channel 1 to 7 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* [ss] 12 byte tuning offset of 12 semitones from C to B 00H means -64 cents 40H means 0 cents (equal temperament) 7FH means +63 cents */ 0xF7 // EOX }; gint i; for (i = 0; i < 12; i++) buffer[i + 8] = 64 + (cents[i] + 0.5); play_midi_event (DEFAULT_BACKEND, 0, buffer); }
//Event generated by MIDI controller or Scheme script //adjusts the note-on volume by preferred dynamic compression and plays the passed event on default backend void play_adjusted_midi_event (gchar * buf) { adjust_midi_velocity (buf, 100 - Denemo.prefs.dynamic_compression); add_after_touch (buf); adjust_midi_channel (buf); //g_print ("play adj midibytes 0x%hhX 0x%hhX 0x%hhX\n", *(buf+0), *(buf+1), *(buf+2)); play_midi_event (DEFAULT_BACKEND, 0, (guchar*) buf); }
/** * Set the staffs properties * @param cbdata pointer to the callback data structure containing the preference data to set. * @return none */ static void set_properties (struct callbackdata *cbdata) { DenemoStaff *staffstruct = cbdata->staffstruct; #if GTK_MAJOR_VERSION==3 #define ASSIGNTEXT(field) \ if(cbdata->field) {\ gchar *text=gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cbdata->field));\ if (text)\ g_string_assign (staffstruct->field,text);\ } #else #define ASSIGNTEXT(field) \ if(cbdata->field)\ g_string_assign (staffstruct->field,\ gtk_entry_get_text (GTK_ENTRY (cbdata->field))) #endif #define ASSIGNNUMBER(field) \ if(cbdata->field)\ staffstruct->field = \ atoi(gtk_entry_get_text(GTK_ENTRY (cbdata->field))) #define ASSIGNNUMBER_1(field) \ if(cbdata->field)\ staffstruct->field = \ atoi(gtk_entry_get_text(GTK_ENTRY (cbdata->field)))-1 #define ASSIGNBOOLEAN(field) \ if(cbdata->field)\ staffstruct->field = \ (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cbdata->field))); /* rename of set staff/voice name */ canonicalize_denemo_name ((gchar *) gtk_entry_get_text (GTK_ENTRY (cbdata->denemo_name)), staffstruct->denemo_name); if(cbdata->subpart) { if(staffstruct->subpart==NULL) staffstruct->subpart = g_string_new (""); canonicalize_denemo_name ((gchar *) gtk_entry_get_text (GTK_ENTRY (cbdata->subpart)), staffstruct->subpart); } set_lily_name (staffstruct->denemo_name, staffstruct->lily_name); //g_debug("first %d\t", staffstruct->space_above); ASSIGNNUMBER (space_above); //g_debug("then %d\t", staffstruct->space_above); ASSIGNNUMBER (space_below); ASSIGNNUMBER (no_of_lines); ASSIGNNUMBER (transposition); /* set MIDI channel/prognum */ ASSIGNTEXT (midi_instrument); ASSIGNTEXT (device_port); ASSIGNBOOLEAN (override_volume); ASSIGNNUMBER (volume); // ASSIGNBOOLEAN(midi_prognum_override); if (staffstruct->midi_instrument->len) { staffstruct->midi_prognum = get_midi_prognum (staffstruct); gint i; gchar *name; gint preset, bank; gint npresets = ParseSoundfont (Denemo.prefs.fluidsynth_soundfont->str, 0, NULL, NULL, NULL); if (npresets) { for (i = 0; i < npresets - 1; i++) { (void) ParseSoundfont (NULL, i, &name, &preset, &bank); if (!strcmp (name, staffstruct->midi_instrument->str)) { staffstruct->midi_prognum = preset; gchar *scheme = g_strdup_printf ("(d-MidiInstrumentName \"%s\")", GM_Instrument_Names[preset&0xFF]); call_out_to_guile (scheme); g_free (scheme); printf ("\nMIDI Instrument == %s (GM name %s)\nMIDI PROGRAM == %d\n", staffstruct->midi_instrument->str, GM_Instrument_Names[preset&0xFF], staffstruct->midi_prognum); break; } } } // if(staffstruct->midi_prognum != i) /* I am not sure why this was necessary and if it is still needed*/ // ASSIGNNUMBER_1(midi_prognum); ASSIGNNUMBER_1 (midi_channel); printf ("\nAssigned MIDI Instrument == %s \nAssigned MIDI PROGRAM == %d i == %d\n", staffstruct->midi_instrument->str, staffstruct->midi_prognum, i); } else { ASSIGNNUMBER_1 (midi_prognum); ASSIGNNUMBER_1 (midi_channel); } { unsigned char buffer[3];/* third byte is unused but is put into the queue so must be accessible */ /* set selected midi program on the synthesizer so that users can play MIDI controller with current staff instrument without having to do playback first*/ g_info ("Using channel %d port %d prognum %d\n", staffstruct->midi_channel, staffstruct->midi_port, staffstruct->midi_prognum); buffer[0] = 0xC0 /*MIDI_PROG_CHANGE*/ | staffstruct->midi_channel; buffer[1] = staffstruct->midi_prognum; play_midi_event (DEFAULT_BACKEND, staffstruct->midi_port, buffer); } //g_debug ("Staff Transposition %d\n", staffstruct->transposition); gtk_widget_queue_draw (Denemo.scorearea); score_status (cbdata->gui, TRUE); }