1 | /*
|
---|
2 | =============================================================================
|
---|
3 | delnote.c -- MIDAS-VII note deletion
|
---|
4 | Version 16 -- 1988-10-27 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "stddefs.h"
|
---|
9 | #include "score.h"
|
---|
10 | #include "scfns.h"
|
---|
11 | #include "graphdef.h"
|
---|
12 | #include "vsdd.h"
|
---|
13 |
|
---|
14 | #include "midas.h"
|
---|
15 | #include "scdsp.h"
|
---|
16 |
|
---|
17 | extern int16_t pix2mid(void);
|
---|
18 | extern int16_t sc_refr(int32_t t);
|
---|
19 |
|
---|
20 | #define TO_LFT (TO_BAK + 1)
|
---|
21 |
|
---|
22 | extern int16_t cflag; /* accidental flag */
|
---|
23 | extern int16_t cnote; /* note value at cursor */
|
---|
24 | extern int16_t cxval; /* cursor x value */
|
---|
25 | extern int16_t cyval; /* cursor y value */
|
---|
26 | extern int16_t lstflag; /* last note entry list end flag */
|
---|
27 | extern int16_t recsw; /* record status */
|
---|
28 |
|
---|
29 | extern int32_t ctime; /* time at cursor */
|
---|
30 |
|
---|
31 | extern int16_t grpmode[12]; /* group record modes */
|
---|
32 | extern int16_t grpstat[12]; /* group status */
|
---|
33 | /* |
---|
34 |
|
---|
35 | */
|
---|
36 |
|
---|
37 | /*
|
---|
38 | =============================================================================
|
---|
39 | delnote() -- delete a note
|
---|
40 | =============================================================================
|
---|
41 | */
|
---|
42 |
|
---|
43 | int16_t delnote(void)
|
---|
44 | {
|
---|
45 | register struct n_entry *bp, *cp, *ep;
|
---|
46 | register int32_t t_left;
|
---|
47 | register int16_t tnote, grp;
|
---|
48 | register int16_t runtag, scantag;
|
---|
49 | int16_t disptag;
|
---|
50 |
|
---|
51 | disptag = FALSE; /* nothing changed yet */
|
---|
52 |
|
---|
53 | if (NOT recsw) /* must be in record mode */
|
---|
54 | return(FAILURE);
|
---|
55 |
|
---|
56 | /* convert cursor position to note number and time */
|
---|
57 |
|
---|
58 | if (pix2mid())
|
---|
59 | goto notnote;
|
---|
60 |
|
---|
61 | ++cflag;
|
---|
62 | tnote = cnote;
|
---|
63 | t_left = t_cur - TO_LFT;
|
---|
64 | cp = (struct n_entry *)frfind(ctime, 0);
|
---|
65 |
|
---|
66 | /* |
---|
67 |
|
---|
68 | */
|
---|
69 | while (cflag--) { /* handle both naturals and accidentals */
|
---|
70 |
|
---|
71 | for (grp = 0; grp < 12; grp++) { /* for each group ... */
|
---|
72 |
|
---|
73 | if ((grpstat[grp] EQ 0) OR /* ... enabled and ... */
|
---|
74 | (grpmode[grp] NE 2)) /* ... in record mode: */
|
---|
75 | continue;
|
---|
76 |
|
---|
77 | runtag = TRUE;
|
---|
78 | bp = cp; /* start at cursor */
|
---|
79 |
|
---|
80 | while (runtag) { /* scan left from cursor until: */
|
---|
81 |
|
---|
82 | if ((bp->e_time LT t_left) OR
|
---|
83 | (bp->e_type EQ EV_SCORE)) { /* left edge */
|
---|
84 |
|
---|
85 | /* done -- nothing to delete */
|
---|
86 |
|
---|
87 | runtag = FALSE;
|
---|
88 | continue;
|
---|
89 | /* |
---|
90 |
|
---|
91 | */
|
---|
92 | } else if ((bp->e_type EQ EV_NEND) AND
|
---|
93 | (bp->e_note EQ tnote) AND
|
---|
94 | (bp->e_group EQ grp)) { /* note end */
|
---|
95 |
|
---|
96 | /* done -- overlap */
|
---|
97 |
|
---|
98 | runtag = FALSE;
|
---|
99 | continue;
|
---|
100 | /* |
---|
101 |
|
---|
102 | */
|
---|
103 |
|
---|
104 | } else if ((bp->e_type EQ EV_NBEG) AND
|
---|
105 | (bp->e_note EQ tnote) AND
|
---|
106 | (bp->e_group EQ grp)) { /* note begin */
|
---|
107 |
|
---|
108 | /* possible deletion */
|
---|
109 |
|
---|
110 | /* scan right from note begin until: */
|
---|
111 |
|
---|
112 | ep = bp->e_fwd;
|
---|
113 | scantag = TRUE;
|
---|
114 |
|
---|
115 | while (scantag) {
|
---|
116 |
|
---|
117 | /* note begin -- done -- overlap */
|
---|
118 |
|
---|
119 | if ((ep->e_type EQ EV_NBEG) AND
|
---|
120 | (ep->e_note EQ tnote) AND
|
---|
121 | (ep->e_group EQ grp)) {
|
---|
122 |
|
---|
123 | scantag = FALSE;
|
---|
124 | runtag = FALSE;
|
---|
125 | continue;
|
---|
126 | /* |
---|
127 |
|
---|
128 | */
|
---|
129 |
|
---|
130 | } else if ((ep->e_type EQ EV_NEND) AND
|
---|
131 | (ep->e_note EQ tnote) AND
|
---|
132 | (ep->e_group EQ grp)) {
|
---|
133 |
|
---|
134 | /* note end */
|
---|
135 |
|
---|
136 | /* delete note end */
|
---|
137 |
|
---|
138 | if (cp EQ ep)
|
---|
139 | cp = cp->e_bak;
|
---|
140 |
|
---|
141 | if (p_ctr EQ ep)
|
---|
142 | p_ctr = p_ctr->e_bak;
|
---|
143 |
|
---|
144 | if (p_bak EQ ep)
|
---|
145 | p_bak = p_bak->e_bak;
|
---|
146 |
|
---|
147 | if (p_fwd EQ ep)
|
---|
148 | p_fwd = p_fwd->e_bak;
|
---|
149 |
|
---|
150 | if (p_cur EQ ep)
|
---|
151 | p_cur = p_cur->e_bak;
|
---|
152 |
|
---|
153 | e_del(e_rmv(ep));
|
---|
154 | /* |
---|
155 |
|
---|
156 | */
|
---|
157 |
|
---|
158 | /* delete note begin */
|
---|
159 |
|
---|
160 | if (cp EQ bp)
|
---|
161 | cp = cp->e_bak;
|
---|
162 |
|
---|
163 | if (p_ctr EQ bp)
|
---|
164 | p_ctr = p_ctr->e_bak;
|
---|
165 |
|
---|
166 | if (p_bak EQ bp)
|
---|
167 | p_bak = p_bak->e_bak;
|
---|
168 |
|
---|
169 | if (p_fwd EQ bp)
|
---|
170 | p_fwd = p_fwd->e_bak;
|
---|
171 |
|
---|
172 | if (p_cur EQ bp)
|
---|
173 | p_cur = p_cur->e_bak;
|
---|
174 |
|
---|
175 | e_del(e_rmv(bp));
|
---|
176 |
|
---|
177 | disptag = TRUE;
|
---|
178 | runtag = FALSE;
|
---|
179 | scantag = FALSE;
|
---|
180 | continue;
|
---|
181 | /* |
---|
182 |
|
---|
183 | */
|
---|
184 |
|
---|
185 | } else if (ep->e_type EQ EV_FINI) {
|
---|
186 |
|
---|
187 | /* score end */
|
---|
188 |
|
---|
189 | /* delete note begin */
|
---|
190 |
|
---|
191 | if (cp EQ bp)
|
---|
192 | cp = cp->e_bak;
|
---|
193 |
|
---|
194 | if (p_ctr EQ bp)
|
---|
195 | p_ctr = p_ctr->e_bak;
|
---|
196 |
|
---|
197 | if (p_bak EQ bp)
|
---|
198 | p_bak = p_bak->e_bak;
|
---|
199 |
|
---|
200 | if (p_fwd EQ bp)
|
---|
201 | p_fwd = p_fwd->e_bak;
|
---|
202 |
|
---|
203 | if (p_cur EQ bp)
|
---|
204 | p_cur = p_cur->e_bak;
|
---|
205 |
|
---|
206 | e_del(e_rmv(bp));
|
---|
207 |
|
---|
208 | disptag = TRUE;
|
---|
209 | runtag = FALSE;
|
---|
210 | scantag = FALSE;
|
---|
211 | continue;
|
---|
212 | }
|
---|
213 |
|
---|
214 | /* scan right */
|
---|
215 |
|
---|
216 | ep = ep->e_fwd;
|
---|
217 |
|
---|
218 | } /* end while (scantag) */
|
---|
219 |
|
---|
220 | } /* end if */
|
---|
221 | /* |
---|
222 |
|
---|
223 | */
|
---|
224 |
|
---|
225 | /* scan left */
|
---|
226 |
|
---|
227 | bp = bp->e_bak;
|
---|
228 |
|
---|
229 | } /* end while (runtag) */
|
---|
230 |
|
---|
231 | } /* end for (grp) */
|
---|
232 |
|
---|
233 | /* handle accidentals */
|
---|
234 |
|
---|
235 | if (ac_code EQ N_SHARP)
|
---|
236 | ++tnote; /* treat accidentals as sharps */
|
---|
237 | else
|
---|
238 | --tnote; /* treat accidentals as flats */
|
---|
239 |
|
---|
240 | } /* end while (cflag) */
|
---|
241 |
|
---|
242 |
|
---|
243 | /* |
---|
244 |
|
---|
245 | */
|
---|
246 |
|
---|
247 | notnote: /* jumped to if pix2mid() returned FAILURE (not on a note) */
|
---|
248 |
|
---|
249 | /* check for a bar marker delete operation */
|
---|
250 |
|
---|
251 | if (NOT disptag) { /* if no notes were deleted, try for a bar */
|
---|
252 |
|
---|
253 | if (ctime < 0L) /* time has to be good */
|
---|
254 | return(FAILURE);
|
---|
255 |
|
---|
256 | /* search current time for a bar marker - delete any found */
|
---|
257 |
|
---|
258 | ep = ep_adj(p_cur, 1, ctime);
|
---|
259 |
|
---|
260 | while (ctime EQ ep->e_time) {
|
---|
261 |
|
---|
262 | bp = ep->e_fwd;
|
---|
263 |
|
---|
264 | if (EV_BAR EQ ep->e_type) {
|
---|
265 |
|
---|
266 | if (ep EQ p_bak)
|
---|
267 | p_bak = p_bak->e_bak;
|
---|
268 |
|
---|
269 | if (ep EQ p_ctr)
|
---|
270 | p_ctr = p_ctr->e_bak;
|
---|
271 |
|
---|
272 | if (ep EQ p_cur)
|
---|
273 | p_cur = p_cur->e_bak;
|
---|
274 |
|
---|
275 | if (ep EQ p_fwd)
|
---|
276 | p_fwd = p_fwd->e_bak;
|
---|
277 |
|
---|
278 | e_del(e_rmv(ep));
|
---|
279 | disptag = TRUE;
|
---|
280 | }
|
---|
281 |
|
---|
282 | ep = bp;
|
---|
283 | }
|
---|
284 | }
|
---|
285 |
|
---|
286 | if (disptag)
|
---|
287 | sc_refr(t_cur);
|
---|
288 |
|
---|
289 | return(disptag ? SUCCESS : FAILURE);
|
---|
290 | }
|
---|