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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
|
/* datastructures.h
*
* the important data structures and defines for denemo, a gtk+ frontend to
* Lilypond, the GNU music typesetter
*
* (c) 1999, 2000, 2001 Matthew Hiller <matthew.hiller@yale.edu>
*
*/
#ifndef DENEMO_DATASTRUCTURES
#define DENEMO_DATASTRUCTURES
/* Include the internationalization stuff. */
/* Only if not on Cygwin, because libintl does not work with mingw */
/* G_OS_WIN32 is defined in gtk.h for mingw */
#include <gtk/gtk.h>
#ifndef G_OS_WIN32
# include <libintl.h>
# include <locale.h>
# define _(String) gettext (String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define _(String) (String)
# define N_(String) (String)
# define setlocale(x,y)
# define bindtextdomain(x,y)
# define textdomain(x)
#endif
#include <gtk/gtk.h>
#include <glib.h>
/* This unit of memory size is used all over the place. */
#define SEVENGINTS (sizeof (gint) * 7)
/* The idea here is to make everything recursive. The dominant
paradigm is a linked list. Handy that there's such a nice
precooked implementation of them in glib, eh? Note, however, that
the whole score isn't treated as a linked list of notes and other
objects as it is in, say Rosegarden; instead, the program has a
linked list of musical objects for each measure, and only then are
measures linked into staffs. That's my main beef with Rosegarden
-- I don't tend to compose my stuff in the order in which it will
eventually be played. As such, I like being able to start entering
music in the middle of my score, then the beginning, then the end,
or whatever, as appropriate. */
enum objtype
{
CHORD,
TUPOPEN,
TUPCLOSE,
CLEF,
TIMESIG,
KEYSIG,
BARLINE,
LILYDIRECTIVE,
COMMENT,
STEMDIRECTIVE,
MEASUREBREAK,
DYNAMIC,
GRACE_START,
GRACE_END
};
enum headtype
{
NORMAL,
CROSS,
HARMONIC,
DIAMOND
};
typedef struct grace
{
gboolean on_beat;
gint duration;
}
grace;
typedef struct note
{
gint mid_c_offset;
gint enshift;
gboolean reversealign;
gboolean showaccidental;
/* Holds number of pixels to the left of the notehead that the
accidental should be drawn at. */
gint position_of_accidental;
/* Holds y co-ordinate for drawing rather than recalculating it each
run through the drawing loop. */
gint y;
/* Holds note head type. */
enum headtype noteheadtype;
/* Holds x offset from default position. */
gint x_off;
/* Holds y offset from default position. */
gint y_off;
}
note;
typedef struct chord
{
GList *tones; /* Holds pointers to actual note structures */
/* test for new dynamic handling */
GList *dynamics;
gboolean has_dynamic;
gint highestpitch;
gint lowestpitch;
gint highesty;
gint lowesty;
gint baseduration;
gint numdots;
gint sum_mid_c_offset;
gint numtones;
gboolean is_tied;
gboolean is_stemup;
gboolean is_reversealigned;
gboolean slur_begin_p;
gboolean slur_end_p;
gboolean crescendo_begin_p;
gboolean crescendo_end_p;
gboolean diminuendo_begin_p;
gboolean diminuendo_end_p;
gboolean hasanacc;
/*Flag to show whether note is a grace note*/
gboolean is_grace;
gboolean struck_through; /*Flag for a struck through stem*/
gint stemy; /* Stores the y position of the end of the stem */
gboolean has_stacatto_p;
gboolean is_accented_p;
gboolean has_fermata_p;
gboolean has_tenuto_p;
gboolean has_trill_p;
gboolean has_turn_p;
gboolean has_mordent_p;
gboolean has_staccatissimo_p;
gboolean has_marcato_p;
gboolean has_ubow_p;
gboolean has_dbow_p;
gboolean has_rheel_p;
gboolean has_lheel_p;
gboolean has_rtoe_p;
gboolean has_ltoe_p;
/* Note highlighting flag if
* true change notes colour
*/
gboolean is_highlighted;
}
chord;
/* Indicator that a tuplet is starting */
typedef struct tupopen
{
gint numerator;
gint denominator;
}
tupopen;
enum clefs
{
TREBLE,
BASS,
ALTO,
G_8,
TENOR,
SOPRANO
};
/* Indicator for a clef change */
typedef struct clef
{
enum clefs type;
}
clef;
/* Indicator for a time-signature change. Only appears at the
* beginning of a measure */
typedef struct timesig
{
gint time1;
gint time2;
}
timesig;
/* Indicator for a key-signature change. */
typedef struct keysig
{
gint number;
gboolean isminor;
gint accs[7];
}
keysig;
/* Dynamic */
typedef struct dynamic
{
GString *type;
}
dynamic;
enum barline_type {
ORDINARY_BARLINE,
DOUBLE_BARLINE,
END_BARLINE,
OPENREPEAT_BARLINE,
CLOSE_REPEAT,
OPEN_CLOSE_REPEAT
};
typedef struct barline
{
gint type;
}
barline;
/* Data structure for an arbitrary directive to be passed to
* Lilypond that Denemo doesn't understand. This type is useful
* in that the user can insert such directives into a mudela file
* by hand and have Denemo respect them when it loads a file and
* write them back when it saves it */
typedef struct lilydirective
{
GString *directive;
}
lilydirective;
enum stemdirections
{
STEMDOWN,
STEMBOTH,
STEMUP
};
/* Indicator that the following music should be all stemup, all
* stemdown, or stemmed normally */
typedef struct stemdirective
{
enum stemdirections type;
}
stemdirective;
/* A comment in the mudela file; treated similarly to a lilydirective. */
typedef struct mudelacomment
{
GString *text;
}
mudelacomment;
typedef union mudelaobjunion
{
chord chordval;
tupopen tupval;
clef clefval;
timesig timeval;
keysig keyval;
dynamic dynval;
barline blval;
lilydirective lilyval;
mudelacomment commentval;
stemdirective stemval;
grace graceval;
}
mudelaobjunion;
typedef struct mudelaobject
{
enum objtype type;
gint basic_durinticks;
gint durinticks;
gint starttick;
gint starttickofnextnote;
/* Allots extra space for accidentals or reverse-aligned notes if
* the stem is down */
gint space_before;
gint minpixelsalloted;
/* Holds x co-ordinate relative to the beginning of the measure. */
gint x;
gboolean isstart_beamgroup;
gboolean isend_beamgroup;
mudelaobjunion u;
}
mudelaobject;
/* and the following typedefs are basically here for so that it's
possible to understand what my code is doing -- just as much for my
sake as yours!
What can I say; I've done a lot of programming in Java and SML/NJ;
I like my type names to convey information. */
/* The ->data part of each objnode presently points to a mudelaobject */
typedef GList objnode;
/* The ->data part of each measurenode points to an objlist, which is
a list of the musical objects in that measure. */
typedef GList measurenode;
typedef struct staff
{
measurenode *measures;
gint sclef;
gint skey;
gint skey_isminor;
gint skeyaccs[7];
gint stime1;
gint stime2;
gint leftmost_clefcontext;
gint leftmost_keysigcontext;
gint leftmost_keywidth;
gint leftmost_time1context;
gint leftmost_time2context;
gint leftmost_keyaccs[7];
gint leftmost_stem_directive;
/*
* Staff Parameters
* Added Adam Tee 27/1/2000, 2001
*/
gint no_of_lines;
gint transposition;
gint pos_in_half_lines;
/* Back to Hiller stuff */
GString *denemo_name;
GString *lily_name;
GString *midi_instrument;
gint space_above;
gint space_below;
gint voicenumber;
/* presently set to 2 for any non-primary voices; we might want to
* change that, though */
}
staff;
/* The ->data part of each staffnode points to a staff structure */
typedef GList staffnode;
typedef staffnode *score;
/* This structure is what's stored in the keymap data structure, both
in the array and in the hash tables. Note that some redundant
information is stored in either case, but either one structure or
the other will need or find it useful to have each piece of information. */
union func_union
{
GtkFunction nocallback;
GtkItemFactoryCallback1 callback;
};
struct keybinding_info
{
gint keyval;
gint state;
gint command_number;
gint callback_action;
union func_union func;
};
struct keymap
{
GList **commands;
GHashTable *quick_lookup_hashes;
};
/* prefinfo holds information on user preferences. */
struct prefinfo
{
GString *lilypath;
GString *midiplayer;
gboolean playbackoutput;
gboolean immediateplayback;
gboolean lilyentrystyle;
gboolean createclones;
struct keymap *the_keymap;
};
/* struct scoreinfo is actually a somewhat misleading name. It contains
* within it a struct prefinfo *, and when Denemo supports editing
* multiple scores simultaneously, each score's scoreinfo structure will
* contain a pointer to the same single prefinfo structure.
*
* I originally hit on this idea as a hack -- everything in Denemo was
* coded to pass around struct scoreinfo *s, and I didn't want to
* change this around -- but then I realized that it was a reasonably
* good idea. Basically all operations need access to the scoreinfo
* structure, and a handful need access to the prefinfo structure as
* well. Only the preferences dialog needs access to _just_ the
* prefinfo structure. So, why not keep things simple and always pass
* around scoreinfos? */
struct scoreinfo
{
/* Fields used fairly directly for drawing */
GtkWidget *window;
GtkWidget *scorearea;
GdkPixmap *pixmap;
GtkObject *vadjustment;
GtkWidget *vscrollbar;
GtkObject *hadjustment;
GtkWidget *hscrollbar;
gint leftmeasurenum;
gint rightmeasurenum;
gint top_staff;
gint bottom_staff;
gint measurewidth;
/* List of all minimum measure widths */
GList *measurewidths;
gint widthtoworkwith;
gint staffspace;
/* Fields that have more to do with the data model and its manipulation,
* though they may be modified by side-effects of the drawing routines */
score thescore;
staffnode *currentprimarystaff;
staffnode *currentstaff;
gint currentstaffnum;
measurenode *currentmeasure;
gint currentmeasurenum;
objnode *currentobject;
/* currentobject points to the note preceding the cursor when the
* cursor is appending. == NULL only when currentmeasure is empty. */
gint cursor_x;
gint cursor_y;
gint staffletter_y;
gint maxkeywidth;
gboolean cursor_appending;
gboolean rest_mode;
gboolean cursoroffend;
gint cursorclef;
gint cursoraccs[7];
gint cursortime1;
gint cursortime2;
gint curmeasureclef;
gint curmeasurekey;
gint curmeasureaccs[7];
gint nextmeasureaccs[7];
/* These are used for determining what accidentals should be there
* if the cursor advances to the next measure from the next "insert chord"
* operation */
gint curmeasure_stem_directive;
gboolean is_grace_mode;
/* Now stuff that's used for marking areas */
gint markstaffnum;
gint markmeasurenum;
gint markcursor_x;
gint firststaffmarked;
gint laststaffmarked;
gint firstmeasuremarked;
gint lastmeasuremarked;
gint firstobjmarked;
gint lastobjmarked;
gboolean haschanged;
/*Temp field fo testing for a slur*/
gboolean is_slured;
/* Fields used for MIDI playback */
gint tempo;
gint start;
gint end;
gint stafftoplay;
/* Mudela file header information */
GString *title;
GString *subtitle;
GString *composer;
/* Filename */
GString *filename;
/* And the prefinfo pointer */
struct prefinfo *prefs;
GList *savebuffer;
};
#endif /* #ifndef DENEMO_DATASTRUCTURES */
|