How to use the node-osc.Message function in node-osc

To help you get started, we’ve selected a few node-osc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MAKIO135 / aioi / desktop / src / scripts / helpers.js View on Github external
const parseInputMsg = data => {
    const parseInputArg = arg => {
        // Float
        if (/\b\d+\.d?\b/.test(arg) || /\b\d?\.d+\b/.test(arg)) {
            return { type: 'f', value: parseFloat(arg) }
        }
        // Integer
        else if (/\b\d+\b/.test(arg)) {
            return parseInt(arg)
        }
        // String
        return `${arg}`
    }

    const [path, ...args] = data.split(' ').filter(d => d !== '')
    const oscMsg = new osc.Message(`${path}`)

    // console.log(args.map(parseInputArg))

    args.map(parseInputArg)
        .forEach(arg => oscMsg.append(arg))

    return oscMsg
}
github MAKIO135 / aioi / desktop / js / clients.js View on Github external
const sendFromInput = (index, inputString) => {
        const client = clients[index];
        
        if (client.type === 'udp') {
            client.send(Buffer.from(inputString), sendCallback);
        }
        else {
            if (!inputString.startsWith('/')) {
                inputString = `/${inputString}`;
                document.querySelector(`p.msg[data-index="${index}"]`).innerText = inputString;
            }
            
            const [path, ...args] = inputString.split(' ').filter(d => d !== '');
            client.path = path;
            const oscMsg = new osc.Message(`${path}`);
        
            args.map((arg) => {
                    // Float
                    if (/\b\d+\.d?\b/.test(arg) || /\b\d?\.d+\b/.test(arg)) return { type: 'f', value: parseFloat(arg) };
                    // Integer
                    else if (/\b\d+\b/.test(arg)) return parseInt(arg);
                    // String
                    return `${arg}`;
                })
                .forEach(arg => oscMsg.append(arg));
            client.send(oscMsg, sendCallback);
        }

        client.oscString = client.udpString = inputString;
        
        const updatedHost = {
github MAKIO135 / aioi / desktop / js / clients.js View on Github external
helpers.saveConfig();
                    
                    app.ui.bangHost(index);
                });

            return;
        }
        
        if (clientPath.includes('#')) { // specified hosts 
            const [clientArg, pathArg] = clientPath.split('#');
            indices = clientArg.split('').map(d=>parseInt(d, 36));
            path = `/${pathArg}`;
            udpMsg = Buffer.from(`${msg}`.split('#')[1]);
        }
        
        const oscMsg = new osc.Message(path);
        oscArgs.forEach(arg => oscMsg.append(arg));

        const oscString = oscArgs.reduce((acc, arg) => {
            return acc.concat(arg.value !== undefined ? arg.value : arg);
        }, [path]).join(' ');
        
        indices.filter((index) => index < clients.length)
            .forEach((index) => {
                const client = clients[index];
                client.send(client.type === 'udp' ? udpMsg : oscMsg, sendCallback);

                client.path = path;
                client.oscString = oscString;
                client.udpString = `${udpMsg}`;
                    
                const updatedHost = {
github MAKIO135 / aioi / desktop / src / scripts / helpers.js View on Github external
let indexes = [0]
    let path = clientPath

    if(clientPath.startsWith('#')) {
        indexes = [parseInt(clientPath[1], 36)]
        path = document.querySelector(`p.msg[data-index="${indexes[0]}"]`).innerText.split(' ')[0].substr(1)
    }
    else if(clientPath.includes('#')) {
        const [clientArg, pathArg] = clientPath.split('#')
        indexes = clientArg.split('').map(d=>parseInt(d, 36))
        path = pathArg
    }
    
    const inputMsg = [`/${path}`]
    const oscMsg = new osc.Message(`/${path}`)

    args.map(parseOrcaArg)
        .forEach(arg => {
            inputMsg.push(arg.value !== undefined ? arg.value : arg)
            oscMsg.append(arg)
        })

    return {
        indexes,
        inputMsg: inputMsg.join(' '),
        oscMsg
    }
}
github hundredrabbits / Orca / desktop / sources / scripts / core / io / osc.js View on Github external
this.play = function ({ path, msg }) {
    if (!this.socket) { console.warn('OSC', 'Unavailable socket'); return }
    const oscMsg = new osc.Message(path)
    for (var i = 0; i < msg.length; i++) {
      oscMsg.append(client.orca.valueOf(msg.charAt(i)))
    }
    this.socket.send(oscMsg, (err) => {
      if (err) { console.warn(err) }
    })
  }
github MAKIO135 / aioi / desktop / js / clients.js View on Github external
.forEach((index) => {
                    const client = clients[index];
                    let path = client.path;
                    if (!path) path = client.path = '/';
                    const oscMsg = new osc.Message(path);
                    oscArgs.forEach(arg => oscMsg.append(arg));
                    client.send(client.type === 'udp' ? udpMsg : oscMsg, sendCallback);

                    client.oscString = oscArgs.reduce((acc, arg) => {
                        return acc.concat(arg.value !== undefined ? arg.value : arg);
                    }, [path]).join(' ');
                    client.udpString = `${udpMsg}`;
                    
                    const updatedHost = {
                        ...client
                    };
                    delete updatedHost.send;
                    app.config.hosts[index] = updatedHost;
                    helpers.saveConfig();
                    
                    app.ui.bangHost(index);

node-osc

pyOSC inspired library for sending and receiving OSC messages

LGPL-3.0
Latest version published 2 months ago

Package Health Score

76 / 100
Full package analysis