h = HarmonicVector.with([0,3,0])

1200 - h.cents

1.addCents(1200-h.cents).asRatio

// different representations of h:

HarmonicVector.repr = \vector 

HarmonicVector.repr = \reduced

HarmonicVector.repr = \ratio

HarmonicVector.repr = \pow2

HarmonicVector.repr = \reducedRatio //back to default


a = HarmonicVector.with([-2])

b = HarmonicVector.with([2,-1])

a + b

a - b

b - a

a * b

a / b

b / a


(b - a).cents; // difference is a syntonic comma

(a + b).cents; // sum is a just minor sixth:

1.addCents(813.6862).asRatio; 


(a * b).cents; // what does mult mean?

1.addCents(792.17999).asRatio; // a low sixth?

(a + b) - (a * b); // which is a syntonic comma away from the sum? Mult as a simmetric sum?


(a/b).cents; // and what about division? It gives a 4/3?


// the following is very interesting:

(a / b) * (b - a); // a fourth times a comma the sixth lowered by a syntonic comma

(a / b) / (b - a); // fourth dividied by comma: unison!

(a / b) + a; // fourth plus 3 lim min 7: pyth maj6

(a / b) + b; // fourth plus 5 lim min 7: 5 lim min3

(a / b) * a; // error, check what going on...


(a * b) * (a / b); // does not compute

(a * b) / (b - a)


w = HarmonicVector.from([3,2]);

x = HarmonicVector.from([16,15]);

w + x

w - x

w / x; // strange, again 4/3

w * x; // Error!


c = HarmonicVector.with([12]); // Pithagorean comma

c.cents.round(0.001)

1.addCents(c.cents).asRatio; 


e = HarmonicVector.with([0,0,3])

f = HarmonicVector.with([-1])

g = e - f

g.cents

1.addCents(g.cents).asRatio


j = HarmonicVector.with([12,0,0])

k = HarmonicVector.with([4,-1])

j - k

j + k

1.addCents((j-k).cents).asRatio


m = HarmonicVector.with([3,2,2])

1.addCents(m.cents).asRatio


HarmonicVector.with([2,2,-1])

HarmonicVector.with([-7,4,1])


/*  */


z = ();

z.d = Object.readArchive("/docs/supercolaider/Dissonance\ Curves/pitch_sets/even\ harmonics\ \[16,\ 4\ oct\].dis"); 

z.v = z.d.ratios.asHvector

z.v.do(_.postln)


z.v[19].vector


HarmonicVector.from([256,27]);

z.d.play

/*   */


x.magnitude

x.ratio.harmonicDistance

x.vector.normalize


~comma1 = HarmonicVector.with([2,2,-1])

~comma2 = HarmonicVector.with([-7,4,1])

~comma3 = HarmonicVector.with([12])

~comma4 = HarmonicVector.with([4,-1])

w = HarmonicVector.from([3,2]);

x = HarmonicVector.from([16,15]);

y = HarmonicVector.from([7,4]);

~comma2.isInIsland

x.isInIsland

y.isInIsland

x.reduced

y.reduced

~um = [[-1,3,2],[-7,-1,3],[2,2,1]];

x.isInIsland(~um)


~harmonic = [];

~timbral = [];

~partition = {|pitchSet|

pitchSet.do{|pitch|

if (pitch.isInIsland(~um)) {

~harmonic = ~harmonic.add(pitch)

}{

~timbral = ~timbral.add(pitch)

}

}

};


~partition.(z.v)


~harmonic.size

~timbral.size


~harmonic.do(_.postln)

~timbral.do(_.postln)

~harmonic[0].reduced


~comma1 - x

~comma3.magnitude

x.magnitude

v = HarmonicVector.with([2,3,-1])

v.vector.magnitude


z.harmIsland = [];

z.timbrIsland = [];

z.v.collect{|x| 

if(x.magnitude.postln < ~comma4.magnitude) {

z.harmIsland = z.harmIsland.add(x)

}{

z.timbrIsland = z.timbrIsland.add(x)

}

}


z.timbrIsland

z.harmIsland.size

z.v.size



/*artículo fokker:*/



HarmonicVector.with([2,2,-1])

HarmonicVector.with([-6,-2,-1])

HarmonicVector.with([2,-6,1])

HarmonicVector.with([4,1,-2])

HarmonicVector.with([1,6,-2])



[[3,2]].asHvector


[ [-5, -2, 2]].toHVector[0].cents

[ [-4,3,3]].toHVector[0]




~unisonmatrix = [ [4, 2, 0], [4, -3, 2], [2, 2, -1] ];

~isInIsland = {|vector| var max, min, tvect, truth=true;

max = ~unisonmatrix.collect{|x| max(0,x)};

min = ~unisonmatrix.collect{|x| min(x,0)};

max = max.flop.collect{|x| x.maxItem};

min = min.flop.collect{|x| x.minItem};

[min,max].postln;

tvect = vector.collect{|v,i| v.inclusivelyBetween(min[i], max[i])};

tvect.collect{|x| if (x!=true) {truth = false}};

truth

};

~isInIsland.([4,-3,2]);

~partitionIsland = {|pitchSet|

};


~max


~mm = ~max.flop.collect{|x| x.maxItem};

~mn = ~min.flop.collect{|x| x.minItem};

([0,3,1] <= ~mm) and: ([0,1,1] >= ~mn)


~tvect = [0,3,1].collect{|v,i| v.inclusivelyBetween(~mn[i], ~mm[i])};

~truth = true;

~tvect.collect{|x| if (x == true) {}{~truth = false}}

~truth