Skip to content
joshsh edited this page Dec 3, 2011 · 7 revisions

The media: library is an extension which supports three basic multimedia operations: playing MIDI files, displaying images, and speaking text. Compared with the core Ripple libraries, this one has "toy" status, but who knows... maybe you'll find it useful.

In order to use it with the Ripple Java implementation, you need to build the ripple-media module from source or import it using Maven (see Running Ripple). For a media-enabled Ripple command line, use ripple-media.sh:

cd ripple-media/
./ripple-media.sh 

Naturally, you must run the script on your local machine (or at any rate, one with a graphical desktop and audio output) in order to get the benefit of these primitives.

To use the library in another project, include the full class name net.fortytwo.ripple.libs.media.MediaLibrary in the net.fortytwo.ripple.model.Library provider-configuration file, i.e. use this file.

play

This primitive fetches and plays a MIDI file. It expects one argument at the top of the stack: the URI of the MIDI file to play. It inspects stack to find the URI, attempts to fetch a file from the URI, and if successful, plays the file before producing the original stack as a solution. The file continues playing until either the end of the track is reached, or the Ripple process terminates.

Example:

# Turn on your speakers, and...
1)  <http://www.bachcentral.com/BachCentral/WTCBkI/Prelude1.mid> play.

   [1]  <http://www.bachcentral.com/BachCentral/WTCBkI/Prelude1.mid>

show

This primitive fetches an image and displays it in a popup window. It expects one argument at the top of the stack: the URI of the image file to display. It peeks at the argument on the stack, attempts to fetch the file and, if successful, renders it in a popup window before producing the original stack as a solution. The popup window remains open until closed by the user, or until the Ripple process terminates.

Example:

# Show some identi.ca profile pictures
1)  <http://identi.ca/user/114> foaf:knows. foaf:img. 5 limit. show.

  [1]  <http://avatar.identi.ca/1-397-20100903013814.jpeg>
  [2]  <http://avatar.identi.ca/12668-original-20090124160414.jpeg>
  [3]  <http://avatar.identi.ca/58-original-20080618232014.png>
  [4]  <http://avatar.identi.ca/12956-original-20090131063357.png>
  [5]  <http://avatar.identi.ca/226-original-20080706205455.jpeg>

speak

This primitive speaks the text of a string in the default FreeTTS voice. It expects a single argument at the top of the stack: the text to speak. It peeks at the text on the stack, then speaks the text while producing the original stack as a solution.

At the command line, you can cause the primitive to stop speaking new text by double-tapping the ESC key.

Examples:

# It speaks while it solves.
1)  (1 2 3 4 5) each. to-string. speak.

  [1]  "1"^^xsd:string
  [2]  "2"^^xsd:string
  [3]  "3"^^xsd:string
  [4]  "4"^^xsd:string
  [5]  "5"^^xsd:string

2)  <http://identi.ca/user/114> foaf:knows. foaf:name. 5 limit. speak.

  [1]  "Dan Brickley"
  [2]  "Robert Mark White"
  [3]  "Marco Frattola"
  [4]  "Yoan Blanc"
  [5]  "Keith Alexander"
  [...]