-
Notifications
You must be signed in to change notification settings - Fork 0
/
musiclibrary.pl
51 lines (46 loc) · 1.38 KB
/
musiclibrary.pl
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
notestonames(Progression1, Progression2) :-
clean(Progression1, Progression2).
flag1(Items, Flag, Progression) :-
flag2(Items, Flag, [], Progression), !.
flag1([], b, []) :- !.
flag2([], a, Progression, Progression) :- !.
flag2([[a,Progression1]|Items], _, Progression2, Progression3) :-
append(Progression2, [Progression1], Progression4),
flag2(Items, _, Progression4, Progression3).
flag2([[b,_]|Items], _, Progression2, Progression3) :-
flag2(Items, _, Progression2, Progression3).
clean(Items1, Items2) :-
clean1(Items1,[],Items2).
clean1([],I,I).
clean1(Items,I1,F1) :-
allnumbers(Items,[],Names),append(I1,[Names],F1),!.
clean1([Item|Items],I1,F1) :-
clean1(Item, I1, F2),
clean1(Items, F2, F1).
allnumbers([],Names,Names).
allnumbers([Item|Items],Names1,Names2):-
number(Item),note(Item,Name),append(Names1,[Name],Names3),allnumbers(Items,Names3,Names2).
note0(0,'C').
note0(1,'D').
note0(2,'E').
note0(3,'F').
note0(4,'G').
note0(5,'A').
note0(6,'B').
note(0,'C').
note(1,'C#').
note(2,'D').
note(3,'D#').
note(4,'E').
note(5,'F').
note(6,'F#').
note(7,'G').
note(8,'G#').
note(9,'A').
note(10,'A#').
note(11,'B').
check_asc2mid :-
directory_files("./",F),delete_invisibles_etc(F,G),%writeln1(G),
(member("asc2mid",G)->true;(writeln1("Error: asc2mid not found."),abort)).
delete_invisibles_etc(F,G) :-
findall(J,(member(H,F),atom_string(H,J),not(J="."),not(J=".."),not(string_concat(".",_,J))),G).