diff options
-rw-r--r-- | .ropeproject/config.py | 85 | ||||
-rw-r--r-- | SuperCollider/random241.scd | 106 | ||||
-rw-r--r-- | entropy_harvester/random241.log | 57 | ||||
-rw-r--r-- | remote_control/read_gpio.py | 54 |
4 files changed, 217 insertions, 85 deletions
diff --git a/.ropeproject/config.py b/.ropeproject/config.py deleted file mode 100644 index ffebcd4..0000000 --- a/.ropeproject/config.py +++ /dev/null @@ -1,85 +0,0 @@ -# The default ``config.py`` - - -def set_prefs(prefs): - """This function is called before opening the project""" - - # Specify which files and folders to ignore in the project. - # Changes to ignored resources are not added to the history and - # VCSs. Also they are not returned in `Project.get_files()`. - # Note that ``?`` and ``*`` match all characters but slashes. - # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' - # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' - # '.svn': matches 'pkg/.svn' and all of its children - # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' - # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' - prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject', - '.hg', '.svn', '_svn', '.git'] - - # Specifies which files should be considered python files. It is - # useful when you have scripts inside your project. Only files - # ending with ``.py`` are considered to be python files by - # default. - #prefs['python_files'] = ['*.py'] - - # Custom source folders: By default rope searches the project - # for finding source folders (folders that should be searched - # for finding modules). You can add paths to that list. Note - # that rope guesses project source folders correctly most of the - # time; use this if you have any problems. - # The folders should be relative to project root and use '/' for - # separating folders regardless of the platform rope is running on. - # 'src/my_source_folder' for instance. - #prefs.add('source_folders', 'src') - - # You can extend python path for looking up modules - #prefs.add('python_path', '~/python/') - - # Should rope save object information or not. - prefs['save_objectdb'] = True - prefs['compress_objectdb'] = False - - # If `True`, rope analyzes each module when it is being saved. - prefs['automatic_soa'] = True - # The depth of calls to follow in static object analysis - prefs['soa_followed_calls'] = 0 - - # If `False` when running modules or unit tests "dynamic object - # analysis" is turned off. This makes them much faster. - prefs['perform_doa'] = True - - # Rope can check the validity of its object DB when running. - prefs['validate_objectdb'] = True - - # How many undos to hold? - prefs['max_history_items'] = 32 - - # Shows whether to save history across sessions. - prefs['save_history'] = True - prefs['compress_history'] = False - - # Set the number spaces used for indenting. According to - # :PEP:`8`, it is best to use 4 spaces. Since most of rope's - # unit-tests use 4 spaces it is more reliable, too. - prefs['indent_size'] = 4 - - # Builtin and c-extension modules that are allowed to be imported - # and inspected by rope. - prefs['extension_modules'] = [] - - # Add all standard c-extensions to extension_modules list. - prefs['import_dynload_stdmods'] = True - - # If `True` modules with syntax errors are considered to be empty. - # The default value is `False`; When `False` syntax errors raise - # `rope.base.exceptions.ModuleSyntaxError` exception. - prefs['ignore_syntax_errors'] = False - - # If `True`, rope ignores unresolvable imports. Otherwise, they - # appear in the importing namespace. - prefs['ignore_bad_imports'] = False - - -def project_opened(project): - """This function is called after opening the project""" - # Do whatever you like here! diff --git a/SuperCollider/random241.scd b/SuperCollider/random241.scd new file mode 100644 index 0000000..94afe4d --- /dev/null +++ b/SuperCollider/random241.scd @@ -0,0 +1,106 @@ +( +s.waitForBoot{ +// s.makeWindow; + s.record; + OSCFunc.trace(true); + OSCFunc.trace(false); + //Dictionary for storing timing and related synths + ~tasks = Dictionary.new(); + //maximum allowed nodes on Server + ~maximumSynths = 55; + ~allowOSC = true; + ~test = 0; + // Filter SynthDef for post-processing + ~filter = SynthDef(\filter, {|in, mix = 0.68, room = 0.54, damp = 0.15, volume = 0.5| + in = In.ar(0, 2); + ReplaceOut.ar(0, + FreeVerb.ar( + in, + mix, + room, + damp + ) * volume + ); + }).play; + // OSCFunc for putting a task to the Dictionary and playing it + OSCFunc({ + |msg, time, address, receivingPort| + var task; + var synth; + var release = msg[1].asFloat; + var freqIn = msg[2].asFloat; + var ampIn = msg[3].asFloat; + if(~allowOSC, { +// ("msg: "++msg++" at port "++receivingPort++" from address "++address).postln; + //randomized SynthDef to be played + synth = SynthDef(time.asSymbol, {|out=0, attackTime=0.01| + var freq = freqIn.linexp(0.0, 1.0, 20, 18000); + var amplitude = ampIn; + var releaseTime = release; + var env = EnvGen.kr(//envelope to automatically release the Synth + Env.perc(attackTime, releaseTime, amplitude, -4), doneAction:2 + ); + var position = LinLin.kr([freqIn, ampIn].median, 0.0, 1.0, -1.0, 1.0); +// ("freq: "++freq++", amplitude: "++amplitude++", position: "++position).postln; + //TODO: make stereo by using pan! + Out.ar( + out, + Pan2.ar(// pan using median of freq and amplitude + Saw.ar( + freq, env, SinOsc.ar(//TODO: lower volume for bbb + freq, 0, env*0.5 + ); + ); + ), position + ); + }).add; + // Task for each SynthDef + task = Task.new({ + { + //play the synth and loop in its own length + synth.play; + msg[1].wait; + }.loop; + }); + NotificationCenter.notify(task, \stopped); + NotificationCenter.register(task, \stopped, ~test, { + ("Task has stopped").postln; + }); + // Put to Task Dictionary and play task (in a loop) + ~tasks.add(time.asSymbol -> task); + ~tasks.at(time.asSymbol).play; + //if the maximum number of synths is reached, remove the oldest + if(s.numSynths > ~maximumSynths,{ +// //get all Tasks ordered, remove the oldest +// ~tasks.atAll(~tasks.order).do({ +// arg item, i; +// if(i < (~tasks.size.asInt - ~maximumSynths.asInt),{ +// item.stop; +// }); +// }); + // disable OSC handling for now + ~allowOSC = false; + ~tasks.atAll(~tasks.order).do({ + arg item, i; + item.stop; + }); + s.stopRecording; + }); +// ("Number of synths playing: "++s.numSynths.asString).postln; + }); + }, '/random'); + // OSCFunc for analog inputs to set + // maximum numbers of synths, FreeVerb setttings + OSCFunc({ + |msg, time, address, receivingPort| + ("msg: "++msg++" at port "++receivingPort++" from address "++address).postln; + switch(msg[1].asSymbol, + \P9_39, ~filter.set(\mix, msg[2]), + \P9_40, ~filter.set(\room, msg[2]), + \P9_41, ~filter.set(\damp, msg[2]), + \P9_42, ~filter.set(\volume, msg[2]), + ); + }, '/analog'); +}; + +) diff --git a/entropy_harvester/random241.log b/entropy_harvester/random241.log new file mode 100644 index 0000000..77d2dbf --- /dev/null +++ b/entropy_harvester/random241.log @@ -0,0 +1,57 @@ +2014-02-14 20:58:59,399 Grabbing random numbers from: 640x480px. +2014-02-14 20:59:02,192 Balancing between one cluster. +2014-02-14 20:59:02,192 318.563838772, 366.493476925 +2014-02-14 20:59:02,192 318.563838772, 366.493476925 (balance mean) +2014-02-14 20:59:02,192 0.497755998081, 0.763528076927 (float) +2014-02-14 20:59:06,866 Balancing between one cluster. +2014-02-14 20:59:06,867 158.489023222, 122.496073032 +2014-02-14 20:59:06,867 238.526430997, 244.494774979 (balance mean) +2014-02-14 20:59:06,867 0.247639098784, 0.25520015215 (float) +2014-02-14 20:59:21,288 Balancing between one cluster. +2014-02-14 20:59:21,288 244.447148175, 206.511969209 +2014-02-14 20:59:21,288 240.50000339, 231.833839722 (balance mean) +2014-02-14 20:59:21,288 0.381948669024, 0.430233269186 (float) +2014-02-14 20:59:45,095 Balancing between one cluster. +2014-02-14 20:59:45,095 540.879599909, 363.808486106 +2014-02-14 20:59:45,095 315.59490252, 264.827501318 (balance mean) +2014-02-14 20:59:45,096 0.845124374858, 0.757934346054 (float) +2014-02-14 20:59:55,247 Balancing between a couple of clusters. +2014-02-14 20:59:55,247 140.694326683, 174.408694235 +2014-02-14 20:59:55,247 280.614787352, 246.743739902 (balance mean) +2014-02-14 20:59:55,247 0.219834885442, 0.363351446324 (float) +2014-02-14 21:00:03,442 Balancing between one cluster. +2014-02-14 21:00:03,443 248.094510127, 201.955945268 +2014-02-14 21:00:03,443 275.194741148, 239.279107463 (balance mean) +2014-02-14 21:00:03,443 0.387647672073, 0.420741552643 (float) +2014-02-14 21:00:18,271 Balancing between one cluster. +2014-02-14 21:00:18,271 330.475657259, 78.4864409544 +2014-02-14 21:00:18,271 283.092014878, 216.308726533 (balance mean) +2014-02-14 21:00:18,272 0.516368214467, 0.163513418655 (float) +2014-02-14 21:00:36,249 Balancing between one cluster. +2014-02-14 21:00:36,249 256.406174297, 476.751619252 +2014-02-14 21:00:36,250 279.756284806, 248.864088123 (balance mean) +2014-02-14 21:00:36,250 0.40063464734, 0.993232540108 (float) +2014-02-14 21:00:44,464 Balancing between one cluster. +2014-02-14 21:00:44,464 244.477272727, 0.0 +2014-02-14 21:00:44,464 275.836394575, 221.212522776 (balance mean) +2014-02-14 21:00:44,464 0.381995738636, 0.0 (float) +2014-02-14 21:00:54,979 Balancing between one cluster. +2014-02-14 21:00:54,979 422.452380952, 202.0 +2014-02-14 21:00:54,979 290.497993212, 219.291270498 (balance mean) +2014-02-14 21:00:54,979 0.660081845238, 0.420833333333 (float) +2014-02-14 21:01:43,662 Balancing between one cluster. +2014-02-14 21:01:43,662 159.037931016, 168.087604319 +2014-02-14 21:01:43,662 278.547078467, 214.636391755 (balance mean) +2014-02-14 21:01:43,662 0.248496767212, 0.350182508998 (float) +2014-02-14 21:02:33,203 Balancing between one cluster. +2014-02-14 21:02:33,203 430.690957968, 383.019316744 +2014-02-14 21:02:33,203 291.225735092, 228.66830217 (balance mean) +2014-02-14 21:02:33,203 0.672954621825, 0.797956909884 (float) +2014-02-14 21:02:37,488 Balancing between one cluster. +2014-02-14 21:02:37,488 490.821583091, 193.855915219 +2014-02-14 21:02:37,488 306.579261861, 225.990426251 (balance mean) +2014-02-14 21:02:37,488 0.76690872358, 0.403866490039 (float) +2014-02-14 21:02:59,852 Balancing between one cluster. +2014-02-14 21:02:59,852 416.487631031, 223.0 +2014-02-14 21:02:59,853 314.429859659, 225.776824376 (balance mean) +2014-02-14 21:02:59,853 0.650761923487, 0.464583333333 (float) diff --git a/remote_control/read_gpio.py b/remote_control/read_gpio.py new file mode 100644 index 0000000..6ddc4a5 --- /dev/null +++ b/remote_control/read_gpio.py @@ -0,0 +1,54 @@ +#a simple beaglebone black instrument, a/v, embedded systems, udk +#see https://github.com/redFrik/udk10-Embedded_Systems + +#this will read analog and digital sensors and send osc data locally to sc +#start it with 'sudo python thursday.py &' + +import Adafruit_BBIO.ADC as ADC +import Adafruit_BBIO.GPIO as GPIO +import time +import liblo as osc + + +#-- settings +analog_sensors= ["P9_39", "P9_40", "P9_41", "P9_42"] # customize here and add your own sensors +#digital_sensors= ["P9_41", "P9_42"] # customize here and add your own sensors +update_rate= 0.05 # time in seconds between each reading +# Define target for osc messages +target = osc.Address('127.0.0.1', 57120, osc.UDP) + +#-- init +ADC.setup() +for sensor in digital_sensors: + GPIO.setup(sensor, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) + + +def send_msg(name, sensor, value): + global target + msg = osc.Message(name) + msg.add(name) + msg.add(value) + try: + sc.send(target, msg) # send out osc + except: + pass # do nothing if seding failed + #print msg # debug + +def main(): + last= {} # remember sensor values in a dict + while True: + for sensor in analog_sensors: + #val= int(ADC.read_raw(sensor)) # 0-1799 + val= float(ADC.read(sensor)) # 0.0 - 1.0 + if last.get(sensor, None)!=val: + send_osc("/ana", sensor, val) + last[sensor]= val # store sensor value +# for sensor in digital_sensors: +# val= GPIO.input(sensor) # 0-1 +# if last.get(sensor, None)!=val: +# sendOSC("/dig", sensor, val) +# last[sensor]= val # store sensor value + time.sleep(update_rate) + +if __name__=='__main__': + main() |