Commit 4c8d39a4 authored by Arshia Cont's avatar Arshia Cont
Browse files

Finalizing HarmLib

parent 84a41950
......@@ -25,6 +25,7 @@ var GlobalGainMult;
var GlobalGainMess;
var GlobalGainLine;
var theSendTilde;
var theDbConvertor;
// subpatcher elements
var AudioInlet = new Array(64);
......@@ -32,6 +33,7 @@ var AudioOutlet = new Array(64);
var thePffts = new Array(64);
var theIntervalReceivers = new Array(64);
var theGainReceivers = new Array(64);
var theDbConvertors = new Array(64);
//// Instantiation arguments
// Arguments in order are: #ofSources #ofSpeakers TargetTime
......@@ -62,6 +64,7 @@ function Harms(val)
this.patcher.remove(GlobalGainMess);
this.patcher.remove(GlobalGainLine);
this.patcher.remove(theSendTilde);
this.patcher.remove(theDbConvertor);
for (k=0;k<numHarms;k++)
{
this.patcher.remove(HarmPatchers[k]);
......@@ -74,22 +77,24 @@ function Harms(val)
numHarms = a;
theMainInlet = this.patcher.newdefault(20,100, "inlet");
theMainOutlet = this.patcher.newdefault(20,300, "outlet");
var sendt = theNameSpace+'-out';
var sendt = theNameSpace+'_out';
theSendTilde = this.patcher.newdefault(100, 300, "send~", sendt);
// Global Gain Control
GlobalGainReceive = this.patcher.newdefault(500,25, "receive", 'hr-out-gain');
GlobalGainMess = this.patcher.newobject("message",500, 50,90,15, "$1 30");
GlobalGainLine = this.patcher.newdefault(500, 75, "line~");
GlobalGainReceive = this.patcher.newdefault(500,25, "receive", 'hr_out_gain');
theDbConvertor = this.patcher.newdefault(500, 50, "dbtoa");
GlobalGainMess = this.patcher.newobject("message",500, 75,90,15, "$1 30");
GlobalGainLine = this.patcher.newdefault(500, 100, "line~");
GlobalGainMult = this.patcher.newdefault(20,250, "*~", 0.01);
this.patcher.connect(GlobalGainReceive, 0, GlobalGainMess, 0);
this.patcher.connect(GlobalGainReceive, 0, theDbConvertor, 0);
this.patcher.connect(theDbConvertor, 0, GlobalGainMess, 0);
this.patcher.connect(GlobalGainMess, 0, GlobalGainLine, 0);
this.patcher.connect(GlobalGainLine, 0, GlobalGainMult, 1);
for (i=0; i<numHarms; i++)
{
var sin = theNameSpace+(i+1)+'-in'; // receive~ input name
var sout = theNameSpace+(i+1)+'-out'; // send~ output name
var sin = theNameSpace+(i+1)+'_in'; // receive~ input name
var sout = theNameSpace+(i+1)+'_out'; // send~ output name
theReceiveTildes[i] = this.patcher.newdefault(20+(i*100),150, "receive~", sin);
var snum = 'harm'+(i+1); // patcher name
var snum = theNameSpace+(i+1); // patcher name
HarmPatchers[i] = this.patcher.newdefault(20+(i*100),175, "patcher", snum);
HarmPatchers[i].subpatcher().wind.visible=0; // hide them!
HarmCreator(HarmPatchers[i].subpatcher(), i );
......@@ -122,17 +127,19 @@ function HarmCreator(thispatcher, u)
thispatcher.connect(AudioInlet[u], 0, thePffts[u], 0);
// build variable names
var interval_var = theNameSpace+(u+1)+'-interval';
var gain_var = theNameSpace+(u+1)+'-gain';
var interval_var = theNameSpace+(u+1)+'_interval';
var gain_var = theNameSpace+(u+1)+'_gain';
theIntervalReceivers[u] = thispatcher.newdefault(100, 20, "receive", interval_var);
theGainReceivers[u] = thispatcher.newdefault(50, 200, "receive", gain_var);
theGainReceivers[u] = thispatcher.newdefault(50, 175, "receive", gain_var);
theDbConvertors[u] = thispatcher.newdefault(50, 200, "dbtoa");
// Gain control
var messi = thispatcher.newobject("message",50, 225,90,15, "$1 30");
var linet = thispatcher.newdefault(50, 250, "line~");
var multip = thispatcher.newdefault(20, 275, "*~", 0.01);
thispatcher.connect(thePffts[u], 0, multip, 0);
thispatcher.connect(theGainReceivers[u], 0, messi, 0);
thispatcher.connect(theGainReceivers[u], 0, theDbConvertors[u], 0);
thispatcher.connect(theDbConvertors[u], 0, messi, 0);
thispatcher.connect(messi, 0, linet, 0);
thispatcher.connect(linet, 0, multip, 1);
thispatcher.connect(multip, 0, AudioOutlet[u], 0);
......
......@@ -8,79 +8,52 @@ print Lace test of 3: (@lace($t, 3))
;$index := [1,3,4]
;print Subindexing: ($t[($index)])
;$u := 1
;curve @command("hr"+$u+"-gain") 0.0, 1.0 1.0
;;;;;;;;; Load Library
@INSERT "zInclude/Lib_Stroppa-harms1.txt"
;;print Db -6.0 gives (@db2linear(-6.0))
curve hr-out-gain 0.0, 0.9 3.0
;;;;;;;;;;;; INITIALIZATIONS
::InitHarms(5)
::InitHarms(5, "hr")
curve hr_out_gain -150.0, 0.0 3.0 ; All Gain values are in DB
::trans([100, -100],3.0)
NOTE C4 5.0 Trans_OfSilence
2.0 abort ::trans
print called abort??
::trans([100, -100, -50, 50],3.0)
NOTE C4 5.0
;2.0 abort ::trans
NOTE C#4 3.0 GainControl
/*NOTE D4 5.0
curve hr-out-db-ctrl 0.0 500ms
curve hr1-out 0. 300ms
loop hr1-baland 2.0 @abort:= { curve hr1-out -96. 60ms }
loop gc 2.0
{
curve slider @Grain := 0.05s, @Action :=
{
@harm(1, $hr1)
}
{
$hr1
{
{ -1. } ;@type "exp"
1 { 1. }
1 { -1. }
}
}
::transgain([1, 2, 3, 4], [-50.0, -12.0, -12.0, -32.0], 1.0)
1.0 ::transgain([1, 2, 3, 4], [-12.0, -50.0, -32.0, -12,0], 1.0)
}
NOTE D4 5.0
abort gc
NOTE E4 5.0 SingleHarm-Jitter
curve hr-out-db-ctrl 0.0 500ms
curve hr1-out 0. 300ms
loop hr1-jitter 200ms @abort:= { curve hr1-out -96. 60ms }
{
curve slider @Grain := 0.01s, @Action :=
{
@harm(1, $hr1)
}
{
$hr1
{
{ -0.25 } ;@type "exp"
100ms { 0.25 }
100ms { -0.25 }
}
}
}
abort ::trans
abort hr1-jitter
::transgain([1], [-3.0], 1.0)
curve hr1-out 0. 300ms
$random1 := @random()
loop hr1-jitter2 200ms @abort:= { curve hr1-out -96. 60ms }
$random1 := @random()
loop hr1-jitter2 200ms @abort:= { curve hr1_gain -96. 60ms }
{
@local $temp
curve slider @Grain := 0.01s,
@Action :=
{
$temp := $hr1
@harm(1, $hr1)
::set_harminterval(1, $hr1)
}
{
$hr1
......@@ -93,19 +66,15 @@ loop hr1-jitter2 200ms @abort:= { curve hr1-out -96. 60ms }
200ms $random1 := $temp
}
abort hr1-jitter2
NOTE F4 5.0 Trans
abort hr1-jitter2
curve hr1-out 0. 300ms
curve hr2-out 0. 300ms
::trans( [-200, 200], 2.0)
curve hr3-out 0. 300ms
::trans( [-100, 100, -50], 5.0)
2.0 ::trans( [-100, 100, -50], 5.0)
curve hr4-out 0. 300ms
::trans( [-100, 100, -50, 50], 2.0)
2.0 ::trans( [-100, 100, -50, 50], 2.0)
NOTE G4 5.0 Trans-Reordering
......@@ -114,23 +83,20 @@ abort ::trans
;;; IMPORTANT NOTE: The above is NOT effective if ::trans has already finished (auto-kill) like a Group
curve hr1-out 0. 300ms
curve hr2-out 0. 300ms
curve hr3-out 0. 300ms
curve hr4-out 0. 300ms
;;; Scrambling (random re-ordering)
$transpositions := [ -75, -25, 25, 75]
$loop := 2.0
print Scramble Transposition
loop scramble $loop
{
::trans($transpositions, $loop)
$loop $transpositions := @scramble($transpositions)
}
abort scramble
4.0 abort scramble
print Permutation Transposition
;;; Permuting the same list in a loop
$transpositions := [ -75, -25, 25, 75]
$loop := 2.0
......@@ -141,8 +107,9 @@ loop permutation $loop
$loop $transpositions := @permute($transpositions, (@rand_int(@size($transpositions))))
}
abort permutation
4.0 abort permutation
print Order_Reversal Transposition
;;; Order reversal
$transpositions := [ -75, -25, 25, 75]
$loop := 2.0
......@@ -153,8 +120,8 @@ loop reversal $loop
$loop $transpositions := @reverse($transpositions)
}
abort reversal
4.0 abort reversal
print Rotating Transposition
;;; Rotation
$transpositions := [ -75, -25, 25, 75]
$loop := 2.0
......@@ -165,9 +132,7 @@ loop rotate $loop
$loop $transpositions := @rotate($transpositions, 1) ; use negative for left rotation
}
abort rotate
*/
4.0 abort rotate
print yo
......@@ -8,7 +8,7 @@
"architecture" : "x86"
}
,
"rect" : [ 151.0, 45.0, 779.0, 419.0 ],
"rect" : [ 10.0, 45.0, 779.0, 419.0 ],
"bglocked" : 0,
"openinpresentation" : 1,
"default_fontsize" : 12.0,
......@@ -28,68 +28,6 @@
"digest" : "",
"tags" : "",
"boxes" : [ {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-11",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 621.0, 197.0, 81.0, 20.0 ],
"presentation" : 1,
"presentation_rect" : [ 549.0, 184.0, 81.0, 20.0 ],
"text" : "print hr1-gain"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-14",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 621.0, 163.0, 62.0, 20.0 ],
"presentation" : 1,
"presentation_rect" : [ 549.0, 150.0, 62.0, 20.0 ],
"text" : "r hr1-gain"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-8",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 492.0, 265.0, 97.0, 20.0 ],
"presentation" : 1,
"presentation_rect" : [ 656.0, 179.0, 97.0, 20.0 ],
"text" : "print hr1-interval"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 12.0,
"id" : "obj-5",
"maxclass" : "newobj",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 492.0, 231.0, 78.0, 20.0 ],
"presentation" : 1,
"presentation_rect" : [ 656.0, 150.0, 78.0, 20.0 ],
"text" : "r hr1-interval"
}
}
, {
"box" : {
"bgcolor" : [ 0.0, 1.0, 1.0, 1.0 ],
"fontface" : 1,
......@@ -1851,15 +1789,6 @@
"source" : [ "obj-12", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-11", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-14", 0 ]
}
}
, {
"patchline" : {
......@@ -2067,15 +1996,6 @@
"source" : [ "obj-43", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-5", 0 ]
}
}
, {
"patchline" : {
......@@ -2232,14 +2152,14 @@
}
],
"parameters" : {
"obj-84::obj-32" : [ "[9]", "[2]", 0 ],
"obj-84::obj-35" : [ "[9]", "Level", 0 ],
"obj-76::obj-21::obj-6" : [ "live.tab[3]", "live.tab[1]", 0 ],
"obj-25" : [ "harms.gain~", "harms.gain~", 0 ],
"obj-76::obj-35" : [ "[5]", "Level", 0 ],
"obj-4" : [ "Amplification", "Amplification", 0 ],
"obj-84::obj-21::obj-6" : [ "live.tab[1]", "live.tab[1]", 0 ],
"obj-76::obj-32" : [ "[8]", "[2]", 0 ],
"obj-84::obj-35" : [ "[10]", "Level", 0 ]
"obj-84::obj-32" : [ "[10]", "[2]", 0 ]
}
,
"dependency_cache" : [ {
......
......@@ -4,26 +4,69 @@
Gain Control in DB (0.0 is linear 1.0)
*/
/******* DOCUMENTATION
NAMESPACE:
- The name space is defined by a PREFIX string (typically 'hr') upon Initialization (see below). This will produce the following controls:
<PREFIX>_out_gain : The overall Gain control in DB values (use Simplified Curves for memory maintenance)
example: curve hr_out_gain -150, 0.0 3.0 ; will fade from -150DB to 0.0 DB in 3 beats
<PREFIX>N_interval : The interval in MIDICents for Harmonizer N
example: hr1_interval @midicent2pitchfactor(-100) ; will send to harmonizer 1
<PREFIX>N_gain : The gain control in DB for harmonizer N. Use simplified curve for memory maintenance.
example: curve hr1_gain -6.0, -150.0 3.0 ; will fade out harmonizer 1 in 3 beats
INITIALIZATION:
- use ::InitHarms(INT, NAMESPACE) where INT is the Number Of Harmonizers in your patch, NAMESPACE is a string refering to <PREFIX>
SIMPLIFIED PROCESSES:
- Convenient processes for accesing each Harmonizer elements:
::set_harmgain($index, $value) , value is in DB. Values below $MINIMUM_HARM_DBLEVEL will MUTE the PFFT
::set_harminterval($index, $value) , value is in MIDICENTS
- ::trans process : Automation process on Intervals with Passive Gains
syntax: ::trans($transtable, $time)
$transtable : Table of interval values (in MIDI Cents)
$time : Time to achieve $transtable
This process will automatically activate and use the FIRST harmonizers in the list starting on index 1
Aborting the process while in use will Fade out and MUTE ongoing transpositions.
Aborting when the process is done has NO EFFECT.
- ::transgain process: Automation process on GAINS ONLY
syntax: ::transgain($destinations, $gains, $time)
$destinations : Table of harminozer index. Ex: [1, 3, 5]
$Gains : Destination gain in DB (table of same size as $destinations)
$time : duration for attaining $Gains
It is possible to launch several ::transgain on different destinations
Values are globally stored.
********/
$GlobalHarmNamespace := "toto"
; Initialize and (re)construct $source structure
@proc_def ::InitHarms($NumberOfSources)
@proc_def ::InitHarms($NumberOfSources, $NameSpace)
{
abort ::trans
$GlobalHarmNamespace := $NameSpace
;; (re)define source structure
$harmintervals := [ 0.0 | ($NumberOfSources)]
$harmgains := [ 0.0 | ($NumberOfSources)]
print The harmonizer matrix has dimension reset with @size($harmgains) harmonizers
$harmgains := [ -150.0 | ($NumberOfSources)]
print The harmonizer namespace ($GlobalHarmNamespace) has dimension reset with @size($harmgains) harmonizers
;; (re)instantiate source processes
$t := tab [$x | $x in $NumberOfSources]
forall $x in $t
{
curve @command("hr"+($x+1)+"-gain") 0.0, 0.0 50ms
;@command("hr"+($x+1)+"-gain") 0.0 ; linear
@command("hr"+($x+1)+"-interval") mute 1
curve @command($GlobalHarmNamespace+($x+1)+"_gain") -150.0, -150.0 50ms
;@command($GlobalHarmNamespace+($x+1)+"_gain") 0.0 ; linear
@command($GlobalHarmNamespace+($x+1)+"_interval") mute 1
}
hr-out-gain 0.0 ;; turns off global gain (linear)
hr_out_gain -150.0 ;; turns off global gain (linear)
}
$MINIMUM_HARM_DBLEVEL := -120.0
$MINIMUM_HARM_DBLEVEL := -150.0
;;;;;;;;; Definition of global variables for Harmonizers
; define $initlevels here in case it is undefined. User definition SHOULD come next (after @include)
......@@ -44,21 +87,21 @@ if (@is_undef($harmgains))
; linear = 10^(db/20)
;; Convenience macros for each harmonizer
;; Convenience macros for each harmonizer -- ONLY SETS the interval!
@macro_def harm($num,$x)
{
;;; Set local level value and shut off if zero
if ($x=0.0)
/*if ($x=0.0)
{
@command("hr"+$num+"-gain") @db2linear($MINIMUM_HARM_DBLEVEL)
50ms @command("hr"+$num+"-interval") mute 1
@command($GlobalHarmNamespace+$num+"_gain") ($MINIMUM_HARM_DBLEVEL)
50ms @command($GlobalHarmNamespace+$num+"_interval") mute 1
}else
{
@command("hr"+$num+"-interval") mute 0
@command("hr"+$num+"-gain") ($harmnorm)
}
@command($GlobalHarmNamespace+$num+"_interval") mute 0
@command($GlobalHarmNamespace+$num+"_gain") ($harmnorm)
}*/
;;; Set harm value
@command("hr"+$num+"-interval") (@pow(2., ( $x/100.0)/12.0))
@command($GlobalHarmNamespace+$num+"_interval") (@midi2pitchfactor($x))
let $harmintervals[($num-1)] := $x
}
......@@ -72,21 +115,19 @@ if (@is_undef($harmgains))
* Aborting the process will set all values back to 0.0 after fadeout
*
*/
@PROC_DEF trans($transp, $dur)
@PROC_DEF ::trans($transp, $dur)
@abort :=
{
print Aborting ($transp_temp)
;print Aborting ($transp_temp)
@local $initkoo, $fadeout, $tt, $koo
$initkoo := (@lace($harmgains, @size($transp)))
$fadeout := [ ($MINIMUM_HARM_DBLEVEL) | (@size($transp_temp)) ]
print INITKOO ($initkoo) ____ FADEOUT ($fadeout)
; use a curve to set gain to $MINIMUM_HARM_DBLEVEL
curve abortfoo @grain := 0.03s,
@action :=
{
print in Curve with initial value (@lace($initkoo, @size($transp))) and ending at ($fadeout) _ shutting down with ($koo)
;print in Curve with initial value (@lace($initkoo, @size($transp))) and ending at ($fadeout) _ shutting down with ($koo)
$tt := tab [$u | $u in (@size($transp_temp)) ]
forall $u in $tt
{
......@@ -101,7 +142,7 @@ if (@is_undef($harmgains))
}
}
;curve @command("hr"+($u+1)+"-gain") 0.0 50ms
;curve @command($GlobalHarmNamespace+($u+1)+"_gain") 0.0 50ms
;90ms ::set_harminterval( ($u+1), @midi2pitchfactor(0.0))
abort trans_curve
......@@ -111,11 +152,28 @@ if (@is_undef($harmgains))
$harmnorm := (20* @log10(1.0/@size($transp)))
print normalization factor is ($harmnorm) for (@size($transp)) voices
@local $transp_temp
@local $transp_temp, $t
$transp_temp := $transp
;print Trans request on ($transp)
;;; Turn them on slowly if not already
$t := tab [$u | $u in (@size($transp))]
forall $u in $t
{
curve cg @grain := 0.03s,
@action :=
{
::set_harmgain($u+1, $xgcurve)
}
{
$xgcurve
{
{ ($harmgains[$u])}
300ms { ($harmnorm) }
}
}
}
;;; launch curve interpolation
curve trans_curve @grain := 0.03s,
@action :=
......@@ -123,10 +181,9 @@ if (@is_undef($harmgains))
$t := tab [$u | $u in (@size($transp))]
forall $u in $t
{
@command("hr"+($u+1)+"-interval") mute 0
@command($GlobalHarmNamespace+($u+1)+"_interval") mute 0
::set_harminterval($u+1, $xcurve[$u])
::set_harmgain($u+1, $harmnorm)
print Sending ((@midi2pitchfactor(($xcurve[$u])))) to Harm Number ($u+1)
;print Sending ((@midi2pitchfactor(($xcurve[$u])))) to Harm Number ($u+1)
}
}
{
......@@ -139,6 +196,35 @@ if (@is_undef($harmgains))
}
// Transposition GAIN control by INDEX(es), Passive on Intervals
// Automatically mutes if gain is less than $MINIMUM_HARM_DBLEVEL
@PROC_DEF ::transgain($destinations, $gains, $dur)
{
@local $transg_temp, $initialg, $t
$transg_temp := $gains
$initialg := $harmgains
;print Trans request on ($transp)
;;; launch curve interpolation
$t := tab [$u | $u in (@size($destinations))]
forall $u in $t
{
curve trans_gain @grain := 0.03s,
@action :=
{
::set_harmgain( ($destinations[$u]) , $xcurve)
}
{
$xcurve
{
{ ($initialg[$u]) }
$dur { ($transg_temp[$u]) }
}
}
}
}
/* Transposition Automation process on Intervals with NO EFFECT on Gains
* Arguments:
......@@ -149,7 +235,7 @@ if (@is_undef($harmgains))
* Aborting the process will set all values back to 0.0 after fadeout
*
*/
@PROC_DEF transinterval($destinations, $intervals, $dur)
@PROC_DEF ::transinterval($destinations, $intervals, $dur)
@abort :=
{
print abort request on trans
......@@ -181,7 +267,7 @@ if (@is_undef($harmgains))
{
forall $u in $transdest
{
@command("hr"+($u)+"-interval") mute 0
@command($GlobalHarmNamespace+($u)+"_interval") mute 0
::set_harminterval($u, $xcurve[$u])
;print Sending ((@midi2pitchfactor(($xcurve[$u])))) to Harm Number ($u+1)
}
......@@ -195,66 +281,6 @@ if (@is_undef($harmgains))
}
}
/* Transposition Automation process on Gains
* Arguments:
* $transtab: table consisting of destination values.
* $dur: duration for interpolation
* Note: Always departs from last value of the harmonizer table $harmvals
* Aborting the process will set all values back to 0.0 after fadeout
*
*/
@PROC_DEF transgain($transp, $dur)
@abort :=
{