Can you provide us with some code please so we can have a look for you 😀
from vpython import *
import math as m
import threading as th
from scamp import *
# s = Session()
#theramin = s.new_midi_part("theramin", "IAC Bus 1", start_channel=0, num_channels=1)
lengths = [
0.3438,0.3307,0.31836,0.3067,
0.2956,0.28516,0.27524, 0.26583,
0.2569, 0.2484, 0.24033,0.23264,
0.2253, 0.21833, 0.21166, 0.2053
]
class Pendulum:
def
init(self,length):
self.rod = cylinder(radius=0.001)
self.bob = sphere(radius=0.01)
self.length = length
self.theta = 7*m.pi/4
self.gravity = 0.003
self.theta_vel = 0
self.z = 0
self.s = Session()
def swing(self):
force = self.gravity * m.cos(self.theta)
theta_acc = (-1 * force) / self.length
self.theta_vel+=theta_acc
self.theta+=self.theta_vel
x = m.cos(self.theta)*self.length
y = m.sin(self.theta)*self.length
# +5000 moves the whole thing up on y axis
self.rod.axis=vector(x,y,self.z)
self.bob.pos=vector(x,y,self.z)
# self.bob.color=vector(1,0,0)#red
# self.bob.color=vector(1,0.5,0)#orange
# self.bob.color=vector(1,1,0)#yellow
# self.bob.color=vector(0,1,0)#green
# self.bob.color=vector(0,0,255)#blue
# self.bob.color=vector(0.29,0,0.51)#indigo
# self.bob.color=vector(0.5,0,1)#violet
if self.length == lengths[0] and (self.theta <= 5*m.pi/4 or self.theta >= 7*m.pi/4):
self.sound(0,48,0.5,0.1)
print("hit")
elif self.length == lengths[1] and (self.theta <= 5*m.pi/4 or self.theta >= 7*m.pi/4):
self.sound(1,53,0.5,0.1)
elif self.length == lengths[2] and (self.theta <= 5*m.pi/4 or self.theta >= 7*m.pi/4):
self.sound(2,60,0.5,0.1)
elif self.length == lengths[3] and (self.theta <= 5*m.pi/4 or self.theta >= 7*m.pi/4):
self.sound(3,65,0.5,0.1)
elif self.length == lengths[4] and (self.theta <= 5*m.pi/4 or self.theta >= 7*m.pi/4):
self.sound(4,72,0.5,0.5)
def sound(self,MIDI_ch, MIDI_note,volume,duration):
#self.s.new_midi_part("theramin", "IAC Bus 1", start_channel=0, num_channels=1)
self.MIDI_ch = MIDI_ch
self.MIDI_note = MIDI_note
self.volume = volume
self.duration = duration
self.s.new_midi_part("theramin", "IAC Bus 1", start_channel=self.MIDI_ch, num_channels=1).play_note(self.MIDI_note,self.volume,self.duration)
pendulums = [Pendulum(length) for length in lengths]
# for pendulum in pendulums:
# threads = [th.Thread(target = Pendulum, args = length,) for length in lengths]
#
# for thread in threads:
# thread.start()
# thread.join()
while True:
rate(25)
for i in pendulums:
i.swing()