Some "cast to pointer from integer of different size" warnings removed.
[AROS-Contrib.git] / MultiMedia / radium / common / nsmtracker.h
blobd77ea4ff0bbee8677fdb8e705c0b206516ca243c
1 /* Copyright 2000 Kjetil S. Matheussen
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.
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.
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. */
21 /******************************************************************
22 Main header file for the tracker. Each struct often has a source-
23 file with the same, or nearly the same, name.
25 Note, the files OS_Visual.h and OS_Semaphores.h are OS spesific
26 and must be put into their respective directories. The other
27 OS_*.h files are not.
28 ******************************************************************/
30 #ifndef TRACKER_DEFINE
31 #define TRACKER_DEFINE 1
33 #ifdef __cplusplus
34 # define LANGSPEC "C"
35 #else
36 # define LANGSPEC
37 #endif
40 #include <limits.h>
41 #include <stdint.h>
42 #include <stdbool.h>
43 #include "debug_proc.h"
44 #include "memory_proc.h"
45 #include "nsmtracker_events.h"
46 #include "OS_error_proc.h"
47 #include <OS_Semaphores.h>
50 /* Unfortunately, AmigaOS has one absolute address that is legal to
51 read from; 4, which often fools MuForce to not report a faulty
52 address. By inserting SDB at all 4 offsets, we
53 never read from 4 if a pointer is NULL.
55 #ifdef SYSBASEDEBUG
56 # define SDB int sysbasedebug;
57 #else
58 # define SDB
59 #endif
61 /* Next two lines must be placed in its own OS_depend file later. */
62 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. */
63 /* uint_32 is allways loaded/saved as 64, and converted to 64 bit if uint_32 is 32 bit. */
64 #define MAX_UINT32 65534 /* Sqr(max(uint_32))-1 (rounded down)*/
66 typedef int32_t STime; /* Time can be negative. */
67 typedef STime NInt;
68 #define PFREQ 48000 /* Subseconds for STime */
69 //#define PFREQ 1200
71 #define MAXBLOCKRELTIME 6.0f
72 #define MINBLOCKRELTIME 0.001f
74 #include <OS_Visual.h>
78 #ifdef max
79 #undef max
80 #endif
82 #define max(a,b) (((a)>(b))?(a):(b))
84 #ifdef min
85 #undef min
86 #endif
88 #define min(a,b) (((a)<(b))?(a):(b))
90 #ifdef abs
91 #undef abs
92 #endif
94 #define abs(a) ((a)<0?(-(a)):(a))
96 #define boundaries(a,b,c) (min(max((a),(b)),(c)))
99 /*********************************************************************
100 placement.h
101 *********************************************************************/
105 struct Placement{
106 int line;
108 uint_32 counter;
109 uint_32 dividor;
111 typedef struct Placement Place;
114 /*********************************************************************
115 list.h
116 *********************************************************************/
119 struct ListHeader1{
120 struct ListHeader1 *next;
122 NInt num;
125 struct ListHeader3{
126 struct ListHeader3 *next;
128 Place p;
131 #define Tline l.p.line
132 #define Tcounter l.p.counter
133 #define Tdividor l.p.dividor
136 struct ListHeaderP{
137 struct ListHeaderP *next;
139 STime time;
143 /*********************************************************************
144 velocities.h
145 *********************************************************************/
149 struct Velocities{
150 struct ListHeader3 l;
152 int velocity;
154 #define NextVelocity(a) ((struct Velocities *)((a)->l.next))
158 /*********************************************************************
159 notes.h
160 *********************************************************************/
163 struct Notes{
164 struct ListHeader3 l;
166 int note;
167 int cents;
168 int velocity;
170 Place end;
171 int velocity_end;
173 struct Velocities *velocities;
175 int noend;
177 #define NextNote(a) ((struct Notes *)((a)->l.next))
181 /*********************************************************************
182 patch.h
183 *********************************************************************/
185 struct Tracks;
187 struct Patch{
188 struct ListHeader1 l;
189 char *name;
190 int minvel;
191 int maxvel;
192 int standardvel;
193 void (*playnote)(int notenum,int velocity,struct Tracks *track,struct Notes *note);
194 void (*changevelocity)(int velocity,struct Tracks *track,struct Notes *note);
195 void (*stopnote)(int notenum,int velocity,struct Tracks *track,struct Notes *note);
196 void (*closePatch)(void);
198 void *patchdata; // Free use by the instrument plug-in.
200 void (*changeTrackPan)(int newpan,struct Tracks *track);
202 #define PATCH_FAILED 0
203 #define PATCH_SUCCESS 1
204 #define NextPatch(a) ((struct Patch *)((a)->l.next))
206 /*********************************************************************
207 fx.h
208 *********************************************************************/
211 struct FX{
212 struct ListHeader1 l;
213 char *name;
214 int color;
215 void (*configureFX)(struct FX *fx,struct Tracks *track);
216 int min;
217 int max;
218 void (*treatFX)(struct FX *fx,int val,struct Tracks *track,int skip);
219 void (*closeFX)(struct FX *fx,struct Tracks *track);
220 void *fxdata; //Free use for the instrument plug-in.
221 void (*SaveFX)(struct FX *fx,struct Tracks *track);
223 #define FX_FAILED 0
224 #define FX_SUCCESS 1
227 /*********************************************************************
228 instruments.h
229 *********************************************************************/
231 struct Tracker_Windows;
232 struct Instruments{
233 struct ListHeader1 l;
235 struct Patch *patches;
237 char *instrumentname;
238 int (*getMaxVelocity)(struct Tracks *track);
239 int (*getFX)(struct Tracker_Windows *window,struct Tracks *track,struct FX *fx);
240 int (*getPatch)(struct Tracker_Windows *window,ReqType reqtype,struct Tracks *track,struct Patch *patch);
241 void (*treatSpecialCommand)(char *command,struct Tracks *track);
242 void (*CloseInstrument)(struct Instruments *instrument);
243 void (*SelectTrackInstrument)(struct Tracks *track,struct Instruments *instrument);
244 void (*StopPlaying)(struct Instruments *instrument);
245 int (*getStandardVelocity)(struct Tracks *track);
246 void (*PP_Update)(struct Instruments *instrument,struct Patch *patch);
247 void *(*CopyInstrumentData)(struct Tracks *track); //Necesarry for undo.
249 void (*PlayFromStartHook)(struct Instruments *instrument);
251 void *(*LoadFX)(struct FX *fx,struct Tracks *track);
253 #define INSTRUMENT_FAILED 0
254 #define INSTRUMENT_SUCCESS 1
255 #define NextInstrument(a) ((struct Instruments *)((a)->l.next))
259 /*********************************************************************
260 stops.h
261 *********************************************************************/
264 struct Stops{
265 struct ListHeader3 l;
267 #define NextStop(a) ((struct Stops *)((a)->l.next))
271 /*********************************************************************
272 fxnodelines.h
273 *********************************************************************/
276 struct FXNodeLines{
277 struct ListHeader3 l;
278 int val;
280 #define NextFXNodeLine(a) ((struct FXNodeLines *)((a)->l.next))
283 struct FXs{
284 struct ListHeader1 l; /* l.num=fxnum */
285 struct FX *fx;
286 struct FXNodeLines *fxnodelines;
288 #define NextFX(a) ((struct FXs *)((a)->l.next))
292 /*********************************************************************
293 tracks.h
294 *********************************************************************/
295 struct Tracks{
296 struct ListHeader1 l;
298 struct Notes *notes;
299 struct Stops *stops;
300 int onoff; /* 1=on, 0=off */
301 int relvol;
303 char *trackname;
304 struct Instruments *instrument; /* Only referenced. */
305 struct Patch *patch;
306 struct FXs *fxs;
308 void *instrumentdata; /* Free use for the instrument plug-in. */
310 int pan;
311 int volume;
313 bool panonoff;
314 bool volumeonoff;
316 #define NextTrack(a) (struct Tracks *)((a)->l.next)
318 #define MAXTRACKVOL 1000
319 #define MAXTRACKPAN 1000
321 /*********************************************************************
322 area.h
323 *********************************************************************/
327 typedef struct{
328 int x,x2;
329 }Area;
331 typedef struct{
332 int y,y2;
333 }YArea;
335 typedef struct{
336 int width;
337 int x,x2;
338 }WArea;
341 /*********************************************************************
342 trackreallines.h
343 *********************************************************************/
347 struct TrackReallineElements{
348 struct TrackReallineElements *next;
350 int type;
351 int subtype;
352 int y1,y2;
353 int x1,x2;
354 void *pointer; /* Only referenced. */
356 /************* Types: */
357 #define TRE_THISNOTELINES 0
358 #define TRE_VELLINECENTS 0x5
359 #define TRE_VELLINENODE 0x10
360 #define TRE_VELLINE 0x20
361 #define TRE_VELLINESTART 0x30
362 #define TRE_VELLINEEND 0x40
363 #define TRE_STOPLINE 0x90
364 #define TRE_REALSTARTSTOP 0xa0
366 /* Subtype for 0-0x40 is
367 the same as subtrack for the note.
371 struct TrackRealline{
372 int note; /* Is 0 if no note. */
374 struct TrackReallineElements *trackreallineelements;
376 #define NOTE_MUL 128
377 #define NOTE_STP 129
378 #define NOTE_MUR 130
380 /*********************************************************************
381 wfxnodes.h
382 *********************************************************************/
385 typedef struct TrackReallineElements WFXNodes;
387 struct WFXNodes{
388 struct WFXNodes *next;
390 unsigned char type;
391 unsigned char subtype; // not used.
392 unsigned char y1,y2;
393 unsigned short x1,x2;
394 void *pointer; // Only referenced.
397 /************* Types: */
398 #define TRE_FXNODE 0x50
399 #define TRE_FXLINE 0x60
402 /*********************************************************************
403 tbox.h
404 *********************************************************************/
405 struct TBoxstruct{
406 int x1,y1,x2,y2;
408 typedef struct TBoxstruct TBox;
411 /*********************************************************************
412 wtracks.h
413 *********************************************************************/
415 struct WTracks{
416 struct ListHeader1 l;
417 // l.num=wtracknum;
419 int x,y,x2,y2; /* GFX area. */
421 int notesonoff; /* notearea and placementarea on/off. */
422 int notelength; /* Number of characters the notes is. Usually 2 or 3. */
423 Area notearea; /* These are all parts of the GFX area. */
424 int fxonoff; /* FX area on/off */
425 int fxwidth; /* is fxarea.x2-fxarea.x */
426 Area fxarea;
428 int l_num_vel; /* Last drawn number of velocity lines showed sim. */
429 int num_vel; /* Max number of velocity lines showed simultaniously. */
431 struct Tracks *track; /* Only referenced. wtracknum=track->tracknum */
433 struct TrackRealline *trackreallines;
434 WFXNodes **wfxnodes;
436 TBox pan;
437 TBox volume;
439 TBox panonoff;
440 TBox volumeonoff;
443 #define NextWTrack(a) ((struct WTracks *)((a)->l.next))
447 /*********************************************************************
448 lpb.h
449 *********************************************************************/
452 struct LPBs{
453 struct ListHeader3 l;
454 int lpb;
456 #define NextLPB(a) (struct LPBs *)((a)->l.next)
458 struct WLPBs{
459 int lpb;
460 int type; /* 0=normal, 1=below positioned, 2=mul. */
462 struct LPBs *LPB; /* Only referenced. */
464 #define LPB_NORMAL 0
465 #define LPB_BELOW 1
466 #define LPB_MUL 2
470 /*********************************************************************
471 tempos.h
472 *********************************************************************/
475 struct Tempos{
476 struct ListHeader3 l;
477 int tempo;
479 #define NextTempo(a) (struct Tempos *)((a)->l.next)
481 struct WTempos{
482 int tempo;
483 int type; /* 0=normal, 1=below positioned, 2=mul. */
485 struct Tempos *Tempo; /* Only referenced. */
487 /* Types */
488 #define TEMPO_NORMAL 0
489 #define TEMPO_BELOW 1
490 #define TEMPO_MUL 2
494 /*********************************************************************
495 temponodes.h
496 *********************************************************************/
500 struct TempoNodes{
501 struct ListHeader3 l;
502 float reltempo;
504 #define NextTempoNode(a) ((struct TempoNodes *)((a)->l.next))
506 typedef struct TrackReallineElements WTempoNodes;
508 struct WTempoNodes{
509 struct WTempoNodes *next;
510 unsigned char type;
511 unsigned char subtype; // Currently not used.
512 unsigned char y1,y2;
513 unsigned short x1,x2;
515 void *temponode; // Only referenced.
518 /* Types */
519 #define TEMPONODE_NODE 0
520 #define TEMPONODE_LINE 1
523 /*********************************************************************
524 time.h
525 *********************************************************************/
527 struct STimeChanges{
528 struct ListHeader3 l;
529 STime time;
531 float tempo1; // tempo (tempo*lpb) at this->l.p
532 float rel; // reltempo for this->l.p
533 float deltarel; // rel+deltarel is reltempo for this->l.next->l.p
535 #define NextSTimeChange(a) (struct STimeChanges *)((a)->l.next)
538 struct STimes{ /* One element for each line. */
539 STime time; /* Start-time for the line. */
541 struct STimeChanges *timechanges;
545 /*********************************************************************
546 blocks.h
547 *********************************************************************/
550 struct Blocks{
551 struct ListHeader1 l;
553 char *name;
555 NInt num_tracks;
556 int num_lines;
558 struct Tracks *tracks;
559 struct LPBs *lpbs;
560 struct Tempos *tempos;
561 struct TempoNodes *temponodes;
562 struct TempoNodes *lasttemponode;
564 struct STimes *times; /* Pointer to array. Last element (times[num_lines]) is the playtime of the block. */
566 float reltempo; /* factor that the tempo is multiplied with when playing this block. */
569 #define NextBlock(a) (struct Blocks *)((a)->l.next)
573 /*********************************************************************
574 localzooms.h
575 *********************************************************************/
578 struct LocalZooms{
579 struct ListHeader3 l;
580 // struct LocalZooms *next; /* Next on the same level. */
581 // int line; /* The same type of line that note has. */
582 // uint_32 counter; /* Same type of counter that line has. */
583 // uint_32 dividor; /* Same type of dividor that line has. */
585 int zoomline; /* The linetype that is showed in the editor. */
586 int level;
587 int realline;
589 struct LocalZooms *uplevel; /* Contains 'num_newlines' # of elements. */
591 #define NextLocalZoom(a) ((struct LocalZooms *)((a)->l.next))
595 /*********************************************************************
596 wblocks.h
597 *********************************************************************/
600 struct WBlocks{
601 struct ListHeader1 l;
603 int tempotrackonoff; /* 1=on, 0=off */
604 int temponodetrackonoff; /* 1=on, 0=off */
606 TBox a;
607 // int x,y,x2,y2; /* GFX area. */
609 TBox t;
610 // int tx,ty,tx2,ty2; /* lines, nodes, etc. GFX area. */
612 WArea zoomlevelarea;
613 WArea linenumarea;
614 WArea lpbTypearea;
615 WArea lpbarea;
616 WArea tempoTypearea;
617 WArea tempoarea;
618 WArea temponodearea;
620 YArea linearea;
622 int maxwtracksize; /* The size of the widest wtrack. */
624 int num_visiblelines;
626 int top_realline;
628 int curr_realline;
629 int till_curr_realline; /* The player-routine sets this on. */
631 int bot_realline;
633 struct Blocks *block; /* Only referenced. wblocknum=block->blocknum */
635 struct LocalZooms *localzooms;
636 struct LocalZooms **reallines;
637 int num_reallines;
638 int num_reallines_last;
640 struct WTracks *wtracks;
641 struct WTracks *wtrack; /* Current track. Only referenced. */
643 char *title; /* Window title. */
645 NInt left_track; /* The leftmost visible track. */
646 int left_subtrack;
647 NInt right_track; /* The rightmost visible track. */
648 int right_subtrack;
650 struct WTempos *wtempos;
651 WTempoNodes **wtemponodes;
652 struct WLPBs *wlpbs;
653 float reltempomax;
655 bool isranged;
656 NInt rangex1;
657 NInt rangex2;
658 NInt rangey1;
659 NInt rangey2;
661 bool isgfxdatahere;
663 TBox reltempo;
666 #define NextWBlock(a) (struct WBlocks *)((a)->l.next)
670 /*********************************************************************
671 slider.h
672 *********************************************************************/
675 struct Slider{
676 int show;
677 int width;
678 int x,x2;
679 int lx,lx2;
683 /*********************************************************************
684 blts.h
685 ********************************************************************/
687 typedef struct{
689 /* Used by Blt_blt Blt_mark */
690 bool blt_do;
691 int x1;int x2;
692 int startrealline;
693 int endrealline;
695 /* Used by Blt_clearNotUsedVisible and Blt_markVisible */
696 bool clear_do;
697 int v_x1;int v_x2;
698 int v_y1;int v_y2;
699 }Blt;
702 /*********************************************************************
703 windows.h
704 *********************************************************************/
705 #include "mouse.h"
707 struct Tracker_Windows{
708 struct ListHeader1 l;
710 struct OS_visual *os_visual;
711 int x,y; /* Where window is placed. (for amiga: screen-pos)*/
712 int width,height; /* Size of area to use. */
713 char *fontname;
714 int fontID; /* System spesific. For amiga: fontsize. */
715 int fontTags; /* System spesific. For amiga: nothing. */
716 int fontwidth,fontheight; /* Proportional fonts not so very allowed. */
718 NInt curr_track;
719 int curr_track_sub; /* -1=note, 0,1,2,...,n=vel */
720 NInt curr_block;
722 int maxwtracksize; /* The size of the widest wtrack for all wblocks. */
724 struct Slider bottomslider;
725 struct Slider leftslider;
726 struct Slider rightslider;
727 TBox resizebox;
729 bool playalong; /* If true, this window allso shows whats being played
730 if any other window is playing. default=true. */
732 struct WBlocks *wblock; /* Current wblock. Only referenced. */
733 struct WBlocks *wblocks;
735 struct TEventFIFO *TELroot;
736 struct TEventFIFO *TELlast;
737 uint32_t event_treat; /* Chooses which event type(s) to treat. (0=all)*/
738 int dontbuffer;
740 struct MouseAction curraction;
741 struct MouseAction prevaction;
743 int org_fontheight;
744 char *h_fontname;
745 int h_fontID; /* System spesific. For amiga: fontsize. */
746 int h_fontTags; /* System spesific. For amiga: nothing. */
747 int h_fontwidth;
749 bool textborder;
751 int minnodesize;
753 int num_pixmapdefs;
754 int *pixmapdefs;
755 int *pixmapdefs_calc;
757 Blt blt;
759 #define NextWindow(a) (struct Tracker_Windows *)((a)->l.next)
761 /* curr_track types */
762 #define TEMPONODETRACK -1
763 #define TEMPOTRACK -2
764 #define LPBTRACK -3
765 #define LINENUMBTRACK -4
768 /*********************************************************************
769 song.h
770 *********************************************************************/
773 struct Song{
774 struct Tracker_Windows *tracker_windows;
775 struct Blocks *blocks;
776 struct Blocks **playlist; /* This variable is just temporarily. Later, the playlist will be much more advanced. */
777 struct Instruments *instruments;
779 NInt num_blocks;
780 int length; /* Playlist length. */
781 char *songname;
783 NInt maxtracks; /* The highest number of tracks in a block. (changed when exceeding) */
788 /*********************************************************************
789 root.h
790 *********************************************************************/
793 struct Root{
794 struct Song *song;
795 struct Instruments *def_instrument; /* Default instrument. */
798 int curr_playlist;
799 NInt curr_block;
801 bool setfirstpos;
803 int clearall;
805 int tempo; /* Standard tempo. */
806 int lpb; /* Standard lpb. */
808 float quantitize;
809 int keyoct;
810 int standardvel;
812 bool editonoff;
813 bool scrollplayonoff;
816 #endif