source: buchla-68k/orig/RAM/DELNOTE.C@ 66b48e7

Last change on this file since 66b48e7 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

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