Skip to content

Commit

Permalink
finalized v3 w/ vectrex prior to merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
ffd8 committed Jul 24, 2018
1 parent 9e67d46 commit c797bca
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 18 deletions.
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
- removed


////////////////////////////////////////////////////////////
XYScope 2.1.0 (REV 3) - 25.07.2018

+ Vectrex compatibility (custom aspect ratio and +/- 90° rotation)
+ Vectrex example

* BuildWaves + drawXY to work with Vectrex mode


////////////////////////////////////////////////////////////
XYScope 2.0.0 (REV 2) - 08.05.2018

Expand Down
50 changes: 50 additions & 0 deletions examples/vectrex/vectrex.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
vectrex
Basics settings for using a modded Vectrex monitor.
cc teddavis.org 2018
*/

// import and create instance of XYscope
import xyscope.*;
XYscope xy;

// minim is required to generate audio
import ddf.minim.*;

void setup() {
size(512, 512);

// initialize XYscope with default sound out
xy = new XYscope(this, "");

// set XYscope into Vectrex mode, using 90° rotation (landscape)
xy.vectrex(90);

/*
If the anti-blanking mod was applied (z/brightness is always on),
this auto sets the brightness (from way turned down) when the sketch runs.
*/
//xy.z("*set to 3rd audio channel out*");
//xy.zRange(.5, 0);
}

void draw() {
background(0);

// clear waves like refreshing background
xy.clearWaves();

// set detail of vertex ellipse
xy.ellipseDetail(30);

// draw two primative shapes, testing boundry of screen
xy.rect(0, 0, width, height);
float s = map(mouseX, 0, width, -height/2, height/2);
xy.ellipse(width/2, height/2, s, s);

// build audio from shapes
xy.buildWaves();

// draw all analytics
xy.drawAll();
}
4 changes: 2 additions & 2 deletions resources/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ source.repository=https://github.com/ffd8/xyscope.git
# This is used to compare different versions of the same Library, and check if
# an update is available.

library.version=2
library.version=3


# The version as the user will see it.

library.prettyVersion=2.0.0
library.prettyVersion=2.1.0


# The min and max revision of Processing compatible with your Library.
Expand Down
83 changes: 67 additions & 16 deletions src/xyscope/XYscope.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,37 +387,78 @@ public void zRange(float zMin, float zMax) {
zaxisMax = zMax;
}

/**
* Use XYscope on a modded Vectrex monitor for XYZ input. This will automatically adjust the canvas and amplitude settings to match the ratio of the Vectrex.
*
*/
public void vectrex(){
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit);
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit, vectrexRotation);
}

/**
* Use XYscope on a modded Vectrex monitor for XYZ input. This will automatically adjust the canvas and amplitude settings to match the ratio of the Vectrex. You can customize the rotation of the monitor +/- 90° if landscape oriented.
*
* @param vrot
* int for degrees of rotation, 90 or -90
*/
public void vectrex(int vrot){
if(vrot == 90){
vectrexRotation = vrot;
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit);
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit, vectrexRotation);
}else if(vrot == -90){
vectrexRotation = vrot;
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit);
}else{
vectrexRotation = vrot;
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit);
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit, vectrexRotation);
}else {
vectrexRotation = 0;
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit, vectrexRotation);
}
}

public void vectrex(int vw, int vh, float vamp){
/**
* Use XYscope on a modded Vectrex monitor for XYZ input. Set custom width, height, initial amplitude scaling and rotation/orientation.
*
* @param vw
* int for width of canvas, default is 330
* @param vh
* int for height of canvas, default is 410
* @param vrot
* float for initial amplitude adjustment of signal to screen (0.0 - 1.0), default is .6
* @param vrot
* int for degrees of rotation, 90 or -90, default is 0
*/
public void vectrex(int vw, int vh, float vamp, int vrot){
useVectrex = true;
vectrexRotation = vrot;
myParent.getSurface().setResizable(true);
myParent.getSurface().setSize(vw, vh);
xyWidth = vw;
xyHeight = vh;
amp(vamp);
vectrexAmpInit = vamp;
amp(vectrexAmpInit);
}


/**
* Get current amplitude difference used for ratio of Vectrex.
*
* @return float
*/
public float vectrexRatio(){
return vectrexAmp;
}


/**
* Set current amplitude difference used for ratio of Vectrex.
*
* @param vectrexAmpVal
* float for amplitude difference (0.0 - 1.0), default is .82
*/
public void vectrexRatio(float vectrexAmpVal){
vectrexAmp = constrain(vectrexAmpVal, 0f, 1f);
amp(vectrexAmpInit);
}

// public void vectrexRotation(int vrot){
// myParent.translate(xyWidth / 2, xyHeight / 2);
// myParent.rotate(radians(vrot));
// myParent.translate(-xyWidth / 2, -xyHeight / 2);
// }

/**
* Get current amplitude setting of XY oscillators.
Expand Down Expand Up @@ -754,18 +795,20 @@ public void buildWaves(int bwm) {
for (int i = 0; i < shapePreX.length; i++) {
shapeX[i] = shapePreX[i];
shapeY[i] = shapePreY[i];

if(useVectrex){
if(vectrexRotation == 90){
shapeX[i] = shapePreY[i];
shapeY[i] = shapePreX[i]*-1;
}else if(vectrexRotation == -90){
shapeX[i] = shapePreY[i]*-1;
shapeY[i] = shapePreX[i];
}else{
}else if(vectrexRotation == 0){
shapeX[i] = shapePreX[i]*-1;
shapeY[i] = shapePreY[i]*-1;
}
}

if (zaxis && useZ)
shapeZ[i] = shapePreZ[i];
}
Expand Down Expand Up @@ -1008,12 +1051,20 @@ public void drawXY() {
for (int i = 0; i < tempXY.bufferSize() - 1; i++) {
float lAudio = tempXY.left.get(i) * (float) xyWidth / 2;
float rAudio = tempXY.right.get(i) * (float) xyHeight / 2;

if(useVectrex){
if(vectrexRotation == 90){
rAudio = tempXY.left.get(i) * (float) xyWidth / 2;
lAudio = tempXY.right.get(i) * (float) xyHeight / 2 * -1f;
rAudio = tempXY.left.get(i) * (float) xyHeight / 2;
lAudio = tempXY.right.get(i) * (float) xyWidth / 2 * -1f * vectrexAmp;
}else if(vectrexRotation == -90){
rAudio = tempXY.left.get(i) * (float) xyHeight / 2 * -1f;
lAudio = tempXY.right.get(i) * (float) xyWidth / 2 * vectrexAmp;
}else if(vectrexRotation == 0){
lAudio = tempXY.left.get(i) * (float) xyWidth / 2 * -1f;
rAudio = tempXY.right.get(i) * (float) xyHeight / 2 * -1f * vectrexAmp;
}
}

myParent.curveVertex(lAudio, rAudio * -1f);
}

Expand Down

0 comments on commit c797bca

Please sign in to comment.