-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathBeats_proc.h
75 lines (45 loc) · 1.36 KB
/
Beats_proc.h
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
extern LANGSPEC struct Beats *Beats_get(struct Blocks *block, StaticRatio default_signature, int default_lpb);
static inline bool get_barbeat_start_and_end(const struct Blocks *block, int barnum, int beatnum, Place *start, Place *end){
bool find_beat_only = true;
if (beatnum < 1){
find_beat_only = false;
beatnum = 1;
}
bool found_start = false;
const struct Beats *beat = block->beats;
while(beat != NULL){
if (beat->bar_num > barnum)
break;
if (beat->bar_num==barnum && beat->beat_num==beatnum){
if (found_start==false) {
if (start != NULL)
*start = beat->l.p;
if (end==NULL)
return true;
found_start = true;
if (find_beat_only) {
beat = NextBeat(beat);
R_ASSERT_RETURN_IF_FALSE2(end!=NULL, false);
if (beat==NULL)
*end = p_Absolute_Last_Pos(block);
else
*end = beat->l.p;
return true;
} else {
barnum++;
}
} else {
R_ASSERT_RETURN_IF_FALSE2(end!=NULL, false);
*end = beat->l.p;
return true;
}
}
beat = NextBeat(beat);
}
if (found_start){
R_ASSERT_RETURN_IF_FALSE2(end!=NULL, false);
*end = p_Absolute_Last_Pos(block);
return true;
}
return false;
}