Exemplo n.º 1
0
def stop():
    c = OSC.OSCClient()
    c.connect(('127.0.0.1', 4557))  # connect to SuperCollider
    sendCmd("/stop-all-jobs")
    return redirect(url_for('my_form'))
Exemplo n.º 2
0
class PiException(Exception):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)


##########################
#	OSC##########################

# Initialize the OSC server and the client.
s = OSC.OSCServer(receive_address)

# initialise sending
c = OSC.OSCClient()
c.connect(send_address)

# initialise SuperCollider connection
scclient = OSC.OSCClient()
scclient.connect(SC_address)

# initialise Processing connection
processingclient = OSC.OSCClient()
processingclient.connect(Processing_address)

# load default handlers
s.addDefaultHandlers()


# define a message-handler function for the server to call.
Exemplo n.º 3
0
 def __init__(self, endpoint, host='127.0.0.1', port=8001):
     self.client = OSC.OSCClient()
     self.client.connect((host, port))
     self.endpoint = endpoint
Exemplo n.º 4
0
/character/letter
/character/symbol
/character/linebreak
"""

import os, random, time, sys, OSC, threading, re

#declaring OSC Addresses
receive2_address = '127.0.0.1', 9998  #Mac Adress, Outgoing Port
SC_address = '127.0.0.1', 57120
qlc_address = '127.0.0.1', 7700
python_address = '127.0.0.1', 9999
# Initialize the OSC server and the client.
s = OSC.OSCServer(receive2_address)
# initialise SuperCollider connection
scclient = OSC.OSCClient()
scclient.connect(SC_address)
# initialise qlc connection
qlcclient = OSC.OSCClient()
qlcclient.connect(qlc_address)
# initialise python master connection
pythonclient = OSC.OSCClient()
pythonclient.connect(python_address)
s.addDefaultHandlers()


# Exception class (nopt used)
class PiException(Exception):
    def __init__(self, value):
        self.value = value
Exemplo n.º 5
0
# >python tracking.py model_3d.txt
# the argument is the name of a file containing a list of 3D points of a model
# see glasses.txt for an example

# import necessary modules

import cv2.cv as cv
import time
import numpy
from math import *
import sys
import OSC

#send OSC tracking message in the network
client = OSC.OSCClient()
client.connect(('127.0.0.1', 7000))

# capture frame from available camera
capture = cv.CaptureFromCAM(0)

# get image size
testframe = cv.QueryFrame(capture)
size_image = cv.GetSize(testframe)
print "image is size %d x %d" % size_image

# images for base processing

# RGB format
rgb_image = cv.CreateImage(size_image, 8, 3)
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
##########################################################################

import sys
sys.path.append('../../sensel-lib-wrappers/sensel-lib-python')
import sensel
import binascii
import threading
import OSC
import time

oscClient = OSC.OSCClient()
oscClient.connect(("127.0.0.1", 7500))

enter_pressed = False


def waitForEnter():
    global enter_pressed
    raw_input("Press Enter to exit...")
    enter_pressed = True
    return


def openSensel():
    handle = None
    (error, device_list) = sensel.getDeviceList()
Exemplo n.º 7
0
def netdancer():
    if pyver3:
        print(args.host, args.port_osc)
        c = udp_client.SimpleUDPClient(args.host, args.port_osc)
    else:
        c = OSC.OSCClient()
        c.connect((args.host, args.port_osc))

    with h5py.File(args.minmax, 'r') as f:
        pos_min = f['minmax'][0, :][None, :]
        pos_max = f['minmax'][1, :][None, :]
    div = (pos_max - pos_min)
    div[div == 0] = 1
    slope_pos = (rng_pos[1] - rng_pos[0]) / div
    intersec_pos = rng_pos[1] - slope_pos * pos_max

    net = imp.load_source('Network', args.model)
    audionet = imp.load_source('Network', './deepdancer/models/audio_nets.py')
    model = net.Dancer(args.initOpt, getattr(audionet, args.encoder))
    ext = os.path.basename(args.pretrained).split('.')
    ext = ext[1] if len(ext) > 1 else None

    try:
        if ext == 'model':
            serializers.load_hdf5(args.pretrained, model)
        else:
            print(args.pretrained)
            serializers.load_npz(args.pretrained, model)
    except Exception as e:
        raise e

    model.to_gpu()
    # current_step = np.random.randn(1,args.initOpt[2]).astype(np.float32)
    current_step = np.zeros((1, args.initOpt[2]), dtype=np.float32)
    state = model.state
    start = False
    config = {'rot': 'quat'}
    rot = 'quat'
    frame = 0
    max_frames = 12000
    feats = np.zeros((max_frames, args.initOpt[1]))
    steps = np.zeros((max_frames, 54))
    while True:
        while data_w.empty():
            sleep(0.01)
        inp = data_w.get()
        if isinstance(inp, str):
            if inp == 'fail':
                print('Error during music processing... Exit')
                break
            elif inp == 'start':
                start = True
                fn = os.path.basename(args.track).split('.')[0]
                expname = args.pretrained.split('exp/')[1]
                expname = expname.split('/')
                expname = '{}_{}'.format(expname[0], expname[1])
                if not pyver3:
                    oscmsg = OSC.OSCMessage()
                    oscmsg.setAddress('WidgetTV')
                    if videolink is None:
                        oscmsg.append(
                            'file:///D:/nyalta/Documents/black/index.html')
                        c.send(oscmsg)
                        oscmsg = OSC.OSCMessage()
                        oscmsg.setAddress('WidgetTV')
                        oscmsg.append(
                            'file:///D:/nyalta/Documents/black/index.html?dc={}'
                            .format(fn))
                        c.send(oscmsg)
                    else:
                        oscmsg.append(youtube_link.format(videolink))
                        c.send(oscmsg)
                    oscmsg = OSC.OSCMessage()
                    oscmsg.setAddress('ExpName')
                    oscmsg.append(expname.replace('_', ' '))
                    c.send(oscmsg)
                else:
                    oscmsg = osc_message_builder.OscMessageBuilder(
                        address='WidgetTV')
                    if videolink is None:
                        oscmsg.add_arg(
                            'file:///D:/nyalta/Documents/black/index.html')
                        c.send(oscmsg.build())
                        oscmsg = osc_message_builder.OscMessageBuilder(
                            address='WidgetTV')
                        oscmsg.add_arg(
                            'file:///D:/nyalta/Documents/black/index.html?dc={}'
                            .format(fn))
                        c.send(oscmsg.build())
                    else:
                        oscmsg.add_arg(youtube_link.format(videolink))
                        c.send(oscmsg.build())
                    oscmsg = osc_message_builder.OscMessageBuilder(
                        address='ExpName')
                    oscmsg.add_arg(expname.replace('_', ' '))
                    c.send(oscmsg.build())
                continue
            elif inp == 'end':
                if enable_record:
                    ws.call(requests.StopRecording())
                    ws.disconnect()
                start = False
                fn = os.path.basename(args.track).split('.')[0]
                fn = '{}/{}_feats.h5'.format(args.save, fn)
                with h5py.File(fn, 'w') as f:
                    f.create_dataset('feats', data=feats[0:frame])
                    f.create_dataset('steps', data=steps[0:frame])
                # osc_message_buildercmsg = OSC.OSCMessage()
                if pyver3:
                    pass
                else:
                    oscmsg.setAddress('ExpName')
                    oscmsg.append('ExpName')
                    c.send(oscmsg)
                break

        if start:
            t = time.time()
            _, audiodata = inp
            try:
                with chainer.no_backprop_mode(), chainer.using_config(
                        'train', False):
                    _h, state, current_step = model.forward(
                        state, Variable(xp.asarray(current_step)),
                        model.audiofeat(
                            Variable(xp.asarray(audiodata[None, None, :, :]))),
                        True)
            except Exception as e:
                print(audiodata.shape)
                raise e

            current_step = chainer.cuda.to_cpu(current_step.data)
            predicted_motion = (current_step - intersec_pos) / slope_pos
            rdmt = render_motion(predicted_motion, rot, scale=args.height)
            if frame < max_frames:
                feats[frame] = chainer.cuda.to_cpu(_h.data)
                steps[frame] = rdmt[0]
            for i in range(len(list_address)):
                if pyver3:
                    oscmsg = osc_message_builder.OscMessageBuilder(
                        address=args.character)
                    oscmsg.add_arg(list_address[i])
                    if i == 0:
                        oscmsg.add_arg(float(rdmt[0, 0] / 10.0))
                        oscmsg.add_arg(float(rdmt[0, 1] / -10.0))
                        oscmsg.add_arg(float(rdmt[0, 2] / 10.0 + args.height))
                    else:
                        oscmsg.add_arg(float(rdmt[0, i * 3]))
                        oscmsg.add_arg(float(rdmt[0, i * 3 + 1] * -1.))
                        oscmsg.add_arg(float(rdmt[0, i * 3 + 2] * -1.))
                    c.send(oscmsg.build())
                else:
                    oscmsg = OSC.OSCMessage()
                    oscmsg.setAddress(args.character)
                    oscmsg.append(list_address[i])
                    if i == 0:
                        msg = [
                            rdmt[0, 0] / 10.0, rdmt[0, 1] / -10.0,
                            rdmt[0, 2] / 10.0 + args.height
                        ]
                    else:
                        msg = [
                            rdmt[0, i * 3], rdmt[0, i * 3 + 1] * -1.,
                            rdmt[0, i * 3 + 2] * -1.
                        ]
                    oscmsg += msg
                    c.send(oscmsg)
            frame += 1
            stdout.write('Frame: {:06d}, time: {:.03f}\r'.format(
                frame,
                time.time() - t))
            stdout.flush()
    return
Exemplo n.º 8
0
pin_last_release = {}
pin_tap_count = {}

for pin in pins:
    GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    #GPIO.add_event_detect(pin, GPIO.RISING, callback=detectPress, bouncetime=200)
    pin_data[pin] = {}
    pin_data[pin]['pin_first_tap'] = time.time()
    pin_data[pin]['pin_last_tap'] = time.time()
    pin_data[pin]['pin_last_release'] = time.time()
    pin_data[pin]['pin_tap_count'] = 0
    pin_data[pin]['last_status'] = True

time.sleep(1)

c = OSC.OSCClient()
c.connect(('127.0.0.1', 7110))

lights = OSC.OSCClient()
lights.connect(('127.0.0.1', 7111))

# allow wifi to be disabled at startup
held_button = GPIO.input(19)
if not held_button:
    # button held
    os.system('ifconfig wlan0 down')
    lights.send(OSC.OSCMessage("/status", [2, 2, 2, 2, 2]))
    time.sleep(2)
    lights.send(OSC.OSCMessage("/status", [-1, -1, -1, -1, -1]))
else:
    # button not held
Exemplo n.º 9
0
pose_timestamp=0



#BROADCAST_ADDRESS = "10.105.1.22"
#BROADCAST_ADDRESS = "10.105.15.255"
BROADCAST_ADDRESS = "255.255.255.255"

SERVER_PORT = 10750
LOCAL_PORT = 10751

# The server IP address string. None before any discovery
server_address = None

# Used to send osc data
osc_bcast_client = OSC.OSCClient()
osc_bcast_client.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)  
osc_bcast_client.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) 


#
# OSC reception handlers
#

def joint_position(addr, tags, joint_info, source):
    global joints_data, joints_data_timestamp
    # store in the dictionary, using the joint_id as key
    joints_data[joint_info[0]]=joint_info
    joints_data_timestamp = time.time()
    
Exemplo n.º 10
0
            print 'setting seconds to', data[0]
            position[1] = data[0]
        if addr.startswith('/-stat/userpar/') and addr.endswith('/value') \
                and data and data[0]:
            button = int(addr[15:17])
            if button >= 21 and button <= 24:
                song_index = button - 21
                reset_track_buttons(client, except_track=song_index)
                print 'selecting song ', song_index

    print 'Starting OSC server'
    server = OSC.OSCServer(("", server_udp_port))
    server.addMsgHandler("default", msgPrinter_handler)

    print 'Starting OSC client'
    client = OSC.OSCClient(server=server)
    client.connect((x32_address, 10023))

    reset_track_buttons(client)
    # Turn on the button for track 0.
    client.send(OSC.OSCMessage('/-stat/userpar/21/value', [127]))

    # Request the current minutes and seconds values.
    client.send(OSC.OSCMessage('/-stat/userpar/33/value'))
    client.send(OSC.OSCMessage('/-stat/userpar/34/value'))

    print 'Staring change notification thread'
    thread = threading.Thread(target=request_x32_to_send_change_notifications,
        kwargs = {"client": client})
    thread.setDaemon(True)
    thread.start()
Exemplo n.º 11
0
        def main():
            atr = []
            ManV = []
            totrev = []
            rdm = []
            for iS in range(len(Sources)):
                Closest_pt_on_sphere = (rs.BrepClosestPoint((rs.AddSphere(
                    (Sources[iS])[1], (Sources[iS])[2])), Lp))
                Si.append("S_{}".format(iS + 1))
                Distance = (rs.Distance(Lp, (Closest_pt_on_sphere[0])))
                SDi.append(DecDist(Lh, Distance))
                spthi = (Sources[iS][0]).replace('\\', '/')
                PathList = (spthi).split()
                PercentS = ("\ ").join(PathList)
                SPa.append(PercentS)
                if Lock == True:
                    SPa[iS] = '/i/NoSource_LOCKED'
                    self.AddRuntimeMessage(
                        rem,
                        'Your Sketch is locked, no sound until you unlock ;)')
                    self.Message = "EsquisSons is locked"
                SPan.append(pan(Listener, (Sources[iS])[1]))
                Sint.append(inter_S_B((Sources[iS]), 3, Listener, Geometry))
                if Reverb_on == True:
                    Srev = (rev(Geometry, Listener, (Sources[iS]), 50))
                    Srev1.append((Srev)[0] * Factor)
                    Srev2.append((Srev)[1] * Factor)
                    Str.append((Srev)[2])
                    atr.append((Srev)[2])
                    totrev.append(Srev[0] + Srev[1])
                ManV.append(volm(Sources[iS]))
                rdm.append(Sources[iS][4])
            if Reverb_on is True:
                for i in range(0, len(atr)):
                    RTsource.append(round(atr[i] / 1000, 1))
                    Revinfo.append(
                        str(round(atr[i] / 1000, 1)) + 'sec // mix : ' +
                        str(totrev[i] * Factor) + '%')
            else:
                RTsource.append('No RT: Reverb is disabled')
                Revinfo.append('No infos: Reverb is disabled')
            io = int((len(Sources) - 1))
            i_msg = []
            iosc = []
            for i in range(10):
                try:
                    pathold = oldpath[i]
                except IndexError:
                    oldpath.insert(i, ["empty"])
                except NameError:
                    oldpath = []
                    oldpath.append(["empty"])
                iport = (57100 + i)
                iosc.append(OSC.OSCClient())
                iosc[i].connect(("127.0.0.1", iport))
                i_msg.append(OSC.OSCMessage())
                if i <= io:
                    i_msg[i].append(SDi[i][0])
                    i_msg[i].append(SDi[i][1])
                    i_msg[i].append(SPa[i])
                    i_msg[i].append(SPan[i])
                    if Lock is True:
                        i_msg[i].append(0)
                    else:
                        if ((i_msg[i])[2]) != (oldpath[i]):
                            i_msg[i].append(1)
                        else:
                            i_msg[i].append(2)
                        i_msg[i].append(Sint[i])

                    try:
                        i_msg[i].append(Srev1[i])
                        i_msg[i].append(Srev2[i])
                        i_msg[i].append(Str[i])
                    except:
                        i_msg[i].append(0)
                        i_msg[i].append(0)
                        i_msg[i].append(0)
                    i_msg[i].append(ManV[i])
                    i_msg[i].append(rdm[i])
                    iosc[i].send(i_msg[i])
                    oldpath[i] = SPa[i]

                else:
                    i_msg[i].append(-127)
                    i_msg[i].append(0)
                    i_msg[i].append('/i/NoSource')
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)

                try:
                    iosc[i].send(i_msg[i])
                except:
                    self.AddRuntimeMessage(
                        ero,
                        'Connexion Failed, please ensure APP is open (use launcher) then reset the engine (with lock/unlock)'
                    )
                    self.Message = 'Connexion Failure'
                print "message, source {} : {}".format(i, i_msg[i])
Exemplo n.º 12
0
 def __init__(self, ip, port):
     #Initialize OSC communication (to send message to puredata)
     self.isSendingOSC = False
     self.c = OSC.OSCClient()
     self.c.connect((ip, port))
     print "OSC Client defined on ip", ip, "through port", port
Exemplo n.º 13
0
def initOSCClient():
    global client
    client = OSC.OSCClient()
    client.connect(('127.0.0.1', 9000))
Exemplo n.º 14
0
 def __init__(self):
     self.client = OSC.OSCClient()
     self.client.connect(('127.0.0.1', 2000))
Exemplo n.º 15
0
def parse_x32_change_messages(x32A_address, x32B_address, server_udp_port):

    #get message from A and send it to B
    def msgFilter_handlerA(addr, tags, data, client_address):
        txt = 'OSCMessage("%s", %s)' % (addr, data)
        print "input from A:" + txt
        clientB.send(OSC.OSCMessage(addr, data))

    #same as above, another way around
    def msgFilter_handlerB(addr, tags, data, client_address):
        txt = 'OSCMessage("%s", %s)' % (addr, data)
        print "input from B:" + txt
        clientA.send(OSC.OSCMessage(addr, data))

    serverA = OSC.OSCServer(("", server_udp_port))
    serverA.addMsgHandler("default", msgFilter_handlerA)
    clientA = OSC.OSCClient(
        server=serverA
    )  #This makes sure that client and server uses same socket. This has to be this way, as the X32 sends notifications back to same port as the /xremote message came from
    clientA.connect((x32A_address, 10023))
    print "client A created:"
    print serverA
    print clientA

    serverB = OSC.OSCServer(
        ("", server_udp_port + 1))  # +1 to not use same port as A
    serverB.addMsgHandler("default", msgFilter_handlerB)
    clientB = OSC.OSCClient(server=serverB)
    clientB.connect((x32B_address, 10023))
    print "client B created:"
    print serverB
    print clientB
    print ""

    thread_xremote = threading.Thread(
        target=request_x32_to_send_change_notifications,
        kwargs={
            "clientA": clientA,
            "clientB": clientB
        })
    thread_xremote.daemon = True  # to get ctrl+c work
    thread_xremote.start()

    thread_A = threading.Thread(target=mixer_thread,
                                kwargs={"server": serverA})
    thread_A.daemon = True
    thread_A.start()

    thread_B = threading.Thread(target=mixer_thread,
                                kwargs={"server": serverB})
    thread_B.daemon = True
    thread_B.start()

    #main loop, wait for full sync
    while True:
        print "\n input \"A\" to do full sync from " + x32A_address + " to " + x32B_address + " and \"B\" to another way \n"
        print " ctrl+c to stop\n"
        choice = raw_input("> ")

        if choice == 'A':
            print "running sync A to B"

            for setting in settings:
                print setting
                clientA.send(OSC.OSCMessage(setting))

        elif choice == 'B':
            print "running sync B to A"

            for setting in settings:
                print setting
                clientB.send(OSC.OSCMessage(setting))
Exemplo n.º 16
0
            if (splitAddress[2] == "poweroff"):
                print("forward poweroff on C programm")
                forwardQuit(hitchbot_osc_client, hitchbot_osc_adress,
                            hitchbot_osc_port)
                time.sleep(4)
                print("forward poweroff fit")
                forwardPowerOff(python_face_client, python_face_adress,
                                python_face_port)


if __name__ == "__main__":
    print "************** SEQUENCE ******************"

    #SEND OSC MESSAGE TO DASHBOARD CONTROL
    python_face_client = OSC.OSCClient()
    python_face_port = 12345
    python_face_adress = "127.0.0.1"

    #SEND OSC MESSAGE TO HITCHBOT APP
    hitchbot_osc_client = OSC.OSCClient()
    hitchbot_osc_port = 12346
    hitchbot_osc_adress = "127.0.0.1"

    if (len(sys.argv) > 1):
        print("Sequence.py Arg Found : start server on :" + str(sys.argv[1]))
        server = SimpleServer((str(sys.argv[1]), 12344))
    else:
        print("Sequence.py No Arg Found : start server on localhost")
        server = SimpleServer(('127.0.0.1', 12344))
Exemplo n.º 17
0
    def RunScript(self, Open_Esquissons, On_Off, Alt_path_Optionnal):

        __author__ = "theomarchal"
        self.Params.Input[
            0].Description = "Boolean input, set True to run the Sound Algorythm"
        self.Params.Input[
            0].Description = "General Status of Esquis'Sons! module"
        self.Params.Input[
            1].Description = "Alternative Path to -EsquisSons.exe/app-"
        self.Name = "EsquisSons Launcher"
        self.NickName = "Launcher"
        self.Message = "EsquisSons V3"
        self.Category = "EsquisSons"
        self.SubCategory = "0/ EsquisSons"
        import os
        import OSC
        import platform
        import time
        import subprocess
        import Grasshopper.Kernel as gh

        rem = gh.GH_RuntimeMessageLevel.Remark
        ero = gh.GH_RuntimeMessageLevel.Error
        war = gh.GH_RuntimeMessageLevel.Warning

        esqpath = Alt_path_Optionnal

        if esqpath is None:

            if platform.system() == 'Windows':
                #esqpath = os.environ["USERPROFILE"]+'\Documents\EsquisSons\EsquisSons.exe'
                esqpath = os.getenv(
                    'APPDATA'
                ) + '\Grasshopper\Libraries\EsquisSons\EsquisSons.exe'

            if platform.system() == 'Darwin':
                esqpath = '/applications/EsquisSons.app'

        c = OSC.OSCClient()
        d = OSC.OSCClient()
        c.connect(('127.0.0.1', 58234))
        oscmsg = OSC.OSCMessage()
        oscmsg.append("no message")
        oscmsg.append("no int")

        if Open_Esquissons == True:
            try:
                if platform.system() == 'Windows':
                    os.startfile(esqpath)
                    error = ''
                if platform.system() == 'Darwin':
                    subprocess.call(['open', esqpath])
                    error = ''
            except:
                error = 'True'
            if error == 'True':
                self.AddRuntimeMessage(
                    war, "EsquisSons can't be open ! " + esqpath +
                    ' can not be found Please check the installation !')
                self.Message = "EsquisSons is OFF"
            else:
                if On_Off == True:
                    oscmsg[1] = 1
                    oscmsg[
                        0] = "EsquisSons\\ is\\ Online!\\ Let's\\ make\\ some\\ noise"
                    self.AddRuntimeMessage(
                        rem, 'EsquisSons! is Online ! Lets make some noise !')
                    self.Message = "EsquisSons is ON"
                else:
                    oscmsg[
                        0] = 'EsquisSons\\ is\\ not\\ Online\\ turn\\ it\\ on\\ (in\\ Gh)\\ to\\ start\\ the\\ sketch'
                    self.AddRuntimeMessage(
                        war,
                        'EsquisSons app should be open ! Now turn it ON with a boolean Toogle (On_Off input)!'
                    )
                    self.Message = "Almost there : Turn it on !"
        else:
            if On_Off is True:
                oscmsg[1] = 1
                oscmsg[
                    0] = "EsquisSons\\ is\\ Online!\\ Let's\\ make\\ some\\ noise"
                self.AddRuntimeMessage(
                    war,
                    'Message sent, EsquisSons should be online but...Check if Esquissons app is open ! (if not, use the Open_esquissons input with boolean toggle ;)'
                )
                self.Message = "EsquisSons is ON"
            else:
                self.AddRuntimeMessage(
                    ero,
                    'EsquisSons is not Online and probably not Open, You should Open_esquissons, then turn it On with On_Off !'
                )
                oscmsg[
                    0] = "EsquisSons\\ is\\ not\\ Online\\ turn\\ it\\ on\\ (in\\ Gh)\\ to\\ start\\ the\\ sketch"
                oscmsg[1] = "0"
                self.Message = "EsquisSons is OFF"

        c.send(oscmsg)
        return
Exemplo n.º 18
0
def initialize_osc(dest_ip, dest_port):
    destination = dest_ip, dest_port
    dest = OSC.OSCClient()
    dest.connect(destination)
    return dest
Exemplo n.º 19
0
 def __init__(self):
     self.__client = OSC.OSCClient()
     self.__client.connect(('127.0.0.1', 2223))
     self.__isPlaying = False
Exemplo n.º 20
0
import struct

import OSC

#destinations = [1,2,3,4,5]   # destination xbees
destinations = [1]   # destination xbees
PORT = '/dev/ttyACM3'
hostip = '127.0.0.1'
hostport = 57120

deltatime = 0.05 # should be more than 0.005 (since we send five messages at 0.001 interval
verbose = False

BAUD_RATE = 57600

oschost = OSC.OSCClient()
send_address = ( hostip, hostport )
oschost.connect( send_address )

# Open serial port
ser = serial.Serial(PORT, BAUD_RATE)

def ByteToHex( byteStr ):
    """
    Convert a byte string to it's hex string representation e.g. for output.
    """
    
    # Uses list comprehension which is a fractionally faster implementation than
    # the alternative, more readable, implementation below
    #   
    #    hex = []
Exemplo n.º 21
0
 def __init__(self, port):
     self.client = OSC.OSCClient()
     self.client.connect(('127.0.0.1', port))
Exemplo n.º 22
0
sw3 = 0
sw4 = 0
swsens = 7000
inductioniter = 0

# Exception class (nopt used)
class PiException(Exception):
	def __init__(self, value):
		self.value = value
	def __str__(self):
		return repr(self.value)

# Initialize the OSC server and the client.
s = OSC.OSCServer(receive_address)
# initialise QLC+ connecyion
qlcclient = OSC.OSCClient()
qlcclient.connect(qlc_address)
# initialise SuperCollider connection
scclient = OSC.OSCClient()
scclient.connect(SC_address)
# initialise Processing connection
processingclient = OSC.OSCClient()
processingclient.connect(Processing_address)
# initialise python printer connection
pythonclient = OSC.OSCClient()
pythonclient.connect(pythonslave_address)
# load default handlers
s.addDefaultHandlers()

# define a message-handler function for the server to call.
def test_handler(addr, tags, stuff, source):
Exemplo n.º 23
0
from magenta.models.drums_rnn import drums_rnn_sequence_generator
from magenta.music import sequences_lib
from magenta.protobuf import generator_pb2
from magenta.protobuf import music_pb2

importlib.import_module('ascii_arts')
import ascii_arts
importlib.import_module('arturiamap')
import arturiamap

# Global Variables
# Addresses and ports to communicate with SuperCollider.
receive_address = ('127.0.0.1', 12345)
send_address = ('127.0.0.1', 57120)
server = OSC.OSCServer(receive_address)  # To receive from SuperCollider.
client = OSC.OSCClient()  # To send to SuperCollier.
client.connect(send_address)

class TimeSignature:
  numerator = 7
  denominator = 8

time_signature = TimeSignature()
qpm = magenta.music.DEFAULT_QUARTERS_PER_MINUTE
num_bars = 2
num_steps = int(num_bars * time_signature.numerator * 16 / time_signature.denominator)

PlayableNote = collections.namedtuple('playable_note',
                                      ['type', 'note', 'instrument', 'onset'])
playable_notes = SortedList(key=lambda x: x.onset)
Exemplo n.º 24
0
 def setConnection(self):
     # setting the socket comunication
     self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.client.connect((self.IP, self.Port))
     self.osc = OSC.OSCClient()
     self.osc.connect(('127.0.0.1', 60000))
Exemplo n.º 25
0
 def __init__(self, beats):
     self.client = OSC.OSCClient()
     self.client.connect(("127.0.0.1",8777))
     self.beats = beats
     self.data = [0 for _ in xrange(5)]
Exemplo n.º 26
0
 def __init__(self):
     self.superColliderClient = OSC.OSCClient()
     self.superColliderClient.connect(('127.0.0.1', 57120))
Exemplo n.º 27
0
    Nfft = S.shape[0]
    S = np.log1p(S)  # ln(1 + S)
    a = np.exp(S) - 1
    p = 2 * np.pi * np.random.random_sample(
        a.shape) - np.pi  # Init random phase
    for k in range(Nfft):  # Iterate to approximate phase
        S = a * np.exp(1j * p)
        x = np.fft.ifft(S, Nfft)
        p = np.angle(np.fft.fft(x, Nfft))
    return (p + np.pi) / (2 * np.pi)  # Rescaled between 0. and 1. for Max


#---Initialize and connect OSC server and client---

inOSC = OSC.OSCServer(('127.0.0.1', 7000))
outOSC = OSC.OSCClient()
outOSC.connect(('127.0.0.1', 9004))  # Match port number to Max out

#---------------------------------------


def cntrlHandler(addr, tags, data, client_address):
    """Handler function called for incoming OSC messages.
    Args: local arguments used by the OSC server class.
    """
    global i
    zAx = data[0]
    zVal = data[1]
    #    S = np.zeros(4096,dtype='complex') # If using ifft/istft algorithm
    if (zAx < zDim):
        z[0, zAx] = zVal
Exemplo n.º 28
0
class PiException(Exception):
    def __init__(self, value):
        self.value = value

    def __str__(self):
        return repr(self.value)


##########################
#	OSC##########################

# Initialize the OSC server and the client.
s = OSC.OSCServer(receive_address)

# initialise sending
c = OSC.OSCClient()
c.connect(send_address)

scclient = OSC.OSCClient()
scclient.connect(SC_address)

# load default handlers
s.addDefaultHandlers()


# define a message-handler function for the server to call.
def test_handler(addr, tags, stuff, source):
    print "---"
    print "received new osc msg from %s" % OSC.getUrlStr(source)
    print "with addr : %s" % addr
    print "typetags %s" % tags
Exemplo n.º 29
0
import OSC

c = OSC.OSCClient()
c.connect(('127.0.0.1', 5005))   # connect to SuperCollider
oscmsg = OSC.OSCMessage()
oscmsg.setAddress("/startup")
oscmsg.append('HELLO')
c.send(oscmsg)
Exemplo n.º 30
0
 def _connectWavClient(self):
     self._wavClient = OSC.OSCClient()
     outPort = 9003
     self._wavClient.connect(("192.168.4.1", outPort))
     log.info(self._wavClient)