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. */
19 #include "nsmtracker.h"
20 #include "list_proc.h"
22 #include "gfx_subtrack_proc.h"
27 /************************************************************************
29 Returns the left X coordinate relative to track->fx.y for the subtrack
31 ************************************************************************/
33 struct WTracks
*wtrack
,
36 return (wtrack
->fxwidth
*subtrack
/wtrack
->num_vel
) + (subtrack
>0 ? 1 : 0 ) ;
39 /************************************************************************
41 Returns the absolute left X coordinate to track->fx.y for the subtrack
43 ************************************************************************/
45 struct WTracks
*wtrack
,
48 if(subtrack
==-1) return wtrack
->notearea
.x
;
49 return wtrack
->fxarea
.x
+ GetRelXSubTrack1(wtrack
,subtrack
);
52 /************************************************************************
54 Returns the right X coordinate relative to track->fx.y for the subtrack
56 ************************************************************************/
58 struct WTracks
*wtrack
,
62 (wtrack
->fxwidth
*(subtrack
+1)/wtrack
->num_vel
) -
63 (subtrack
== wtrack
->num_vel
-1 ? 0 : 1)
67 /************************************************************************
69 Returns the absolute right X coordinate to track->fx.y for the subtrack
71 ************************************************************************/
73 struct WTracks
*wtrack
,
76 if(subtrack
==-1) return wtrack
->notearea
.x2
;
77 return wtrack
->fxarea
.x
+ GetRelXSubTrack2(wtrack
,subtrack
);
80 /************************************************************************
82 These two functions works just like GetXSubTrack1 and 2, except
83 that they allso accept the tracks that contains to the block. Which
84 is the lpb-track, tempo-track, and the temponode-track.
85 ************************************************************************/
87 struct WBlocks
*wblock
,
91 if(track
>=0) return GetXSubTrack1(ListFindElement1(&wblock
->wtracks
->l
,track
),subtrack
);
94 return wblock
->lpbarea
.x
;
97 return wblock
->tempoarea
.x
;
100 return wblock
->temponodearea
.x
;
103 RError("Error in function GetXSubTrack_B1 in file gfx_subtrack.c\n");
108 struct WBlocks
*wblock
,
112 if(track
>=0) return GetXSubTrack2(ListFindElement1(&wblock
->wtracks
->l
,track
),subtrack
);
115 return wblock
->lpbarea
.x2
;
118 return wblock
->tempoarea
.x2
;
121 return wblock
->temponodearea
.x2
;
124 RError("Error in function GetXSubTrack_B2 in file gfx_subtrack.c\n");
128 /************************************************************************
130 Make shure that x is placed within the boundaries of the subtrack.
131 ************************************************************************/
132 int SubtrackBoundaries(struct WTracks
*wtrack
,int subtrack
,int x
){
133 int x1
=GetRelXSubTrack1(wtrack
,subtrack
);
134 int x2
=GetRelXSubTrack2(wtrack
,subtrack
);
137 if(x
==2000) printf("2000\n");
142 int GetSubTrackWidth(struct WTracks
*wtrack
,int subtrack
){
143 return GetXSubTrack2(wtrack
,subtrack
)-GetXSubTrack1(wtrack
,subtrack
);
147 /**************************************************************
149 Returns the relative X position according to X1 value
150 of the wtrack 'wtrack', calculated from the vector (x,maxx).
152 subtrack - Start at zero.
153 **************************************************************/
155 struct WTracks
*wtrack
,
162 x2
=x
*GetSubTrackWidth(wtrack
,subtrack
)/maxx
;
163 x2
=x2
+GetRelXSubTrack1(wtrack
,subtrack
);
165 return (int) (x2
+0.5);
168 /**************************************************************
170 Returns the subtrack 'x' belongs to in the wtrack 'wtrack'.
171 If it doesn't belong to a subtrack. Returns -2;
172 **************************************************************/
174 struct WTracks
*wtrack
,
178 int num_vel
=wtrack
->num_vel
;
180 for(lokke
= -1;lokke
<num_vel
;lokke
++){
181 if(x
==SubtrackBoundaries(wtrack
,lokke
,x
)) return lokke
;