annotate README @ 11:cda9dbcd319d

Merge
author samer
date Fri, 20 Feb 2015 14:42:47 +0000
parents bbd2b1abfb32
children
rev   line source
samer@0 1 ***
samer@0 2 *** plosc - OSC message sending from SWI Prolog
samer@0 3 ***
samer@0 4
samer@0 5 This module allows Prolog code to send Open Sound Control (OSC)
samer@0 6 messages using liblo.
samer@0 7
samer@0 8
samer@0 9 PREREQUISITES
samer@0 10
samer@0 11 - SWI Prolog
samer@0 12 - liblo
samer@0 13
samer@0 14
samer@0 15 INSTALLATION
samer@0 16
samer@0 17 First check and edit as necessary the variables in the top half of the
samer@0 18 root Makefile.
samer@0 19
samer@0 20 The build process installs a Prolog module file and a foreign library
samer@0 21 to ~/lib/prolog by default. If you wish to change this, edit the root Makefile
samer@0 22 accordingly and be sure that the referenced directories are in your
samer@0 23 Prolog file_search_path.
samer@0 24
samer@0 25 In the root directory of this package, type
samer@0 26
samer@0 27 $ make install
samer@0 28
samer@0 29
samer@0 30
samer@0 31 USAGE
samer@0 32
samer@0 33 This example talks to a Supercollider server running on the local machine
samer@0 34 listening to port 57110. It sends a message to create a Synth from SynthDef 'Square'
samer@0 35 with some given parameters.
samer@0 36
samer@0 37 __________________________________________________________
samer@0 38 :- use_module(library(plosc)).
samer@0 39 :- dynamic osc_addr/1.
samer@0 40
samer@0 41 init :-
samer@0 42 osc_mk_address(localhost,57110, A),
samer@0 43 assert(osc_addr(A)).
samer@0 44
samer@0 45 bing :-
samer@0 46 osc_addr(A),
samer@0 47 get_time(T),
samer@0 48 osc_send(A,'/s_new',[string('Square'),int(-1),int(0),int(1),string('freq'),float(440)],T).
samer@0 49
samer@0 50 :- init, bing.
samer@0 51 __________________________________________________________
samer@0 52
samer@0 53
samer@0 54 The following code shows how to make an OSC server.
samer@0 55 __________________________________________________________
samer@0 56 :- use_module(library(plosc)).
samer@0 57
samer@0 58 dumposc(P,A) :- writeln(msg(P,A)).
samer@0 59 forward(P,[string(Host),int(Port),string(Msg)|Args]) :-
samer@0 60 osc_mk_address(Host,Port,Addr),
samer@0 61 osc_send(Addr,Msg,Args).
samer@0 62
samer@0 63 :- osc_mk_server(7770,S),
samer@0 64 osc_mk_address(localhost,7770,P),
samer@0 65 osc_add_handler(S,'/fish',any,dumposc),
samer@0 66 osc_add_handler(S,'/fwd',any,forward),
samer@0 67 assert(server(S,P)).
samer@0 68
samer@0 69 % start and stop the asynchronous server
samer@0 70 start :- server(S,_), osc_start_server(S).
samer@0 71 stop :- server(S,_), osc_stop_server(S).
samer@0 72
samer@0 73 % run the server synchronously - send /plosc/stop to stop it
samer@0 74 run :- server(S,_), osc_run_server(S).
samer@0 75
samer@0 76 % send a message to the current server
samer@0 77 send(M,A) :- server(_,P), osc_send(P,M,A).
samer@0 78 __________________________________________________________
samer@0 79
samer@0 80
samer@0 81 To run the code in the example directory, from the shell type
samer@0 82
samer@0 83 $ swipl -s example/testosc.pl
samer@0 84
samer@0 85
samer@0 86
samer@0 87 BUGS AND LIMITATIONS
samer@0 88
samer@0 89 The message sending predicates are limited in the types of arguments
samer@0 90 they can use - currently, the following functors can be used:
samer@0 91
samer@0 92 Head functor OSC Type
samer@0 93 ------------ --------
samer@0 94 int i - 32 bit integer
samer@0 95 float f - Single precision float
samer@0 96 double d - Double precision float
samer@0 97 string s - String
samer@0 98 symbol S - Symbol
samer@0 99 true T - True
samer@0 100 false F - False
samer@0 101 nil N - Nil
samer@0 102 inf I - Infinitum or Impuse
samer@0 103
samer@0 104 BLOBs, 64 bit integers, 8 bit integers, time tags and MIDI messages cannot be sent.
samer@0 105 However, all types can be received except BLOBs.
samer@0 106
samer@0 107