-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjmusictest01.java
executable file
·144 lines (105 loc) · 3.02 KB
/
jmusictest01.java
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package ali;
import com.cycling74.max.*;
import jm.JMC;
// import static jm.constants.*;
import jm.music.data.*;
import jm.music.tools.*;
import jm.util.*;
import java.lang.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class jmusictest01 extends MaxObject
{
private int recordcounter = 0;
private double quantom = 0.125;
private ArrayList notearray = new ArrayList();
private int[] MAJOR_SCALE = {0,2,4,5,7,9,11};
private static final String[] featureNames = {
"01 - Pitch Variety",
"02 - Pitch Range",
"03 - Key Centeredness",
"04 - Tonal Deviation",
"05 - Dissonance",
"06 - Overall Pitch Direction",
"07 - Melodic Direction Stability",
"08 - Pitch Movement By Tonal Step",
"09 - Leap Compensation",
"10 - Climax Strength",
"11 - Climax Position",
"12 - Climax Tonality",
"13 - Note Density",
"14 - Rest Density",
"15 - Rhythmic Variety",
"16 - Rhythmic Range",
"17 - Syncopation",
"18 - Repeated Pitch Density",
"19 - Repeated Rhythmic Value Density",
"20 - Repeated Pitch Patterns Of Three",
"21 - Repeated Pitch Patterns Of Four",
"22 - Repeated Rhythm Patterns Of Three",
"23 - Repeated Rhythm Patterns Of Four" };
private static final String[] INLET_ASSIST = new String[]{
"inlet 1 help"
};
private static final String[] OUTLET_ASSIST = new String[]{
"outlet 1 help"
};
public jmusictest01(Atom[] args)
{
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});
setInletAssist(INLET_ASSIST);
setOutletAssist(OUTLET_ASSIST);
}
public void setquantom(double newquantom)
{
quantom = newquantom;
}
public void clear()
{
notearray.clear();
}
public void recordnote(int index,int pitch,double dur, int vel)
{
// post("Adding note: " + index + pitch + dur + vel);
Note newnote = new Note(pitch,dur,vel);
notearray.add(index,newnote);
}
public void printall()
{
//post(featureNames);
post("array size: " + notearray.size());
for (int i=0;i<notearray.size();i++) {
Note thisnote = (Note)notearray.get(i);
post("index: " + i);
post("pitch/dur/vel: " + thisnote.getPitch()+ " "+ thisnote.getDuration() + " "+ thisnote.getDynamic());
}
}
public void getStats()
{
Note[] notearrayConverted = new Note[notearray.size()];
double[] statlist;
for (int i=0;i<notearray.size();i++) {
notearrayConverted[i]=(Note)notearray.get(i);
}
//notearrayConverted = (Note[])notearray.toArray();
statlist = PhraseAnalysis.getAllStatisticsAsDoubles(notearrayConverted,quantom,0,MAJOR_SCALE);
for (int i=0;i<23;i++) {
outlet(0, featureNames[i],statlist[i]);
}
}
public void bang()
{
}
public void inlet(int i)
{
}
public void inlet(float f)
{
}
public void list(Atom[] list)
{
}
}