Manuel PortaNum

Rebol3 Extensions for Windows

        mis à jour le 14-Nov-2010

index

Introduction
Simple Text To Speech extension
simpleTTS
download
pending questions
Matlab extension
ImageMagick extension
Windows API extension

Introduction

Updated Nov 13th, 2010, for compatibility with R3-a110+

You will find here several extensions for Rebol3 under windows. Rebol3 is the new version (alpha version) of the Rebol language. Feel free to try, and share your experience, reminding that R3 is alpha, and some commands may change.

Warnings

  • these extensions are experimental, as R3 is still alpha. In many cases, the checks and error messages are not fully processed.
  • they are not a full library extend for R3, but more an experiment of interfacing
  • a deliberate choice has been made to do mostly high level interfacing, with a small number of entry points, in order to stany in the "KISS" rebol spirit
  • special care should be taken when working with commands able to write or change files on the disk
  • and, at last, don't forget, when visiting, to refresh this page in your web navigator, as some changes/updates can occur

Enjoy.

R3 alpha downloads : R3 Releases

Information on extensions : Rebol 3 Extensions

For information on Rebol : http://www.rebol.com

Simple Text To Speech extension

simpleTTS

The purpose is to access the SAPI5 voices installed in Windows, through Com calls.

The extension has been tested under WinXP and Vista with rebol3 a-110

Usage is simple:

secure [extension allow]
t: import %simpleTTS.dll
TTS "hello, guys !"
TTS rejoin ["it is " now/time]

Some other examples are given in the test-simpleTTS.r3 program

It accepts TTS-XML commands which are powerful and simple. For instance :

TTS {<voice required="Gender=Female;Age!=Child"> Hello everybody}

a-text: {<lang langid="409"> A U.S. English voice should speak this.</lang>}
TTS a-text

About TTS-XML, see :

url= http://msdn.microsoft.com/en-us/library/ms717077%28VS.85%29.aspx

download

simpleTTS example :

executable and example

project source for Visual Studio 2003:

C++ project source

The code is simple, and comes directly from :

http://msdn.microsoft.com/en-us/library/ms720163%28VS.85%29.aspx

pending questions

Depending on your windows installation, you may have funny mixtures of voices, languages and accents. You should check the available voices and possibly the regional settings in the Windows Configuration Panel

retour

Matlab extension

A Matlab extension for Windows allows to launch and use the Matlab engine from Rebol. Matlab executes commands and .m files, and returns the results to Rebol. Of course, to use this extension, Matlab must be installed on your PC.

The code of the demo shows how simple it is to execute Matlab instructions from Rebol, and get the results.

; start the matlab engine
Matlab-Start

; is it necessary to change the current matlab directory ? ...
; yes, in case of batch file execution
current-dir: to-string to-local-file what-dir
Matlab rejoin ["cd " current-dir]

; change the display format in the Matlab console, redirected to Rebol
; use a "compact" display format to avoid blank lines
Matlab {format compact; format long}
print Matlab "a = factorial(20)"

; execution of several instructions
Matlab {x=1:500; plot(x,sin(0.1*x)); title 'sin(0.1*x)'}
Matlab {figure; surfc(peaks(20)); title 'surfc(peaks(20))'}

; execution of a batch file : myTestFile.m
Matlab { myTestFile }

ask "quit ?"

; when leaving the session
; close the matlab engine
Matlab-Stop

The MatlabExt dll and test file:

executable and example

project source for Visual Studio 2003:

C++ project source

retour

ImageMagick extension

A new extension allows to use the powerful ImageMagick image processing functions thru the use of a ImageMagickObject Com component. You will be able to launch from Rebol3 a large set of command-line functions of ImageMagick.

This extension performs a high level access to the powerful ImageMagick tools.

An excellent low-level interface access has been realized by Oldes for R2 (im-min.r).

for more info on ImageMagick, see :

http://www.imagemagick.org/script/index.php

A very rich documentation on the many usages, and coding examples of ImageMagick:

http://www.imagemagick.org/Usage/

To use this extension you need to:

  • install the ImageMagick runtime (ImageMagick-6.6.5-8-Q16-windows-dll.exe)
  • register the ImageMagickObject dll : regsvr32 ImageMagickObject.dll
  • in case of using pdf format, install Ghostscript http://pages.cs.wisc.edu/~ghost/
  • you may have to install also the Microsoft C runtime libraries : msvcr71.dll and msvcp71.dll, if requested.

The extension has been tested under Windows XP, with R3-a110, ImageMagick 6.6.5, and Ghostscript 8.61

There are 3 main commands : Magick, Magick-load, Magick-save, which can be used alone or combined to interface the two worlds, without passing by disk reads/write.

The best is to have a look on the code given in the example file:

secure [extension allow]
import %MagickExt.dll

Magick gives access to the command line interpreter of ImageMagick. It is full of options and possibilities. Inputs and outputs are made from and to files, with a very large number of image formats, including pdf if Ghostscript is installed.

; --- Magick command

Magick "convert label.gif label.jpg"
Magick "convert -resize 400x400 label.gif label2.jpg"
Magick "convert logo: logo.jpg"
Magick {convert -resize "200x200>" logo: logo.gif}

; more complex examples from http://www.imagemagick.org/script/command-line-processing.php
Magick {convert label.gif +matte ( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite ) 
   ( -clone 0 -shade  110x50 -normalize -channel BG -fx 0 +channel -matte ) 
   -delete 0 +swap -compose Multiply -composite button.gif}

Magick {montage -background #336699 -geometry +4+4 label2.jpg logo.jpg montage.jpg}

; this line may need to install Ghostscript: http://pages.cs.wisc.edu/~ghost/
; Magick "convert montage.jpg  montage.pdf"

Magick-load allows to load an image in the Rebol environment, with the full set of ImageMagick formats

; --- Magick-load command

im: Magick-load "label.gif"
print im/size

Magick-save allows to save a Rebol image, with the full set of ImageMagick formats

; --- Magick-save command

im: load %logo.gif
;Magick-save im "res3.pdf"  
Magick-save im "res3.jpg"
print "image saved"

Combinations of the three commands allows exchange between Rebol and ImageMagick, without passing by read/write on the disk. We exchange data thanks to "memory program register" (mpr), a pseudo-file format, used like a normal file, allowing in-memory saves.

Specific user functions can then be defined.

; --- Command combinations, full interfacing

edge: func[ im [image!]][
   Magick-save im "mpr:im1"
   Magick "convert mpr:im1 -edge 1 mpr:im1r"
   im: Magick-load "mpr:im1r"
   im
   ]

im1: load %logo.jpg
im: edge im1

To download the MagickExt dll and test file:

Magick Extension dll and example

To download the MagickExt VisualStudio project

Magick Extension source code

retour

Windows API extension

Windows API is very complex and offers a lot of fonctions in many domains. The extension here takes a small number of these functions to call them from Rebol 3. It is focused on functions facilitating access to the computer for disabled people, as it allows some control on applications (launch, close ...), on windows (send messages ...), keyboard emulation by sending keys, and on multimedia devices through the MCI commands.

a windows API extension

retour


Valid HTML 4.01 Transitional

copyright J.Colineau - 14-Nov-2010