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
28 ******************************************************************/
30 #ifndef TRACKER_DEFINE
31 #define TRACKER_DEFINE 1
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.
56 # define SDB int sysbasedebug;
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. */
68 #define PFREQ 48000 /* Subseconds for STime */
71 #define MAXBLOCKRELTIME 6.0f
72 #define MINBLOCKRELTIME 0.001f
74 #include <OS_Visual.h>
82 #define max(a,b) (((a)>(b))?(a):(b))
88 #define min(a,b) (((a)<(b))?(a):(b))
94 #define abs(a) ((a)<0?(-(a)):(a))
96 #define boundaries(a,b,c) (min(max((a),(b)),(c)))
99 /*********************************************************************
101 *********************************************************************/
111 typedef struct Placement Place
;
114 /*********************************************************************
116 *********************************************************************/
120 struct ListHeader1
*next
;
126 struct ListHeader3
*next
;
131 #define Tline l.p.line
132 #define Tcounter l.p.counter
133 #define Tdividor l.p.dividor
137 struct ListHeaderP
*next
;
143 /*********************************************************************
145 *********************************************************************/
150 struct ListHeader3 l
;
154 #define NextVelocity(a) ((struct Velocities *)((a)->l.next))
158 /*********************************************************************
160 *********************************************************************/
164 struct ListHeader3 l
;
173 struct Velocities
*velocities
;
177 #define NextNote(a) ((struct Notes *)((a)->l.next))
181 /*********************************************************************
183 *********************************************************************/
188 struct ListHeader1 l
;
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 /*********************************************************************
208 *********************************************************************/
212 struct ListHeader1 l
;
215 void (*configureFX
)(struct FX
*fx
,struct Tracks
*track
);
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
);
227 /*********************************************************************
229 *********************************************************************/
231 struct Tracker_Windows
;
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 /*********************************************************************
261 *********************************************************************/
265 struct ListHeader3 l
;
267 #define NextStop(a) ((struct Stops *)((a)->l.next))
271 /*********************************************************************
273 *********************************************************************/
277 struct ListHeader3 l
;
280 #define NextFXNodeLine(a) ((struct FXNodeLines *)((a)->l.next))
284 struct ListHeader1 l
; /* l.num=fxnum */
286 struct FXNodeLines
*fxnodelines
;
288 #define NextFX(a) ((struct FXs *)((a)->l.next))
292 /*********************************************************************
294 *********************************************************************/
296 struct ListHeader1 l
;
300 int onoff
; /* 1=on, 0=off */
304 struct Instruments
*instrument
; /* Only referenced. */
308 void *instrumentdata
; /* Free use for the instrument plug-in. */
316 #define NextTrack(a) (struct Tracks *)((a)->l.next)
318 #define MAXTRACKVOL 1000
319 #define MAXTRACKPAN 1000
321 /*********************************************************************
323 *********************************************************************/
341 /*********************************************************************
343 *********************************************************************/
347 struct TrackReallineElements
{
348 struct TrackReallineElements
*next
;
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
;
380 /*********************************************************************
382 *********************************************************************/
385 typedef struct TrackReallineElements WFXNodes
;
388 struct WFXNodes *next;
391 unsigned char subtype; // not used.
393 unsigned short x1,x2;
394 void *pointer; // Only referenced.
397 /************* Types: */
398 #define TRE_FXNODE 0x50
399 #define TRE_FXLINE 0x60
402 /*********************************************************************
404 *********************************************************************/
408 typedef struct TBoxstruct TBox
;
411 /*********************************************************************
413 *********************************************************************/
416 struct ListHeader1 l
;
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 */
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
;
443 #define NextWTrack(a) ((struct WTracks *)((a)->l.next))
447 /*********************************************************************
449 *********************************************************************/
453 struct ListHeader3 l
;
456 #define NextLPB(a) (struct LPBs *)((a)->l.next)
460 int type
; /* 0=normal, 1=below positioned, 2=mul. */
462 struct LPBs
*LPB
; /* Only referenced. */
470 /*********************************************************************
472 *********************************************************************/
476 struct ListHeader3 l
;
479 #define NextTempo(a) (struct Tempos *)((a)->l.next)
483 int type
; /* 0=normal, 1=below positioned, 2=mul. */
485 struct Tempos
*Tempo
; /* Only referenced. */
488 #define TEMPO_NORMAL 0
489 #define TEMPO_BELOW 1
494 /*********************************************************************
496 *********************************************************************/
501 struct ListHeader3 l
;
504 #define NextTempoNode(a) ((struct TempoNodes *)((a)->l.next))
506 typedef struct TrackReallineElements WTempoNodes
;
509 struct WTempoNodes *next;
511 unsigned char subtype; // Currently not used.
513 unsigned short x1,x2;
515 void *temponode; // Only referenced.
519 #define TEMPONODE_NODE 0
520 #define TEMPONODE_LINE 1
523 /*********************************************************************
525 *********************************************************************/
528 struct ListHeader3 l
;
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 /*********************************************************************
547 *********************************************************************/
551 struct ListHeader1 l
;
558 struct Tracks
*tracks
;
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 /*********************************************************************
575 *********************************************************************/
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. */
589 struct LocalZooms
*uplevel
; /* Contains 'num_newlines' # of elements. */
591 #define NextLocalZoom(a) ((struct LocalZooms *)((a)->l.next))
595 /*********************************************************************
597 *********************************************************************/
601 struct ListHeader1 l
;
603 int tempotrackonoff
; /* 1=on, 0=off */
604 int temponodetrackonoff
; /* 1=on, 0=off */
607 // int x,y,x2,y2; /* GFX area. */
610 // int tx,ty,tx2,ty2; /* lines, nodes, etc. GFX area. */
622 int maxwtracksize
; /* The size of the widest wtrack. */
624 int num_visiblelines
;
629 int till_curr_realline
; /* The player-routine sets this on. */
633 struct Blocks
*block
; /* Only referenced. wblocknum=block->blocknum */
635 struct LocalZooms
*localzooms
;
636 struct LocalZooms
**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. */
647 NInt right_track
; /* The rightmost visible track. */
650 struct WTempos
*wtempos
;
651 WTempoNodes
**wtemponodes
;
666 #define NextWBlock(a) (struct WBlocks *)((a)->l.next)
670 /*********************************************************************
672 *********************************************************************/
683 /*********************************************************************
685 ********************************************************************/
689 /* Used by Blt_blt Blt_mark */
695 /* Used by Blt_clearNotUsedVisible and Blt_markVisible */
702 /*********************************************************************
704 *********************************************************************/
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. */
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. */
719 int curr_track_sub
; /* -1=note, 0,1,2,...,n=vel */
722 int maxwtracksize
; /* The size of the widest wtrack for all wblocks. */
724 struct Slider bottomslider
;
725 struct Slider leftslider
;
726 struct Slider rightslider
;
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)*/
740 struct MouseAction curraction
;
741 struct MouseAction prevaction
;
745 int h_fontID
; /* System spesific. For amiga: fontsize. */
746 int h_fontTags
; /* System spesific. For amiga: nothing. */
755 int *pixmapdefs_calc
;
759 #define NextWindow(a) (struct Tracker_Windows *)((a)->l.next)
761 /* curr_track types */
762 #define TEMPONODETRACK -1
763 #define TEMPOTRACK -2
765 #define LINENUMBTRACK -4
768 /*********************************************************************
770 *********************************************************************/
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
;
780 int length
; /* Playlist length. */
783 NInt maxtracks
; /* The highest number of tracks in a block. (changed when exceeding) */
788 /*********************************************************************
790 *********************************************************************/
795 struct Instruments
*def_instrument
; /* Default instrument. */
805 int tempo
; /* Standard tempo. */
806 int lpb
; /* Standard lpb. */
813 bool scrollplayonoff
;