| 1 | /* Copyright 2000 Kjetil S. Matheussen |
| 2 | |
| 3 | This program is free software; you can redistribute it and/or |
| 4 | modify it under the terms of the GNU General Public License |
| 5 | as published by the Free Software Foundation; either version 2 |
| 6 | of the License, or (at your option) any later version. |
| 7 | |
| 8 | This program is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with this program; if not, write to the Free Software |
| 15 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | /****************************************************************** |
| 22 | Main header file for the tracker. Each struct often has a source- |
| 23 | file with the same, or nearly the same, name. |
| 24 | |
| 25 | Note, the file OS_Visual.h is OS spesific |
| 26 | and must be put into the OS directory it belongs te. The other |
| 27 | OS_*_proc.h files are not. |
| 28 | ******************************************************************/ |
| 29 | |
| 30 | #ifndef TRACKER_DEFINE |
| 31 | #define TRACKER_DEFINE 1 |
| 32 | |
| 33 | #ifdef __cplusplus |
| 34 | # define LANGSPEC "C" |
| 35 | #else |
| 36 | # define LANGSPEC |
| 37 | #endif |
| 38 | |
| 39 | |
| 40 | #ifndef DEBUG |
| 41 | # error "Missing DEBUG option. Edit the Makefile." |
| 42 | #endif |
| 43 | |
| 44 | #if !USE_GTK_VISUAL && !USE_GTK_REQTYPE && !USE_GTK_MENU |
| 45 | # define GTK_IS_USED 0 |
| 46 | #else |
| 47 | # define GTK_IS_USED 1 |
| 48 | #endif |
| 49 | |
| 50 | #include <stdio.h> |
| 51 | #include <stdlib.h> |
| 52 | #include <limits.h> |
| 53 | #include <stdint.h> |
| 54 | #include <stdbool.h> |
| 55 | #include "debug_proc.h" |
| 56 | #include "memory_proc.h" |
| 57 | #include "nsmtracker_events.h" |
| 58 | #include "OS_error_proc.h" |
| 59 | #include "OS_Semaphores.h" |
| 60 | |
| 61 | |
| 62 | /* Unfortunately, AmigaOS has one absolute address that is legal to |
| 63 | read from; 4, which often makes MuForce not to report reading |
| 64 | from the wrong address (radiums fault, not MuFurces). By |
| 65 | inserting SDB at all 4 offsets, we never read from 4 if a pointer is NULL. |
| 66 | */ |
| 67 | #ifdef SYSBASEDEBUG |
| 68 | # define SDB int sysbasedebug; |
| 69 | #else |
| 70 | # define SDB |
| 71 | #endif |
| 72 | |
| 73 | /* Next two lines must be placed in its own OS_depend file later. */ |
| 74 | typedef uint32_t uint_32; /* A type that should be 64 bits, but may be 32 if 64 is _really_ slow or 64 is not available. */ |
| 75 | /* uint_32 is allways loaded/saved as 64, and converted to 64 bit if uint_32 is 32 bit. */ |
| 76 | #define MAX_UINT32 65534 /* Sqr(max(uint_32))-1 (rounded down)*/ |
| 77 | |
| 78 | //typedef int32_t STime; /* Time can be negative. */ |
| 79 | typedef int64_t STime; /* Time can be negative. */ |
| 80 | //typedef STime NInt; |
| 81 | typedef int32_t NInt; |
| 82 | //#define PFREQ (48000*8) /* Subseconds for STime */ /* Replaced by samplerate */ |
| 83 | |
| 84 | //#define LATENCY (PFREQ/200) |
| 85 | #define LATENCY 0 // Dont need this when the player is called from the jack thread. |
| 86 | |
| 87 | #define MAXBLOCKRELTIME 6.0f |
| 88 | #define MINBLOCKRELTIME 0.001f |
| 89 | |
| 90 | // Higher than 255 is no point. |
| 91 | #define MAX_BRIGHTNESS 63 |
| 92 | |
| 93 | enum{ |
| 94 | PAINT_DIRECTLY = 0, |
| 95 | PAINT_BUFFER = 1 |
| 96 | }; |
| 97 | |
| 98 | #include <OS_Visual.h> |
| 99 | |
| 100 | |
| 101 | #define R_MAX(a,b) (((a)>(b))?(a):(b)) |
| 102 | #define R_MIN(a,b) (((a)<(b))?(a):(b)) |
| 103 | #define R_ABS(a) ((a)<0?(-(a)):(a)) |
| 104 | #define R_BOUNDARIES(a,b,c) (R_MIN(R_MAX((a),(b)),(c))) |
| 105 | |
| 106 | static inline double scale_double(double x, double x1, double x2, double y1, double y2){ |
| 107 | return y1 + ( ((x-x1)*(y2-y1)) |
| 108 | / |
| 109 | (x2-x1) |
| 110 | ); |
| 111 | } |
| 112 | |
| 113 | static inline float scale(float x, float x1, float x2, float y1, float y2){ |
| 114 | return y1 + ( ((x-x1)*(y2-y1)) |
| 115 | / |
| 116 | (x2-x1) |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | |
| 121 | /********************************************************************* |
| 122 | placement.h |
| 123 | *********************************************************************/ |
| 124 | |
| 125 | |
| 126 | |
| 127 | struct Placement{ |
| 128 | int line; |
| 129 | SDB |
| 130 | uint_32 counter; |
| 131 | uint_32 dividor; |
| 132 | }; |
| 133 | typedef struct Placement Place; |
| 134 | |
| 135 | |
| 136 | /********************************************************************* |
| 137 | list.h |
| 138 | *********************************************************************/ |
| 139 | |
| 140 | struct ListHeader1{ |
| 141 | struct ListHeader1 *next; |
| 142 | SDB |
| 143 | NInt num; |
| 144 | }; |
| 145 | |
| 146 | struct ListHeader3{ |
| 147 | struct ListHeader3 *next; |
| 148 | SDB |
| 149 | Place p; |
| 150 | }; |
| 151 | |
| 152 | #define Tline l.p.line |
| 153 | #define Tcounter l.p.counter |
| 154 | #define Tdividor l.p.dividor |
| 155 | |
| 156 | |
| 157 | struct ListHeaderP{ |
| 158 | struct ListHeaderP *next; |
| 159 | SDB |
| 160 | STime time; |
| 161 | }; |
| 162 | |
| 163 | |
| 164 | /********************************************************************* |
| 165 | hashmap.h |
| 166 | *********************************************************************/ |
| 167 | |
| 168 | struct _hash_t; |
| 169 | typedef struct _hash_t hash_t; |
| 170 | |
| 171 | |
| 172 | |
| 173 | /********************************************************************* |
| 174 | vector.h |
| 175 | *********************************************************************/ |
| 176 | |
| 177 | typedef struct{ |
| 178 | int num_elements; |
| 179 | int num_elements_allocated; |
| 180 | void **elements; |
| 181 | } vector_t; |
| 182 | |
| 183 | |
| 184 | |
| 185 | /********************************************************************* |
| 186 | velocities.h |
| 187 | *********************************************************************/ |
| 188 | |
| 189 | #define MAX_VELOCITY (1<<16) |
| 190 | |
| 191 | struct Velocities{ |
| 192 | struct ListHeader3 l; |
| 193 | |
| 194 | int velocity; |
| 195 | }; |
| 196 | #define NextVelocity(a) ((struct Velocities *)((a)->l.next)) |
| 197 | |
| 198 | |
| 199 | |
| 200 | /********************************************************************* |
| 201 | notes.h |
| 202 | *********************************************************************/ |
| 203 | |
| 204 | |
| 205 | struct Notes{ |
| 206 | struct ListHeader3 l; |
| 207 | |
| 208 | int note; |
| 209 | int cents; |
| 210 | int velocity; |
| 211 | |
| 212 | Place end; |
| 213 | int velocity_end; |
| 214 | |
| 215 | struct Velocities *velocities; |
| 216 | |
| 217 | int noend; |
| 218 | }; |
| 219 | #define NextNote(a) ((struct Notes *)((a)->l.next)) |
| 220 | |
| 221 | |
| 222 | |
| 223 | /********************************************************************* |
| 224 | patch.h |
| 225 | *********************************************************************/ |
| 226 | |
| 227 | struct Tracks; |
| 228 | |
| 229 | struct Instruments; |
| 230 | |
| 231 | union SuperType{ |
| 232 | void *pointer; |
| 233 | int64_t int_num; |
| 234 | double float_num; |
| 235 | }; |
| 236 | |
| 237 | enum TimeFormat{ |
| 238 | TIME_IN_BEATS = 0, |
| 239 | TIME_IN_MS = 1, |
| 240 | TIME_IN_S = 2 |
| 241 | }; |
| 242 | |
| 243 | struct PatchVoice{ |
| 244 | bool is_on; |
| 245 | int transpose; |
| 246 | float volume; |
| 247 | float start; |
| 248 | float length; |
| 249 | enum TimeFormat time_format; |
| 250 | }; |
| 251 | |
| 252 | #define MAX_PATCH_VOICES 6 |
| 253 | |
| 254 | // Note that Patch objects are stored directly in undo/redo (not copied), so it must not be freed, reused for other purposes, or othervice manipulated when not available. |
| 255 | struct Patch{ |
| 256 | int id; |
| 257 | |
| 258 | const char *name; |
| 259 | |
| 260 | STime last_time; // player lock must be held when setting this value. |
| 261 | |
| 262 | void (*playnote)(struct Patch *patch,int notenum,int velocity,STime time,float pan); |
| 263 | void (*changevelocity)(struct Patch *patch,int notenum,int velocity,STime time); |
| 264 | void (*stopnote)(struct Patch *patch,int notenum,int velocity,STime time); |
| 265 | void (*closePatch)(struct Patch *patch); |
| 266 | |
| 267 | struct Instruments *instrument; |
| 268 | |
| 269 | void *patchdata; // Free use by the instrument plug-in. |
| 270 | |
| 271 | void (*changeTrackPan)(int newpan,struct Tracks *track); |
| 272 | |
| 273 | struct PatchVoice voices[MAX_PATCH_VOICES]; |
| 274 | |
| 275 | int num_ons[128]; /* To keep track of how many times a voice has to be turned off. */ |
| 276 | int notes_num_ons[128]; /* To keep track of which notes are playing. (Useful to avoid hanging notes when turning on and off voices)*/ |
| 277 | |
| 278 | bool peaks_are_dirty; /* Can be set to true by any thread. */ |
| 279 | }; |
| 280 | #define PATCH_FAILED 0 |
| 281 | #define PATCH_SUCCESS 1 |
| 282 | #define NextPatch(a) ((struct Patch *)((a)->l.next)) |
| 283 | |
| 284 | |
| 285 | /********************************************************************* |
| 286 | fx.h |
| 287 | *********************************************************************/ |
| 288 | |
| 289 | struct FX{ |
| 290 | // struct ListHeader1 l; // The next field in 'l' is not used. FX objects are stored one by one in the FXs object. |
| 291 | int num; |
| 292 | const char *name; |
| 293 | int color; |
| 294 | void (*configureFX)(struct FX *fx,struct Tracks *track); |
| 295 | int min; |
| 296 | int max; |
| 297 | |
| 298 | int effect_num; // Set by the instrument plugin. |
| 299 | |
| 300 | // Having pointers to variables in sliders is a bit strange, but letting sliders reference FX instead would cause bookkeeping of live and not alive FX objects. |
| 301 | // Not getting that bookkeeping correct would mean crashes that could be difficult to track. |
| 302 | // This, on the other hand, is safe, since sliders are always alive as long as the Patch is alive, and the patch always outlives an FX object. |
| 303 | // (The refactor to let Patch own FX hasn't been done yet. It didn't make sense when there were only MIDI instrument, but now it's too complicated to let FX live independently. |
| 304 | // However, when an instrument is deleted, all tracks are scanned, and FX are deleted when a patch is deleted. Same when changing patch for a track.) |
| 305 | float *slider_automation_value; // Pointer to the float value showing automation in slider. Value is scaled between 0-1. May be NULL. |
| 306 | int *slider_automation_color; // Pointer to the integer holding color number for showing automation in slider. May be NULL. |
| 307 | |
| 308 | void (*treatFX)(struct FX *fx,int val,struct Tracks *track,STime time,int skip); |
| 309 | |
| 310 | void (*closeFX)(struct FX *fx,struct Tracks *track); |
| 311 | void *fxdata; //Free use for the instrument plug-in. |
| 312 | void (*SaveFX)(struct FX *fx,struct Tracks *track); |
| 313 | }; |
| 314 | #define FX_FAILED 0 |
| 315 | #define FX_SUCCESS 1 |
| 316 | |
| 317 | |
| 318 | /********************************************************************* |
| 319 | instruments.h |
| 320 | *********************************************************************/ |
| 321 | |
| 322 | // These constants are not only used internally, but they are also saved to disk. |
| 323 | enum{ |
| 324 | NO_INSTRUMENT_TYPE = 0, |
| 325 | MIDI_INSTRUMENT_TYPE, |
| 326 | AUDIO_INSTRUMENT_TYPE |
| 327 | }; |
| 328 | |
| 329 | struct Tracker_Windows; |
| 330 | struct Instruments{ |
| 331 | struct ListHeader1 l; |
| 332 | |
| 333 | const char *instrumentname; |
| 334 | |
| 335 | vector_t patches; // Not safe to traverse from player thread. |
| 336 | |
| 337 | int (*getMaxVelocity)(struct Patch *patch); |
| 338 | |
| 339 | int (*getFX)(struct Tracker_Windows *window,struct Tracks *track,struct FX *fx); |
| 340 | int (*getPatch)(struct Tracker_Windows *window,ReqType reqtype,struct Tracks *track,struct Patch *patch); |
| 341 | //void (*treatSpecialCommand)(char *command,struct Tracks *track); |
| 342 | void (*CloseInstrument)(struct Instruments *instrument); |
| 343 | void (*StopPlaying)(struct Instruments *instrument); |
| 344 | void (*PP_Update)(struct Instruments *instrument,struct Patch *patch); |
| 345 | void *(*CopyInstrumentData)(struct Tracks *track); //Necesarry for undo. |
| 346 | |
| 347 | void (*PlayFromStartHook)(struct Instruments *instrument); |
| 348 | |
| 349 | void *(*LoadFX)(struct FX *fx,struct Tracks *track); |
| 350 | |
| 351 | void (*handle_fx_when_theres_a_new_patch_for_track)(struct Tracks *track, struct Patch *old_patch, struct Patch *new_patch); |
| 352 | void (*remove_patch)(struct Patch *patch); |
| 353 | |
| 354 | void (*setPatchData)(struct Patch *patch, char *key, char *value); |
| 355 | char *(*getPatchData)(struct Patch *patch, char *key); |
| 356 | }; |
| 357 | #define INSTRUMENT_FAILED 0 |
| 358 | #define INSTRUMENT_SUCCESS 1 |
| 359 | #define NextInstrument(a) ((struct Instruments *)((a)->l.next)) |
| 360 | |
| 361 | |
| 362 | |
| 363 | /********************************************************************* |
| 364 | stops.h |
| 365 | *********************************************************************/ |
| 366 | |
| 367 | |
| 368 | struct Stops{ |
| 369 | struct ListHeader3 l; |
| 370 | }; |
| 371 | #define NextStop(a) ((struct Stops *)((a)->l.next)) |
| 372 | |
| 373 | |
| 374 | |
| 375 | /********************************************************************* |
| 376 | fxnodelines.h |
| 377 | *********************************************************************/ |
| 378 | |
| 379 | |
| 380 | struct FXNodeLines{ |
| 381 | struct ListHeader3 l; |
| 382 | int val; |
| 383 | }; |
| 384 | #define NextFXNodeLine(a) ((struct FXNodeLines *)((a)->l.next)) |
| 385 | |
| 386 | |
| 387 | struct FXs{ |
| 388 | struct ListHeader1 l; /* l.num=fxnum */ |
| 389 | struct FX *fx; |
| 390 | struct FXNodeLines *fxnodelines; |
| 391 | }; |
| 392 | #define NextFX(a) ((struct FXs *)((a)->l.next)) |
| 393 | |
| 394 | |
| 395 | |
| 396 | /********************************************************************* |
| 397 | tracks.h |
| 398 | *********************************************************************/ |
| 399 | struct Tracks{ |
| 400 | struct ListHeader1 l; |
| 401 | |
| 402 | struct Notes *notes; |
| 403 | struct Stops *stops; |
| 404 | int onoff; |
| 405 | |
| 406 | const char *trackname; |
| 407 | struct Patch *patch; |
| 408 | struct FXs *fxs; |
| 409 | |
| 410 | void *midi_instrumentdata; /* Used by the midi instrument. */ |
| 411 | |
| 412 | int pan; |
| 413 | int volume; |
| 414 | |
| 415 | bool panonoff; |
| 416 | bool volumeonoff; /* The volume-button on/off, not track on/off. */ |
| 417 | }; |
| 418 | #define NextTrack(a) ((struct Tracks *)((a)->l.next)) |
| 419 | |
| 420 | #define MAXTRACKVOL 1000 |
| 421 | #define MAXTRACKPAN 1000 |
| 422 | |
| 423 | /********************************************************************* |
| 424 | area.h |
| 425 | *********************************************************************/ |
| 426 | |
| 427 | |
| 428 | |
| 429 | typedef struct{ |
| 430 | int x,x2; |
| 431 | }Area; |
| 432 | |
| 433 | typedef struct{ |
| 434 | int y,y2; |
| 435 | }YArea; |
| 436 | |
| 437 | typedef struct{ |
| 438 | int width; |
| 439 | int x,x2; |
| 440 | }WArea; |
| 441 | |
| 442 | |
| 443 | /********************************************************************* |
| 444 | trackreallines.h |
| 445 | *********************************************************************/ |
| 446 | |
| 447 | #define NUM_PEAKS_PER_LINE 8 |
| 448 | struct APoint{ |
| 449 | float x,y; |
| 450 | }; |
| 451 | |
| 452 | #define TRE_Max INT16_MAX |
| 453 | struct TrackReallineElements{ |
| 454 | struct TrackReallineElements *next; |
| 455 | |
| 456 | struct Notes *note; |
| 457 | |
| 458 | int type; |
| 459 | int subtype; |
| 460 | float y1,y2; |
| 461 | float x1,x2; |
| 462 | void *pointer; |
| 463 | |
| 464 | struct APoint *velocity_polygon; |
| 465 | |
| 466 | int num_peaks; |
| 467 | struct APoint *peaks[2]; |
| 468 | }; |
| 469 | /************* Types: */ |
| 470 | #define TRE_THISNOTELINES 0 |
| 471 | #define TRE_VELLINECENTS 0x5 |
| 472 | #define TRE_VELLINENODE 0x10 |
| 473 | #define TRE_VELLINE 0x20 |
| 474 | #define TRE_VELLINESTART 0x30 |
| 475 | #define TRE_VELLINEEND 0x40 |
| 476 | #define TRE_STOPLINE 0x90 |
| 477 | #define TRE_REALSTARTSTOP 0xa0 |
| 478 | |
| 479 | /* Subtype for 0-0x40 is |
| 480 | the same as subtrack for the note. |
| 481 | */ |
| 482 | |
| 483 | |
| 484 | struct TrackRealline{ |
| 485 | int note; /* Is 0 if no note. */ |
| 486 | struct TrackReallineElements *trackreallineelements; |
| 487 | }; |
| 488 | #define NOTE_MUL 128 |
| 489 | #define NOTE_STP 129 |
| 490 | #define NOTE_MUR 130 |
| 491 | |
| 492 | /********************************************************************* |
| 493 | wfxnodes.h |
| 494 | *********************************************************************/ |
| 495 | |
| 496 | |
| 497 | typedef struct TrackReallineElements WFXNodes; |
| 498 | /* |
| 499 | struct WFXNodes{ |
| 500 | struct WFXNodes *next; |
| 501 | SDB |
| 502 | unsigned char type; |
| 503 | unsigned char subtype; // not used. |
| 504 | unsigned char y1,y2; |
| 505 | unsigned short x1,x2; |
| 506 | void *pointer; // Only referenced. |
| 507 | }; |
| 508 | */ |
| 509 | /************* Types: */ |
| 510 | #define TRE_FXNODE 0x50 |
| 511 | #define TRE_FXLINE 0x60 |
| 512 | |
| 513 | |
| 514 | /********************************************************************* |
| 515 | tbox.h |
| 516 | *********************************************************************/ |
| 517 | struct TBoxstruct{ |
| 518 | int x1,y1,x2,y2; |
| 519 | }; |
| 520 | typedef struct TBoxstruct TBox; |
| 521 | |
| 522 | |
| 523 | /********************************************************************* |
| 524 | wtracks.h |
| 525 | *********************************************************************/ |
| 526 | |
| 527 | struct WTracks{ |
| 528 | struct ListHeader1 l; |
| 529 | // l.num=wtracknum; |
| 530 | |
| 531 | int x,y,x2,y2; /* GFX area. */ |
| 532 | |
| 533 | int notesonoff; /* notearea and placementarea on/off. */ |
| 534 | int notelength; /* Number of characters the notes is. Usually 2 or 3. */ |
| 535 | int notewidth; |
| 536 | Area notearea; /* These are all parts of the GFX area. */ |
| 537 | int fxonoff; /* FX area on/off */ |
| 538 | int fxwidth; /* is fxarea.x2-fxarea.x */ |
| 539 | Area fxarea; |
| 540 | |
| 541 | int num_vel; /* Max number of velocity lines showed simultaniously. (I.e the number of subtracks)*/ |
| 542 | |
| 543 | struct Tracks *track; /* Only referenced. wtracknum=track->tracknum */ |
| 544 | |
| 545 | struct TrackRealline *trackreallines; |
| 546 | WFXNodes **wfxnodes; |
| 547 | |
| 548 | TBox pan; |
| 549 | TBox volume; |
| 550 | |
| 551 | TBox panonoff; |
| 552 | TBox volumeonoff; |
| 553 | |
| 554 | int noteshowtype; |
| 555 | }; |
| 556 | #define NextWTrack(a) ((struct WTracks *)((a)->l.next)) |
| 557 | |
| 558 | #define TEXTTYPE 0 |
| 559 | #define GFXTYPE1 1 |
| 560 | #define MAXTYPE 1 |
| 561 | |
| 562 | |
| 563 | /********************************************************************* |
| 564 | lpb.h |
| 565 | *********************************************************************/ |
| 566 | |
| 567 | |
| 568 | struct LPBs{ |
| 569 | struct ListHeader3 l; |
| 570 | int lpb; |
| 571 | }; |
| 572 | #define NextLPB(a) (struct LPBs *)((a)->l.next) |
| 573 | |
| 574 | struct WLPBs{ |
| 575 | int lpb; |
| 576 | int type; /* 0=normal, 1=below positioned, 2=mul. */ |
| 577 | |
| 578 | struct LPBs *LPB; /* Only referenced. */ |
| 579 | }; |
| 580 | #define LPB_NORMAL 0 |
| 581 | #define LPB_BELOW 1 |
| 582 | #define LPB_MUL 2 |
| 583 | |
| 584 | |
| 585 | |
| 586 | /********************************************************************* |
| 587 | tempos.h |
| 588 | *********************************************************************/ |
| 589 | |
| 590 | |
| 591 | struct Tempos{ |
| 592 | struct ListHeader3 l; |
| 593 | int tempo; |
| 594 | }; |
| 595 | #define NextTempo(a) (struct Tempos *)((a)->l.next) |
| 596 | |
| 597 | struct WTempos{ |
| 598 | int tempo; |
| 599 | int type; /* 0=normal, 1=below positioned, 2=mul. */ |
| 600 | SDB |
| 601 | struct Tempos *Tempo; /* Only referenced. */ |
| 602 | }; |
| 603 | /* Types */ |
| 604 | #define TEMPO_NORMAL 0 |
| 605 | #define TEMPO_BELOW 1 |
| 606 | #define TEMPO_MUL 2 |
| 607 | |
| 608 | |
| 609 | |
| 610 | /********************************************************************* |
| 611 | temponodes.h |
| 612 | *********************************************************************/ |
| 613 | |
| 614 | |
| 615 | |
| 616 | struct TempoNodes{ |
| 617 | struct ListHeader3 l; |
| 618 | float reltempo; |
| 619 | }; |
| 620 | #define NextTempoNode(a) ((struct TempoNodes *)((a)->l.next)) |
| 621 | |
| 622 | typedef struct TrackReallineElements WTempoNodes; |
| 623 | /* |
| 624 | struct WTempoNodes{ |
| 625 | struct WTempoNodes *next; |
| 626 | unsigned char type; |
| 627 | unsigned char subtype; // Currently not used. |
| 628 | unsigned char y1,y2; |
| 629 | unsigned short x1,x2; |
| 630 | |
| 631 | void *temponode; // Only referenced. |
| 632 | }; |
| 633 | */ |
| 634 | /* Types */ |
| 635 | #define TEMPONODE_NODE 0 |
| 636 | #define TEMPONODE_LINE 1 |
| 637 | |
| 638 | |
| 639 | /********************************************************************* |
| 640 | time.h |
| 641 | *********************************************************************/ |
| 642 | |
| 643 | struct STimeChanges{ |
| 644 | struct ListHeader3 l; |
| 645 | STime time; |
| 646 | |
| 647 | float tempo1; // tempo (tempo*lpb) at this->l.p |
| 648 | float rel; // reltempo for this->l.p |
| 649 | float deltarel; // rel+deltarel is reltempo for this->l.next->l.p |
| 650 | }; |
| 651 | #define NextSTimeChange(a) (struct STimeChanges *)((a)->l.next) |
| 652 | |
| 653 | |
| 654 | struct STimes{ /* One element for each line. */ |
| 655 | STime time; /* Start-time for the line. */ |
| 656 | SDB |
| 657 | struct STimeChanges *timechanges; |
| 658 | }; |
| 659 | |
| 660 | |
| 661 | /********************************************************************* |
| 662 | blocks.h |
| 663 | *********************************************************************/ |
| 664 | |
| 665 | |
| 666 | struct Blocks{ |
| 667 | struct ListHeader1 l; |
| 668 | |
| 669 | char *name; |
| 670 | |
| 671 | NInt num_tracks; |
| 672 | int num_lines; |
| 673 | |
| 674 | struct Tracks *tracks; |
| 675 | struct LPBs *lpbs; |
| 676 | struct Tempos *tempos; |
| 677 | struct TempoNodes *temponodes; |
| 678 | struct TempoNodes *lasttemponode; |
| 679 | |
| 680 | struct STimes *times; /* Pointer to array. Last element (times[num_lines]) is the playtime of the block. */ |
| 681 | |
| 682 | float reltempo; /* factor that the tempo is multiplied with when playing this block. */ |
| 683 | |
| 684 | // This variable is checked after each keyboard or menu event. If true, trackreallines, wtracks, etc. will be updated. |
| 685 | bool is_dirty; |
| 686 | }; |
| 687 | #define NextBlock(a) (struct Blocks *)((a)->l.next) |
| 688 | |
| 689 | |
| 690 | |
| 691 | /********************************************************************* |
| 692 | localzooms.h |
| 693 | *********************************************************************/ |
| 694 | |
| 695 | |
| 696 | struct LocalZooms{ |
| 697 | struct ListHeader3 l; |
| 698 | // struct LocalZooms *next; /* Next on the same level. */ |
| 699 | // int line; /* The same type of line that note has. */ |
| 700 | // uint_32 counter; /* Same type of counter that line has. */ |
| 701 | // uint_32 dividor; /* Same type of dividor that line has. */ |
| 702 | |
| 703 | int zoomline; /* The linetype that is showed in the editor. */ |
| 704 | int level; |
| 705 | int realline; |
| 706 | |
| 707 | struct LocalZooms *uplevel; /* Contains 'num_newlines' # of elements. */ |
| 708 | }; |
| 709 | #define NextLocalZoom(a) ((struct LocalZooms *)((a)->l.next)) |
| 710 | |
| 711 | |
| 712 | |
| 713 | /********************************************************************* |
| 714 | wblocks.h |
| 715 | *********************************************************************/ |
| 716 | |
| 717 | |
| 718 | struct WBlocks{ |
| 719 | struct ListHeader1 l; |
| 720 | |
| 721 | int tempotrackonoff; /* 1=on, 0=off */ |
| 722 | int temponodetrackonoff; /* 1=on, 0=off */ |
| 723 | |
| 724 | TBox a; // everything |
| 725 | // int x,y,x2,y2; /* GFX area. */ |
| 726 | |
| 727 | TBox t; |
| 728 | // int tx,ty,tx2,ty2; /* lines, nodes, etc. GFX area. */ |
| 729 | |
| 730 | //WArea zoomlevelarea; |
| 731 | WArea linenumarea; |
| 732 | WArea zoomlinearea; |
| 733 | WArea tempocolorarea; |
| 734 | WArea lpbTypearea; |
| 735 | WArea lpbarea; |
| 736 | WArea tempoTypearea; // When one character signals whether the tempo is down "d", or multi "m" |
| 737 | WArea tempoarea; |
| 738 | WArea temponodearea; |
| 739 | |
| 740 | YArea linearea; |
| 741 | |
| 742 | int maxwtracksize; /* The size of the widest wtrack. */ |
| 743 | |
| 744 | int num_visiblelines; |
| 745 | |
| 746 | int top_realline; |
| 747 | |
| 748 | int curr_realline; |
| 749 | int till_curr_realline; /* The player-routine sets this on. */ |
| 750 | |
| 751 | int bot_realline; |
| 752 | |
| 753 | int mouse_track; // The track the mouse is currently above. -1 if not on a track. |
| 754 | struct Notes *mouse_note; // The note the mouse is currently above. NULL if mouse is not above a note. |
| 755 | |
| 756 | struct Blocks *block; /* Only referenced. wblocknum=block->blocknum */ |
| 757 | |
| 758 | struct LocalZooms *localzooms; |
| 759 | struct LocalZooms **reallines; |
| 760 | int num_reallines; |
| 761 | int num_reallines_last; |
| 762 | |
| 763 | struct WTracks *wtracks; |
| 764 | struct WTracks *wtrack; /* Current track. Only referenced. */ |
| 765 | |
| 766 | char *title; /* Window title. */ |
| 767 | |
| 768 | NInt left_track; /* The leftmost visible track. */ |
| 769 | int left_subtrack; |
| 770 | NInt right_track; /* The rightmost visible track. */ |
| 771 | int right_subtrack; |
| 772 | |
| 773 | struct WTempos *wtempos; |
| 774 | WTempoNodes **wtemponodes; |
| 775 | struct WLPBs *wlpbs; |
| 776 | float reltempomax; |
| 777 | |
| 778 | bool isranged; |
| 779 | NInt rangex1; |
| 780 | NInt rangex2; |
| 781 | NInt rangey1; |
| 782 | NInt rangey2; |
| 783 | |
| 784 | bool isgfxdatahere; |
| 785 | |
| 786 | TBox reltempo; |
| 787 | |
| 788 | //tempocolor stuff |
| 789 | bool tc_onoff; |
| 790 | int tc_numcolors; |
| 791 | int tc_maxtime; |
| 792 | int tc_mintime; |
| 793 | int tc_type; |
| 794 | }; |
| 795 | #define NextWBlock(a) (struct WBlocks *)((a)->l.next) |
| 796 | |
| 797 | |
| 798 | |
| 799 | /********************************************************************* |
| 800 | slider.h |
| 801 | *********************************************************************/ |
| 802 | |
| 803 | |
| 804 | struct Slider{ |
| 805 | int show; |
| 806 | int width; |
| 807 | int x,x2; |
| 808 | int lx,lx2; |
| 809 | }; |
| 810 | |
| 811 | |
| 812 | /********************************************************************* |
| 813 | blts.h |
| 814 | ********************************************************************/ |
| 815 | |
| 816 | typedef struct{ |
| 817 | |
| 818 | /* Used by Blt_blt Blt_mark */ |
| 819 | bool blt_do; |
| 820 | int x1;int x2; |
| 821 | int startrealline; |
| 822 | int endrealline; |
| 823 | |
| 824 | /* Used by Blt_blt and Blt_marktrackheader */ |
| 825 | bool blt_doheader; |
| 826 | NInt starttrack; |
| 827 | NInt endtrack; |
| 828 | |
| 829 | /* Used by Blt_clearNotUsedVisible and Blt_markVisible */ |
| 830 | bool clear_do; |
| 831 | int v_x1;int v_x2; |
| 832 | int v_y1;int v_y2; |
| 833 | }Blt; |
| 834 | |
| 835 | |
| 836 | /********************************************************************* |
| 837 | windows.h |
| 838 | *********************************************************************/ |
| 839 | #include "mouse.h" |
| 840 | |
| 841 | struct Tracker_Windows{ |
| 842 | struct ListHeader1 l; |
| 843 | |
| 844 | struct OS_visual os_visual; |
| 845 | int x,y; /* Where window is placed. (for amiga: screen-pos)*/ |
| 846 | int width,height; /* Size of area to use. */ |
| 847 | char *fontname; |
| 848 | int fontID; /* System spesific. For amiga: fontsize. */ |
| 849 | int fontTags; /* System spesific. For amiga: nothing. */ |
| 850 | int fontwidth,fontheight; /* Proportional fonts not so very allowed. */ |
| 851 | |
| 852 | NInt curr_track; |
| 853 | int curr_track_sub; /* -1=note, 0,1,2,...,n=vel */ |
| 854 | NInt curr_block; |
| 855 | |
| 856 | int maxwtracksize; /* The size of the widest wtrack for all wblocks. */ |
| 857 | |
| 858 | struct Slider bottomslider; |
| 859 | struct Slider leftslider; |
| 860 | struct Slider rightslider; |
| 861 | |
| 862 | bool playalong; /* If true, this window allso shows whats being played |
| 863 | if any other window is playing. default=true. */ |
| 864 | |
| 865 | struct WBlocks *wblock; /* Current wblock. Only referenced. */ |
| 866 | struct WBlocks *wblocks; |
| 867 | |
| 868 | struct TEventFIFO *TELroot; |
| 869 | struct TEventFIFO *TELlast; |
| 870 | uint32_t event_treat; /* Chooses which event type(s) to treat. (0=all)*/ |
| 871 | int dontbuffer; |
| 872 | |
| 873 | struct MouseAction curraction; |
| 874 | struct MouseAction prevaction; |
| 875 | |
| 876 | int org_fontheight; |
| 877 | #ifdef _AMIGA |
| 878 | char *h_fontname; |
| 879 | int h_fontID; /* System spesific. For amiga: fontsize. */ |
| 880 | int h_fontTags; /* System spesific. For amiga: nothing. */ |
| 881 | int h_fontwidth; |
| 882 | #endif |
| 883 | |
| 884 | int num_pixmapdefs; |
| 885 | int *pixmapdefs; |
| 886 | int *pixmapdefs_calc; |
| 887 | |
| 888 | Blt blt; |
| 889 | |
| 890 | #ifdef USE_GFX_OP_QUEUE |
| 891 | void *op_queue; |
| 892 | #endif |
| 893 | bool must_redraw; |
| 894 | }; |
| 895 | #define NextWindow(a) (struct Tracker_Windows *)((a)->l.next) |
| 896 | |
| 897 | /* curr_track types */ |
| 898 | #define TEMPONODETRACK -1 |
| 899 | #define TEMPOTRACK -2 |
| 900 | #define LPBTRACK -3 |
| 901 | #define LINENUMBTRACK -4 |
| 902 | #define TEMPOCOLORTRACK -5 |
| 903 | #define NOTRACK -10000 |
| 904 | |
| 905 | /********************************************************************* |
| 906 | song.h |
| 907 | *********************************************************************/ |
| 908 | |
| 909 | |
| 910 | struct Song{ |
| 911 | struct Tracker_Windows *tracker_windows; |
| 912 | struct Blocks *blocks; |
| 913 | struct Blocks **playlist; /* This variable is just temporarily. Later, the playlist will be much more advanced. */ |
| 914 | |
| 915 | NInt num_blocks; |
| 916 | int length; /* Playlist length. */ |
| 917 | char *songname; |
| 918 | |
| 919 | NInt maxtracks; /* The highest number of tracks in a block. (changed when exceeding) */ |
| 920 | |
| 921 | hash_t *mixerwidget_state; // Only used during loading. |
| 922 | hash_t *instrument_widget_order_state; // Only used during loading. |
| 923 | }; |
| 924 | |
| 925 | |
| 926 | |
| 927 | /********************************************************************* |
| 928 | root.h |
| 929 | *********************************************************************/ |
| 930 | |
| 931 | |
| 932 | struct Root{ |
| 933 | struct Song *song; |
| 934 | |
| 935 | int curr_playlist; |
| 936 | NInt curr_block; |
| 937 | |
| 938 | bool setfirstpos; |
| 939 | |
| 940 | int tempo; /* Standard tempo. */ |
| 941 | int lpb; /* Standard lpb. */ |
| 942 | |
| 943 | float quantitize; |
| 944 | int keyoct; |
| 945 | int min_standardvel; |
| 946 | int standardvel; |
| 947 | |
| 948 | bool editonoff; |
| 949 | bool scrollplayonoff; |
| 950 | }; |
| 951 | |
| 952 | |
| 953 | |
| 954 | |
| 955 | /************************************************* |
| 956 | Structures for the advanced functions. |
| 957 | (especially made for extension language support.) |
| 958 | *************************************************/ |
| 959 | |
| 960 | struct NoteAdds_track{ |
| 961 | float place; // A placement type represented as float |
| 962 | int notenum; |
| 963 | float volume; // 0.0 is off, 1.0 is max, -0.0 - -2.0 is default |
| 964 | float endplace; // The end place. A value -0.0 - -2.0 means no spesified end-place (end-place is set to the same as the start-place of the next note in the array). |
| 965 | }; |
| 966 | |
| 967 | struct NoteAdds_track_do{ |
| 968 | NInt tracknum; |
| 969 | int num_nats; |
| 970 | struct NoteAdds_track *nats; |
| 971 | float startplace; |
| 972 | int sort; |
| 973 | }; |
| 974 | |
| 975 | struct NoteAdds_block{ |
| 976 | NInt blocknum; |
| 977 | int num_nats_do; |
| 978 | struct NoteAdds_track_do **nats_do; |
| 979 | }; |
| 980 | |
| 981 | |
| 982 | #endif |
| 983 | |
| 984 | |
| 985 | |
| 986 | |
| 987 | |
| 988 | |
| 989 | |
| 990 | |
| 991 | |
| 992 | |
| 993 |