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