1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2020 Joël Krähemann
3  *
4  * This file is part of GSequencer.
5  *
6  * GSequencer is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GSequencer is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GSequencer.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include <ags/X/ags_notation_editor_callbacks.h>
21 
22 #include <ags/X/ags_ui_provider.h>
23 
24 void
ags_notation_editor_machine_changed_callback(AgsMachineSelector * machine_selector,AgsMachine * machine,AgsNotationEditor * notation_editor)25 ags_notation_editor_machine_changed_callback(AgsMachineSelector *machine_selector, AgsMachine *machine,
26 					     AgsNotationEditor *notation_editor)
27 {
28   ags_notation_editor_machine_changed(notation_editor, machine);
29 }
30 
31 void
ags_notation_editor_piano_key_pressed_callback(AgsPiano * piano,gchar * note,gint key_code,AgsNotationEditor * notation_editor)32 ags_notation_editor_piano_key_pressed_callback(AgsPiano *piano,
33 					       gchar *note, gint key_code,
34 					       AgsNotationEditor *notation_editor)
35 {
36   g_message("AgsPiano - key pressed %s %d", note, key_code);
37 
38   ags_notation_editor_start_play_key(notation_editor,
39 				     key_code);
40 }
41 
42 void
ags_notation_editor_piano_key_released_callback(AgsPiano * piano,gchar * note,gint key_code,AgsNotationEditor * notation_editor)43 ags_notation_editor_piano_key_released_callback(AgsPiano *piano,
44 						gchar *note, gint key_code,
45 						AgsNotationEditor *notation_editor)
46 {
47   g_message("AgsPiano - key released %s %d", note, key_code);
48 
49   ags_notation_editor_stop_play_key(notation_editor,
50 				    key_code);
51 }
52 
53 void
ags_notation_editor_resize_audio_channels_callback(AgsMachine * machine,guint audio_channels,guint audio_channels_old,AgsNotationEditor * notation_editor)54 ags_notation_editor_resize_audio_channels_callback(AgsMachine *machine,
55 						   guint audio_channels, guint audio_channels_old,
56 						   AgsNotationEditor *notation_editor)
57 {
58   guint i;
59 
60   if(audio_channels > audio_channels_old){
61     GList *tab;
62 
63     for(i = audio_channels_old; i < audio_channels; i++){
64       ags_notebook_insert_tab(notation_editor->notebook,
65 			      i);
66 
67       tab = notation_editor->notebook->tab;
68       gtk_toggle_button_set_active(AGS_NOTEBOOK_TAB(tab->data)->toggle,
69 				   TRUE);
70     }
71   }else{
72     /* shrink notebook */
73     for(i = audio_channels; i < audio_channels_old; i++){
74       ags_notebook_remove_tab(notation_editor->notebook,
75 			      audio_channels);
76     }
77   }
78 }
79 
80 void
ags_notation_editor_resize_pads_callback(AgsMachine * machine,GType channel_type,guint pads,guint pads_old,AgsNotationEditor * notation_editor)81 ags_notation_editor_resize_pads_callback(AgsMachine *machine, GType channel_type,
82 					 guint pads, guint pads_old,
83 					 AgsNotationEditor *notation_editor)
84 {
85   AgsAudio *audio;
86 
87   audio = machine->audio;
88 
89   /* verify pads */
90   if(ags_audio_test_behaviour_flags(audio, AGS_SOUND_BEHAVIOUR_DEFAULTS_TO_INPUT)){
91     if(!g_type_is_a(channel_type,
92 		    AGS_TYPE_INPUT)){
93       return;
94     }
95   }else{
96     if(!g_type_is_a(channel_type,
97 		    AGS_TYPE_OUTPUT)){
98       return;
99     }
100   }
101 
102   /*  */
103   g_object_set(notation_editor->scrolled_piano->piano,
104 	       "key-count", pads,
105 	       NULL);
106   gtk_widget_queue_resize((GtkWidget *) notation_editor->scrolled_piano->piano);
107   gtk_widget_queue_draw((GtkWidget *) notation_editor->scrolled_piano->piano);
108 
109   /*  */
110   gtk_widget_queue_draw((GtkWidget *) notation_editor->notation_edit);
111 }
112