Skip to content

Commit 2ed5e08

Browse files
committed
audio overhaul and partial content addition
nodescript
1 parent 1211fed commit 2ed5e08

File tree

9 files changed

+439
-171
lines changed

9 files changed

+439
-171
lines changed

dist/README.TXT

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
========================
2+
BUILD OUTPUT DESCRIPTION
3+
========================
4+
5+
When you build an Java application project that has a main class, the IDE
6+
automatically copies all of the JAR
7+
files on the projects classpath to your projects dist/lib folder. The IDE
8+
also adds each of the JAR files to the Class-Path element in the application
9+
JAR files manifest file (MANIFEST.MF).
10+
11+
To run the project from the command line, go to the dist folder and
12+
type the following:
13+
14+
java -jar "ArrayVisualizer.jar"
15+
16+
To distribute this project, zip up the dist folder (including the lib folder)
17+
and distribute the ZIP file.
18+
19+
Notes:
20+
21+
* If two JAR files on the project classpath have the same name, only the first
22+
JAR file is copied to the lib folder.
23+
* Only JAR files are copied to the lib folder.
24+
If the classpath contains other types of files or folders, these files (folders)
25+
are not copied.
26+
* If a library on the projects classpath also has a Class-Path element
27+
specified in the manifest,the content of the Class-Path element has to be on
28+
the projects runtime path.
29+
* To set a main class in a standard Java project, right-click the project node
30+
in the Projects window and choose Properties. Then click Run and enter the
31+
class name in the Main Class field. Alternatively, you can manually type the
32+
class name in the manifest Main-Class element.

src/ArrayVisualizer.java

Lines changed: 218 additions & 56 deletions
Large diffs are not rendered by default.

src/HeapSort.java

Lines changed: 55 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,93 +7,74 @@ public class HeapSort {
77

88
static int SLP = 1;
99

10-
static int heapify(int parent, int child1, boolean max){
11-
aa+=2;
12-
comps+=1;
13-
if((max && array[child1]>array[parent]) || (!max && array[child1]<array[parent])){
14-
swap(array, parent, child1, SLP);
15-
return child1;
10+
static void maxheapifyrec(int pos, boolean max){
11+
if(pos>=array.length)
12+
return;
13+
14+
int child1 = pos*2+1;
15+
int child2 = pos*2+2;
16+
17+
maxheapifyrec(child1,max);
18+
maxheapifyrec(child2,max);
19+
20+
if(child2>=array.length){
21+
if(child1>=array.length)
22+
return; //Done, no children
23+
if(array[child1]>array[pos])
24+
swap(array,pos,child1,SLP);
25+
return;
1626
}
1727

18-
return -1;
28+
//Find largest child
29+
int lrg = child1;
30+
if(array[child2]>array[child1])
31+
lrg = child2;
32+
33+
//Swap with largest child
34+
if(array[lrg]>array[pos]){
35+
swap(array, pos, lrg,SLP);
36+
percdwn(lrg, true, array.length);
37+
return;
38+
}
1939
}
2040

21-
static int heapify(int parent, int child1, int child2, boolean max){
22-
int candidate = 0;
23-
24-
aa+=4;
25-
comps+=2;
41+
static void percdwn(int pos, boolean max, int len){
42+
int child1 = pos*2+1;
43+
int child2 = pos*2+2;
2644

27-
if(max){
28-
if(array[child1]>array[child2])
29-
candidate = child1;
30-
else
31-
candidate = child2;
32-
33-
if(array[candidate]>array[parent]){
34-
swap(array, parent, candidate, SLP);
35-
return candidate;
45+
if(child2 >= len){
46+
if(child1 >= len) //Done
47+
return;
48+
else{
49+
//Single Child
50+
if((max && (array[child1]>array[pos])) || (!max && (array[child1]<array[pos])))
51+
swap(array, pos, child1, SLP);
52+
return;
3653
}
3754
}
38-
else{
39-
if(array[child1]<array[child2])
40-
candidate = child1;
41-
else
42-
candidate = child2;
43-
44-
if(array[candidate]<array[parent]){
45-
swap(array, parent, candidate, SLP);
46-
return candidate;
47-
}
55+
56+
if(array[child1]>array[child2]){
57+
//Ensure child1 is the smallest for easy programming
58+
int tmp = child1;
59+
child1 = child2;
60+
child2 = tmp;
4861
}
4962

50-
return -1;
51-
}
52-
53-
static void maxheapify(int len) {
54-
for(int i = len/2-1; i >= 0; i--){
55-
int child2 = i*2+2;
56-
if(child2>=len)
57-
//Special case for only one child.
58-
heapify(i, child2-1, true);
59-
else
60-
heapify(i,child2-1,child2,true);
63+
if(max && (array[child2]>array[pos])){
64+
swap(array, pos, child2,SLP);
65+
percdwn(child2,max,len);
66+
}
67+
else if (!max && (array[child1]<array[pos])){
68+
swap(array, pos, child1,SLP);
69+
percdwn(child1,max,len);
6170
}
6271
}
6372

64-
// static void maxheapify(int len){
65-
// int loc = 0;
66-
// int child1 = 1;
67-
// int child2 = 2;
68-
//
69-
// while(loc != -1){
70-
// child1 = loc*2+1;
71-
// child2 = child1+1;
72-
//
73-
//
74-
//
75-
// if(child1>=len)
76-
// //DONE
77-
// return;
78-
//
79-
// System.out.println("loc: "+loc+" child1: "+child1+" child2: "+child2);
80-
// System.out.println("loc: "+array[loc]+" child1: "+array[child1]+" child2: "+array[child2]);
81-
// if(child2>=len)
82-
// //SPECIAL SINGLE CHILD CASE
83-
// loc = heapify(loc, child1, true);
84-
// else
85-
// loc = heapify(loc, child1, child2, true);
86-
//
87-
// System.out.println("Chose "+loc);
88-
// }
89-
// }
90-
9173
static void maxheapsort(){
92-
//maxheapifyinitial(array.length);
93-
//swap(array, 0, array.length-1, SLP);
94-
for(int i = array.length; i > 1; i--){
95-
maxheapify(i);
96-
swap(array, 0, i-1, SLP);
74+
maxheapifyrec(0,true);
75+
for(int i = array.length-1; i > 0; i--){
76+
swap(array, 0, i, SLP);
77+
percdwn(0,true,i);
9778
}
9879
}
9980

src/ShellSort.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package array.visualizer;
2+
3+
import static array.visualizer.ArrayVisualizer.*;
4+
import static array.visualizer.Swaps.*;
5+
6+
public class ShellSort {
7+
public static void shellSort(int gap, int divrate){
8+
double sleepamt = 1d;
9+
while(gap>0){
10+
for(int j = 0; j <= gap-1; j++){
11+
for(int i = j+gap; i < array.length; i+=gap){
12+
int pos = i;
13+
int prev = pos-gap;
14+
while(prev>=0){
15+
if(array[pos] < array[prev]){
16+
swap(array, pos, prev);
17+
sleep(sleepamt);
18+
}else
19+
break;
20+
pos = prev;
21+
prev = pos-gap;
22+
}
23+
}
24+
}
25+
26+
if(gap==1) //Done
27+
break;
28+
29+
gap = Math.max(gap/divrate,1); //Ensure that we do gap 1
30+
//sleepamt /= divrate;
31+
}
32+
}
33+
}

src/UtilFrame.form

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@
3232
<Group type="103" groupAlignment="0" attributes="0">
3333
<Group type="102" alignment="0" attributes="0">
3434
<EmptySpace max="-2" attributes="0"/>
35-
<Group type="103" groupAlignment="0" attributes="0">
36-
<Component id="jCheckBox3" min="-2" max="-2" attributes="0"/>
37-
<Component id="jCheckBox2" min="-2" max="-2" attributes="0"/>
38-
<Group type="103" groupAlignment="1" max="-2" attributes="0">
39-
<Component id="jButton3" max="32767" attributes="0"/>
40-
<Component id="jButton2" alignment="1" max="32767" attributes="0"/>
41-
<Component id="jButton1" alignment="1" max="32767" attributes="0"/>
35+
<Group type="103" groupAlignment="1" max="-2" attributes="0">
36+
<Component id="jButton4" max="32767" attributes="0"/>
37+
<Group type="103" groupAlignment="0" attributes="0">
38+
<Component id="jCheckBox3" min="-2" max="-2" attributes="0"/>
39+
<Component id="jCheckBox2" min="-2" max="-2" attributes="0"/>
40+
<Group type="103" groupAlignment="1" max="-2" attributes="0">
41+
<Component id="jButton3" max="32767" attributes="0"/>
42+
<Component id="jButton2" alignment="1" max="32767" attributes="0"/>
43+
<Component id="jButton1" alignment="1" max="32767" attributes="0"/>
44+
</Group>
4245
</Group>
4346
</Group>
44-
<EmptySpace min="0" pref="8" max="32767" attributes="0"/>
47+
<EmptySpace min="0" pref="10" max="32767" attributes="0"/>
4548
</Group>
4649
</Group>
4750
</DimensionLayout>
@@ -54,11 +57,13 @@
5457
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
5558
<EmptySpace max="-2" attributes="0"/>
5659
<Component id="jButton3" min="-2" max="-2" attributes="0"/>
57-
<EmptySpace type="unrelated" max="-2" attributes="0"/>
60+
<EmptySpace max="-2" attributes="0"/>
61+
<Component id="jButton4" min="-2" max="-2" attributes="0"/>
62+
<EmptySpace pref="7" max="32767" attributes="0"/>
5863
<Component id="jCheckBox2" min="-2" max="-2" attributes="0"/>
5964
<EmptySpace max="-2" attributes="0"/>
6065
<Component id="jCheckBox3" min="-2" max="-2" attributes="0"/>
61-
<EmptySpace max="32767" attributes="0"/>
66+
<EmptySpace max="-2" attributes="0"/>
6267
</Group>
6368
</Group>
6469
</DimensionLayout>
@@ -106,5 +111,13 @@
106111
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBox3ActionPerformed"/>
107112
</Events>
108113
</Component>
114+
<Component class="javax.swing.JButton" name="jButton4">
115+
<Properties>
116+
<Property name="text" type="java.lang.String" value="Change Inst"/>
117+
</Properties>
118+
<Events>
119+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/>
120+
</Events>
121+
</Component>
109122
</SubComponents>
110123
</Form>

src/UtilFrame.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private void initComponents() {
5151
jButton3 = new javax.swing.JButton();
5252
jCheckBox2 = new javax.swing.JCheckBox();
5353
jCheckBox3 = new javax.swing.JCheckBox();
54+
jButton4 = new javax.swing.JButton();
5455

5556
jCheckBox1.setText("jCheckBox1");
5657

@@ -93,20 +94,29 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
9394
}
9495
});
9596

97+
jButton4.setText("Change Inst");
98+
jButton4.addActionListener(new java.awt.event.ActionListener() {
99+
public void actionPerformed(java.awt.event.ActionEvent evt) {
100+
jButton4ActionPerformed(evt);
101+
}
102+
});
103+
96104
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
97105
getContentPane().setLayout(layout);
98106
layout.setHorizontalGroup(
99107
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
100108
.addGroup(layout.createSequentialGroup()
101109
.addContainerGap()
102-
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
103-
.addComponent(jCheckBox3)
104-
.addComponent(jCheckBox2)
105-
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
106-
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
107-
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
108-
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
109-
.addGap(0, 8, Short.MAX_VALUE))
110+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
111+
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
112+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
113+
.addComponent(jCheckBox3)
114+
.addComponent(jCheckBox2)
115+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
116+
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
117+
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
118+
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
119+
.addGap(0, 10, Short.MAX_VALUE))
110120
);
111121
layout.setVerticalGroup(
112122
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -117,11 +127,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
117127
.addComponent(jButton2)
118128
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
119129
.addComponent(jButton3)
120-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
130+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
131+
.addComponent(jButton4)
132+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
121133
.addComponent(jCheckBox2)
122134
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
123135
.addComponent(jCheckBox3)
124-
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
136+
.addContainerGap())
125137
);
126138

127139
pack();
@@ -166,10 +178,19 @@ private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
166178
LINKEDPIXELDRAW = jCheckBox3.isSelected();
167179
}//GEN-LAST:event_jCheckBox3ActionPerformed
168180

181+
static int pos = 0;
182+
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
183+
// //Change Instrument DEPRECATED
184+
// chan.programChange(synth.getLoadedInstruments()[pos].getPatch().getProgram());
185+
// System.out.println("Instrument: "+synth.getLoadedInstruments()[pos].getName());
186+
// pos++;
187+
}//GEN-LAST:event_jButton4ActionPerformed
188+
169189
// Variables declaration - do not modify//GEN-BEGIN:variables
170190
private javax.swing.JButton jButton1;
171191
private javax.swing.JButton jButton2;
172192
private javax.swing.JButton jButton3;
193+
private javax.swing.JButton jButton4;
173194
private javax.swing.JCheckBox jCheckBox1;
174195
private javax.swing.JCheckBox jCheckBox2;
175196
private javax.swing.JCheckBox jCheckBox3;

src/ViewPrompt.form

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<Component id="jButton1" alignment="1" max="32767" attributes="0"/>
3232
<Component id="jButton3" alignment="1" max="32767" attributes="0"/>
3333
<Component id="jButton7" alignment="0" max="32767" attributes="0"/>
34+
<Component id="jButton9" alignment="0" max="32767" attributes="0"/>
3435
</Group>
3536
<EmptySpace max="32767" attributes="0"/>
3637
<Group type="103" groupAlignment="0" max="-2" attributes="0">
@@ -73,7 +74,9 @@
7374
<Component id="jButton7" alignment="3" min="-2" max="-2" attributes="0"/>
7475
<Component id="jButton8" alignment="3" min="-2" max="-2" attributes="0"/>
7576
</Group>
76-
<EmptySpace pref="16" max="32767" attributes="0"/>
77+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
78+
<Component id="jButton9" min="-2" max="-2" attributes="0"/>
79+
<EmptySpace pref="39" max="32767" attributes="0"/>
7780
</Group>
7881
</Group>
7982
</DimensionLayout>
@@ -154,5 +157,13 @@
154157
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton8ActionPerformed"/>
155158
</Events>
156159
</Component>
160+
<Component class="javax.swing.JButton" name="jButton9">
161+
<Properties>
162+
<Property name="text" type="java.lang.String" value="TriMesh"/>
163+
</Properties>
164+
<Events>
165+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton9ActionPerformed"/>
166+
</Events>
167+
</Component>
157168
</SubComponents>
158169
</Form>

0 commit comments

Comments
 (0)