Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "plosc"

Title:OSC input/output via liblo
Rating:Not rated. Create the first rating!
Latest version:0.4.6
SHA1 sum:2733aa8042ac7c054f533ac62dcbed6d44074457
Author:Samer Abdallah <samer.abdallah.00@gmail.com>
Download URL:https://github.com/samer--/plosc.git

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.4214795f4233bca4d29532894a25f8aad582a7a095https://code.soundsoftware.ac.uk/projects/plosc/repository/raw/release/plosc-0.4.tgz
0.4.14e90038e345e588f426ddfb762e887c2cca2c8c51http://code.soundsoftware.ac.uk/projects/plosc/repository/raw/release/plosc-0.4.1.tgz
0.4.223c841f1352b7f4260efaddbddd29c728e90a7ed5http://code.soundsoftware.ac.uk/projects/plosc/repository/raw/release/plosc-0.4.2.tgz
0.4.3bf3c8b80530d65c6b1afccdac243e346f03ede341https://code.soundsoftware.ac.uk/projects/plosc/repository/raw/release/plosc-0.4.3.tgz
0.4.4bf4ef6875745d02f71a0e2324c171c11817c58b313https://code.soundsoftware.ac.uk/projects/plosc/repository/raw/release/plosc-0.4.4.tgz
0.4.5c25bcc975995c1f5f33efb2609306c360123a55d6https://github.com/samer--/plosc.git
0.4.62733aa8042ac7c054f533ac62dcbed6d4407445720https://github.com/samer--/plosc.git

plosc

OSC client and server for SWI Prolog

This module allows Prolog code to send and receive Open Sound Control (OSC) messages using liblo.

PREREQUISITES

  • SWI Prolog
  • liblo

INSTALLATION

First check and edit as necessary the variables in the top half of the root Makefile.

The build process installs a Prolog module file and a foreign library to ~/lib/prolog by default. If you wish to change this, edit the root Makefile accordingly and be sure that the referenced directories are in your Prolog file_search_path.

In the root directory of this package, type

$ make install

USAGE

This example talks to a Supercollider server running on the local machine listening to port 57110. It sends a message to create a Synth from SynthDef 'Square' with some given parameters.

:- use_module(library(plosc)).
:- dynamic osc_addr/1.

init :-
        osc_mk_address(localhost,57110, A),
        assert(osc_addr(A)).

bing :-
        osc_addr(A),
        get_time(T),
        osc_send(A,'/s_new',[string('Square'),int(-1),int(0),int(1),string('freq'),float(440)],T).

:- init, bing.

The following code shows how to make an OSC server.

        :- use_module(library(plosc)).

        dumposc(P,A) :- writeln(msg(P,A)).
        forward(P,[string(Host),int(Port),string(Msg)|Args]) :-
                osc_mk_address(Host,Port,Addr),
                osc_send(Addr,Msg,Args).

        :- osc_mk_server(7770,S),
                osc_mk_address(localhost,7770,P),
                osc_add_handler(S,'/fish',any,dumposc),
                osc_add_handler(S,'/fwd',any,forward),
                assert(server(S,P)).

        % start and stop the asynchronous server
        start :- server(S,_), osc_start_server(S).
        stop  :- server(S,_), osc_stop_server(S).

        % run the server synchronously - send /plosc/stop to stop it
        run   :- server(S,_), osc_run_server(S).

        % send a message to the current server
        send(M,A) :- server(_,P), osc_send(P,M,A).

To run the code in the example directory, from the shell type

$ swipl -s example/testosc.pl

BUGS AND LIMITATIONS

The message sending predicates are limited in the types of arguments they can use - currently, the following functors can be used:

Head functor      OSC Type
------------      --------
int               i - 32 bit integer
float             f - Single precision float
double            d - Double precision float
string            s - String
symbol            S - Symbol
true              T - True
false             F - False
nil               N - Nil
inf               I - Infinitum or Impuse

BLOBs, 64 bit integers, 8 bit integers, time tags and MIDI messages cannot be sent. However, all types can be received except BLOBs.

Contents of pack "plosc"

Pack contains 7 files holding a total of 70.4K bytes.