initial reboot commit

main
mwinter 3 years ago
commit 1a3453d1b7

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=""/>
<classpathentry kind="lib" path="libs/jsyn_16_7_3.jar"/>
<classpathentry kind="output" path=""/>
</classpath>

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Rise_I</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

Binary file not shown.

Binary file not shown.

BIN
main/.DS_Store vendored

Binary file not shown.

75
main/.gitignore vendored

@ -0,0 +1,75 @@
/BoundingBox.class
/Cue.class
/CuePanel.class
/Glissandi.class
/GrainStream.class
/Note.class
/NoteFrame$1.class
/NoteFrame.class
/OpenClassIterator.class
/PitchVector.class
/PrintUtilities.class
/Rise.class
/SaveClassIterator.class
/Score.class
/ScrollBar.class
/ToolFrame$1.class
/ToolFrame$10.class
/ToolFrame$11.class
/ToolFrame$12.class
/ToolFrame$13.class
/ToolFrame$14.class
/ToolFrame$15.class
/ToolFrame$16.class
/ToolFrame$17.class
/ToolFrame$18.class
/ToolFrame$19.class
/ToolFrame$2.class
/ToolFrame$20.class
/ToolFrame$21.class
/ToolFrame$22.class
/ToolFrame$23.class
/ToolFrame$24.class
/ToolFrame$25.class
/ToolFrame$26.class
/ToolFrame$27.class
/ToolFrame$28.class
/ToolFrame$29.class
/ToolFrame$3.class
/ToolFrame$30.class
/ToolFrame$31.class
/ToolFrame$32.class
/ToolFrame$33.class
/ToolFrame$34.class
/ToolFrame$35.class
/ToolFrame$36.class
/ToolFrame$37.class
/ToolFrame$38.class
/ToolFrame$39.class
/ToolFrame$4.class
/ToolFrame$40.class
/ToolFrame$41.class
/ToolFrame$42.class
/ToolFrame$43.class
/ToolFrame$44.class
/ToolFrame$45.class
/ToolFrame$46.class
/ToolFrame$47.class
/ToolFrame$48.class
/ToolFrame$49.class
/ToolFrame$5.class
/ToolFrame$50.class
/ToolFrame$51.class
/ToolFrame$52.class
/ToolFrame$53.class
/ToolFrame$54.class
/ToolFrame$55.class
/ToolFrame$56.class
/ToolFrame$57.class
/ToolFrame$58.class
/ToolFrame$6.class
/ToolFrame$7.class
/ToolFrame$8.class
/ToolFrame$9.class
/ToolFrame.class
/WaveForm.class

@ -0,0 +1,49 @@
package main;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import javax.swing.JPanel;
public class BoundingBox extends JPanel {
double x1;
double x2;
double y1;
double y2;
public BoundingBox() {
this.setOpaque(false);
this.setBounds((int) 0, (int) 0,(int) (Rise.PAGE_WIDTH*Rise.ZOOM), (int) (Rise.PAGE_HEIGHT*Rise.ZOOM));
this.setVisible(false);
}
public void setCoordinates(double x1, double x2, double y1, double y2) {
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
if (this.x1<0){
this.x1=0;
}
if (this.x2>this.getWidth()){
this.x2=this.getWidth()-1;
}
if (this.y1<0){
this.y1=0;
}
if (this.y2>this.getHeight()){
this.y2=this.getHeight()-1;
}
}
public void paint(Graphics g){
//super.paint(g);
g.setColor(Color.BLUE);
Graphics2D g2 = (Graphics2D) g;
g2.draw(new Rectangle2D.Double(x1, y1, x2-x1, y2-y1));
}
}

@ -0,0 +1,82 @@
package main;
import java.awt.Color;
import javax.swing.JPanel;
import com.softsynth.jsyn.Synth;
public class Cue extends Thread {
JPanel cuePanel;
int startTick;
int cuesPast;
int clicksPast;
int[] cuesPoints;
public Cue(JPanel cP){
super();
cuePanel = cP;
//add(new LineOut());
}
public void init(int[] cP){
//startTick = sT;
cuesPoints = cP;
cuesPast = 0;
clicksPast = 0;
}
public synchronized void run() {
try {
//System.out.println("waiting");
this.wait(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
//boolean isOn = true;
int startTime = cuesPoints[0];
int duration = (int) (Synth.getTickRate() / 10);
//int duration = (int) (Synth.getTickRate() / 50);
int advanceTime = (int) (Synth.getTickRate() * .5); // half second advance
Synth.sleepUntilTick(startTime - advanceTime);// /*(int) (Math.random() * 2 * Synth.getTickRate())*/); // Wake up early!
int nextTime = startTime;
int nextCueTime = startTime;
while(true)
{
if (Rise.IS_ENGINE_ON == true) {
if (Synth.getTickCount() > nextCueTime) {
if (cuesPast % 2 == 0) {
cuePanel.setBackground(Color.BLACK);
}
else{
cuePanel.setBackground(Color.WHITE);
}
cuesPast++;
nextCueTime = cuesPoints[cuesPast];
//System.out.println("test " + clicksPast + " " + nextCueTime + " " + Synth.getTickCount());
}
nextTime += duration;
Synth.sleepUntilTick(nextTime);
}
else {
try {
//System.out.println("waiting");
this.wait(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}

@ -0,0 +1,40 @@
package main;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import javax.swing.JPanel;
public class CuePanel extends JPanel{
public double envPos;
public Color color;
// public void setEnv(double eV){
// envPos
// }
public void paint(Graphics g){
super.paint(g);
Graphics2D g2 = (Graphics2D) g;
FontRenderContext frc = g2.getFontRenderContext();
Font fontTime = new Font("Times", Font.PLAIN, 40);
int totalSecs = (int) (envPos * Rise.TOTAL_DUR);
int minutes = totalSecs/60;
int seconds = totalSecs%60;
String secondString = seconds + "";
if (seconds < 10){
secondString = "0" + secondString;
}
String timeForString = minutes + ":" + secondString;
TextLayout time = new TextLayout(timeForString, fontTime, frc);
g2.setFont(fontTime);
g2.setColor(color);
time.draw(g2,5,50);
}
}

@ -0,0 +1,373 @@
package main;
import java.awt.Color;
import com.softsynth.jsyn.AddUnit;
import com.softsynth.jsyn.DivideUnit;
import com.softsynth.jsyn.EnvelopePlayer;
import com.softsynth.jsyn.EqualTemperedTuning;
import com.softsynth.jsyn.ExponentialLag;
import com.softsynth.jsyn.LineOut;
import com.softsynth.jsyn.MultiplyUnit;
import com.softsynth.jsyn.SynthEnvelope;
import com.softsynth.jsyn.Synth;
import com.softsynth.jsyn.SynthMixer;
public class Glissandi extends Thread{
WaveForm[] gliss;
AddUnit[] num;
DivideUnit[] ratio;
MultiplyUnit[] freq;
SynthEnvelope env;
MultiplyUnit denMult;
AddUnit den;
EnvelopePlayer envPlayer;
boolean isOn = false;
double fund;
GrainStream grainStream[];
LineOut lineOut;
SynthMixer glissMixer;
SynthMixer grainMixer;
ExponentialLag grainFader;
MultiplyUnit grainMult;
ExponentialLag glissFader;
MultiplyUnit glissMult;
//MultiplyUnit glissMultForCurve;
int currentTick;
public Glissandi(){
}
public void init(GrainStream[] gS, int gMin, int cT, int nG){
currentTick = cT;
Rise.MASTER_MIXER = new SynthMixer(3,1);
glissMixer = new SynthMixer(Rise.VOICES,1);
grainMixer = new SynthMixer(nG,1);
Rise.CLICK_MIXER = new SynthMixer(10,1);
lineOut = new LineOut();
Rise.MASTER_MULT = new MultiplyUnit();
Rise.MASTER_FADER = new ExponentialLag();
grainMult = new MultiplyUnit();
grainFader = new ExponentialLag();
glissMult = new MultiplyUnit();
glissFader = new ExponentialLag();
Rise.CLICK_MULT = new MultiplyUnit();
Rise.CLICK_FADER = new ExponentialLag();
//System.out.println(Rise.FIRST_NUM + " " + Rise.VOICES);
gliss = new WaveForm[Rise.VOICES];
num = new AddUnit[Rise.VOICES];
ratio = new DivideUnit[Rise.VOICES];
freq = new MultiplyUnit[Rise.VOICES];
fund = EqualTemperedTuning.getMIDIFrequency(24+Rise.TRANSPOSE_SCORE+Rise.TRANSPOSE_SOUND);
//System.out.println(Rise.TOTAL_DUR);
//Make sure this is ok
envPlayer = new EnvelopePlayer();
double[] envData = new double[302];
double playDuration = Rise.TOTAL_DUR - Rise.START_TIME;
double startEnvPosition = Rise.START_TIME/Rise.TOTAL_DUR;
double envLength = 1 - startEnvPosition;
envData[0] = 0;
envData[1] = startEnvPosition;
for (int i = 1; i < envData.length/2; i++){
envData[i * 2] = playDuration/((envData.length-2)/2);
envData[i * 2 + 1] = startEnvPosition + (envLength/ ((envData.length-2)/2)) * (i);
}
//System.out.println(envData[1] + " " + envData[envData.length-1]);
env = new SynthEnvelope(envData);
denMult = new MultiplyUnit();
denMult.inputA.connect(envPlayer.output);
denMult.inputB.set(-1 * (Rise.VOICES - 1));
den = new AddUnit();
den.inputA.set(Rise.FIRST_NUM);
den.inputB.connect(denMult.output);
int advanceTime = (int) (currentTick + 4 * Synth.getTickRate());
//int[] cuePoints = new int[Rise.VOICES * 14];
for (int i = 0; i < Rise.VOICES; i++){
//System.out.println(i);
gliss[i] = new WaveForm();
num[i] = new AddUnit();
ratio[i] = new DivideUnit();
freq[i] = new MultiplyUnit();
double spectrum = (Rise.MAX_SPECTRUM - Rise.MIN_SPECTRUM)/2. + Rise.MIN_SPECTRUM;
gliss[i].spectrum.set(spectrum);
num[i].inputA.set(i);
num[i].inputB.connect(den.output);
ratio[i].inputA.connect(num[i].output);
ratio[i].inputB.connect(den.output);
freq[i].inputA.connect(ratio[i].output);
freq[i].inputB.set(fund);
freq[i].output.connect(gliss[i].frequency);
//gliss[i].envRate.set(1); // figure out this number
int startTick = (int) (advanceTime + (((Rise.TOTAL_DUR/(Rise.VOICES-1.) * i) - Rise.START_TIME) * Synth.getTickRate()));
double startPitch = fund * Rise.FIRST_NUM/(Rise.FIRST_NUM-i);
//System.out.println("test " + startTick + " " + Synth.getTickCount());
//System.out.println("show " + ((Rise.TOTAL_DUR/(Rise.VOICES-1.) * i) - Rise.START_TIME));
//double st = (Rise.TOTAL_DUR/(Rise.VOICES-1.) * i);
double startAmp = (((1/(Rise.VOICES-1.)) * i) * (Rise.GLISS_AMP_END - Rise.GLISS_AMP_START)) + Rise.GLISS_AMP_START;
envData = new double[6];
envData[0] = 1;
envData[1] = startAmp;
envData[2] = Rise.TOTAL_DUR - ((1/(Rise.VOICES-1.)) * i) - 1;
envData[3] = Rise.GLISS_AMP_END;
envData[4] = Rise.FADE_DUR + Math.random()*5;
envData[5] = 0;
if (Rise.START_TIME > (Rise.TOTAL_DUR/(Rise.VOICES-1.) * i)){
startAmp = (Rise.START_TIME/Rise.TOTAL_DUR) * (Rise.GLISS_AMP_END - Rise.GLISS_AMP_START) + Rise.GLISS_AMP_START;
envData[0] = 1;
envData[1] = startAmp;
envData[2] = Rise.TOTAL_DUR - Rise.START_TIME - 1;
envData[3] = Rise.GLISS_AMP_END;
envData[4] = Rise.FADE_DUR + Math.random()*5;
envData[5] = 0;
}
if (i == Rise.VOICES-1){
envData = new double[4];
envData[0] = 1;
envData[1] = Rise.GLISS_AMP_END;
envData[2] = Rise.FADE_DUR + Math.random()*5;
envData[3] = 0;
}
// for (int j = 0; j < envData.length; j++) {
// System.out.println(i + " " + envData[j]);
// }
gliss[i].glissOn(startTick, startPitch, 1 /*(1./Rise.VOICES)*/, envData );
// envData = new double[4];
//
// envData[0] = 0;
// envData[1] = startAmp;
// envData[2] = Rise.TOTAL_DUR - ((1/(Rise.VOICES-1.)) * i) - 1;
// envData[3] = 1;
//
// gliss[i].glissSustain((int) (startTick + Synth.getTickRate()), envData);
// for (int j = 0; j < 14; j++){
// cuePoints[14 * i + j] = (int) (startTick - 3 * Synth.getTickRate() + Synth.getTickRate()/2. * j);
// }
//System.out.println("test " + startTick + " " + endTick + " " + Synth.getTickCount() + " " + ((1./ (Rise.VOICES-1)) * i));
//make this have jitter??
//gliss[i].glissOff(endTick, (.5 / (Rise.FADE_DUR + Math.random()*5)));
num[i].start(startTick);
ratio[i].start(startTick);
freq[i].start(startTick);
glissMixer.connectInput(i, gliss[i].output, 0);
glissMixer.setGain(i, 0, (1./Rise.VOICES));
}
//c.init(cuePoints);
denMult.start(advanceTime);
den.start(advanceTime);
//System.out.println(envPlayer.getSynthContext().getTickCount());
envPlayer.start(advanceTime);
envPlayer.envelopePort.clear(advanceTime);
envPlayer.envelopePort.queue(advanceTime,env,0,env.getNumFrames());
grainStream = gS;
for (int i = 0; i < nG; i++){
grainMixer.connectInput(i, grainStream[i].grain.output, 0);
grainMixer.setGain(i, 0, 1);
int grainStartTick = (int) (advanceTime + Rise.START_TIME * Synth.getTickRate());
if (i > gMin){
grainStartTick = (int) (advanceTime + (((Rise.TOTAL_DUR/(nG - gMin) * (i - gMin)) - Rise.START_TIME) * Synth.getTickRate()));
}
//System.out.println("tick " + grainStartTick);
grainStream[i].setStartTick(grainStartTick + (int) (Synth.getTickRate() * Math.random() * 5));
int endTick = (int) (advanceTime + ((Rise.TOTAL_DUR - Rise.START_TIME) * Synth.getTickRate()));
grainStream[i].setEndTick(endTick);
}
grainMult.inputA.connect(grainFader.output);
grainMult.inputB.connect(grainMixer.getOutput(0));
glissMult.inputA.connect(glissFader.output);
glissMult.inputB.connect(glissMixer.getOutput(0));
for (int count = 0; count < 10; count++){
Rise.CLICK_MIXER.setGain(count, 0, 1);
}
Rise.CLICK_MULT.inputA.connect(Rise.CLICK_FADER.output);
Rise.CLICK_MULT.inputB.connect(Rise.CLICK_MIXER.getOutput(0));
Rise.MASTER_MIXER.connectInput(0, glissMult.output, 0);
Rise.MASTER_MIXER.setGain(0, 0, 1);
Rise.MASTER_MIXER.connectInput(1, grainMult.output, 0);
Rise.MASTER_MIXER.setGain(1, 0, 1);
Rise.MASTER_MIXER.connectInput(2, Rise.CLICK_MULT.output, 0);
Rise.MASTER_MIXER.setGain(2, 0, 1);
Rise.MASTER_MULT.inputA.connect(Rise.MASTER_FADER.output);
Rise.MASTER_MULT.inputB.connect(Rise.MASTER_MIXER.getOutput(0));
lineOut.input.connect(0, Rise.MASTER_MULT.output, 0);
lineOut.input.connect(1, Rise.MASTER_MULT.output, 0);
lineOut.start(advanceTime);
glissMixer.start(advanceTime);
grainMixer.start(advanceTime);
Rise.MASTER_MIXER.start(advanceTime);
Rise.MASTER_MULT.start(advanceTime);
Rise.MASTER_FADER.start(advanceTime);
Rise.CLICK_MIXER.start(advanceTime);
Rise.CLICK_MULT.start(advanceTime);
Rise.CLICK_FADER.start(advanceTime);
grainMult.start(advanceTime);
grainFader.start(advanceTime);
glissMult.start(advanceTime);
glissFader.start(advanceTime);
for (int i = 0; i < nG; i++){
grainStream[i].setTimer(envPlayer);
}
isOn = true;
}
public void setGlissFader(double a){
if (Rise.IS_ENGINE_ON == true) {
glissFader.input.set(a);
}
}
public void setGrainFader(double a){
if (Rise.IS_ENGINE_ON == true) {
grainFader.input.set(a);
}
}
public synchronized void run() {
try {
//System.out.println("waiting");
this.wait(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
Synth.sleepUntilTick( (int) (currentTick + 1 * Synth.getTickRate()) );
Rise.CUE_PANEL.color = Color.YELLOW;
Rise.CUE_PANEL.repaint();
Synth.sleepUntilTick( (int) (currentTick + 2 * Synth.getTickRate()) );
Rise.CUE_PANEL.color = Color.GREEN;
Rise.CUE_PANEL.repaint();
Synth.sleepUntilTick( (int) (currentTick + 3 * Synth.getTickRate()) );
Rise.CUE_PANEL.color = Color.BLACK;
Rise.CUE_PANEL.repaint();
int startTime = (int) (currentTick + 3 * Synth.getTickRate()); ///*Synth.getTickCount()*/ currentTick + (int) Synth.getTickRate();
int duration = (int) (Synth.getTickRate() / 5); // Resolution should be pixles in view
int advanceTime = (int) (Synth.getTickRate() * 0.05); // half second advance
Synth.sleepUntilTick( startTime - advanceTime ); // Wake up early!
int nextTime = startTime;
while(true)
{
if (Rise.IS_ENGINE_ON == true) {
//System.out.println(envPlayer.output.get());
Rise.CUE_PANEL.envPos = envPlayer.output.get();
Rise.CUE_PANEL.repaint();
Rise.SCROLLBAR.xPos = envPlayer.output.get() * Rise.SCROLLBAR_WIDTH;
if (envPlayer.output.get() == 0){
Rise.SCROLLBAR.xPos = (Rise.START_TIME/Rise.TOTAL_DUR) * Rise.SCROLLBAR_WIDTH;
}
Rise.SCROLLBAR.repaint();
nextTime += duration; // Advance nextTime by fixed amount.
Synth.sleepUntilTick( nextTime - advanceTime ); // Wake up early!
}
else {
try {
//System.out.println("waiting");
this.wait(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public void kill() {
isOn = false;
for (int i = 0; i < Rise.VOICES; i++){
gliss[i].glissOff(0, 1);
num[i].stop();
ratio[i].stop();
freq[i].stop();
}
denMult.stop();
den.stop();
envPlayer.stop();
glissMixer.stop(0);
grainMixer.stop(0);
Rise.MASTER_FADER.stop(0);
Rise.MASTER_MULT.stop(0);
Rise.MASTER_MIXER.stop(0);
Rise.CLICK_FADER.stop(0);
Rise.CLICK_MULT.stop(0);
Rise.CLICK_MIXER.stop(0);
grainMult.stop(0);
grainFader.stop(0);
glissMult.stop(0);
glissFader.stop(0);
lineOut.stop(0);
}
}

@ -0,0 +1,194 @@
package main;
import com.softsynth.jsyn.EnvelopePlayer;
import com.softsynth.jsyn.Synth;
public class GrainStream extends Thread {
WaveForm grain = new WaveForm();
// double ampValStart;
// double ampValEnd;
// double ampJitStart;
// double ampJitEnd;
//
// double soundDurValStart;
// double soundDurValEnd;
// double soundDurJitStart;
// double soundDurJitEnd;
//
// double silenceDurValStart;
// double silenceDurValEnd;
// double silenceDurJitStart;
// double silenceDurJitEnd;
int startTick;
int endTick;
EnvelopePlayer envPlayer;
PitchVector pitchVector;
int instance;
int noGrains;
public GrainStream(){
}
public void init(double aVS, double aVE, double aJS, double aJE,
double soDVS, double soDVE, double soDJS, double soDJE,
double siDVS, double siDVE, double siDJS, double siDJE,
PitchVector pV, int nG, int i){
//System.out.println("WOOHOO!!!");
// ampValStart = aVS;
// ampValEnd = aVE;
// ampJitStart = aJS;
// ampJitEnd = aJE;
//
// soundDurValStart = soDVS;
// soundDurValEnd = soDVE;
// soundDurJitStart = soDJS;
// soundDurJitEnd = soDJE;
//
// //System.out.println(soundDurValStart);
//
// silenceDurValStart = siDVS;
// silenceDurValEnd = siDVE;
// silenceDurJitStart = siDJS;
// silenceDurJitEnd = siDJE;
pitchVector = pV;
noGrains = nG;
instance = i;
}
public void setStartTick(int sT){
startTick = sT;
}
public void setEndTick(int eT){
endTick = eT;
}
public void setTimer(EnvelopePlayer eP){
envPlayer = eP;
}
public synchronized void run() {
try {
//System.out.println("waiting");
this.wait(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
//boolean isOn = true;
int startTime = startTick;
int endTime = endTick;
int advanceTime = (int) (Synth.getTickRate() * 0.5); // half second advance
Synth.sleepUntilTick( startTime - advanceTime /*(int) (Math.random() * 2 * Synth.getTickRate())*/); // Wake up early!
int upDuration = (int) (Synth.getTickRate() / 10);
int nextTime = startTime;
int nextGrainTime = startTime;
while(true)
{
if (Rise.IS_ENGINE_ON == true) {
//System.out.println("IM ON!!!");
//double freq = Math.random() * 300 + 300;
if (Synth.getTickCount() > nextGrainTime - advanceTime) {
double envPosition = envPlayer.output.get();
int aPos = (int) (envPosition * (int) (Rise.TOTAL_DUR * 10));
int rand = (int) (Math.random() * pitchVector.array[aPos].size());
double randFadeJitter = (Math.random() * 5);
//System.out.println(aPos + " " + pitchVector.array[aPos].size());
double freq = (Double) pitchVector.array[aPos].get(rand);
// double duration =
// (soundDurValStart - envPosition * Math.abs(soundDurValStart - soundDurValEnd)) +
// ((soundDurJitStart - envPosition * Math.abs(soundDurJitStart - soundDurJitEnd)) *
// (Math.random() * 2 - 1));
// grain.envRate.set(1./duration);
//
// double pause =
// (silenceDurValStart - envPosition * Math.abs(silenceDurValStart - silenceDurValEnd)) +
// ((silenceDurJitStart - envPosition * Math.abs(silenceDurJitStart - silenceDurJitEnd)) *
// (Math.random() * 2 - 1));
//
// double amp =
// ((ampValStart + envPosition * Math.abs(ampValEnd - ampValStart)) +
// ((ampJitStart + envPosition * Math.abs(ampJitEnd - ampJitStart)) *
// (Math.random() * 2 - 1)));
double duration =
(Rise.GRAIN_SOUND_DUR_VAL_START - envPosition * Math.abs(Rise.GRAIN_SOUND_DUR_VAL_START - Rise.GRAIN_SOUND_DUR_VAL_END)) +
((Rise.GRAIN_SOUND_DUR_JIT_START - envPosition * Math.abs(Rise.GRAIN_SOUND_DUR_JIT_START - Rise.GRAIN_SOUND_DUR_JIT_END)) *
(Math.random() * 2 - 1));
grain.envRate.set(1./duration);
double pause =
(Rise.GRAIN_SILENCE_DUR_VAL_START - envPosition * Math.abs(Rise.GRAIN_SILENCE_DUR_VAL_START - Rise.GRAIN_SILENCE_DUR_VAL_END)) +
((Rise.GRAIN_SILENCE_DUR_JIT_START - envPosition * Math.abs(Rise.GRAIN_SILENCE_DUR_JIT_START - Rise.GRAIN_SILENCE_DUR_JIT_END)) *
(Math.random() * 2 - 1));
double amp =
((Rise.GRAIN_AMP_VAL_START + envPosition * Math.abs(Rise.GRAIN_AMP_VAL_END - Rise.GRAIN_AMP_VAL_START)) +
((Rise.GRAIN_AMP_JIT_START + envPosition * Math.abs(Rise.GRAIN_AMP_JIT_END - Rise.GRAIN_AMP_JIT_START)) *
(Math.random() * 2 - 1)));
if (Synth.getTickCount() > endTime) {
amp = amp * Math.abs((Synth.getTickCount() - endTime)/((Rise.FADE_DUR+randFadeJitter)*Synth.getTickRate())-1);
if (Synth.getTickCount() > endTime + (Rise.FADE_DUR+randFadeJitter)*Synth.getTickRate()){
amp = 0;
}
}
//System.out.println((Synth.getTickCount() - endTime) + " " + amp + " " + (Synth.getTickCount() - endTime)/(Rise.FADE_DUR*Synth.getTickRate()));
double spectrum =
Rise.MIN_SPECTRUM + Math.random() * Math.abs(Rise.MAX_SPECTRUM - Rise.MIN_SPECTRUM);
grain.spectrum.set(spectrum);
grain.grainOn(0, freq, amp);
//System.out.println("instance = " + instance);
//System.out.println(duration + " " + pause + " " + amp);
int durationInTicks = (int) (Synth.getTickRate() * duration);
int pauseInTicks = (int) (Synth.getTickRate() * pause);
nextGrainTime += (durationInTicks + pauseInTicks);
}
nextTime += (upDuration); // Advance nextTime by fixed amount.
Synth.sleepUntilTick( nextTime - advanceTime ); // Wake up early!
}
else {
try {
//System.out.println("waiting");
this.wait(0);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}

@ -0,0 +1,405 @@
package main;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import javax.swing.JPanel;
import java.awt.geom.Rectangle2D;
public class Note extends JPanel{
int noTimesClicked = 0;
double x;
double y;
int n;
int d;
int v;
int p;
double pitch;
int clefChoice;
int octavaAndBassoChoice;
int spellingChoice;
int ratioChoice;
int noteHeadChoice = 0;
String[] clefs = {"\uf03f", "\uf042", "\uf042", "\uf026"};
String[] octavasAndBassos = {"15", "8", " ", "8", "15"};
String[] acc = {"\uf062","\uf06e", "\uf023"};
float clickAndPlayX1;
float clickAndPlayX2;
Color color = Color.BLACK;
boolean isListening = false;
public Note(double x, double y, double p, int v, int pP){
this.x = x;
this.y = y;
n = (int) (Rise.FIRST_NUM+v-pP);
d = (int) (Rise.FIRST_NUM-pP);
this.pitch = p + Rise.TRANSPOSE_SCORE * 100.;
this.v = v;
this.p = pP;
this.setOpaque(false);
this.setBackground(Color.WHITE);
this.setBounds((int) 0, (int) 0,(int) (Rise.PAGE_WIDTH*Rise.ZOOM), (int) (Rise.PAGE_HEIGHT*Rise.ZOOM));
initializeChoices();
}
public void paint(Graphics g){
g.setColor(color);
Graphics2D g2 = (Graphics2D) g;
this.setBounds((int) 0, (int) 0,(int) (Rise.PAGE_WIDTH*Rise.ZOOM), (int) (Rise.PAGE_HEIGHT*Rise.ZOOM));
g2.translate(Rise.PAGE_MARGIN*Rise.ZOOM, Rise.PAGE_MARGIN*Rise.ZOOM);
g2.scale(Rise.ZOOM, Rise.ZOOM);
FontRenderContext frc = g2.getFontRenderContext();
Font fontMusic = new Font("Maestro", Font.PLAIN, (int) Rise.FONT);
fontMusic.deriveFont(Rise.FONT);
Font fontNumbers = new Font("Liberation Serif", Font.PLAIN, (int) Math.round(Rise.FONT/1.714));
Font fontOBSigns = new Font("Liberation Serif", Font.PLAIN, (int) Math.round(Rise.FONT/2.4));
TextLayout note = new TextLayout("\uf0cf", fontMusic, frc);
TextLayout staff = new TextLayout("\uf03d\uf03d", fontMusic, frc);
TextLayout ledgerLine = new TextLayout("\uf02d", fontMusic, frc);
g2.setFont(fontMusic);
FontMetrics fontMetrics = g2.getFontMetrics();
double noteWidth = fontMetrics.stringWidth("\uf0cf");
double staffWidth = fontMetrics.stringWidth("\uf03d");
double ledgerWidth = fontMetrics.stringWidth("\uf02d");
double staffSpace = Rise.FONT/8.;
float noteX = (float) (x*Rise.IMAGE_WIDTH - noteWidth/2. /*- ((1./(Rise.VOICES-1))*(p-v)/p)*Rise.IMAGE_WIDTH*Rise.X_DIV*/);
float noteY = (float) y*Rise.IMAGE_HEIGHT;
float toneX1 = (float) (x*Rise.IMAGE_WIDTH - ((1./(Rise.VOICES-1))*(p-v)/p)*Rise.IMAGE_WIDTH*Rise.X_DIV);
float toneX2;
if (p != Rise.VOICES-1) {
toneX2 = (float) (x*Rise.IMAGE_WIDTH + ((1./(Rise.VOICES-1))*v/(p+1))*Rise.IMAGE_WIDTH*Rise.X_DIV);
}
else {
toneX2 = (float) (x*Rise.IMAGE_WIDTH + ((1./(Rise.VOICES-1))*.25)*Rise.IMAGE_WIDTH*Rise.X_DIV);
}
float toneY1 = (float) (noteY - note.getBounds().getMaxY()/3);
float toneY2 = (float) (noteY - note.getBounds().getMinY()/3);
//System.out.println("notes " + ((1./(Rise.VOICES-1))*(p-v)/p) + " " + ((1./(Rise.VOICES-1))*v/(p+1)));
g2.setColor(new Color(200, 200, 200));
g2.fill(new Rectangle2D.Float(toneX1, toneY1, toneX2-toneX1, toneY2-toneY1));
g2.setColor(color);
clickAndPlayX1 = toneX1;
clickAndPlayX2 = toneX2;
note.draw(g2,noteX,noteY);
double accWidth = fontMetrics.stringWidth(acc[getAcc((int) (Math.round(pitch/100.)%12))]);
TextLayout accidental = new TextLayout(acc[getAcc((int) (Math.round(pitch/100.)%12))], fontMusic, frc);
accidental.draw(g2,(float) (noteX-accWidth-2),(float) y*Rise.IMAGE_HEIGHT);
int notePosition = getNotePosition((int) (Math.round(pitch/100.)%12));
int centDeviation = (int) Math.round((pitch/100. - Math.round(pitch/100.))*100.);
TextLayout centDeviationText;
if (centDeviation >= 0) {
centDeviationText = new TextLayout("+" + String.valueOf(centDeviation), fontNumbers, frc);
}
else {
centDeviationText = new TextLayout(String.valueOf(centDeviation), fontNumbers, frc);
}
for (int i = d; i > 0; i--) {
if (Math.round((float) d/i) == (float) d/i
&& Math.round((float) n/i) == (float) n/i) {
n = n/i;
d = d/i;
}
}
TextLayout ratioText = new TextLayout(String.valueOf(n) + "/" + String.valueOf(d), fontNumbers, frc);
int stepsToLowestC = 0;
int addOctaves = 0;
int stepsToClef = 0;
if (clefChoice == 0){
stepsToLowestC = -11;
stepsToClef = 6;
}
else if (clefChoice == 1){
stepsToLowestC = -15;
stepsToClef = 6;
}
else if (clefChoice == 2){
stepsToLowestC = -17;
stepsToClef = 4;
}
else if (clefChoice == 3){
stepsToLowestC = -23;
stepsToClef = 2;
}
if (octavaAndBassoChoice == 0){
stepsToLowestC = stepsToLowestC+14;
}
else if (octavaAndBassoChoice == 1){
stepsToLowestC = stepsToLowestC+7;
}
else if (octavaAndBassoChoice == 2){
}
else if (octavaAndBassoChoice == 3){
stepsToLowestC = stepsToLowestC-7;
}
else if (octavaAndBassoChoice == 4){
stepsToLowestC = stepsToLowestC-14;
}
addOctaves = (int) (Math.round(pitch/100.)/12)*7;
float staffX = (float) (x*Rise.IMAGE_WIDTH - 1.5*staffWidth /*- ((1./(Rise.VOICES-1))*(p-v)/p)*Rise.IMAGE_WIDTH*Rise.X_DIV*noteHeadChoice*/);
float staffY = (float) (y*Rise.IMAGE_HEIGHT+(stepsToLowestC+notePosition+addOctaves)*staffSpace);
staff.draw(g2, staffX, staffY);
float clefX = (float) (x*Rise.IMAGE_WIDTH - 1.5*staffWidth /*- ((1./(Rise.VOICES-1))*(p-v)/p)*Rise.IMAGE_WIDTH*Rise.X_DIV*noteHeadChoice*/);
float clefY = (float) (y*Rise.IMAGE_HEIGHT+((stepsToLowestC-stepsToClef)+notePosition+addOctaves)*staffSpace);
TextLayout clef = new TextLayout(clefs[clefChoice], fontMusic, frc);
clef.draw(g2, clefX, clefY);
TextLayout octavaAndBasso = new TextLayout(octavasAndBassos[octavaAndBassoChoice], fontOBSigns, frc);
if (octavaAndBassoChoice < 2){
octavaAndBasso.draw(g2,(float) (clefX+clef.getVisibleAdvance()/2.-octavaAndBasso.getAdvance()/2),(float) (clefY+clef.getBounds().getMaxY()-octavaAndBasso.getBounds().getMinY()));
}
else if (octavaAndBassoChoice < 3){
}
else if(octavaAndBassoChoice < 5){
if (clefChoice == 3 && octavaAndBassoChoice == 3) {
octavaAndBasso.draw(g2,(float) (clefX+clef.getVisibleAdvance()/2.-octavaAndBasso.getAdvance()/16.),(float) (clefY+clef.getBounds().getMinY()));
}
else if (clefChoice == 3 && octavaAndBassoChoice == 4) {
octavaAndBasso.draw(g2,(float) (clefX+clef.getVisibleAdvance()/2.-octavaAndBasso.getAdvance()/4.),(float) (clefY+clef.getBounds().getMinY()));
}
else {
octavaAndBasso.draw(g2,(float) (clefX+clef.getVisibleAdvance()/2.-octavaAndBasso.getAdvance()/2),(float) (clefY+clef.getBounds().getMinY()));
}
}
if (noteY-staffY >= staffSpace*2){
float ledgerLineX = (float) (x*Rise.IMAGE_WIDTH - ledgerWidth/2.);
float ledgerLineY = (float) (staffY+staffSpace*2);
while (ledgerLineY <= noteY){
ledgerLine.draw(g2, ledgerLineX, ledgerLineY);
ledgerLineY = (float) (ledgerLineY+staffSpace*2);
}
}
if (staffY-noteY >= staffSpace*10){
float ledgerLineX = (float) (x*Rise.IMAGE_WIDTH - ledgerWidth/2.);
float ledgerLineY = (float) (staffY-staffSpace*10);
while (ledgerLineY >= noteY){
ledgerLine.draw(g2, ledgerLineX, ledgerLineY);
ledgerLineY = (float) (ledgerLineY-staffSpace*2);
}
}
if (noteY >= staffY-staffSpace*6){
centDeviationText.draw(g2, (float) (noteX-centDeviationText.getAdvance()/4.), (float) (staffY-staffSpace*9));
}
else {
centDeviationText.draw(g2, (float) (noteX-centDeviationText.getAdvance()/4.), (float) (noteY-staffSpace*3));
}
if (ratioChoice == 0) {
if (noteY <= staffY-staffSpace*2){
ratioText.draw(g2, (float) (noteX-ratioText.getAdvance()/4.), (float) (staffY+staffSpace*1+ratioText.getAscent()));
}
else {
ratioText.draw(g2, (float) (noteX-ratioText.getAdvance()/4.), (float) (noteY+staffSpace*3+ratioText.getAscent()));
}
}
}
public int getNotePosition(int mN) {
int notePosition = 0;
if (spellingChoice == 0) {
int modNote = mN;
switch(modNote) {
case 0 : notePosition = 0; break;
case 1 : notePosition = 0; break;
case 2 : notePosition = 1; break;
case 3 : notePosition = 1; break;
case 4 : notePosition = 2; break;
case 5 : notePosition = 3; break;
case 6 : notePosition = 3; break;
case 7 : notePosition = 4; break;
case 8 : notePosition = 4; break;
case 9 : notePosition = 5; break;
case 10 : notePosition = 5; break;
case 11: notePosition = 6; break;
case 12: notePosition = 7; break;
}
}
else if (spellingChoice == 1){
int modNote = mN;
switch(modNote) {
case 0 : notePosition = 0; break;
case 1 : notePosition = 1; break;
case 2 : notePosition = 1; break;
case 3 : notePosition = 2; break;
case 4 : notePosition = 2; break;
case 5 : notePosition = 3; break;
case 6 : notePosition = 4; break;
case 7 : notePosition = 4; break;
case 8 : notePosition = 5; break;
case 9 : notePosition = 5; break;
case 10 : notePosition = 6; break;
case 11: notePosition = 6; break;
case 12: notePosition = 7; break;
}
}
return notePosition;
}
public int getAcc(int mN) {
int accidental = 1;
if (spellingChoice == 0){
int modNote = mN;
switch(modNote) {
case 0 : accidental = 1; break;
case 1 : accidental = 2; break;
case 2 : accidental = 1; break;
case 3 : accidental = 2; break;
case 4 : accidental = 1; break;
case 5 : accidental = 1; break;
case 6 : accidental = 2; break;
case 7 : accidental = 1; break;
case 8 : accidental = 2; break;
case 9 : accidental = 1; break;
case 10 : accidental = 2; break;
case 11: accidental = 1; break;
case 12: accidental = 1; break;
}
}
if (spellingChoice == 1){
int modNote = mN;
switch(modNote) {
case 0 : accidental = 1; break;
case 1 : accidental = 0; break;
case 2 : accidental = 1; break;
case 3 : accidental = 0; break;
case 4 : accidental = 1; break;
case 5 : accidental = 1; break;
case 6 : accidental = 0; break;
case 7 : accidental = 1; break;
case 8 : accidental = 0; break;
case 9 : accidental = 1; break;
case 10 : accidental = 0; break;
case 11: accidental = 1; break;
case 12: accidental = 1; break;
}
}
return accidental;
}
public void initializeChoices(){
spellingChoice = 1;
ratioChoice = 0;
int stepsToLowestC = 0;
int addOctaves = 0;
double staffSpace = Rise.FONT/8.;
float noteY = (float) y*Rise.IMAGE_HEIGHT;
int notePosition = getNotePosition((int) (Math.round(pitch/100.)%12));
float min = 500000;
for (int c = 0; c < 4; c++){
int oBStart = 0;
int oBMax = 0;
if (c == 0) {
oBStart = 0;
oBMax = 3;
}
else if (c < 3) {
oBStart = 2;
oBMax = 3;
}
else if (c < 4) {
oBStart = 2;
oBMax = 5;
}
for (int oB = oBStart; oB < oBMax; oB++){
if (c == 0){
stepsToLowestC = -11;
}
else if (c == 1){
stepsToLowestC = -15;
}
else if (c == 2){
stepsToLowestC = -17;
}
else if (c == 3){
stepsToLowestC = -23;
}
if (oB == 0){
stepsToLowestC = stepsToLowestC+14;
}
else if (oB == 1){
stepsToLowestC = stepsToLowestC+7;
}
else if (oB == 2){
}
else if (oB == 3){
stepsToLowestC = stepsToLowestC-7;
}
else if (oB == 4){
stepsToLowestC = stepsToLowestC-14;
}
addOctaves = (int) (Math.round(pitch/100.)/12)*7;
float staffY = (float) (y*Rise.IMAGE_HEIGHT+(stepsToLowestC+notePosition+addOctaves)*staffSpace);
if (Math.abs((staffY-4*staffSpace)-noteY) < min){
clefChoice = c;
octavaAndBassoChoice = oB;
min = (float) Math.abs((staffY-4*staffSpace)-noteY);
}
}
}
}
public int testSelect(float x1, float y1, float x2, float y2){
if ((float) (Rise.PAGE_MARGIN*Rise.ZOOM+x*Rise.IMAGE_WIDTH*Rise.ZOOM) > x1
&& (float) (Rise.PAGE_MARGIN*Rise.ZOOM+x*Rise.IMAGE_WIDTH*Rise.ZOOM) < x2
&& (float) (Rise.PAGE_MARGIN*Rise.ZOOM+y*Rise.IMAGE_HEIGHT*Rise.ZOOM) > y1
&& (float) (Rise.PAGE_MARGIN*Rise.ZOOM+y*Rise.IMAGE_HEIGHT*Rise.ZOOM) < y2){
color = Color.BLUE;
isListening = true;
return 1;
}
else {
color = Color.BLACK;
isListening = false;
return 0;
}
}
public int testSelectClickAndPlay(float xMouse, float yMouse){
if ((Rise.PAGE_MARGIN*Rise.ZOOM + clickAndPlayX1*Rise.ZOOM) < xMouse
&& (Rise.PAGE_MARGIN*Rise.ZOOM + clickAndPlayX2*Rise.ZOOM) > xMouse
&& (float) (Rise.PAGE_MARGIN*Rise.ZOOM+(y)*Rise.IMAGE_HEIGHT*Rise.ZOOM + 10*Rise.ZOOM) > yMouse
&& (float) (Rise.PAGE_MARGIN*Rise.ZOOM+(y)*Rise.IMAGE_HEIGHT*Rise.ZOOM - 10*Rise.ZOOM) < yMouse){
color = Color.BLUE;
isListening = true;
//double toReturn = (xMouse - Rise.PAGE_MARGIN*Rise.ZOOM)/(Rise.IMAGE_WIDTH*Rise.ZOOM);
//System.out.println((xMouse) + " " + (clickAndPlayX1*Rise.ZOOM) + " " + (clickAndPlayX2*Rise.ZOOM) + " " + yMouse + " " + (Rise.PAGE_MARGIN*Rise.ZOOM+y*Rise.IMAGE_HEIGHT*Rise.ZOOM));
//System.out.println(toReturn);
return 1;
}
else {
color = Color.BLACK;
isListening = false;
return 0;
}
}
}

@ -0,0 +1,255 @@
package main;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class NoteFrame extends JFrame implements ActionListener{
JRadioButton bass = new JRadioButton("bass");
JRadioButton tenor = new JRadioButton("tenor");
JRadioButton alto = new JRadioButton("alto");
JRadioButton treble = new JRadioButton("treble");
JRadioButton clefNada = new JRadioButton("nada");
JRadioButton ma = new JRadioButton("15ma");
JRadioButton va = new JRadioButton("8va");
JRadioButton none = new JRadioButton("none");
JRadioButton vb = new JRadioButton("8vb");
JRadioButton mb = new JRadioButton("15mb");
JRadioButton oBNada = new JRadioButton("nada");
JRadioButton sharps = new JRadioButton("sharps");
JRadioButton flats = new JRadioButton("flats");
JRadioButton spellNada = new JRadioButton("nada");
JRadioButton show = new JRadioButton("show");
JRadioButton hide = new JRadioButton("hide");
JRadioButton ratiosNada = new JRadioButton("nada");
ArrayList notes;
ArrayList listeningNotes;
int clefChoice;
int octavaAndBassoChoice;
int ratioChoice;
int spellingChoice;
public NoteFrame(){
this.setTitle("Note Frame");
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we){
Rise.BOUNDING_BOX.setVisible(false);
for (int i = 0; i < notes.size(); i++) {
((Note) notes.get(i)).color = Color.BLACK;
}
}
});
Container noteContainer = this.getContentPane();
noteContainer.setLayout(new GridLayout(0,2));
bass.setActionCommand("bass");
bass.addActionListener(this);
tenor.setActionCommand("tenor");
tenor.addActionListener(this);
alto.setActionCommand("alto");
alto.addActionListener(this);
treble.setActionCommand("treble");
treble.addActionListener(this);
ma.setActionCommand("ma");
ma.addActionListener(this);
va.setActionCommand("va");
va.addActionListener(this);
none.setActionCommand("none");
none.addActionListener(this);
vb.setActionCommand("vb");
vb.addActionListener(this);
mb.setActionCommand("mb");
mb.addActionListener(this);
sharps.setActionCommand("sharps");
sharps.addActionListener(this);
flats.setActionCommand("flats");
flats.addActionListener(this);
show.setActionCommand("show");
show.addActionListener(this);
hide.setActionCommand("hide");
hide.addActionListener(this);
ButtonGroup clef = new ButtonGroup();
clef.add(bass);
clef.add(tenor);
clef.add(alto);
clef.add(treble);
clef.add(clefNada);
//clefNada.setVisible(false);
ButtonGroup oB = new ButtonGroup();
oB.add(ma);
oB.add(va);
oB.add(none);
oB.add(vb);
oB.add(mb);
oB.add(oBNada);
//oBNada.setVisible(false);
ButtonGroup spell = new ButtonGroup();
spell.add(sharps);
spell.add(flats);
spell.add(spellNada);
//spellNada.setVisible(false);
ButtonGroup ratios = new ButtonGroup();
ratios.add(show);
ratios.add(hide);
ratios.add(ratiosNada);
//ratiosNada.setVisible(false);
JPanel clefPanel = new JPanel();
clefPanel.setBorder(BorderFactory.createLineBorder(Color.black));
clefPanel.setLayout(new GridLayout(0,1));
clefPanel.add(new JLabel("Clef"));
clefPanel.add(bass);
clefPanel.add(tenor);
clefPanel.add(alto);
clefPanel.add(treble);
JPanel oBPanel = new JPanel();
oBPanel.setBorder(BorderFactory.createLineBorder(Color.black));
oBPanel.setLayout(new GridLayout(0,1));
oBPanel.add(new JLabel("Octava/Basso"));
oBPanel.add(ma);
oBPanel.add(va);
oBPanel.add(none);
oBPanel.add(vb);
oBPanel.add(mb);
JPanel spellPanel = new JPanel();
spellPanel.setBorder(BorderFactory.createLineBorder(Color.black));
spellPanel.setLayout(new GridLayout(0,1));
spellPanel.add(new JLabel("Spelling Pref."));
spellPanel.add(sharps);
spellPanel.add(flats);
JPanel ratiosPanel = new JPanel();
ratiosPanel.setBorder(BorderFactory.createLineBorder(Color.black));
ratiosPanel.setLayout(new GridLayout(0,1));
ratiosPanel.add(new JLabel("Ratios"));
ratiosPanel.add(show);
ratiosPanel.add(hide);
noteContainer.add(clefPanel);
noteContainer.add(oBPanel);
noteContainer.add(spellPanel);
noteContainer.add(ratiosPanel);
this.setSize(200,400);
this.setLocation(0, 0);
}
public void setNoteAccess(ArrayList n){
notes = n;
}
public void setListeningNotes(){
listeningNotes = new ArrayList();
for (int i = 0; i < notes.size(); i++) {
if (((Note) notes.get(i)).isListening == true){
//System.out.println(((Note) notes.get(i)).pitch);
listeningNotes.add(notes.get(i));
}
}
}
public void actionPerformed(ActionEvent e) {
if ("bass".equals(e.getActionCommand())){
clefChoice = 0;
}
else if ("tenor".equals(e.getActionCommand())){
clefChoice = 1;
}
else if ("alto".equals(e.getActionCommand())){
clefChoice = 2;
}
else if ("treble".equals(e.getActionCommand())){
clefChoice = 3;
}
else if ("mb".equals(e.getActionCommand())){
octavaAndBassoChoice = 0;
}
else if ("vb".equals(e.getActionCommand())){
octavaAndBassoChoice = 1;
}
else if ("none".equals(e.getActionCommand())){
octavaAndBassoChoice = 2;
}
else if ("va".equals(e.getActionCommand())){
octavaAndBassoChoice = 3;
}
else if ("ma".equals(e.getActionCommand())){
octavaAndBassoChoice = 4;
}
else if ("sharps".equals(e.getActionCommand())){
spellingChoice = 0;
}
else if ("flats".equals(e.getActionCommand())){
spellingChoice = 1;
}
else if ("show".equals(e.getActionCommand())){
ratioChoice = 0;
}
else if ("hide".equals(e.getActionCommand())){
ratioChoice = 1;
}
for (int i = 0; i < listeningNotes.size(); i++){
if ("bass".equals(e.getActionCommand())
|| "tenor".equals(e.getActionCommand())
|| "alto".equals(e.getActionCommand())
|| "treble".equals(e.getActionCommand())){
((Note) listeningNotes.get(i)).clefChoice = clefChoice;
}
if ("mb".equals(e.getActionCommand())
|| "vb".equals(e.getActionCommand())
|| "none".equals(e.getActionCommand())
|| "va".equals(e.getActionCommand())
|| "ma".equals(e.getActionCommand())){
((Note) listeningNotes.get(i)).octavaAndBassoChoice = octavaAndBassoChoice;
}
if ("sharps".equals(e.getActionCommand())
|| "flats".equals(e.getActionCommand())){
((Note) listeningNotes.get(i)).spellingChoice = spellingChoice;
}
if ("show".equals(e.getActionCommand())
|| "hide".equals(e.getActionCommand())){
((Note) listeningNotes.get(i)).ratioChoice = ratioChoice;
}
((Note) listeningNotes.get(i)).repaint();
}
}
}

@ -0,0 +1,40 @@
package main;
import java.awt.Container;
import java.io.IOException;
import java.io.ObjectInputStream;
import javax.swing.JSlider;
import javax.swing.JTextField;
public class OpenClassIterator {
public OpenClassIterator(Container c, ObjectInputStream in){
if (c.getClass() == new JTextField().getClass()){
try {
((JTextField) c).setText((String) in.readObject());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if (c.getClass() == new JSlider().getClass()){
try {
((JSlider) c).setValue(in.readInt());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
for (int i = 0; i < c.getComponentCount(); i++){
OpenClassIterator oCI = new OpenClassIterator((Container) c.getComponent(i),in);
}
}
}

@ -0,0 +1,54 @@
package main;
import java.util.Vector;
import com.softsynth.jsyn.EqualTemperedTuning;
public class PitchVector{
Vector[] array;
public PitchVector(){
}
public void init(){
int aLength = (int) (Rise.TOTAL_DUR * 10);
array = new Vector[aLength];
double fund = EqualTemperedTuning.getMIDIFrequency(24+Rise.TRANSPOSE_SCORE+Rise.TRANSPOSE_SOUND);
for (int i = 0; i < aLength; i++){
array[i] = new Vector();
array[i].add(fund);
}
for (int plotPoint = 1; plotPoint < Rise.VOICES; plotPoint++){
//int plotPoint =
for (int voice = 1; voice <= plotPoint; voice++){
double x = (1./(Rise.VOICES-1))*plotPoint;
double pitch = 1200./Math.log(2.)*Math.log((double) (Rise.FIRST_NUM+voice-plotPoint)/(Rise.FIRST_NUM-plotPoint));
double frequency = EqualTemperedTuning.getMIDIFrequency(24+Rise.TRANSPOSE_SCORE+Rise.TRANSPOSE_SOUND+pitch/100.);
int start = (int) ((x - ((1./(Rise.VOICES-1))*(plotPoint-voice)/plotPoint)) * (aLength-1));
int end = (int) ((x + ((1./(Rise.VOICES-1))*voice/(plotPoint+1))) * (aLength-1));
if (end >= aLength){
end = aLength;
}
//System.out.println("s and e " + start + " " + end + " " + pitch);
for (int i = start; i < end; i++) {
array[i].add(frequency);
}
//System.out.println("notes 2 " + plotPoint + " " + pitch + " " + frequency + (x - ((1./(Rise.VOICES-1))*(plotPoint-voice)/plotPoint)) + " " + (x + ((1./(Rise.VOICES-1))*voice/(plotPoint+1))));
// p is plot point, v is voice
}
}
}
}

@ -0,0 +1,79 @@
package main;
import java.awt.*;
import javax.swing.*;
import java.awt.print.*;
public class PrintUtilities extends JPanel implements Printable {
Score score;
int xPage;
int yPage;
PrinterJob pj = PrinterJob.getPrinterJob();
public PrintUtilities() {
}
public void init(Score score, int xPage, int yPage){
this.score = score;
this.xPage = xPage;
this.yPage = yPage;
pageSetup();
//this.setName("yo");
}
public void pageSetup() {
PageFormat pf = new PageFormat();
//figure out how to get this to return user page format
pf = pj.pageDialog(pj.defaultPage());
Paper paper = new Paper();
double margin = 0;
paper.setSize(pf.getPaper().getWidth(), pf.getPaper().getHeight());
paper.setImageableArea(margin, margin, paper.getWidth(), paper.getHeight());
pf.setPaper(paper);
pj.setPrintable(this, pf);
if (pj.printDialog()) {
try { pj.print(); }
catch (PrinterException e) {
System.out.println(e);
}
}
}
public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
if (pageIndex >= Rise.X_DIV * Rise.Y_DIV){
Rise.CURRENT_X_PAGE = xPage;
Rise.CURRENT_Y_PAGE = yPage;
return(NO_SUCH_PAGE);
}
else {
Rise.CURRENT_X_PAGE = pageIndex % Rise.X_DIV;
Rise.CURRENT_Y_PAGE = pageIndex / Rise.X_DIV;
score.removeAll();
score.setNotes();
score.setNoteChoices();
Graphics2D g2 = (Graphics2D)g;
disableDoubleBuffering(this);
g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
Dimension d = score.getSize();
double scaleX = pageFormat.getImageableWidth()/d.width;
double scaleY = pageFormat.getImageableHeight() / d.height;
g2.scale(scaleX, scaleY);
score.paint(g2);
enableDoubleBuffering(this);
return(PAGE_EXISTS);
}
}
public static void disableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(false);
}
public static void enableDoubleBuffering(Component c) {
RepaintManager currentManager = RepaintManager.currentManager(c);
currentManager.setDoubleBufferingEnabled(true);
}
}

@ -0,0 +1,130 @@
package main;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.UIManager;
import java.awt.Font;
import com.softsynth.jsyn.ExponentialLag;
import com.softsynth.jsyn.MultiplyUnit;
import com.softsynth.jsyn.SynthMixer;
public class Rise {
static int PAGE_WIDTH = 1224;
static int PAGE_HEIGHT = 792;
static int PAGE_MARGIN = 36+18;
static int IMAGE_WIDTH = PAGE_WIDTH-PAGE_MARGIN*2;
static int IMAGE_HEIGHT = PAGE_HEIGHT-PAGE_MARGIN*2;
static double ZOOM = .64;
static float FONT = 12;
static float LINE_THICKNESS = (float) .05;
static int FIRST_NUM = 16;
static int VOICES = 12;
static int X_DIV = 1;
static int Y_DIV = 1;
static int CURRENT_X_PAGE = 0;
static int CURRENT_Y_PAGE = 0;
//static float TOTAL_TIME = (VOICES-1)*60;
static float TRANSPOSE_SCORE = 36;
static float TRANSPOSE_SOUND = 0;
static int MODE = 0;
static double MASTER_AMP = 0;
static double START_AMP = 0;
static double END_AMP = 0;
static double MIN_SPECTRUM = 0;
static double MAX_SPECTRUM = 0;
static int START_DENSITY = 0;
static int END_DENSITY = 0;
static double START_DUR = 0;
static double END_DUR = 0;
static double TOTAL_DUR = 1650;
static double START_TIME = 0;
static double FADE_DUR = 150;
static boolean IS_ENGINE_ON = false;
static int SCROLLBAR_WIDTH;
static CuePanel CUE_PANEL;
Score score;
JScrollPane scroller;
JPanel scrollPanel;
static NoteFrame NOTE_FRAME = new NoteFrame();
static BoundingBox BOUNDING_BOX = new BoundingBox();
static ScrollBar SCROLLBAR = new ScrollBar();
static SynthMixer MASTER_MIXER;
static ExponentialLag MASTER_FADER;
static MultiplyUnit MASTER_MULT;
static SynthMixer CLICK_MIXER;
static ExponentialLag CLICK_FADER;
static MultiplyUnit CLICK_MULT;
static double GRAIN_AMP_VAL_START;
static double GRAIN_AMP_VAL_END;
static double GRAIN_AMP_JIT_START;
static double GRAIN_AMP_JIT_END;
static double GRAIN_SOUND_DUR_VAL_START;
static double GRAIN_SOUND_DUR_VAL_END;
static double GRAIN_SOUND_DUR_JIT_START;
static double GRAIN_SOUND_DUR_JIT_END;
static double GRAIN_SILENCE_DUR_VAL_START;
static double GRAIN_SILENCE_DUR_VAL_END;
static double GRAIN_SILENCE_DUR_JIT_START;
static double GRAIN_SILENCE_DUR_JIT_END;
static double GLISS_AMP_START;
static double GLISS_AMP_END;
public static void setUIFont (javax.swing.plaf.FontUIResource f){
java.util.Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get (key);
if (value instanceof javax.swing.plaf.FontUIResource)
UIManager.put (key, f);
}
}
public Rise() {
setUIFont (new javax.swing.plaf.FontUIResource("Liberation Serif", Font.BOLD, 8));
JFrame scoreFrame = new JFrame();
scoreFrame.setTitle("Score Frame");
Container scoreContainer = scoreFrame.getContentPane();
scrollPanel = new JPanel();
scroller = new JScrollPane(scrollPanel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
score = new Score();
score.setPreferredSize(new Dimension((int) (PAGE_WIDTH*ZOOM), (int) (PAGE_HEIGHT*ZOOM)));
score.setBackground(Color.WHITE);
scrollPanel.add(score);
scoreContainer.add(scroller);
scroller.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE);
ToolFrame controlFrame = new ToolFrame(score);
scoreFrame.pack();
scoreFrame.setSize(800,550);
scoreFrame.setVisible(true);
controlFrame.setLocation(800, 0);
controlFrame.setVisible(true);
}
public static void main(String args[]) {
Rise rise = new Rise();
}
}

@ -0,0 +1,37 @@
package main;
import java.awt.Container;
import java.io.IOException;
import java.io.ObjectOutputStream;
import javax.swing.JSlider;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
public class SaveClassIterator {
public SaveClassIterator(Container c, ObjectOutputStream out){
if (c.getClass() == new JTextField().getClass()){
try {
out.writeObject(((JTextField) c).getText());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if (c.getClass() == new JSlider().getClass()){
try {
out.writeInt(((JSlider) c).getValue());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
for (int i = 0; i < c.getComponentCount(); i++){
SaveClassIterator sCI = new SaveClassIterator((Container) c.getComponent(i),out);
}
}
}

@ -0,0 +1,372 @@
package main;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import javax.swing.JPanel;
import com.softsynth.jsyn.EqualTemperedTuning;
import com.softsynth.jsyn.ExponentialLag;
import com.softsynth.jsyn.LineOut;
import com.softsynth.jsyn.MultiplyUnit;
import com.softsynth.jsyn.Synth;
import com.softsynth.jsyn.SynthMixer;
public class Score extends JPanel implements MouseListener, MouseMotionListener{
ArrayList notes = new ArrayList();
ArrayList lastNotes;
float x1;
float x2;
float y1;
float y2;
WaveForm clickAndPlay;
LineOut lineOut;
int counter = 0;
public Score(){
this.addMouseListener(this);
this.addMouseMotionListener(this);
this.setLayout(null);
this.setBackground(Color.WHITE);
this.add(Rise.BOUNDING_BOX);
setNotes();
this.add(Rise.SCROLLBAR);
}
public void setNotes(){
lastNotes = (ArrayList) notes.clone();
notes = new ArrayList();
double centRange = (1200/Math.log(2.))*Math.log((double) Rise.FIRST_NUM/(Rise.FIRST_NUM-Rise.VOICES+1));
int totalVoices = Rise.VOICES;
int plotPoints = totalVoices;
int count = 0;
for (int voice = 0; voice < totalVoices; voice++){
for (int plotPoint = voice; plotPoint < plotPoints; plotPoint++){
double x = (1./(plotPoints-1))*plotPoint;
double pitch = 1200./Math.log(2.)*Math.log((double) (Rise.FIRST_NUM+voice-plotPoint)/(Rise.FIRST_NUM-plotPoint));
double y = Math.abs(((pitch)/centRange)-1);
notes.add(new Note((x*Rise.X_DIV-((double) Rise.X_DIV/Rise.X_DIV)*Rise.CURRENT_X_PAGE),
(y*Rise.Y_DIV-((double) Rise.Y_DIV/Rise.Y_DIV)*Math.abs(Rise.CURRENT_Y_PAGE-(Rise.Y_DIV-1))),
pitch,voice,plotPoint));
if (x >= (1./Rise.X_DIV)*Rise.CURRENT_X_PAGE && x <= (1./Rise.X_DIV)*(Rise.CURRENT_X_PAGE+1)
&& y >= 1-(1./Rise.Y_DIV)*(Rise.CURRENT_Y_PAGE+1) && y <= 1-(1./Rise.Y_DIV)*(Rise.CURRENT_Y_PAGE)) {
this.add((Note) notes.get(count));
}
count++;
}
}
Rise.NOTE_FRAME.setNoteAccess(notes);
}
public void setNoteChoices(){
for (int count = 0; count < notes.size(); count++){
((Note) notes.get(count)).clefChoice = ((Note) lastNotes.get(count)).clefChoice;
((Note) notes.get(count)).octavaAndBassoChoice = ((Note) lastNotes.get(count)).octavaAndBassoChoice;
((Note) notes.get(count)).spellingChoice = ((Note) lastNotes.get(count)).spellingChoice;
((Note) notes.get(count)).ratioChoice = ((Note) lastNotes.get(count)).ratioChoice;
}
}
public void paint(Graphics g){
super.paint(g);
Rise.SCROLLBAR_WIDTH = (int) (this.getPreferredSize().width - Rise.PAGE_MARGIN*Rise.ZOOM * 2);
Graphics2D g2 = (Graphics2D) g;
g2.translate(Rise.PAGE_MARGIN*Rise.ZOOM, Rise.PAGE_MARGIN*Rise.ZOOM);
g2.scale(Rise.ZOOM, Rise.ZOOM);
g2.setStroke(new BasicStroke(Rise.LINE_THICKNESS,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER));
int totalVoices = Rise.VOICES;
double centRange = (1200/Math.log(2.))*Math.log((double) Rise.FIRST_NUM/(Rise.FIRST_NUM-Rise.VOICES+1));
int plotPoints = totalVoices*25;
for (int voice = 1; voice < totalVoices-1; voice++){
for (int plotPoint = voice*(plotPoints/totalVoices); plotPoint < plotPoints-(plotPoints/totalVoices); plotPoint++){
double startX = (1./(plotPoints-plotPoints/totalVoices))*plotPoint;
double startY = Math.abs(((1200./Math.log(2.)*Math.log((Rise.FIRST_NUM+voice-plotPoint/((double) plotPoints/totalVoices))/(Rise.FIRST_NUM-plotPoint/((double) plotPoints/totalVoices))))/centRange)-1);
double endX = (1./(plotPoints-plotPoints/totalVoices))*(plotPoint+1);
double endY = Math.abs(((1200./Math.log(2.)*Math.log((Rise.FIRST_NUM+voice-(plotPoint+1)/((double) plotPoints/totalVoices))/(Rise.FIRST_NUM-(plotPoint+1)/((double) plotPoints/totalVoices))))/centRange)-1);
if (startX >= (1./Rise.X_DIV)*Rise.CURRENT_X_PAGE && startX <= (1./Rise.X_DIV)*(Rise.CURRENT_X_PAGE+1)
&& startY >= 1-(1./Rise.Y_DIV)*(Rise.CURRENT_Y_PAGE+1) && startY <= 1-(1./Rise.Y_DIV)*(Rise.CURRENT_Y_PAGE)) {
g2.draw(new Line2D.Double((startX*Rise.X_DIV-((double) Rise.X_DIV/Rise.X_DIV)*Rise.CURRENT_X_PAGE)*Rise.IMAGE_WIDTH,
(startY*Rise.Y_DIV-((double) Rise.Y_DIV/Rise.Y_DIV)*Math.abs(Rise.CURRENT_Y_PAGE-(Rise.Y_DIV-1)))*Rise.IMAGE_HEIGHT,
(endX*Rise.X_DIV-((double) Rise.X_DIV/Rise.X_DIV)*Rise.CURRENT_X_PAGE)*Rise.IMAGE_WIDTH,
(endY*Rise.Y_DIV-((double) Rise.Y_DIV/Rise.Y_DIV)*Math.abs(Rise.CURRENT_Y_PAGE-(Rise.Y_DIV-1)))*Rise.IMAGE_HEIGHT));
}
}
}
}
public void setMasterFader(double a){
if (Rise.IS_ENGINE_ON == true) {
Rise.MASTER_FADER.input.set(a);
}
}
public void setClickFader(double a){
if (Rise.IS_ENGINE_ON == true) {
Rise.CLICK_FADER.input.set(a);
}
}
public void mouseClicked(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
x1 = e.getX();
y1 = e.getY();
if (Rise.MODE == 0){
Rise.NOTE_FRAME.setVisible(false);
}
else {
int registered = 0;
for(int i = 0; i < notes.size(); i++ ) {
//int add = ((Note) notes.get(i)).testSelectClickAndPlay((float) (x1-20*Rise.ZOOM), (float) (y1-20*Rise.ZOOM), (float) (x1+20*Rise.ZOOM), (float) (y1+20*Rise.ZOOM));
int add = ((Note) notes.get(i)).testSelectClickAndPlay((float) (x1), (float) (y1));
if (add != 0) {
registered = registered + add;
//System.out.println(((Note) notes.get(i)).x + " " + ((Note) notes.get(i)).y +
// " " + ((Note) notes.get(i)).p + " " + ((Note) notes.get(i)).v);
((Note) notes.get(i)).repaint();
if (Rise.IS_ENGINE_ON == false){
Rise.IS_ENGINE_ON = true;
Synth.startEngine(0);
Rise.MASTER_MIXER = new SynthMixer(1,1);
Rise.CLICK_MIXER = new SynthMixer(10,1);
Rise.MASTER_MULT = new MultiplyUnit();
Rise.MASTER_FADER = new ExponentialLag();
Rise.CLICK_MULT = new MultiplyUnit();
Rise.CLICK_FADER = new ExponentialLag();
lineOut = new LineOut();
for (int c = 0; c < 10; c++){
Rise.CLICK_MIXER.setGain(c, 0, 1);
}
Rise.CLICK_MULT.inputA.connect(Rise.CLICK_FADER.output);
Rise.CLICK_MULT.inputB.connect(Rise.CLICK_MIXER.getOutput(0));
Rise.MASTER_MIXER.connectInput(0, Rise.CLICK_MULT.output, 0);
Rise.MASTER_MIXER.setGain(0, 0, 1);
Rise.MASTER_MULT.inputA.connect(Rise.MASTER_FADER.output);
Rise.MASTER_MULT.inputB.connect(Rise.MASTER_MIXER.getOutput(0));
lineOut.input.connect(0, Rise.MASTER_MULT.output, 0);
lineOut.input.connect(1, Rise.MASTER_MULT.output, 0);
lineOut.start(0);
Rise.MASTER_MIXER.start(0);
Rise.MASTER_MULT.start(0);
Rise.MASTER_FADER.start(0);
Rise.CLICK_MIXER.start(0);
Rise.CLICK_MULT.start(0);
Rise.CLICK_FADER.start(0);
setMasterFader(1);
setClickFader(1);
//System.out.println("STARTED!!!");
}
//clickAndPlay = new WaveForm();
clickAndPlay = new WaveForm();
Rise.CLICK_MIXER.connectInput((counter%10), clickAndPlay.output, 0);
counter++;
double envPosition = (x1 - Rise.PAGE_MARGIN*Rise.ZOOM)/(Rise.IMAGE_WIDTH*Rise.ZOOM);
double duration =
(Rise.GRAIN_SOUND_DUR_VAL_START - envPosition * Math.abs(Rise.GRAIN_SOUND_DUR_VAL_START - Rise.GRAIN_SOUND_DUR_VAL_END)) +
((Rise.GRAIN_SOUND_DUR_JIT_START - envPosition * Math.abs(Rise.GRAIN_SOUND_DUR_JIT_START - Rise.GRAIN_SOUND_DUR_JIT_END)) *
(Math.random() * 2 - 1));
clickAndPlay.envRate.set(1./duration);
double amp =
((Rise.GRAIN_AMP_VAL_START + envPosition * Math.abs(Rise.GRAIN_AMP_VAL_END - Rise.GRAIN_AMP_VAL_START)) +
((Rise.GRAIN_AMP_JIT_START + envPosition * Math.abs(Rise.GRAIN_AMP_JIT_END - Rise.GRAIN_AMP_JIT_START)) *
(Math.random() * 2 - 1)));
double spectrum =
Rise.MIN_SPECTRUM + Math.random() * Math.abs(Rise.MAX_SPECTRUM - Rise.MIN_SPECTRUM);
//System.out.println("Tone Info; dur = " + duration + ", amp = " + amp);
clickAndPlay.spectrum.set(spectrum);
double frequency = EqualTemperedTuning.getMIDIFrequency(24/*+Rise.TRANSPOSE_SCORE*/+Rise.TRANSPOSE_SOUND+((Note) notes.get(i)).pitch/100.);
clickAndPlay.clickOn(0, frequency, amp);
}
}
//System.out.println(registered);
}
}
public void mouseReleased(MouseEvent e) {
if (Rise.MODE == 0){
Rise.NOTE_FRAME.bass.setSelected(false);
Rise.NOTE_FRAME.tenor.setSelected(false);
Rise.NOTE_FRAME.alto.setSelected(false);
Rise.NOTE_FRAME.treble.setSelected(false);
int clef = 0;
int oB = 0;
int spell = 0;
int ratio = 0;
x2 = e.getX();
y2 = e.getY();
double rectX1;
double rectX2;
double rectY1;
double rectY2;
if (e.getX() < x1){
rectX2 = x1;
rectX1 = e.getX();
}
else {
rectX1 = x1;
rectX2 = e.getX();
}
if (e.getY() < y1){
rectY2 = y1;
rectY1 = e.getY();
}
else {
rectY1 = y1;
rectY2 = e.getY();
}
int registered = 0;
for(int i = 0; i < notes.size(); i++ ) {
int add = ((Note) notes.get(i)).testSelect((float) (rectX1-10*Rise.ZOOM), (float) (rectY1-10*Rise.ZOOM), (float) (rectX2+10*Rise.ZOOM), (float) (rectY2+10*Rise.ZOOM));
if (add != 0) {
registered = registered + add;
clef = ((Note) notes.get(i)).clefChoice;
oB = ((Note) notes.get(i)).octavaAndBassoChoice;
spell = ((Note) notes.get(i)).spellingChoice;
ratio = ((Note) notes.get(i)).ratioChoice;
}
}
if (registered > 0) {
Rise.NOTE_FRAME.setListeningNotes();
Rise.BOUNDING_BOX.setVisible(true);
Rise.BOUNDING_BOX.setCoordinates(rectX1, rectX2, rectY1, rectY2);
Rise.BOUNDING_BOX.repaint();
Rise.NOTE_FRAME.setVisible(true);
if (registered == 1) {
if (clef == 0) {
Rise.NOTE_FRAME.bass.setSelected(true);
}
else if (clef == 1) {
Rise.NOTE_FRAME.tenor.setSelected(true);
}
else if (clef == 2) {
Rise.NOTE_FRAME.alto.setSelected(true);
}
else if (clef == 3) {
Rise.NOTE_FRAME.treble.setSelected(true);
}
if (oB == 0) {
Rise.NOTE_FRAME.mb.setSelected(true);
}
else if (oB == 1) {
Rise.NOTE_FRAME.vb.setSelected(true);
}
else if (oB == 2) {
Rise.NOTE_FRAME.none.setSelected(true);
}
else if (oB == 3) {
Rise.NOTE_FRAME.va.setSelected(true);
}
else if (oB == 4) {
Rise.NOTE_FRAME.ma.setSelected(true);
}
if (spell == 0) {
Rise.NOTE_FRAME.sharps.setSelected(true);
}
else if (spell == 1) {
Rise.NOTE_FRAME.flats.setSelected(true);
}
if (ratio == 0) {
Rise.NOTE_FRAME.show.setSelected(true);
}
else if (ratio == 1) {
Rise.NOTE_FRAME.hide.setSelected(true);
}
}
else {
Rise.NOTE_FRAME.clefNada.setSelected(true);
Rise.NOTE_FRAME.oBNada.setSelected(true);
Rise.NOTE_FRAME.spellNada.setSelected(true);
Rise.NOTE_FRAME.ratiosNada.setSelected(true);
}
}
else {
Rise.BOUNDING_BOX.setVisible(false);
}
}
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mouseDragged(MouseEvent e) {
if (Rise.MODE == 0){
Rise.BOUNDING_BOX.setVisible(true);
double rectX1;
double rectX2;
double rectY1;
double rectY2;
if (e.getX() < x1){
rectX2 = x1;
rectX1 = e.getX();
}
else {
rectX1 = x1;
rectX2 = e.getX();
}
if (e.getY() < y1){
rectY2 = y1;
rectY1 = e.getY();
}
else {
rectY1 = y1;
rectY2 = e.getY();
}
Rise.BOUNDING_BOX.setCoordinates(rectX1, rectX2, rectY1, rectY2);
Rise.BOUNDING_BOX.repaint();
}
}
public void mouseMoved(MouseEvent e) {
}
}

@ -0,0 +1,26 @@
package main;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import javax.swing.JPanel;
public class ScrollBar extends JPanel{
double xPos;
public ScrollBar() {
this.setOpaque(false);
this.setBounds((int) 0, (int) 0,(int) (Rise.PAGE_WIDTH*Rise.ZOOM), (int) (Rise.PAGE_HEIGHT*Rise.ZOOM));
this.setVisible(false);
}
public void paint(Graphics g){
g.setColor(Color.BLUE);
Graphics2D g2 = (Graphics2D) g;
g2.draw(new Line2D.Double(Rise.PAGE_MARGIN*Rise.ZOOM + xPos,0, Rise.PAGE_MARGIN*Rise.ZOOM + xPos,Rise.PAGE_HEIGHT*Rise.ZOOM));
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,118 @@
package main;
import com.softsynth.jsyn.*;
public class WaveForm extends SynthNote {
EnvelopePlayer envPlayer;
SynthEnvelope env;
SynthInput envRate;
SynthInput spectrum;
int noOsc = 5;
//Set random phase
SineOscillator[] oscBank = new SineOscillator[noOsc];
BusWriter[] busWriter = new BusWriter[noOsc];
MultiplyUnit[] multAmp = new MultiplyUnit[noOsc];
MultiplyUnit[] multFreq = new MultiplyUnit[noOsc];
LineOut lineOut;
BusReader busReader;
SynthDistributor freqDist = new SynthDistributor("frequency");
SynthDistributor spectrumDist = new SynthDistributor("spectrum");
double[] envData;
SynthEnvelope glissEnv;
public WaveForm() {
super();
add(envPlayer = new EnvelopePlayer());
add(busReader = new BusReader());
add(busWriter[0] = new BusWriter());
add(oscBank[0] = new SineOscillator());
add(lineOut = new LineOut());
double randomPhase = Math.random();
oscBank[0].phase.set(randomPhase);
oscBank[0].frequency.connect(freqDist);
oscBank[0].output.connect(busWriter[0].input);
busWriter[0].busOutput.connect(busReader.busInput);
for(int i = 1; i < noOsc; i++){
add(busWriter[i] = new BusWriter());
add(oscBank[i] = new SineOscillator());
add(multFreq[i] = new MultiplyUnit());
add(multAmp[i] = new MultiplyUnit());
multFreq[i].inputA.set(i+1.);
multFreq[i].inputB.connect(freqDist);
multFreq[i].output.connect(oscBank[i].frequency);
multAmp[i].inputA.set(1./(i+1.));
multAmp[i].inputB.connect(spectrumDist);
multAmp[i].output.connect(oscBank[i].amplitude);
oscBank[i].output.connect(busWriter[i].input);
busWriter[i].busOutput.connect(busReader.busInput);
envPlayer.output.connect(busReader.amplitude);
oscBank[i].phase.set(randomPhase);
}
addPort(amplitude = envPlayer.amplitude);
addPort(frequency = freqDist);
addPort(envRate = envPlayer.rate);
addPort(output = busReader.output);
addPort(spectrum = spectrumDist);
//double[] envData = { .5, 1.0, .5, 0.0 };
envData = new double[42];
for (int i = 0; i < 21; i++) {
envData[i*2] = 1/20.;
envData[i*2+1] = (Math.cos(2*(1/20.*i)*Math.PI+Math.PI)+1)/2;
//System.out.println(envData[i*2] + " " + envData[i*2+1]);
}
env = new SynthEnvelope(envData);
frequency.set(400);
amplitude.set(1.);
spectrum.set(0);
}
public void grainOn(int t, double f, double a) {
start(t);
frequency.set(t, f);
amplitude.set(t, a);
//spectrum.set(arg0);
envPlayer.envelopePort.clear(t);
envPlayer.envelopePort.queue(env,0,env.getNumFrames(),Synth.FLAG_AUTO_STOP);
//envPlayer.envelopePort.queueLoop(t, env, 1, 1);
}
public void clickOn(int t, double f, double a) {
start(t);
frequency.set(t, f);
amplitude.set(t, a);
//spectrum.set(arg0);
envPlayer.envelopePort.clear(t);
envPlayer.envelopePort.queue(env,0,env.getNumFrames(),Synth.FLAG_AUTO_STOP);
//envPlayer.envelopePort.queueLoop(t, env, 1, 1);
}
public void glissOn(int t, double f, double a , double[] eD) {
glissEnv = new SynthEnvelope(eD);
start(t);
frequency.set(t, f);
amplitude.set(t, a);
envPlayer.envelopePort.clear(t);
envPlayer.envelopePort.queue(t,glissEnv,0,glissEnv.getNumFrames(), Synth.FLAG_AUTO_STOP);
}
public void glissOff(int t, double r) {
envRate.set(t, r);
envPlayer.envelopePort.clear(t);
envPlayer.envelopePort.queue(t, glissEnv, glissEnv.getNumFrames() - 1, 1, Synth.FLAG_AUTO_STOP);
}
}
Loading…
Cancel
Save