From a3b7092dd19c4b768321bd3c8295fb897dc82ce1 Mon Sep 17 00:00:00 2001 From: Christopher Pietsch Date: Mon, 21 Dec 2015 15:50:29 +0100 Subject: [PATCH] Created a Mindmachine Sketch A mind machine uses pulsing rhythmic sound and/or flashing light to alter the frequency of the user's brainwaves. --- bin/data/scenes/mindmachine/exampleCode.cpp | 13 +++++++++ d4nSFPCRunner.xcodeproj/project.pbxproj | 14 ++++++++++ src/scenes/mindmachine/mindmachine.cpp | 31 +++++++++++++++++++++ src/scenes/mindmachine/mindmachine.h | 18 ++++++++++++ src/scenes/sceneManager.cpp | 4 ++- 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 bin/data/scenes/mindmachine/exampleCode.cpp create mode 100644 src/scenes/mindmachine/mindmachine.cpp create mode 100644 src/scenes/mindmachine/mindmachine.h diff --git a/bin/data/scenes/mindmachine/exampleCode.cpp b/bin/data/scenes/mindmachine/exampleCode.cpp new file mode 100644 index 0000000..8bb6104 --- /dev/null +++ b/bin/data/scenes/mindmachine/exampleCode.cpp @@ -0,0 +1,13 @@ +// you might want to close your eyes and let go + +void draw(){ + int microsePerWave = (int)( 1000*1000 / ( [[Brain Frequency]] *2 )); + int wave = ofGetElapsedTimeMicros() / microsePerWave; + int lastWave = last / microsePerWave; + last = ofGetElapsedTimeMicros(); + + if(wave > lastWave) flip *= -1; + int alpha = ofMap(flip, -1, 1, 0, 255); + + ofBackground(alpha); +} \ No newline at end of file diff --git a/d4nSFPCRunner.xcodeproj/project.pbxproj b/d4nSFPCRunner.xcodeproj/project.pbxproj index e5d6a8b..703afcf 100644 --- a/d4nSFPCRunner.xcodeproj/project.pbxproj +++ b/d4nSFPCRunner.xcodeproj/project.pbxproj @@ -116,6 +116,7 @@ E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4328148138ABC890047C5CB /* openFrameworksDebug.a */; }; E4B69E200A3A1BDC003C02F2 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1D0A3A1BDC003C02F2 /* main.cpp */; }; E4B69E210A3A1BDC003C02F2 /* ofApp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */; }; + EF8EF8F71C284680006C7B1B /* mindmachine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF8EF8F51C284680006C7B1B /* mindmachine.cpp */; }; F285EB3169F1566CA3D93C20 /* ofxPanel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E112B3AEBEA2C091BF2B40AE /* ofxPanel.cpp */; }; FA361F451C18862D00F197F3 /* veraMolnarLines68.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA361F431C18862D00F197F3 /* veraMolnarLines68.cpp */; }; FA361F491C1887A400F197F3 /* alexGifPaletteDitherMenkman.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA361F471C1887A400F197F3 /* alexGifPaletteDitherMenkman.cpp */; }; @@ -403,6 +404,8 @@ E4EB691F138AFCF100A09F29 /* CoreOF.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = CoreOF.xcconfig; path = ../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig; sourceTree = SOURCE_ROOT; }; E4EB6923138AFD0F00A09F29 /* Project.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Project.xcconfig; sourceTree = ""; }; ECF8674C7975F1063C5E30CA /* ofxGuiGroup.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = ofxGuiGroup.cpp; path = ../../../addons/ofxGui/src/ofxGuiGroup.cpp; sourceTree = SOURCE_ROOT; }; + EF8EF8F51C284680006C7B1B /* mindmachine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mindmachine.cpp; sourceTree = ""; }; + EF8EF8F61C284680006C7B1B /* mindmachine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mindmachine.h; sourceTree = ""; }; FA361F431C18862D00F197F3 /* veraMolnarLines68.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = veraMolnarLines68.cpp; sourceTree = ""; }; FA361F441C18862D00F197F3 /* veraMolnarLines68.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = veraMolnarLines68.h; sourceTree = ""; }; FA361F471C1887A400F197F3 /* alexGifPaletteDitherMenkman.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alexGifPaletteDitherMenkman.cpp; sourceTree = ""; }; @@ -733,6 +736,7 @@ 9238719D1BF7993A00171456 /* scenes */ = { isa = PBXGroup; children = ( + EF8EF8F41C284680006C7B1B /* mindmachine */, C1DB5A341C272DEE000C2F7C /* ofxDataBender */, B08FE1911C23B39F0037252E /* RileyRemake-Catarina_Lee__Joao_Freire */, C13A36701C17906200F13242 /* aaronMarcusHieroglyphB */, @@ -1349,6 +1353,15 @@ name = openFrameworks; sourceTree = ""; }; + EF8EF8F41C284680006C7B1B /* mindmachine */ = { + isa = PBXGroup; + children = ( + EF8EF8F51C284680006C7B1B /* mindmachine.cpp */, + EF8EF8F61C284680006C7B1B /* mindmachine.h */, + ); + path = mindmachine; + sourceTree = ""; + }; FA361F421C18862D00F197F3 /* veraMolnarLines68 */ = { isa = PBXGroup; children = ( @@ -1527,6 +1540,7 @@ D39F0DF71C222065004DEAAB /* OscOutboundPacketStream.cpp in Sources */, B00CD10E1C21E81400C529FA /* ofxTween.cpp in Sources */, FA361F491C1887A400F197F3 /* alexGifPaletteDitherMenkman.cpp in Sources */, + EF8EF8F71C284680006C7B1B /* mindmachine.cpp in Sources */, 9237CB9D1C11E9BD0007A916 /* veraFscene.cpp in Sources */, 85B3DCA81C1E47060054975A /* yeseulMenkmanInstitution.cpp in Sources */, B00CD1041C21E81400C529FA /* ofxEasingBounce.cpp in Sources */, diff --git a/src/scenes/mindmachine/mindmachine.cpp b/src/scenes/mindmachine/mindmachine.cpp new file mode 100644 index 0000000..47aebf0 --- /dev/null +++ b/src/scenes/mindmachine/mindmachine.cpp @@ -0,0 +1,31 @@ + +#include "mindmachine.h" + +void mindmachine::setup(){ + + freq.set("Brain Frequency", 5, 1, 20); + parameters.add(freq); + + flip = 1; + + setOriginalArtist("William Grey Walter"); + setAuthor("Christopher Pietsch"); + + loadCode("scenes/mindmachine/exampleCode.cpp"); +} + +void mindmachine::update(){ + +} + +void mindmachine::draw(){ + int microsePerWave = (int)( 1000*1000 / ( freq *2 )); + int wave = ofGetElapsedTimeMicros() / microsePerWave; + int lastWave = last / microsePerWave; + last = ofGetElapsedTimeMicros(); + + if(wave > lastWave) flip *= -1; + int alpha = ofMap(flip, -1, 1, 0, 255); + + ofBackground(alpha); +} diff --git a/src/scenes/mindmachine/mindmachine.h b/src/scenes/mindmachine/mindmachine.h new file mode 100644 index 0000000..0a2c91d --- /dev/null +++ b/src/scenes/mindmachine/mindmachine.h @@ -0,0 +1,18 @@ +#pragma once + +#include "ofMain.h" +#include "baseScene.h" + +class mindmachine : public baseScene { + +public: + + void setup(); + void update(); + void draw(); + + ofParameter freq; + + int last; + int flip; +}; diff --git a/src/scenes/sceneManager.cpp b/src/scenes/sceneManager.cpp index 70b7ad6..5f03fb5 100644 --- a/src/scenes/sceneManager.cpp +++ b/src/scenes/sceneManager.cpp @@ -59,6 +59,7 @@ #include "sarahgpRileyCircle.h" #include "mwalczykVeraSquares.h" #include "yeseulRileyBrokencircle.h" +#include "mindmachine.h" float baseScene::smoothingSpeed = 0.02; @@ -70,7 +71,7 @@ sceneManager::~sceneManager(){ void sceneManager::setup(){ font.load("fonts/ProggySmall.fon", 8, false ,false, false, 0, 96); - + scenes.push_back(new CooperBauhaus()); // this might make for a good start scene -Robby & Becca scenes.push_back(new RileyArcsRoy()); scenes.push_back(new rachelScene()); @@ -116,6 +117,7 @@ void sceneManager::setup(){ scenes.push_back(new olegVeraV()); scenes.push_back(new sarahgpRileyCircle()); scenes.push_back(new mwalczykVeraSquares()); + scenes.push_back(new mindmachine()); // Too slow // scenes.push_back(new andyMenkmanTif());