예제 #1
0
violet = 255, 0, 255
black = 0,0,0
colorTable = [green, violet]

# and the alphabet
alphabet = {}
for i in range(24):
    alphabet[string.lowercase[i]] = i

# and the frequency bins
midiNotes = range(36,84) # 48 bins total
f0 = 44100./4096 # 10.76 hz
allFreqs = f0*np.arange(100) # 100 is the number of frequencies you send across, currently
freqBins = []
for m in midiNotes:
    iwhere = np.where((allFreqs>=m2h(m-0.5)) & (allFreqs<m2h(m+0.5)))
    freqBins.append(iwhere[0])

class RadiatingParticle():

    def __init__(self, appSize, direction, color=green, width=0):
        self.appSize = appSize
        self.xy = np.array([float(dim/2) for dim in self.appSize])
        self.size = 5
        self.color = color
        self.width = width
        self.direction = direction
        self.speed = 5.

    def display(self, screen):
        xy_intuple = (int(self.xy[0]), int(self.xy[1]))
예제 #2
0
#!/usr/bin/python

import liblo, time, random
import numpy as np
from pyo import midiToHz as m2h

# and the frequency bins
midiNotes = range(36,84,6) # 8 bins total
f0 = 44100./4096 # 10.76 hz
allFreqs = f0*np.arange(100) # 100 is the number of frequencies you send across, currently
freqBins = []
for m in midiNotes:
    iwhere = np.where((allFreqs>=m2h(m-3)) & (allFreqs<m2h(m+3)))
    freqBins.append(iwhere[0])

spidev = file('/dev/spidev0.0', 'wb')

class SoundPuddle():

    def __init__(self):
        self.nleds = 160
        self.sensitivity = 1.
        self.OSCserver = liblo.Server(8666)
        self.OSCserver.add_method(None, None, self.handleOSC)
        self.buff = bytearray(self.nleds*3)
        for i in range(len(self.buff)):
            self.buff[i] = 0x80
        self.zeros = bytearray(5)
        self.spokes = []
        for i in range(8):
            self.spokes.append([-1 for j in range(20)])
예제 #3
0
#!/usr/bin/python

import liblo, time, random
import numpy as np
from pyo import midiToHz as m2h

# and the frequency bins
midiNotes = range(36, 84, 6)  # 8 bins total
f0 = 44100. / 4096  # 10.76 hz
allFreqs = f0 * np.arange(
    100)  # 100 is the number of frequencies you send across, currently
freqBins = []
for m in midiNotes:
    iwhere = np.where((allFreqs >= m2h(m - 3)) & (allFreqs < m2h(m + 3)))
    freqBins.append(iwhere[0])

spidev = file('/dev/spidev0.0', 'wb')


class SoundPuddle():
    def __init__(self):
        self.nleds = 160
        self.sensitivity = 1.
        self.OSCserver = liblo.Server(8666)
        self.OSCserver.add_method(None, None, self.handleOSC)
        self.buff = bytearray(self.nleds * 3)
        for i in range(len(self.buff)):
            self.buff[i] = 0x80
        self.zeros = bytearray(5)
        self.spokes = []
        for i in range(8):