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 #ifndef __AGS_NOTATION_EDITOR_H__
21 #define __AGS_NOTATION_EDITOR_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <gtk/gtk.h>
27 
28 #include <ags/libags.h>
29 #include <ags/libags-audio.h>
30 
31 #include <ags/libags-gui.h>
32 
33 #include <ags/X/ags_machine.h>
34 
35 #include <ags/X/editor/ags_notation_toolbar.h>
36 #include <ags/X/editor/ags_machine_selector.h>
37 #include <ags/X/editor/ags_notation_edit.h>
38 #include <ags/X/editor/ags_notation_meta.h>
39 
40 G_BEGIN_DECLS
41 
42 #define AGS_TYPE_NOTATION_EDITOR                (ags_notation_editor_get_type ())
43 #define AGS_NOTATION_EDITOR(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_NOTATION_EDITOR, AgsNotationEditor))
44 #define AGS_NOTATION_EDITOR_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_NOTATION_EDITOR, AgsNotationEditorClass))
45 #define AGS_IS_NOTATION_EDITOR(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_NOTATION_EDITOR))
46 #define AGS_IS_NOTATION_EDITOR_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_NOTATION_EDITOR))
47 #define AGS_NOTATION_EDITOR_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), AGS_TYPE_NOTATION_EDITOR, AgsNotationEditorClass))
48 
49 #define AGS_NOTATION_EDITOR_DEFAULT_VERSION "1.2.0"
50 #define AGS_NOTATION_EDITOR_DEFAULT_BUILD_ID "Mon Nov 27 08:23:16 UTC 2017"
51 
52 #define AGS_NOTATION_EDITOR_MAX_CONTROLS (16 * 16 * 1200)
53 
54 typedef struct _AgsNotationEditor AgsNotationEditor;
55 typedef struct _AgsNotationEditorClass AgsNotationEditorClass;
56 
57 typedef enum{
58   AGS_NOTATION_EDITOR_CONNECTED                    = 1,
59   AGS_NOTATION_EDITOR_PATTERN_MODE                 = 1 <<  1,
60   AGS_NOTATION_EDITOR_PASTE_MATCH_AUDIO_CHANNEL    = 1 <<  2,
61   AGS_NOTATION_EDITOR_PASTE_NO_DUPLICATES          = 1 <<  3,
62 }AgsNotationEditorFlags;
63 
64 struct _AgsNotationEditor
65 {
66   GtkBox box;
67 
68   guint flags;
69 
70   gchar *version;
71   gchar *build_id;
72 
73   guint tact_counter;
74   gdouble current_tact;
75 
76   guint chunk_duration;
77 
78   gint *active_key;
79   guint active_key_count;
80 
81   GObject *soundcard;
82 
83   GtkPaned *paned;
84 
85   AgsNotationToolbar *notation_toolbar;
86 
87   AgsMachineSelector *machine_selector;
88   AgsMachine *selected_machine;
89 
90   AgsNotebook *notebook;
91 
92   AgsScrolledPiano *scrolled_piano;
93 
94   AgsNotationEdit *notation_edit;
95 
96   AgsNotationMeta *notation_meta;
97 };
98 
99 struct _AgsNotationEditorClass
100 {
101   GtkBoxClass box;
102 
103   void (*machine_changed)(AgsNotationEditor *notation_editor, AgsMachine *machine);
104 };
105 
106 GType ags_notation_editor_get_type(void);
107 
108 void ags_notation_editor_machine_changed(AgsNotationEditor *notation_editor,
109 					 AgsMachine *machine);
110 
111 void ags_notation_editor_add_note(AgsNotationEditor *notation_editor,
112 				  AgsNote *note);
113 
114 void ags_notation_editor_delete_note(AgsNotationEditor *notation_editor,
115 				     guint x, guint y);
116 
117 void ags_notation_editor_select_region(AgsNotationEditor *notation_editor,
118 				       guint x0, guint y0,
119 				       guint x1, guint y1);
120 
121 void ags_notation_editor_do_feedback(AgsNotationEditor *notation_editor);
122 
123 void ags_notation_editor_start_play_key(AgsNotationEditor *notation_editor,
124 					gint key_code);
125 void ags_notation_editor_stop_play_key(AgsNotationEditor *notation_editor,
126 				       gint key_code);
127 
128 void ags_notation_editor_select_all(AgsNotationEditor *notation_editor);
129 
130 void ags_notation_editor_paste(AgsNotationEditor *notation_editor);
131 void ags_notation_editor_copy(AgsNotationEditor *notation_editor);
132 void ags_notation_editor_cut(AgsNotationEditor *notation_editor);
133 void ags_notation_editor_invert(AgsNotationEditor *notation_editor);
134 
135 AgsNotationEditor* ags_notation_editor_new();
136 
137 G_END_DECLS
138 
139 #endif /*__AGS_NOTATION_EDITOR_H__*/
140