Mercurial > hg > dml-open-cliopatria
comparison cpack/dml/lib/musiclab.pl @ 0:718306e29690 tip
commiting public release
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 21:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:718306e29690 |
---|---|
1 /* Part of DML (Digital Music Laboratory) | |
2 Copyright 2014-2015 Samer Abdallah, University of London | |
3 | |
4 This program is free software; you can redistribute it and/or | |
5 modify it under the terms of the GNU General Public License | |
6 as published by the Free Software Foundation; either version 2 | |
7 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public | |
15 License along with this library; if not, write to the Free Software | |
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 */ | |
18 | |
19 :- module(musiclab, | |
20 [ kern_pc_hist/2 | |
21 , pitch_class/2 | |
22 , pitch_class_number/2 | |
23 , pc_number_name/2 | |
24 ]). | |
25 | |
26 :- use_module(library(persistency)). | |
27 | |
28 :- use_module(library(humdrum)). | |
29 :- use_module(library(humdrum/kern)). | |
30 :- use_module(library(humdrum/kernutils)). | |
31 :- use_module(library(humdrum/dynam)). | |
32 :- use_module(library(humdrum/humdrum_world)). | |
33 :- use_module(library(typedef)). | |
34 :- use_module(library(memo)). | |
35 | |
36 :- type pitch_class ---> a ; b ; c ; d ; e ; f ; g ; sharp(pitch_class) ; flat(pitch_class). | |
37 | |
38 :- volatile_memo kern_pc_hist(+path:ground, -hist:list(pair(pitch_class,nonneg))). | |
39 | |
40 % ------------ reading kern ---------------- | |
41 | |
42 pitch_class_number(sharp(PC),N) :- !, pitch_class_number(PC,M), N is (M+1) mod 12. | |
43 pitch_class_number(flat(PC),N) :- !, pitch_class_number(PC,M), N is (M-1) mod 12. | |
44 pitch_class_number(c,0). | |
45 pitch_class_number(d,2). | |
46 pitch_class_number(e,4). | |
47 pitch_class_number(f,5). | |
48 pitch_class_number(g,7). | |
49 pitch_class_number(a,9). | |
50 pitch_class_number(b,11). | |
51 | |
52 kern_pc_hist(Path,Hist) :- | |
53 with_kern_module(Path,utf8,M,findall(PC-N,aggregate(count,mod_note_pc(M,PC),N),Hist)). | |
54 | |
55 % pc_hist_to_num(Hist1,Hist2) :- | |
56 % findall(PCN-X, (member(PC-X,Hist1), pitch_class_number(PC,PCN)), Hist2), | |
57 % numlist(0,11,PCNs), | |
58 % maplist(pc_number_name,PCNs,PCNames), | |
59 % maplist(\PCN^Count^(member(PCN-Count,Hist2) -> true; Count=0),PCNs,Counts), | |
60 | |
61 | |
62 mod_note_pc(M,PC) :- | |
63 M:note(pitch(P),_,_,_), | |
64 pitch_class(P,PC). | |
65 | |
66 pc_number_name(0,"c"). | |
67 pc_number_name(1,"c#"). | |
68 pc_number_name(2,"d"). | |
69 pc_number_name(3,"d#"). | |
70 pc_number_name(4,"e"). | |
71 pc_number_name(5,"f"). | |
72 pc_number_name(6,"f#"). | |
73 pc_number_name(7,"g"). | |
74 pc_number_name(8,"g#"). | |
75 pc_number_name(9,"a"). | |
76 pc_number_name(10,"a#"). | |
77 pc_number_name(11,"b"). | |
78 | |
79 | |
80 |