diff --git a/Brain-Fu_k.xcodeproj/project.pbxproj b/Brain-Fu_k.xcodeproj/project.pbxproj index e3acd8d..2788cdb 100644 --- a/Brain-Fu_k.xcodeproj/project.pbxproj +++ b/Brain-Fu_k.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ E4B69E210A3A1BDC003C02F2 /* ofApp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */; }; E717C5A73BE4076EDBC728DC /* IpEndpointName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6EE05DD94DAD5D94142391A8 /* IpEndpointName.cpp */; }; EA075BE31F4C80BC001072CC /* ofDecomposeModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EA075BE11F4C80BC001072CC /* ofDecomposeModel.cpp */; }; + EA2250ED1F56B2EB00967D48 /* BrainModelData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EA2250EB1F56B2EB00967D48 /* BrainModelData.cpp */; }; F0509CA2E805D1D5F70A87D0 /* NetworkingUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F72D5263CF8609CF22E13BD6 /* NetworkingUtils.cpp */; }; F95B04FD042E7407B70EE321 /* OscReceivedElements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01571FD18D74B633FA614437 /* OscReceivedElements.cpp */; }; /* End PBXBuildFile section */ @@ -144,6 +145,8 @@ E9F88CD42BB044F2266BD3B6 /* OscTypes.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; name = OscTypes.h; path = ../../addons/ofxOsc/libs/oscpack/src/osc/OscTypes.h; sourceTree = SOURCE_ROOT; }; EA075BE11F4C80BC001072CC /* ofDecomposeModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofDecomposeModel.cpp; sourceTree = ""; }; EA075BE21F4C80BC001072CC /* ofDecomposeModel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ofDecomposeModel.hpp; sourceTree = ""; }; + EA2250EB1F56B2EB00967D48 /* BrainModelData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BrainModelData.cpp; sourceTree = ""; }; + EA2250EC1F56B2EB00967D48 /* BrainModelData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrainModelData.h; sourceTree = ""; }; EAFA8681058B5F1F30BFFD60 /* ofxOscArg.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; name = ofxOscArg.h; path = ../../addons/ofxOsc/src/ofxOscArg.h; sourceTree = SOURCE_ROOT; }; EC3AD9545B31A870BF84CE63 /* Logger.hpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; name = Logger.hpp; path = ../../addons/ofxAssimpModelLoader/libs/assimp/include/assimp/Logger.hpp; sourceTree = SOURCE_ROOT; }; F20DB77CFF47D59CAFCDF1DE /* ofxOscSender.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 30; name = ofxOscSender.h; path = ../../addons/ofxOsc/src/ofxOscSender.h; sourceTree = SOURCE_ROOT; }; @@ -379,6 +382,8 @@ EA075BE21F4C80BC001072CC /* ofDecomposeModel.hpp */, 7A5EB1B6F04EE1663C90B8D6 /* OSCManager.cpp */, 929DBAAC1D2697E61C5768BE /* OSCManager.hpp */, + EA2250EB1F56B2EB00967D48 /* BrainModelData.cpp */, + EA2250EC1F56B2EB00967D48 /* BrainModelData.h */, ); path = src; sourceTree = SOURCE_ROOT; @@ -524,6 +529,7 @@ DBB73811B127DAE7DE28C895 /* ofxOscParameterSync.cpp in Sources */, 6F2D739BB67B61B0D43AB5BD /* ofxOscReceiver.cpp in Sources */, 866ACEB977FAB3191AD48906 /* ofxOscSender.cpp in Sources */, + EA2250ED1F56B2EB00967D48 /* BrainModelData.cpp in Sources */, E717C5A73BE4076EDBC728DC /* IpEndpointName.cpp in Sources */, F0509CA2E805D1D5F70A87D0 /* NetworkingUtils.cpp in Sources */, C9651B24B869083F299EFA4D /* UdpSocket.cpp in Sources */, diff --git a/Brain-Fu_k.xcodeproj/project.xcworkspace/xcuserdata/murawakimitsuhiro.xcuserdatad/UserInterfaceState.xcuserstate b/Brain-Fu_k.xcodeproj/project.xcworkspace/xcuserdata/murawakimitsuhiro.xcuserdatad/UserInterfaceState.xcuserstate index 1b3f9bd..a4b5753 100644 Binary files a/Brain-Fu_k.xcodeproj/project.xcworkspace/xcuserdata/murawakimitsuhiro.xcuserdatad/UserInterfaceState.xcuserstate and b/Brain-Fu_k.xcodeproj/project.xcworkspace/xcuserdata/murawakimitsuhiro.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/bin/Brain-Fu_kDebug.app/Contents/MacOS/Brain-Fu_kDebug b/bin/Brain-Fu_kDebug.app/Contents/MacOS/Brain-Fu_kDebug index c853d86..56bedde 100755 Binary files a/bin/Brain-Fu_kDebug.app/Contents/MacOS/Brain-Fu_kDebug and b/bin/Brain-Fu_kDebug.app/Contents/MacOS/Brain-Fu_kDebug differ diff --git a/max_fft_sample/fft_sample.maxpat b/max_fft_sample/fft_sample.maxpat new file mode 100644 index 0000000..524e701 --- /dev/null +++ b/max_fft_sample/fft_sample.maxpat @@ -0,0 +1,470 @@ +{ + "patcher" : { + "fileversion" : 1, + "appversion" : { + "major" : 7, + "minor" : 3, + "revision" : 3, + "architecture" : "x86", + "modernui" : 1 + } +, + "rect" : [ 49.0, 240.0, 783.0, 749.0 ], + "bglocked" : 0, + "openinpresentation" : 0, + "default_fontsize" : 12.0, + "default_fontface" : 0, + "default_fontname" : "Arial", + "gridonopen" : 1, + "gridsize" : [ 15.0, 15.0 ], + "gridsnaponopen" : 1, + "objectsnaponopen" : 1, + "statusbarvisible" : 2, + "toolbarvisible" : 1, + "lefttoolbarpinned" : 0, + "toptoolbarpinned" : 0, + "righttoolbarpinned" : 0, + "bottomtoolbarpinned" : 0, + "toolbars_unpinned_last_save" : 0, + "tallnewobj" : 0, + "boxanimatetime" : 200, + "enablehscroll" : 1, + "enablevscroll" : 1, + "devicewidth" : 0.0, + "description" : "", + "digest" : "", + "tags" : "", + "style" : "", + "subpatcher_template" : "", + "boxes" : [ { + "box" : { + "id" : "obj-51", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 22.0, 31.0, 188.0, 20.0 ], + "presentation_rect" : [ 169.0, 23.0, 0.0, 0.0 ], + "style" : "", + "text" : "FFTデータをOSCで送る場合" + } + + } +, { + "box" : { + "id" : "obj-50", + "linecount" : 2, + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 167.0, 258.0, 148.0, 33.0 ], + "presentation_rect" : [ 167.0, 260.0, 0.0, 0.0 ], + "style" : "", + "text" : "100msec ごとに送る\n(10fps" + } + + } +, { + "box" : { + "id" : "obj-49", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 82.0, 650.0, 71.0, 22.0 ], + "style" : "", + "text" : "prepend /fft" + } + + } +, { + "box" : { + "id" : "obj-46", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 82.0, 694.0, 140.0, 22.0 ], + "style" : "", + "text" : "udpsend 127.0.0.1 8787" + } + + } +, { + "box" : { + "id" : "obj-45", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 279.0, 430.0, 148.0, 20.0 ], + "presentation_rect" : [ 278.0, 430.0, 0.0, 0.0 ], + "style" : "", + "text" : "FFT用のメモリの確保" + } + + } +, { + "box" : { + "id" : "obj-44", + "maxclass" : "comment", + "numinlets" : 1, + "numoutlets" : 0, + "patching_rect" : [ 312.0, 495.0, 115.0, 20.0 ], + "style" : "", + "text" : "FFT sizeの半分" + } + + } +, { + "box" : { + "id" : "obj-40", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "bang" ], + "patching_rect" : [ 279.0, 458.0, 60.0, 22.0 ], + "style" : "", + "text" : "loadbang" + } + + } +, { + "box" : { + "id" : "obj-39", + "maxclass" : "message", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 279.0, 495.0, 31.0, 22.0 ], + "style" : "", + "text" : "256" + } + + } +, { + "box" : { + "fontname" : "Arial", + "fontsize" : 12.0, + "id" : "obj-12", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 22.0, 461.0, 57.0, 22.0 ], + "style" : "", + "text" : "thresh 0." + } + + } +, { + "box" : { + "id" : "obj-9", + "maxclass" : "multislider", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "" ], + "parameter_enable" : 0, + "patching_rect" : [ 22.0, 506.0, 215.0, 120.0 ], + "setminmax" : [ 0.0, 1.0 ], + "size" : 256, + "style" : "" + } + + } +, { + "box" : { + "fontname" : "Arial", + "fontsize" : 12.0, + "id" : "obj-8", + "maxclass" : "newobj", + "numinlets" : 3, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 22.0, 420.0, 55.0, 22.0 ], + "style" : "", + "text" : "clip 0. 1." + } + + } +, { + "box" : { + "fontname" : "Geneva", + "fontsize" : 12.0, + "id" : "obj-17", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "int" ], + "patching_rect" : [ 22.0, 347.0, 33.0, 23.0 ], + "style" : "", + "text" : "- 1" + } + + } +, { + "box" : { + "fontface" : 0, + "fontname" : "Geneva", + "fontsize" : 12.0, + "id" : "obj-20", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "bang" ], + "patching_rect" : [ 22.0, 258.0, 135.0, 23.0 ], + "style" : "", + "text" : "metro 100 @active 1" + } + + } +, { + "box" : { + "fontname" : "Geneva", + "fontsize" : 12.0, + "id" : "obj-22", + "maxclass" : "newobj", + "numinlets" : 3, + "numoutlets" : 1, + "outlettype" : [ "float" ], + "patching_rect" : [ 22.0, 381.0, 108.0, 23.0 ], + "style" : "", + "text" : "peek~ _buf_fft_" + } + + } +, { + "box" : { + "fontname" : "Geneva", + "fontsize" : 12.0, + "id" : "obj-23", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 3, + "outlettype" : [ "bang", "bang", "int" ], + "patching_rect" : [ 22.0, 303.0, 56.0, 23.0 ], + "style" : "", + "text" : "Uzi 256" + } + + } +, { + "box" : { + "fontname" : "Geneva", + "fontsize" : 12.0, + "id" : "obj-5", + "maxclass" : "newobj", + "numinlets" : 3, + "numoutlets" : 0, + "patching_rect" : [ 22.0, 207.0, 108.0, 23.0 ], + "style" : "", + "text" : "poke~ _buf_fft_" + } + + } +, { + "box" : { + "fontname" : "Arial", + "fontsize" : 12.0, + "id" : "obj-41", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "float", "bang" ], + "patching_rect" : [ 279.0, 576.0, 114.0, 22.0 ], + "style" : "", + "text" : "buffer~ _buf_fft_ 10" + } + + } +, { + "box" : { + "fontname" : "Geneva", + "fontsize" : 12.0, + "id" : "obj-26", + "maxclass" : "newobj", + "numinlets" : 3, + "numoutlets" : 0, + "patching_rect" : [ 279.0, 603.0, 108.0, 23.0 ], + "style" : "", + "text" : "poke~ _buf_fft_" + } + + } +, { + "box" : { + "id" : "obj-3", + "maxclass" : "ezadc~", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "signal", "signal" ], + "patching_rect" : [ 22.0, 91.0, 45.0, 45.0 ], + "style" : "" + } + + } +, { + "box" : { + "id" : "obj-1", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "signal", "signal" ], + "patching_rect" : [ 22.0, 158.0, 104.0, 22.0 ], + "style" : "", + "text" : "pfft~ fftamp 512 1" + } + + } +, { + "box" : { + "id" : "obj-35", + "maxclass" : "message", + "numinlets" : 2, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 279.0, 529.0, 93.0, 22.0 ], + "style" : "", + "text" : "sizeinsamps $1" + } + + } + ], + "lines" : [ { + "patchline" : { + "destination" : [ "obj-5", 1 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-1", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-5", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-1", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-49", 0 ], + "disabled" : 0, + "hidden" : 0, + "order" : 0, + "source" : [ "obj-12", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-9", 0 ], + "disabled" : 0, + "hidden" : 0, + "order" : 1, + "source" : [ "obj-12", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-22", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-17", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-23", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-20", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-8", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-22", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-17", 0 ], + "disabled" : 0, + "hidden" : 0, + "midpoints" : [ 68.5, 339.0, 31.5, 339.0 ], + "source" : [ "obj-23", 2 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-1", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-3", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-41", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-35", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-35", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-39", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-39", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-40", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-46", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-49", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-12", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-8", 0 ] + } + + } + ], + "dependency_cache" : [ { + "name" : "fftamp.maxpat", + "bootpath" : "~/Dropbox (Rhizomatiks)/tmp/fft_sample", + "type" : "JSON", + "implicit" : 1 + } + ], + "autosave" : 0 + } + +} diff --git a/max_fft_sample/fftamp.maxpat b/max_fft_sample/fftamp.maxpat new file mode 100644 index 0000000..92a79ee --- /dev/null +++ b/max_fft_sample/fftamp.maxpat @@ -0,0 +1,131 @@ +{ + "patcher" : { + "fileversion" : 1, + "appversion" : { + "major" : 7, + "minor" : 3, + "revision" : 3, + "architecture" : "x86", + "modernui" : 1 + } +, + "rect" : [ 448.0, 271.0, 640.0, 480.0 ], + "bglocked" : 0, + "openinpresentation" : 0, + "default_fontsize" : 12.0, + "default_fontface" : 0, + "default_fontname" : "Arial", + "gridonopen" : 1, + "gridsize" : [ 15.0, 15.0 ], + "gridsnaponopen" : 1, + "objectsnaponopen" : 1, + "statusbarvisible" : 2, + "toolbarvisible" : 1, + "lefttoolbarpinned" : 0, + "toptoolbarpinned" : 0, + "righttoolbarpinned" : 0, + "bottomtoolbarpinned" : 0, + "toolbars_unpinned_last_save" : 0, + "tallnewobj" : 0, + "boxanimatetime" : 200, + "enablehscroll" : 1, + "enablevscroll" : 1, + "devicewidth" : 0.0, + "description" : "", + "digest" : "", + "tags" : "", + "style" : "", + "subpatcher_template" : "", + "boxes" : [ { + "box" : { + "id" : "obj-4", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 0, + "patching_rect" : [ 226.0, 190.0, 80.0, 22.0 ], + "style" : "", + "text" : "fftout~ 2 nofft" + } + + } +, { + "box" : { + "id" : "obj-3", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 2, + "outlettype" : [ "signal", "signal" ], + "patching_rect" : [ 142.0, 152.0, 60.0, 22.0 ], + "style" : "", + "text" : "cartopol~" + } + + } +, { + "box" : { + "id" : "obj-2", + "maxclass" : "newobj", + "numinlets" : 2, + "numoutlets" : 0, + "patching_rect" : [ 144.0, 215.0, 80.0, 22.0 ], + "style" : "", + "text" : "fftout~ 1 nofft" + } + + } +, { + "box" : { + "id" : "obj-1", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 3, + "outlettype" : [ "signal", "signal", "signal" ], + "patching_rect" : [ 144.0, 110.0, 93.0, 22.0 ], + "style" : "", + "text" : "fftin~ 1 hanning" + } + + } + ], + "lines" : [ { + "patchline" : { + "destination" : [ "obj-3", 1 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-1", 1 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-3", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-1", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-4", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-1", 2 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-2", 0 ], + "disabled" : 0, + "hidden" : 0, + "source" : [ "obj-3", 0 ] + } + + } + ], + "dependency_cache" : [ ], + "autosave" : 0 + } + +} diff --git a/oschub.maxpat b/oschub.maxpat index 980609c..9e0bf95 100644 --- a/oschub.maxpat +++ b/oschub.maxpat @@ -9,7 +9,7 @@ "modernui" : 1 } , - "rect" : [ 34.0, 79.0, 883.0, 749.0 ], + "rect" : [ 34.0, 79.0, 709.0, 749.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -37,6 +37,42 @@ "style" : "", "subpatcher_template" : "", "boxes" : [ { + "box" : { + "id" : "obj-19", + "maxclass" : "newobj", + "numinlets" : 1, + "numoutlets" : 1, + "outlettype" : [ "" ], + "patching_rect" : [ 95.0, 486.0, 132.0, 22.0 ], + "style" : "", + "text" : "prepend /debug_target" + } + + } +, { + "box" : { + "id" : "obj-18", + "maxclass" : "live.slider", + "numinlets" : 1, + "numoutlets" : 2, + "outlettype" : [ "", "float" ], + "parameter_enable" : 1, + "patching_rect" : [ 95.0, 251.5, 53.0, 203.0 ], + "saved_attribute_attributes" : { + "valueof" : { + "parameter_longname" : "live.slider", + "parameter_shortname" : "live.slider", + "parameter_type" : 0, + "parameter_unitstyle" : 0 + } + + } +, + "varname" : "live.slider" + } + + } +, { "box" : { "id" : "obj-28", "linecount" : 4, @@ -457,8 +493,7 @@ "id" : "obj-1", "maxclass" : "newobj", "numinlets" : 1, - "numoutlets" : 2, - "outlettype" : [ "signal", "signal" ], + "numoutlets" : 0, "patching_rect" : [ 660.0, 80.0, 104.0, 22.0 ], "style" : "", "text" : "pfft~ fftamp 512 1" @@ -480,20 +515,6 @@ } ], "lines" : [ { - "patchline" : { - "destination" : [ "obj-5", 1 ], - "source" : [ "obj-1", 1 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-5", 0 ], - "source" : [ "obj-1", 0 ] - } - - } -, { "patchline" : { "destination" : [ "obj-6", 0 ], "source" : [ "obj-10", 0 ] @@ -571,6 +592,20 @@ "source" : [ "obj-17", 0 ] } + } +, { + "patchline" : { + "destination" : [ "obj-19", 0 ], + "source" : [ "obj-18", 0 ] + } + + } +, { + "patchline" : { + "destination" : [ "obj-7", 0 ], + "source" : [ "obj-19", 0 ] + } + } , { "patchline" : { @@ -677,17 +712,11 @@ } ], "parameters" : { - "obj-13" : [ "live.gain~", "live.gain~", 0 ] + "obj-13" : [ "live.gain~", "live.gain~", 0 ], + "obj-18" : [ "live.slider", "live.slider", 0 ] } , "dependency_cache" : [ { - "name" : "fftamp.maxpat", - "bootpath" : "~/Downloads/fft_sample", - "patcherrelativepath" : "../../../../../../Downloads/fft_sample", - "type" : "JSON", - "implicit" : 1 - } -, { "name" : "pfft_loadme.maxpat", "bootpath" : "C74:/help/msp", "type" : "JSON", diff --git a/src/BrainController.cpp b/src/BrainController.cpp index 07fbfc0..7a50456 100644 --- a/src/BrainController.cpp +++ b/src/BrainController.cpp @@ -9,92 +9,67 @@ #include "BrainController.hpp" void BrainController::setup() { - ifstream ifs("../../../data/model/model_file_name_list.txt"); - string buf; - string dir = "model/"; - - int num; - num = 0; - while(getline(ifs, buf)){ - string tmp; - istringstream stream(buf); - while (getline(stream, tmp, ',')){ - tmp = dir + tmp; - models[num].loadModel(tmp); - models[num].setScaleNormalization(false); - num++; - } + for(int i=0; i 0 && nextDecomposeNum/* * 3*/ - int(ofGetElapsedTimef()) < 0) { + models[nextDecomposeNum].startDecompose(); + + if (nextDecomposeNum == BrainModelData::modelNum - 10) { + nextDecomposeNum = 0; + for (int i=0; i 0.01) { - ofSetColor(0, 255, 0, 30); - } + for (int i = 0; i < BrainModelData::modelNum; i++) { - if (OSCManager::get_instance().fft[i] > 0.025) { - ofSetColor(0, 0, 255, 30); + //decomposed brain parts + if(i < nextDecomposeNum) { + models[i].draw(); + continue; } - if (OSCManager::get_instance().fft[i] > 0.05) { + if (OSCManager::get_instance().bci[i / 9] > 1.0) { ofSetColor(255, 0, 0, 30); - } */ - - /* - if (i == debugTarget) { - ofSetColor(255, 0, 0, 30); - - models[i].drawCustom(); - //drawWithMesh(models[i]); - continue; - }*/ - + } else if (OSCManager::get_instance().bci[i / 9] > 0.6) { + ofSetColor(0, 250, 250, 30); + } else { + ofSetColor(255, 255, 255, 30); + } - models[i].draw(); + //normal draw + models[i].drawWireframe(); } } - -/*draw the model manually -void BrainController::drawWithMesh(ofxAssimpModelLoader model){ - - //get the model attributes we need - ofVec3f scale = model.getScale(); - ofVec3f position = model.getPosition(); - float normalizedScale = model.getNormalizedScale(); - ofVboMesh mesh = model.getMesh(0); - - ofPushMatrix(); - - float randX = ofRandom(-10, 10); - vector& verts = mesh.getVertices(); - for(unsigned int i = 0; i < verts.size(); i++){ - verts[i].y += randX; - } - - mesh.drawVertices();//drawWireframe(); - ofPopMatrix(); -} -*/ diff --git a/src/BrainController.hpp b/src/BrainController.hpp index 3dc40b3..100a290 100644 --- a/src/BrainController.hpp +++ b/src/BrainController.hpp @@ -16,15 +16,20 @@ #include "ofxAssimpModelLoader.h" #include "OSCManager.hpp" #include "ofDecomposeModel.hpp" +#include "BrainModelData.h" +//#include "BrainModelRersource.hpp" class BrainController { private: - static const int modelNum = 152; - ofDecomposeModel models[modelNum]; + ofDecomposeModel models[BrainModelData::modelNum]; + int nextDecomposeNum = 0; void setupOSCMessageReceive(); + int isLearning = 0; + int wasStart = 0; + //debug int gain; int debugTarget; diff --git a/src/BrainModelData.cpp b/src/BrainModelData.cpp new file mode 100644 index 0000000..8a70881 --- /dev/null +++ b/src/BrainModelData.cpp @@ -0,0 +1,157 @@ + + +#include "BrainModelData.h" + +const string BrainModelData::basePath = "model/"; +const string BrainModelData::modelNames[BrainModelData::modelNum] = { + "lh.white.Destrieux.G_Ins_lg_and_S_cent_ins.obj", + "lh.white.Destrieux.G_and_S_cingul-Ant.obj", + "lh.white.Destrieux.G_and_S_cingul-Mid-Ant.obj", + "lh.white.Destrieux.G_and_S_cingul-Mid-Post.obj", + "lh.white.Destrieux.G_and_S_frontomargin.obj", + "lh.white.Destrieux.G_and_S_occipital_inf.obj", + "lh.white.Destrieux.G_and_S_paracentral.obj", + "lh.white.Destrieux.G_and_S_subcentral.obj", + "lh.white.Destrieux.G_and_S_transv_frontopol.obj", + "lh.white.Destrieux.G_cingul-Post-dorsal.obj", + "lh.white.Destrieux.G_cingul-Post-ventral.obj", + "lh.white.Destrieux.G_cuneus.obj", + "lh.white.Destrieux.G_front_inf-Opercular.obj", + "lh.white.Destrieux.G_front_inf-Orbital.obj", + "lh.white.Destrieux.G_front_inf-Triangul.obj", + "lh.white.Destrieux.G_front_middle.obj", + "lh.white.Destrieux.G_front_sup.obj", + "lh.white.Destrieux.G_insular_short.obj", + "lh.white.Destrieux.G_oc-temp_lat-fusifor.obj", + "lh.white.Destrieux.G_oc-temp_med-Lingual.obj", + "lh.white.Destrieux.G_oc-temp_med-Parahip.obj", + "lh.white.Destrieux.G_occipital_middle.obj", + "lh.white.Destrieux.G_occipital_sup.obj", + "lh.white.Destrieux.G_orbital.obj", + "lh.white.Destrieux.G_pariet_inf-Angular.obj", + "lh.white.Destrieux.G_pariet_inf-Supramar.obj", + "lh.white.Destrieux.G_parietal_sup.obj", + "lh.white.Destrieux.G_postcentral.obj", + "lh.white.Destrieux.G_precentral.obj", + "lh.white.Destrieux.G_precuneus.obj", + "lh.white.Destrieux.G_rectus.obj", + "lh.white.Destrieux.G_subcallosal.obj", + "lh.white.Destrieux.G_temp_sup-G_T_transv.obj", + "lh.white.Destrieux.G_temp_sup-Lateral.obj", + "lh.white.Destrieux.G_temp_sup-Plan_polar.obj", + "lh.white.Destrieux.G_temp_sup-Plan_tempo.obj", + "lh.white.Destrieux.G_temporal_inf.obj", + "lh.white.Destrieux.G_temporal_middle.obj", + "lh.white.Destrieux.Lat_Fis-ant-Horizont.obj", + "lh.white.Destrieux.Lat_Fis-ant-Vertical.obj", + "lh.white.Destrieux.Lat_Fis-post.obj", + "lh.white.Destrieux.Pole_occipital.obj", + "lh.white.Destrieux.Pole_temporal.obj", + "lh.white.Destrieux.S_calcarine.obj", + "lh.white.Destrieux.S_central.obj", + "lh.white.Destrieux.S_cingul-Marginalis.obj", + "lh.white.Destrieux.S_circular_insula_ant.obj", + "lh.white.Destrieux.S_circular_insula_inf.obj", + "lh.white.Destrieux.S_circular_insula_sup.obj", + "lh.white.Destrieux.S_collat_transv_ant.obj", + "lh.white.Destrieux.S_collat_transv_post.obj", + "lh.white.Destrieux.S_front_inf.obj", + "lh.white.Destrieux.S_front_middle.obj", + "lh.white.Destrieux.S_front_sup.obj", + "lh.white.Destrieux.S_interm_prim-Jensen.obj", + "lh.white.Destrieux.S_intrapariet_and_P_trans.obj", + "lh.white.Destrieux.S_oc-temp_lat.obj", + "lh.white.Destrieux.S_oc-temp_med_and_Lingual.obj", + "lh.white.Destrieux.S_oc_middle_and_Lunatus.obj", + "lh.white.Destrieux.S_oc_sup_and_transversal.obj", + "lh.white.Destrieux.S_occipital_ant.obj", + "lh.white.Destrieux.S_orbital-H_Shaped.obj", + "lh.white.Destrieux.S_orbital_lateral.obj", + "lh.white.Destrieux.S_orbital_med-olfact.obj", + "lh.white.Destrieux.S_parieto_occipital.obj", + "lh.white.Destrieux.S_pericallosal.obj", + "lh.white.Destrieux.S_postcentral.obj", + "lh.white.Destrieux.S_precentral-inf-part.obj", + "lh.white.Destrieux.S_precentral-sup-part.obj", + "lh.white.Destrieux.S_suborbital.obj", + "lh.white.Destrieux.S_subparietal.obj", + "lh.white.Destrieux.S_temporal_inf.obj", + "lh.white.Destrieux.S_temporal_sup.obj", + "lh.white.Destrieux.S_temporal_transverse.obj", + "lh.white.Destrieux.Unknown.obj", + "rh.white.Destrieux.G_Ins_lg_and_S_cent_ins.obj", + "rh.white.Destrieux.G_and_S_cingul-Ant.obj", + "rh.white.Destrieux.G_and_S_cingul-Mid-Ant.obj", + "rh.white.Destrieux.G_and_S_cingul-Mid-Post.obj", + "rh.white.Destrieux.G_and_S_frontomargin.obj", + "rh.white.Destrieux.G_and_S_occipital_inf.obj", + "rh.white.Destrieux.G_and_S_paracentral.obj", + "rh.white.Destrieux.G_and_S_subcentral.obj", + "rh.white.Destrieux.G_and_S_transv_frontopol.obj", + "rh.white.Destrieux.G_cingul-Post-dorsal.obj", + "rh.white.Destrieux.G_cingul-Post-ventral.obj", + "rh.white.Destrieux.G_cuneus.obj", + "rh.white.Destrieux.G_front_inf-Opercular.obj", + "rh.white.Destrieux.G_front_inf-Orbital.obj", + "rh.white.Destrieux.G_front_inf-Triangul.obj", + "rh.white.Destrieux.G_front_middle.obj", + "rh.white.Destrieux.G_front_sup.obj", + "rh.white.Destrieux.G_insular_short.obj", + "rh.white.Destrieux.G_oc-temp_lat-fusifor.obj", + "rh.white.Destrieux.G_oc-temp_med-Lingual.obj", + "rh.white.Destrieux.G_oc-temp_med-Parahip.obj", + "rh.white.Destrieux.G_occipital_middle.obj", + "rh.white.Destrieux.G_occipital_sup.obj", + "rh.white.Destrieux.G_orbital.obj", + "rh.white.Destrieux.G_pariet_inf-Angular.obj", + "rh.white.Destrieux.G_pariet_inf-Supramar.obj", + "rh.white.Destrieux.G_parietal_sup.obj", + "rh.white.Destrieux.G_postcentral.obj", + "rh.white.Destrieux.G_precentral.obj", + "rh.white.Destrieux.G_precuneus.obj", + "rh.white.Destrieux.G_rectus.obj", + "rh.white.Destrieux.G_subcallosal.obj", + "rh.white.Destrieux.G_temp_sup-G_T_transv.obj", + "rh.white.Destrieux.G_temp_sup-Lateral.obj", + "rh.white.Destrieux.G_temp_sup-Plan_polar.obj", + "rh.white.Destrieux.G_temp_sup-Plan_tempo.obj", + "rh.white.Destrieux.G_temporal_inf.obj", + "rh.white.Destrieux.G_temporal_middle.obj", + "rh.white.Destrieux.Lat_Fis-ant-Horizont.obj", + "rh.white.Destrieux.Lat_Fis-ant-Vertical.obj", + "rh.white.Destrieux.Lat_Fis-post.obj", + "rh.white.Destrieux.Pole_occipital.obj", + "rh.white.Destrieux.Pole_temporal.obj", + "rh.white.Destrieux.S_calcarine.obj", + "rh.white.Destrieux.S_central.obj", + "rh.white.Destrieux.S_cingul-Marginalis.obj", + "rh.white.Destrieux.S_circular_insula_ant.obj", + "rh.white.Destrieux.S_circular_insula_inf.obj", + "rh.white.Destrieux.S_circular_insula_sup.obj", + "rh.white.Destrieux.S_collat_transv_ant.obj", + "rh.white.Destrieux.S_collat_transv_post.obj", + "rh.white.Destrieux.S_front_inf.obj", + "rh.white.Destrieux.S_front_middle.obj", + "rh.white.Destrieux.S_front_sup.obj", + "rh.white.Destrieux.S_interm_prim-Jensen.obj", + "rh.white.Destrieux.S_intrapariet_and_P_trans.obj", + "rh.white.Destrieux.S_oc-temp_lat.obj", + "rh.white.Destrieux.S_oc-temp_med_and_Lingual.obj", + "rh.white.Destrieux.S_oc_middle_and_Lunatus.obj", + "rh.white.Destrieux.S_oc_sup_and_transversal.obj", + "rh.white.Destrieux.S_occipital_ant.obj", + "rh.white.Destrieux.S_orbital-H_Shaped.obj", + "rh.white.Destrieux.S_orbital_lateral.obj", + "rh.white.Destrieux.S_orbital_med-olfact.obj", + "rh.white.Destrieux.S_parieto_occipital.obj", + "rh.white.Destrieux.S_pericallosal.obj", + "rh.white.Destrieux.S_postcentral.obj", + "rh.white.Destrieux.S_precentral-inf-part.obj", + "rh.white.Destrieux.S_precentral-sup-part.obj", + "rh.white.Destrieux.S_suborbital.obj", + "RH.WHITE.DESTRIEUX.S_SUBPARIETAL.OBJ", + "RH.WHITE.DESTRIEUX.S_TEMPORAL_INF.OBJ", + "RH.WHITE.DESTRIEUX.S_TEMPORAL_SUP.OBJ", + "RH.WHITE.DESTRIEUX.S_TEMPORAL_TRANSVERSE.OBJ", + "RH.WHITE.DESTRIEUX.UNKNOWN.OBJ" +}; diff --git a/src/BrainModelData.h b/src/BrainModelData.h new file mode 100644 index 0000000..2093b6d --- /dev/null +++ b/src/BrainModelData.h @@ -0,0 +1,22 @@ +// +// BrainModelData.h +// BrainFu_k +// +// Created by Murawaki on 2017/08/29. +// +// + +#include +#include "ofMain.h" + +#ifndef BrainModelData_h +#define BrainModelData_h + +struct BrainModelData { +public: + static const int modelNum = 152; + static const string basePath; + static const string modelNames[modelNum]; +}; + +#endif /* BrainModelData_h */ diff --git a/src/OSCManager.cpp b/src/OSCManager.cpp index e4e4fea..3ef7685 100644 --- a/src/OSCManager.cpp +++ b/src/OSCManager.cpp @@ -29,6 +29,13 @@ void OSCManager::update() { fft[i] = m.getArgAsFloat(i); } } + + /* Open_BCIからくる16chの脳波データ */ + if (m.getAddress() == "/of") { + for (int i = 0; i < 16; i++) { + bci[i] = m.getArgAsFloat(i); + } + } } //dumpOSC(m); diff --git a/src/OSCManager.hpp b/src/OSCManager.hpp index c7744d3..280d9a7 100644 --- a/src/OSCManager.hpp +++ b/src/OSCManager.hpp @@ -44,6 +44,7 @@ class OSCManager { } float fft[512]; + float bci[16]; void setup(); void update(); diff --git a/src/ofApp.cpp b/src/ofApp.cpp index fdcefd7..b2f4836 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -43,9 +43,17 @@ void ofApp::setup() { void ofApp::update() { OSCManager::get_instance().update(); + float cosPos = cos(ofGetElapsedTimef()/10); + float sinPos = sin(ofGetElapsedTimef()/10); + cam.lookAt(ofVec3f(0,0,0)); //cam.setPosition(300*cos(ofGetElapsedTimef()/10), 300*sin(ofGetElapsedTimef()/10), 0); - cam.setPosition(300*cos(cameraAngle/10), 300*sin(cameraAngle/10), 0); + if(cosPos > 0) { + cam.setPosition(300*cosPos, 300*sinPos, 0); + } else { + cam.setPosition(-300*cosPos, 300*sinPos, 0); + } + cam.rotate(270, cam.getLookAtDir()); brain.update(); @@ -54,6 +62,8 @@ void ofApp::update() { void ofApp::draw(){ ofEnableDepthTest(); + ofEnableBlendMode(OF_BLENDMODE_ADD); + cam.begin(); ofPushStyle(); diff --git a/src/ofDecomposeModel.cpp b/src/ofDecomposeModel.cpp index 9a3c929..8dd2286 100644 --- a/src/ofDecomposeModel.cpp +++ b/src/ofDecomposeModel.cpp @@ -18,6 +18,7 @@ void ofDecomposeModel::startDecompose() { for (int i=0; i 70) { + speeds[i].x = ofRandom(-12, 12); + speeds[i].y = ofRandom(-12, 12); + speeds[i].z = 5.5; + + //float alpha = (vectors[i].z - 100) / 100; + + //colors[i] = ofFloatColor(0.5, 0.8, 1.0, alpha); + //vectors[i].z = 100; + } else if(vectors[i].z > 200) { + state = decomposed; + } + } + } +} + //draw the model manually void ofDecomposeModel::draw() { switch (state) { @@ -52,27 +79,31 @@ void ofDecomposeModel::drawSolid() { void ofDecomposeModel::drawDecomposing() { float elapsedTime = ofGetElapsedTimef() - decomposeBeginTime; - - ofVboMesh mesh = getMesh(0); - - ofPushMatrix(); - - vector& verts = mesh.getVertices(); - for(unsigned int i = 0; i < verts.size(); i++) { - verts[i].y += elapsedTime * 10; - } - - ofSetColor(126, 230, 255, 200); - mesh.drawWireframe(); - ofPopMatrix(); - + /* + ofVboMesh mesh = getMesh(0); + + ofPushMatrix(); + + vector& verts = mesh.getVertices(); + for(unsigned int i = 0; i < verts.size(); i++) { + verts[i].z += elapsedTime * 10; + } + + //ofSetColor(126, 230, 255, 200); + //mesh.drawWireframe(); + ofPopMatrix();*/ ofVec3f vectorArray[vectors.size()]; + ofFloatColor colorArray[colors.size()]; for (int i=0; i vectors; + vector speeds; vector colors; void drawSolid(); void drawDecomposing(); public: + void update(); void draw(); void startDecompose(); + void setStateSolid(); }; #endif /* ofDisassemblyModel_hpp */ +