Ejemplo n.º 1
0
def gothru_masom(addr, tags, stuff, source):
    masom_r = pyOSC3.OSCMessage()
    masom_r.setAddress("/masom_r")
    print(stuff[0])
    function = stuff[0]
    args = []
    if (len(stuff) > 1):
        args = stuff[1:]
        print(args[0])
    # getters
    if function.startswith('get_tempo'):
        masom_r = pyOSC3.OSCMessage()
        masom_r.setAddress("/masom_r")
        audiofile = Path(args[0])
        y, sr = librosa.load(audiofile)
        tempo, beats = librosa.beat.beat_track(y=y, sr=sr)
        print(tempo)
        masom_r.append(tempo)
        c.send(masom_r)
    if function.startswith('test'):
        function = stuff[0]
        args = []
        if (len(stuff) > 1):
            slapback = args[0]
            print(slapback)
            masom_r.append("Golly")
            c.send(masom_r)
Ejemplo n.º 2
0
 def noteOn(self, NIdx):
     msg = pyOSC3.OSCMessage()
     msg.setAddress("/noteOn")
     msg.append(NIdx)
     freq = NIdxToFreq(NIdx)
     # print(freq)
     msg.append(freq)
     with self.lock:
         self.client.send(msg)
Ejemplo n.º 3
0
 def stop_queue():
     switcher = 0
     client = pyOSC3.OSCClient()
     client.connect(('10.5.0.11', 57120))
     msg = pyOSC3.OSCMessage()
     msg.setAddress("/stop")
     msg.append('stopping')
     client.send(msg)
     jsonObject = {"msg": "stop"}
     return jsonObject
Ejemplo n.º 4
0
def send_msg(px, py):
    try:
        msg = pyOSC3.OSCMessage()
        msg.setAddress("/umweltor")
        x = renormalize(px, py)
        msg.append(x)
        msg.append(py)
        print('sent', x, py, 'vs', px)
        client.send(msg)
    except Exception as e:
        pass
Ejemplo n.º 5
0
    def play_random_station(self):

        client = pyOSC3.OSCClient()
        client.connect(('10.5.0.11', 57120))

        if self.switcher == 0:
            pass
        else:
            msg = pyOSC3.OSCMessage()
            msg.setAddress("/stop")
            msg.append('stopping')
            client.send(msg)

        s_auto = self.session.execute(
            'SELECT * FROM streaming_auto ORDER BY timestamp DESC LIMIT 1')
        res = s_auto.fetchone()

        s_user = self.session.execute(
            'SELECT * FROM streaming_user ORDER BY timestamp DESC LIMIT 1')
        res_user = s_user.fetchone()

        if not res_user:
            radio = res.url
            name = res.name
        else:
            if res_user.timestamp > res.timestamp:
                radio = res_user.url
                name = res_user.name
            else:
                radio = res.url
                name = res.name

        msg = pyOSC3.OSCMessage()
        msg.setAddress("/start")
        msg.append(radio)
        client.send(msg)

        logger.info(radio)
        logger.info(name)
        self.switcher = self.switcher + 1
Ejemplo n.º 6
0
    def get(self):
        # args = self.parser.parse_args()
        # print(args)

        chunk = self.fetch()
        song = AudioSegment.from_file(io.BytesIO(chunk), format="mp3").export(
            "/home/app/SuperCollider/file_1.wav", format="wav")

        client = pyOSC3.OSCClient()
        client.connect(('192.168.208.3', 57120))
        msg = pyOSC3.OSCMessage()
        msg.setAddress("/print")
        msg.append("/home/sclang/.local/share/SuperCollider/file_1.wav")
        client.send(msg)

        return None
Ejemplo n.º 7
0
    def send_random_station():

        gpd1 = gdf
        gpd2 = gpd.GeoDataFrame([['test', Point(float(request.args['x']), float(
            request.args['y']))]], columns=['Place', 'geometry'])

        radio_list = gpd1[gpd1.country == request.args['country']]
        logger.info(request.args['country'])
        logger.info(radio_list)
        if not radio_list:
            radio_list = random.choice(ckdnearest(gpd1, gpd2)[
                ['mp3', 'country', 'place_name', 'name']].values)

        logger.info(radio_list[0])

        client = pyOSC3.OSCClient()
        client.connect(('10.5.0.11', 57120))

        radio = radio_list[0]
        msg = pyOSC3.OSCMessage()
        msg.setAddress("/start")
        msg.append(radio)
        msg.append(np.random.exponential())

        client.send(msg)

        station_string = np.array2string(radio_list[1:]).replace(
            '[', '').replace(']', '').replace("'", '')

        s = StreamingAuto(country=radio_list[1], place_name=radio_list[2],
                          name=radio_list[3], url=radio,
                          timestamp=datetime.now().strftime('%Y-%m-%d %H:%M:%S'))

        s.save()
        db.session.commit()

        jsonObject = {"msg": station_string}
        return jsonObject
def send_message(tone, vol, client):
    msg = pyOSC3.OSCMessage()
    msg.setAddress("/theremin.freq")
    msg.append(tone)
    msg.append(vol)
    client.send(msg)
Ejemplo n.º 9
0
import pyOSC3
import argparse

# parse command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("--freq", type=float, help="the frequency", default=200.0)
parser.add_argument("--addr", type=str, help="the address", default="engine")
parser.add_argument("--port",
                    type=int,
                    help="the listener's port number",
                    default=57120)
args = parser.parse_args()

# create OSCClient
client = pyOSC3.OSCClient()
client.connect(('127.0.0.1', args.port))

# adding the address
msg = pyOSC3.OSCMessage()
address = ''.join(["/", str(args.addr)])

# constructing the message
msg.setAddress(str(address))
msg.append(args.freq)

# sending the message to SC
client.send(msg)
Ejemplo n.º 10
0
    def populate_queue():
        """
        Random station playback
        """

        client = pyOSC3.OSCClient()
        client.connect(('10.5.0.11', 57120))

        msg = pyOSC3.OSCMessage()
        msg.setAddress("/stop")
        msg.append('stopping')
        client.send(msg)

        res = StreamingAuto.get_last()
        res_user = StreamingUser.get_last()

        if not res_user:
            radio = res.url
            name = res.name
            country = res.country
            place_name = res.place_name

        else:
            radio = res_user.url
            name = res_user.name
            country = res_user.country
            place_name = res_user.place_name

            StreamingUser.query.filter(StreamingUser.name == name).delete()

        msg = pyOSC3.OSCMessage()
        msg.setAddress("/start")
        msg.append(radio)
        msg.append(np.random.exponential())

        chunk = check_health(radio)
        song = AudioSegment.from_file(io.BytesIO(chunk), format="mp3")
        song.export("SuperCollider/out.wav", format="wav")

        f = open("SuperCollider/out.txt", "w")
        f.write(name)
        f.close()

        client.send(msg)

        if not res_user:
            jsonObj = {"msg": "{0} {1} {2}".format(
                res.country, res.place_name, res.name)}
        else:
            jsonObj = {"msg": "{0} {1} {2}".format(
                res_user.country, res_user.place_name, res_user.name)}

        # sleeping so backend and sc can 'sync'
        time.sleep(5)
        s = NowPlaying(country=str(country), place_name=str(place_name),
                       name=str(name), url=str(radio),
                       timestamp=datetime.now().strftime('%Y-%m-%d %H:%M:%S'))

        db.session.add(s)
        db.session.flush()
        db.session.commit()
        return jsonObj
Ejemplo n.º 11
0
 def clear(self):
     msg = pyOSC3.OSCMessage()
     msg.setAddress("/clear")
     with self.lock:
         self.client.send(msg)
Ejemplo n.º 12
0
 def noteOff(self, NIdx):
     msg = pyOSC3.OSCMessage()
     msg.setAddress("/noteOff")
     msg.append(NIdx)
     with self.lock:
         self.client.send(msg)