Line data Source code
1 : /* Copyright 2017 noseglasses <shinynoseglasses@gmail.com>
2 : *
3 : * This program is free software: you can redistribute it and/or modify
4 : * it under the terms of the GNU Lesser General Public License as published by
5 : * the Free Software Foundation, either version 3 of the License, or
6 : * (at your option) any later version.
7 : *
8 : * This program is distributed in the hope that it will be useful,
9 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 : * GNU Lesser General Public License for more details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 : */
16 :
17 : #include "ppg_note.h"
18 : #include "ppg_debug.h"
19 : #include "detail/ppg_context_detail.h"
20 : #include "detail/ppg_token_detail.h"
21 : #include "detail/ppg_note_detail.h"
22 : #include "detail/ppg_pattern_detail.h"
23 :
24 1284 : PPG_Token ppg_note_create(PPG_Input_Id input, PPG_Count flags)
25 : {
26 1284 : PPG_Note *note = (PPG_Note*)ppg_note_new(ppg_note_alloc());
27 :
28 1284 : note->input = input;
29 :
30 1284 : note->super.misc.flags = flags;
31 :
32 : // Return the new end of the pattern
33 : //
34 1284 : return note;
35 : }
36 :
37 1266 : PPG_Token ppg_note_create_standard(PPG_Input_Id input)
38 : {
39 1266 : return ppg_note_create(input, PPG_Note_Flags_A_N_D);
40 : }
41 :
42 9 : PPG_Token ppg_single_note_line(
43 : PPG_Layer layer,
44 : PPG_Action action,
45 : PPG_Count n_inputs,
46 : PPG_Input_Id inputs[])
47 9 : {
48 : // PPG_LOG("Adding single note line\n");
49 :
50 9 : PPG_Token__ *tokens[n_inputs];
51 :
52 36 : for (PPG_Count i = 0; i < n_inputs; i++) {
53 :
54 27 : tokens[i] = ppg_note_create_standard(inputs[i]);
55 : }
56 :
57 9 : ppg_token_store_action(tokens[n_inputs - 1], action);
58 :
59 9 : PPG_Token__ *leaf_token
60 9 : = ppg_pattern_from_list(NULL, layer, n_inputs, tokens);
61 :
62 9 : return leaf_token;
63 : }
|