From c797bca897d3f293d158f0a50501b27f868091cf Mon Sep 17 00:00:00 2001 From: ffd8 Date: Wed, 25 Jul 2018 00:32:32 +0200 Subject: [PATCH] finalized v3 w/ vectrex prior to merge with master --- changelog.txt | 9 ++++ examples/vectrex/vectrex.pde | 50 ++++++++++++++++++++++ resources/build.properties | 4 +- src/xyscope/XYscope.java | 83 +++++++++++++++++++++++++++++------- 4 files changed, 128 insertions(+), 18 deletions(-) create mode 100644 examples/vectrex/vectrex.pde diff --git a/changelog.txt b/changelog.txt index 6cf91e9..3105593 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/examples/vectrex/vectrex.pde b/examples/vectrex/vectrex.pde new file mode 100644 index 0000000..eb1040e --- /dev/null +++ b/examples/vectrex/vectrex.pde @@ -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(); +} diff --git a/resources/build.properties b/resources/build.properties index 1ea91a5..5e3558f 100644 --- a/resources/build.properties +++ b/resources/build.properties @@ -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. diff --git a/src/xyscope/XYscope.java b/src/xyscope/XYscope.java index b5ab45a..00d3ddc 100644 --- a/src/xyscope/XYscope.java +++ b/src/xyscope/XYscope.java @@ -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. @@ -754,6 +795,7 @@ 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]; @@ -761,11 +803,12 @@ public void buildWaves(int bwm) { }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]; } @@ -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); }