Skip to content

Commit c797bca

Browse files
committed
finalized v3 w/ vectrex prior to merge with master
1 parent 9e67d46 commit c797bca

File tree

4 files changed

+128
-18
lines changed

4 files changed

+128
-18
lines changed

changelog.txt

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
- removed
44

55

6+
////////////////////////////////////////////////////////////
7+
XYScope 2.1.0 (REV 3) - 25.07.2018
8+
9+
+ Vectrex compatibility (custom aspect ratio and +/- 90° rotation)
10+
+ Vectrex example
11+
12+
* BuildWaves + drawXY to work with Vectrex mode
13+
14+
615
////////////////////////////////////////////////////////////
716
XYScope 2.0.0 (REV 2) - 08.05.2018
817

examples/vectrex/vectrex.pde

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
vectrex
3+
Basics settings for using a modded Vectrex monitor.
4+
cc teddavis.org 2018
5+
*/
6+
7+
// import and create instance of XYscope
8+
import xyscope.*;
9+
XYscope xy;
10+
11+
// minim is required to generate audio
12+
import ddf.minim.*;
13+
14+
void setup() {
15+
size(512, 512);
16+
17+
// initialize XYscope with default sound out
18+
xy = new XYscope(this, "");
19+
20+
// set XYscope into Vectrex mode, using 90° rotation (landscape)
21+
xy.vectrex(90);
22+
23+
/*
24+
If the anti-blanking mod was applied (z/brightness is always on),
25+
this auto sets the brightness (from way turned down) when the sketch runs.
26+
*/
27+
//xy.z("*set to 3rd audio channel out*");
28+
//xy.zRange(.5, 0);
29+
}
30+
31+
void draw() {
32+
background(0);
33+
34+
// clear waves like refreshing background
35+
xy.clearWaves();
36+
37+
// set detail of vertex ellipse
38+
xy.ellipseDetail(30);
39+
40+
// draw two primative shapes, testing boundry of screen
41+
xy.rect(0, 0, width, height);
42+
float s = map(mouseX, 0, width, -height/2, height/2);
43+
xy.ellipse(width/2, height/2, s, s);
44+
45+
// build audio from shapes
46+
xy.buildWaves();
47+
48+
// draw all analytics
49+
xy.drawAll();
50+
}

resources/build.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ source.repository=https://github.com/ffd8/xyscope.git
132132
# This is used to compare different versions of the same Library, and check if
133133
# an update is available.
134134

135-
library.version=2
135+
library.version=3
136136

137137

138138
# The version as the user will see it.
139139

140-
library.prettyVersion=2.0.0
140+
library.prettyVersion=2.1.0
141141

142142

143143
# The min and max revision of Processing compatible with your Library.

src/xyscope/XYscope.java

+67-16
Original file line numberDiff line numberDiff line change
@@ -387,37 +387,78 @@ public void zRange(float zMin, float zMax) {
387387
zaxisMax = zMax;
388388
}
389389

390+
/**
391+
* 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.
392+
*
393+
*/
390394
public void vectrex(){
391-
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit);
395+
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit, vectrexRotation);
392396
}
393397

398+
/**
399+
* 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.
400+
*
401+
* @param vrot
402+
* int for degrees of rotation, 90 or -90
403+
*/
394404
public void vectrex(int vrot){
395405
if(vrot == 90){
396406
vectrexRotation = vrot;
397-
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit);
407+
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit, vectrexRotation);
398408
}else if(vrot == -90){
399409
vectrexRotation = vrot;
400-
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit);
401-
}else{
402-
vectrexRotation = vrot;
403-
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit);
410+
vectrex(vectrexHeight, vectrexWidth, vectrexAmpInit, vectrexRotation);
411+
}else {
412+
vectrexRotation = 0;
413+
vectrex(vectrexWidth, vectrexHeight, vectrexAmpInit, vectrexRotation);
404414
}
405415
}
406416

407-
public void vectrex(int vw, int vh, float vamp){
417+
/**
418+
* Use XYscope on a modded Vectrex monitor for XYZ input. Set custom width, height, initial amplitude scaling and rotation/orientation.
419+
*
420+
* @param vw
421+
* int for width of canvas, default is 330
422+
* @param vh
423+
* int for height of canvas, default is 410
424+
* @param vrot
425+
* float for initial amplitude adjustment of signal to screen (0.0 - 1.0), default is .6
426+
* @param vrot
427+
* int for degrees of rotation, 90 or -90, default is 0
428+
*/
429+
public void vectrex(int vw, int vh, float vamp, int vrot){
408430
useVectrex = true;
431+
vectrexRotation = vrot;
409432
myParent.getSurface().setResizable(true);
410433
myParent.getSurface().setSize(vw, vh);
411434
xyWidth = vw;
412435
xyHeight = vh;
413-
amp(vamp);
436+
vectrexAmpInit = vamp;
437+
amp(vectrexAmpInit);
438+
}
439+
440+
441+
/**
442+
* Get current amplitude difference used for ratio of Vectrex.
443+
*
444+
* @return float
445+
*/
446+
public float vectrexRatio(){
447+
return vectrexAmp;
448+
}
449+
450+
451+
/**
452+
* Set current amplitude difference used for ratio of Vectrex.
453+
*
454+
* @param vectrexAmpVal
455+
* float for amplitude difference (0.0 - 1.0), default is .82
456+
*/
457+
public void vectrexRatio(float vectrexAmpVal){
458+
vectrexAmp = constrain(vectrexAmpVal, 0f, 1f);
459+
amp(vectrexAmpInit);
414460
}
415461

416-
// public void vectrexRotation(int vrot){
417-
// myParent.translate(xyWidth / 2, xyHeight / 2);
418-
// myParent.rotate(radians(vrot));
419-
// myParent.translate(-xyWidth / 2, -xyHeight / 2);
420-
// }
421462

422463
/**
423464
* Get current amplitude setting of XY oscillators.
@@ -754,18 +795,20 @@ public void buildWaves(int bwm) {
754795
for (int i = 0; i < shapePreX.length; i++) {
755796
shapeX[i] = shapePreX[i];
756797
shapeY[i] = shapePreY[i];
798+
757799
if(useVectrex){
758800
if(vectrexRotation == 90){
759801
shapeX[i] = shapePreY[i];
760802
shapeY[i] = shapePreX[i]*-1;
761803
}else if(vectrexRotation == -90){
762804
shapeX[i] = shapePreY[i]*-1;
763805
shapeY[i] = shapePreX[i];
764-
}else{
806+
}else if(vectrexRotation == 0){
765807
shapeX[i] = shapePreX[i]*-1;
766808
shapeY[i] = shapePreY[i]*-1;
767809
}
768810
}
811+
769812
if (zaxis && useZ)
770813
shapeZ[i] = shapePreZ[i];
771814
}
@@ -1008,12 +1051,20 @@ public void drawXY() {
10081051
for (int i = 0; i < tempXY.bufferSize() - 1; i++) {
10091052
float lAudio = tempXY.left.get(i) * (float) xyWidth / 2;
10101053
float rAudio = tempXY.right.get(i) * (float) xyHeight / 2;
1054+
10111055
if(useVectrex){
10121056
if(vectrexRotation == 90){
1013-
rAudio = tempXY.left.get(i) * (float) xyWidth / 2;
1014-
lAudio = tempXY.right.get(i) * (float) xyHeight / 2 * -1f;
1057+
rAudio = tempXY.left.get(i) * (float) xyHeight / 2;
1058+
lAudio = tempXY.right.get(i) * (float) xyWidth / 2 * -1f * vectrexAmp;
1059+
}else if(vectrexRotation == -90){
1060+
rAudio = tempXY.left.get(i) * (float) xyHeight / 2 * -1f;
1061+
lAudio = tempXY.right.get(i) * (float) xyWidth / 2 * vectrexAmp;
1062+
}else if(vectrexRotation == 0){
1063+
lAudio = tempXY.left.get(i) * (float) xyWidth / 2 * -1f;
1064+
rAudio = tempXY.right.get(i) * (float) xyHeight / 2 * -1f * vectrexAmp;
10151065
}
10161066
}
1067+
10171068
myParent.curveVertex(lAudio, rAudio * -1f);
10181069
}
10191070

0 commit comments

Comments
 (0)