From a8e5d7c9264fb203f4d07f3e338bd5919e876ab5 Mon Sep 17 00:00:00 2001 From: rgarcia-herrera Date: Mon, 28 Oct 2024 20:58:45 -0600 Subject: [PATCH] procesos se hacen frases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit usando digitos del pid como indices de una escala, las notas se espacían en un compás de ocho octavos usando el algoritmo euclidiano con todo y caminador aleatorio --- mupah/__init__.py | 22 ++++++++++++++++++++++ euclidean.py => mupah/euclidean.py | 0 ps_random_walk.py | 14 ++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 mupah/__init__.py rename euclidean.py => mupah/euclidean.py (100%) diff --git a/mupah/__init__.py b/mupah/__init__.py new file mode 100644 index 0000000..2720cdf --- /dev/null +++ b/mupah/__init__.py @@ -0,0 +1,22 @@ +from mupah.euclidean import euclidean_rythm + + +def eighths_scale(p, scale): + + hits = len(str(p.pid)) + + if hits < 8: + length = 8 + elif hits >= 8 and hits < 16: + length = 16 + + rythm = euclidean_rythm(k=hits, n=length) + + for i in list(str(p.pid)): + rythm = rythm.replace('X', i, 1) + + phrase = [0 if i == '.' + else scale[int(i) % 8] + for i in list(rythm)] + + return phrase diff --git a/euclidean.py b/mupah/euclidean.py similarity index 100% rename from euclidean.py rename to mupah/euclidean.py diff --git a/ps_random_walk.py b/ps_random_walk.py index b4775d9..301b98c 100644 --- a/ps_random_walk.py +++ b/ps_random_walk.py @@ -1,13 +1,17 @@ import psutil import random from time import sleep +from mupah import eighths_scale +import mingus.core.scales as scales + +scale = scales.Aeolian("C").ascending() def reporta(p): - binario = bin(p.pid).replace('0b', '') - return p.pid, binario, binario[0:7], len(str(p.pid)), len(p.name()) + print(eighths_scale(p, scale), p.name()) + p = psutil.Process(pid=random.choice(psutil.pids())) print('random chose', reporta(p)) @@ -20,10 +24,12 @@ while True: p = psutil.Process(pid=random.choice([subp.pid for subp in children])) - print("\t↳", reporta(p)) + print("\t↳", end="") + reporta(p) else: p = psutil.Process(pid=random.choice(psutil.pids())) - print('→', reporta(p)) + print('→', end="") + reporta(p)