-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdefines.h
More file actions
149 lines (130 loc) · 3.91 KB
/
Copy pathdefines.h
File metadata and controls
149 lines (130 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
mah_tracker: AArt1256's custom SID chiptune tracker
Copyright (C) 2026 AArt1256
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see
<https://www.gnu.org/licenses/>.
*/
#include <cstdint>
#include <vector>
// the current .mah module file format version
#define MAH_CURRENT_VERSION 7
// Magic numbers for file format
#define NOTE_OFF 0xfe // Note off in pattern
#define NOTE_EMPTY 0xff // Empty cell in pattern
#define INS_NO_LOOP 0xff // Telltale if an instrument "loops"
#define ORDER_END 0xff // End of order
// audio properties
#define SAMPLE_RATE 48000
#define BUFFER_SIZE (960) // 44100/60
// Pattern editor, for the column cursor position
enum channel_mode {
nothing = -1,
note = 0,
instr = 1,
eff_type = 2,
eff_arg = 3,
end = 4
};
// Pattern row
struct pat_row {
// C-4 01 A 67
uint8_t note, instr, eff_type, eff_arg;
};
// Pattern data, up to 256 rows each
struct pattern_data {
pat_row rows[256];
};
// undo properties
#define MAX_UNDO_LEVELS 50
#define UNDO_CHANNELS 3
struct undo_chunk {
pattern_data ch_rows[UNDO_CHANNELS];
pattern_data ch_rows_old[UNDO_CHANNELS];
int changed_patterns[UNDO_CHANNELS];
int row_cur;
int row_old;
int order_cur;
int order_old;
};
struct pattern_chunk_copy {
pattern_data ch_rows[3];
//int row_start;
int row_len;
int col_start;
int col_len;
};
// Cursor for pattern editor
struct cursor {
int ch, row;
enum channel_mode selection;
int octave;
int latch;
int order;
int instr;
int playing;
int play_row;
bool loop;
bool do_follow;
bool do_record;
bool new_file_popup;
bool chip_mode;
int drag_pat;
int drag_x_start;
int drag_x_end;
enum channel_mode drag_x_start_sel;
enum channel_mode drag_x_end_sel;
int drag_y_start;
int drag_y_end;
bool dragging;
bool already_dragged;
// TODO: make this less memory-intensive :P
pattern_chunk_copy pattern_copy_buffer;
bool is_muted[3];
int undo_pos;
};
// Instrument
// Max number of commands in an instrument struct is 128
struct instrument {
uint8_t a, d, s, r; // ADSR envelope
uint8_t wav_len; // also for arps
uint8_t wav_loop; // also for arps
uint8_t wav[128]; // Waveform select
uint8_t arp[128]; // Arpeggio
uint8_t filter_len; // also for arps
uint8_t filter_loop; // also for arps
uint8_t filter[128]; // Filter intensity
uint8_t filter_mode[128]; // Low-pass, band-pass, high-pass
uint8_t filter_res; // Filter resonance
bool filter_enable; // Filter enable
bool filter_sweep_mode; // Relative/absolute filter sweep selection
uint8_t filter_init_cutoff;
bool duty_reset;
int duty_start; // Pulse duty start position
int duty_end; // Pulse duty end position
int duty_speed; // PWM speed
};
// Song
// Pattern, order table, order length, 128 instruments, and initial speed
struct song {
pattern_data pattern[256];
uint16_t order_table[3][256];
uint8_t order_len;
instrument instr[128];
uint8_t init_speed;
uint8_t pitch_bend_shift;
uint16_t a_frequency;
uint8_t order_loop;
uint16_t row_length;
};
extern void render_pat(song *song, cursor *cur_cursor, std::vector<undo_chunk> *undo_chunks, bool *enable);
extern void render_orders(song *song, cursor *cur_cursor, bool *enable);
extern void render_instr(song *song, cursor *cur_cursor, bool *enable);