Help coding

Hello here is my actual mode coding state :

import os
import pygame
import time
import random
import math

def setup(screen, etc):
global last_point, last_point1, xr, yr, zehn, y72, x180
xr = etc.xres
yr = etc.yres
last_point = [xr/4, 0]
last_point1 = [xr/4, 0]
zehn = (200xr)/1280
y72 = int((72
x180 = (360*xr)/1280

def draw(screen, etc):
global last_point, last_point1, zehn, y72, x180, xr,yr
linewidth = int(etc.knob1zehn)+1
lines = int(y72)
spacehoriz = (x180
spacevert = spacehoriz
color = etc.color_picker(etc.knob4)

for j in range(0, lines) :
    space = j*spacehoriz

    pygame.draw.line(screen, color, (0,space), (xr,space), linewidth)

Here is a pics to give a global idea.

Can someone write me the lines for :

  • Add on knob 3 a global rotation of all my lines
  • Make that the audio/midi trig activate Knob 1 function (linewidth in this code)
  • last question whats the line code to make the trig button stay active when we hold it ? For now when i create a " if " then " else" event , the trig button just fire the action once even if i hold the button he dont hold the action i want when my finger stay pressed
1 Like

You may want to check out the code for a similar looking effect, called “T - Rotation Grid - Trails”. It’s in the Etc section on patchstorage, here’s a link: T - Rotation Grid-Trails | Patchstorage
It uses the audio to rotate instead of change the line width. But, it probably can be re-worked to accomplish your goals. You’ll want to add a line referencing the “etc.audio_in” component to get sound interacting with your mode. It looks like the rotation is achieved by using sin and cos methods.
I recommend downloading that patch, and clearing away irrelevant parts of the code so you can figure out how it makes a single grid rotate. Then, copy that into your mode, but use a knob instead of the audio, and then add a reference to use the audio value in your for loop. Something like:
def draw(screen, etc):
#define globals, then all your other code, plus rotate code. Then:

for j in range(0, lines) :
    space = j*spacehoriz
    sound=abs(etc.audio_in[j%100]) /300 #may want to change 300 value to something else
    linewidth2 = linewidth + sound
    pygame.draw.line(screen, color, (0,space), (xr,space), linewidth2)

Hope that is enough to figure it out!

1 Like