-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c9ef48
commit 0e59c76
Showing
6 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf330 | ||
{\fonttbl\f0\fnil\fcharset0 Monaco;} | ||
{\colortbl;\red255\green255\blue255;\red191\green0\blue0;\red0\green0\blue0;\red0\green0\blue191; | ||
\red96\green96\blue96;} | ||
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural | ||
|
||
\f0\fs18 \cf2 // Vorher Server Booten f\'fcr Sound\cf3 \ | ||
\ | ||
(\ | ||
w = \cf4 GUI\cf3 .window.new(\cf5 "Test the TNode Shit!"\cf3 , \cf4 Rect\cf3 (200,200,420,340));\ | ||
\ | ||
\cf2 // Nodes\cf3 \ | ||
~playNode = \cf4 FunctionTNode\cf3 (\cf4 nil\cf3 , \cf5 "Ding!"\cf3 , function: \{\cf4 |value|\cf3 (freq: value.midicps).play;value;\});\ | ||
\ | ||
~dumpNode = \cf4 DumpTNode\cf3 .new();\ | ||
\ | ||
~startNode = \cf4 ButtonTNode\cf3 (\cf4 nil\cf3 , \cf5 "Click"\cf3 );\ | ||
~randomFreq = \cf4 FunctionTNode\cf3 (\cf4 nil\cf3 , \cf5 "Random Note"\cf3 , function: \{\cf4 |value|\cf3 (48..72).choose\});\ | ||
~delayNode = \cf4 DelayTNode\cf3 (~playNode, \cf5 "Delay um 1s"\cf3 , delayTime: 1);\ | ||
~delay2Node = \cf4 DelayTNode\cf3 (\cf4 nil\cf3 , \cf5 "Delay um 0.5s"\cf3 , delayTime: 0.5);\ | ||
~machQuinte = \cf4 FunctionTNode\cf3 (~playNode, \cf5 "Quinte"\cf3 , function: \{\cf4 |value|\cf3 value + 7;\});\ | ||
~machTerz = \cf4 FunctionTNode\cf3 (~playNode, \cf5 "Terz"\cf3 , function: \{\cf4 |value|\cf3 value + 4;\});\ | ||
\ | ||
\cf2 // Verkabelung, beim erstellen der Nodes wurden schon einige Targets gesetzt\cf3 \ | ||
~startNode.target_(~randomFreq);\ | ||
~randomFreq.target_([~delayNode, ~delay2Node, ~machTerz, ~dumpNode]);\ | ||
~delay2Node.target_(~machQuinte);\ | ||
\ | ||
~startNode.gui(w, \cf4 Rect\cf3 (160,20,100,40));\ | ||
~randomFreq.gui(w, \cf4 Rect\cf3 (160,80,100,40));\ | ||
~delayNode.blink(w, \cf4 Rect\cf3 (20,140,100,40)); \cf2 // Delay wird noch ein eigenes GUI kriegen.\cf3 \ | ||
\cf2 // blink ist allerdings immer verf\'fcgbar.\cf3 \ | ||
~delay2Node.blink(w, \cf4 Rect\cf3 (160,140,100,40));\ | ||
~machQuinte.blink(w, \cf4 Rect\cf3 (160,200,100,40));\ | ||
~machTerz.blink(w, \cf4 Rect\cf3 (300,200,100,40));\ | ||
~playNode.gui(w, \cf4 Rect\cf3 (160, 260, 100,40));\ | ||
\ | ||
w.front;\ | ||
)\ | ||
\ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Classes that provide GUI as sole purpose | ||
|
||
/* | ||
ButtonTNode | ||
*/ | ||
|
||
ButtonTNode : ObjectTNode | ||
{ | ||
var button; | ||
|
||
gui {|win, bounds| | ||
|
||
bounds = bounds ? baseBounds; | ||
view = GUI.compositeView.new(win, bounds); | ||
button = GUI.button.new(view, bounds); | ||
button.states_([[name, guiFontColor, guiColor], [name, guiFontColor, guiPositiveColor]]); | ||
button.action_({|button| | ||
this.trigger(object); | ||
{ | ||
button.value = 0; | ||
}.defer(blinkTime); | ||
}); | ||
^view; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Control Structures | ||
|
||
/* | ||
BooleanFuncTNode | ||
*/ | ||
|
||
BooleanTNode : FunctionTNode | ||
{ | ||
process {|value| | ||
if(function.value(value) == false, | ||
{ | ||
doTrigger = false; | ||
}); | ||
^value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
// Base Class and Simple Helper TNodes | ||
|
||
/* | ||
TNode | ||
DumpTNode | ||
FunctionTNode | ||
SynthNode | ||
ObjectTNode | ||
*/ | ||
|
||
TNode | ||
{ | ||
var <>enabled = true; | ||
var <>target; | ||
var <lastValue; | ||
var <>name; | ||
|
||
var doTrigger = true; | ||
|
||
var <>triggerPost = nil; // Wenn dieser String gesetzt ist wird er bei jedem Trigger ausgegeben. | ||
// NatŸrlich stellt sich auch die Frage ob das nicht eigentlich Aufgabe einer | ||
// PostTNode Klasse wŠre. | ||
|
||
var <>guiColor; | ||
var <>guiPositiveColor; | ||
var <>guiNegativeColor; | ||
var <>guiFontColor; | ||
|
||
var blinkView = nil; | ||
var view = nil; | ||
var win = nil; | ||
|
||
var blinkButton; | ||
var <> blinkTime = 0.1; | ||
|
||
var baseBounds; | ||
|
||
*new {|target = nil, name = nil| | ||
^super.new.init(target, name); | ||
} | ||
|
||
init {|target, name| | ||
|
||
this.target = target; | ||
this.name = name; | ||
|
||
|
||
guiColor = Color.new(0.7,0.7,0.7); | ||
guiPositiveColor = Color.new(0.2,1,0.2); | ||
guiNegativeColor = Color.new(0.8,0,0); | ||
guiFontColor = Color.new(0,0,0); | ||
|
||
baseBounds = Rect(0,0,100,40); | ||
} | ||
|
||
process {|value = nil| | ||
// empty | ||
^value; | ||
} | ||
|
||
// Siehe auch BooleanFuncTNode | ||
trigger {|value = nil| | ||
doTrigger = true; | ||
if(enabled, | ||
{ | ||
|
||
if(triggerPost != nil, { | ||
triggerPost.postln; | ||
}); | ||
|
||
value = this.process(value); | ||
lastValue = value; | ||
|
||
if(doTrigger, { | ||
target.do{|item| | ||
if(item.respondsTo(\trigger),{ | ||
item.trigger(value); | ||
}); | ||
}; | ||
}); | ||
|
||
if(view != nil,{ | ||
this.processGui(value); | ||
}); | ||
|
||
if(blinkView != nil,{ | ||
this.processBlink(value); | ||
}); | ||
|
||
|
||
}); | ||
} | ||
|
||
asString { | ||
|
||
var retString; | ||
|
||
if(name == nil, { | ||
retString = "<" ++ this.class.asString ++ ">"; | ||
}, { | ||
retString = "<" ++ this.class.asString ++ " \"" ++ name ++ "\">"; | ||
}); | ||
|
||
^retString; | ||
} | ||
|
||
trace {|preString = nil| // Feedbacks fŸhren zum crash! | ||
|
||
if(preString == nil, | ||
{ | ||
preString = ""; | ||
}); | ||
|
||
preString = preString ++ this.asString; | ||
|
||
if(target.isArray, | ||
{ | ||
preString = preString ++ " --> <multiple targets, can't trace yet!>"; | ||
},{ | ||
if(target != nil, | ||
{ | ||
preString = preString ++ " --> "; | ||
preString = target.trace(preString); | ||
}); | ||
}); | ||
|
||
^preString; | ||
} | ||
|
||
window {|argName, bounds| | ||
|
||
bounds = bounds ? baseBounds; | ||
|
||
if(argName == nil, { | ||
argName = this.name; | ||
}); | ||
|
||
win = GUI.window.new(argName, bounds, false, true); | ||
view = this.gui(win); | ||
win.front; | ||
^win; | ||
} | ||
|
||
gui {|win, bounds| | ||
^this.blink(win, bounds); | ||
} | ||
|
||
blink {|win, bounds| | ||
|
||
bounds = bounds ? baseBounds; | ||
|
||
blinkView = GUI.compositeView.new(win, bounds); | ||
blinkButton = GUI.button.new(blinkView, bounds); | ||
blinkButton.states_([[name, guiFontColor, guiColor], [name, guiFontColor, guiPositiveColor]]); | ||
blinkButton.action_({|button| button.value = 0;}); | ||
^blinkView; | ||
} | ||
|
||
processBlink{|value| | ||
|
||
{blinkButton.value_(1);}.defer(0.0001); | ||
{blinkButton.value_(0);}.defer(blinkTime); | ||
|
||
} | ||
|
||
processGui{|value| | ||
// stub | ||
} | ||
} | ||
|
||
DumpTNode : TNode | ||
{ | ||
process {|value = nil| | ||
(this.asString ++ ":").post; | ||
if(value == nil,{ | ||
" Triggered".postln; | ||
},{ | ||
"".postln; | ||
value.dump; | ||
}); | ||
^value; | ||
} | ||
} | ||
|
||
FunctionTNode : TNode | ||
{ | ||
var <> function; | ||
|
||
*new {|target = nil, name = nil, function = nil| | ||
^super.new.init(target, name, function); | ||
} | ||
|
||
init {|target = nil, name = nil, function = nil| | ||
|
||
this.function = function; | ||
super.init(target, name); | ||
|
||
} | ||
|
||
process {|value| | ||
|
||
value = function.value(value); | ||
^value; | ||
} | ||
|
||
} | ||
|
||
SynthTNode : TNode | ||
{ | ||
var <> synth; | ||
var <> arguments; | ||
|
||
*new {|target = nil, name = nil, synth = nil, arguments = nil| | ||
^super.new.init(target, name, synth, arguments); | ||
} | ||
|
||
init {|target = nil, name = nil, synth = nil, arguments = nil| | ||
|
||
this.synth = synth; | ||
this.arguments = arguments; | ||
super.init(target, name); | ||
|
||
} | ||
|
||
process {|value| | ||
|
||
Synth.grain(synth,arguments); | ||
^value; | ||
} | ||
|
||
} | ||
|
||
|
||
ObjectTNode : TNode | ||
{ | ||
var <> object; | ||
|
||
*new {|target = nil, name = nil, object = nil| | ||
^super.new.init(target, name, object); | ||
} | ||
|
||
init {|target = nil, name = nil, object = nil| | ||
|
||
this.object = object; | ||
super.init(target, name); | ||
|
||
} | ||
|
||
process {|value| | ||
|
||
value = this.object.copy; | ||
^value; | ||
} | ||
} |
Oops, something went wrong.