Bruce J. Weimer, MD | 3 Jun 06:17 2003

Speech SDK 5.1

I'm using LispWorks for Windows.  Has anyone successfully interfaced MicroSoft's Speech SDK 5.1 for Windows - or something similar?  I'd like to be able to talk to my Lisp application and have it talk back.

Thanks in advance.

Bruce.
Frank Berthold | 3 Jun 06:40 2003

OpenGL and rotation

Hello all,
	I'm in the process of getting my mind wrapped around the Lispworks OpenGL
system.  I've run into a couple of questions that I was hoping someone might be
able to help with. First most of the tutorials I've seen mention using fullscreen, 
is there a way to do this?

In the following code I've noticed that:
1. When part of an object gets a certain distance from the camera that part
	disappears, how can this be fixed?
2. There is a slight flickering, presumably because I have to clear and
	redisplay the screen each time.  Is there another way?
3. An error keeps coming up, generally when resizing:
	"Lock #<MP:LOCK "OpenGL" Unlocked NIL 0 21513A54> not owned."

Here is the full code for the program:
;;;; Draws a triangle and a square next to each other.
;;;; Based on the tutorial at:
;;;;  http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=04

(load "C:/Program Files/Xanalys/LispWorks Personal/lib/4-2-0-0/examples/opengl/host.lisp")
(load "OPENGL:EXAMPLES;load")

(in-package :cl-user)
(use-package :opengl)

(capi:define-interface opengl-interface ()
  ()
  (:panes
   (og-pane
    capi:opengl-pane
    :configuration (list :rgba t)
    :pane-can-scroll t
    :display-callback #'draw-gl-scene
    :resize-callback #'resize-gl-scene
    :horizontal-scroll t
    :vertical-scroll t))
  (:layouts
   (column-layout-1
    capi:column-layout
    '(og-pane)))
  (:default-initargs
   :best-height 480
   :best-width 640
   :layout 'column-layout-1
   :title "Tutorial 4"))

(defmethod initialize-instance :after ((self opengl-interface) &rest ignore &key
&allow-other-keys)
  (init-gl))

(defun resize-gl-scene (canvas x y width height)
  (gl-viewport 0 0 width height)
  (gl-matrix-mode *gl-projection*)
  (gl-load-identity)
  (glu-Perspective 45.0 (* (/ width height) 1.0) 0.1 100.0)
  (gl-matrix-mode *gl-modelview*)
  (gl-scalef (* 0.3 (/ width 640)) (* 0.4 (/ height 480)) 0.16)
  (gl-load-identity))

;;; Exists to create similarity to tutorial.
(defun init-gl ()
  (gl-shade-model *gl-smooth*)
  (gl-clear-color 0.0 0.0 0.0 0.0)
  (gl-shade-model *gl-flat*)
  (gl-clear-depth 1.0)
  (gl-enable *gl-depth-test*)
  (gl-depth-func *gl-lequal*)
  (gl-hint *gl-perspective-correction-hint* *gl-nicest*))

(defvar *rquad* 0.0)
(defvar *rtri* 0.0)
(defvar *timer*)

(defun inc-angle (angle increment)
  (if (> (+ angle increment) 360)
      (- (+ angle increment) 360)
    (+ angle increment)))

(defun draw-triangle (canvas)
  (rendering-on (canvas)
    (gl-load-identity)
    (gl-scalef 0.3 0.4 0.16)
    (gl-translatef -1.5 0.0 -6.0)
    (gl-rotatef *rtri* 0.0 1.0 0.0)
    (gl-begin *gl-triangles*)
    (gl-color3-f 1.0 0.0 0.0)
    (gl-vertex3-f 0.0 1.0 0.0)
    (gl-color3-f 0.0 1.0 0.0)
    (gl-vertex3-f -1.0 -1.0 0.0)
    (gl-color3-f 0.0 0.0 1.0)
    (gl-vertex3-f 1.0 -1.0 0.0)
    (gl-end)))

(defun draw-square (canvas)
  (rendering-on (canvas)
     (gl-load-identity)
     (gl-scalef 0.3 0.4 0.16)
     (gl-translatef 1.5 0.0 -6.0)
     (gl-rotatef *rquad* 0.0 0.0 1.0)
     (gl-begin *gl-quads*)
     (gl-color3-f 0.0 0.0 1.0)
     (gl-vertex3-f -1.0 1.0 0.0)
     (gl-vertex3-f 1.0 1.0 0.0)
     (gl-vertex3-f 1.0 -1.0 0.0)
     (gl-vertex3-f -1.0 -1.0 0.0)
     (gl-end)))

(defun draw-gl-scene (canvas &rest r)
  (declare (ignore r))
  (setf *timer*
        (mp:make-timer #'(lambda (canvas)
                           (setf *rtri* (inc-angle *rtri* 1.0))
                           (setf *rquad* (inc-angle *rquad* 1.0))
                           (rendering-on (canvas)
                             (gl-clear *gl-color-buffer-bit*))
                           (draw-triangle canvas)
                           (draw-square canvas))
                       canvas))
  (mp:schedule-timer *timer* 0 0.05))

(defun run-it ()
  (setf *interface* (capi:display (make-instance 'opengl-interface))))

                    
(run-it)

Joe Marshall | 3 Jun 15:34 2003

Re: Speech SDK 5.1

I have not interfaced the Speech SDK to LispWorks,
but I have interfaced native windows functions and
COM objects.  What does the Speech API look like?
Is it COM based?

----- Original Message ----- 
From: Bruce J. Weimer, MD
To: lisp-hug <at> xanalys.com
Sent: Tuesday, June 03, 2003 00:17
Subject: Speech SDK 5.1

I'm using LispWorks for Windows.  Has anyone successfully interfaced
MicroSoft's Speech SDK 5.1 for Windows - or something similar?  I'd like to
be able to talk to my Lisp application and have it talk back.

Thanks in advance.

Bruce.

Jeff Caldwell | 3 Jun 21:06 2003
Picon

Speech SDK

Bruce Weimar asked recently about calling the
Microsoft Speech API from within Lispworks for
Windows.  I can't make it work and here is what I
found:

There is a web demo in the Speech SDK. The crucial
parts seem to be:

<SCRIPT LANGUAGE="JavaScript">

// Create the Sapi SpVoice object
var VoiceObj = new ActiveXObject("Sapi.SpVoice");
...
// Speak the string in the edit box
  try
    {
	VoiceObj.Speak( idTextBox.value, 1 );
    }
  catch(exception)
    {
	alert("Speak error");
    }
</SCRIPT>

<SCRIPT FOR="window" EVENT="OnQuit()"
LANGUAGE="JavaScript">
	// Clean up voice object
	delete VoiceObj;
</SCRIPT>

Doesn't seem like a whole lot, does it? Heh. I go to
the LWW COM manual and...

(require "com")
<many messages>
(com:midl "sapi.idl")
<many messages and then...>

Error: [c:\cygwin\home\owner\temp\sapi.idl:971]:
Unexpected symbol "struct"
Skipping rest of statement.

Line 971 and following is:

[hidden] struct SPPHRASERULE
{
    const WCHAR *           pszName;

I comment out the structs that begin with [hidden] but
then I get in trouble with sapiaut.idl (I did not
specifically request sapiaut.idl, it is used in
spapi.idl):

Error: [c:\cygwin\home\owner\temp\sapiaut.idl:13]:
Unexpected symbol "import"
Skipping rest of statement.

Line 13 is the first import below:

//  Includes                
import "oaidl.idl";
import "ocidl.idl";

If I try sapiaut.idl by itself:

(com:midl "sapiaut.idl")

I get:

Error: [c:\cygwin\home\owner\temp\sapiaut.idl:99]:
Unexpected symbol "HKEY_CURRENT_USER"
Skipping rest of statement.

I don't think that approach is giving results so I try
automation. We have to have a type library (tlb),
which doesn't seem to come with the SDK, so I:

$ midl /proxy nul /header nul /iid nujl /dlldata nul
/win32 sapiaut.idl

and get sapiaut.tlb, which I copy to the appropriate
directory. I create a system file containing:

(defpackage "speech"
  (:use "COMMON-LISP")
  (:export "SAY"))

(defsystem speech-system
    (:default-pathname "c:/my/lisp/projects/"
     :default-type :lisp-file)
  :members
  (("sapi.lib" :type :midl-type-library-file)
   "speech"))

and in the listener I try:

(require "com")
(require "automation")

(load "speech.system")
<goes OK>

(compile-system 'speech-system)

;;; Compiling type library
c:\my\lisp\projects\sapi.tlb.

**++++ Error between functions:
  #<function COM::MAKE-COCLASS-DESCRIPTOR 21CCE53A> 

is called with unknown keyword :RESTRICTED 

amoung the arguments 

(:NAME SP-NOTIFY-TRANSLATOR 
 :INTERFACES 
  ((:INTERFACE I-SP-NOTIFY-TRANSLATOR 
   (:DEFAULT T))) 
 :TYPE-LIBRARY SPEECH-LIB   
 :HELPSTRING  "SpNotify" :HELPCONTEXT 0 
 :UUID "E2AE5372-5D40-11D2-960E-00C04F8EE628" 
 :FOREIGN-NAME "SpNotifyTranslator" 
 :HIDDEN T :RESTRICTED T) 

which is not one of 

(:NAME :FOREIGN-NAME 
 :TYPE-LIBRARY :INTERFACES :APPOBJECT 
 :HELPSTRING :HELPCONTEXT :LICENSED 
 :VERSION :CONTROL :HIDDEN :UUID 
 :NONCREATABLE :AGGREGATABLE).

; *** 1 error detected, no fasl file produced.

I'll appreciate any tips.

Thanks,

Jeff

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

Frank Berthold | 5 Jun 00:15 2003

Re: OpenGL and rotation

> On Tue, 03 Jun 2003 00:40:34 -0400, you wrote:
> 
> >In the following code I've noticed that:
> >1. When part of an object gets a certain distance from the camera that =
> part
> >	disappears, how can this be fixed?
> >2. There is a slight flickering, presumably because I have to clear and
> >	redisplay the screen each time.  Is there another way?
> 
> Have you tried using double-buffering? Turn it on using
> :configuration (list :rgba t :double-buffered t)

Thanks Peter, that cleared my flickering problem, but parts of my objects
are still dissapearing, any idea what might be doing that?

-Frank

Claudio Natoli | 5 Jun 02:34 2003

RE: OpenGL and rotation


> Thanks Peter, that cleared my flickering problem, but parts 
> of my objects are still dissapearing, any idea what might be doing that?

Is it the parts furthest from the camera? Perhaps the "far clipping plane"
is too close?

Try increasing the last value passed to glu-Perspective...

Cheers,
Claudio

Certain disclaimers and policies apply to all email sent from Memetrics.
For the full text of these disclaimers and policies see
http://www.memetrics.com/emailpolicy.html

Tim Bradshaw | 5 Jun 12:24 2003

Forcing a console window to open (in windows)

If I have an image dumped in such a way that it doesn't normally open
a console, is there an easy way to force one to open (if I want to
show a message or something) during init-file processing?

In particular, I've done something like:

    (save-image "lw-dev" ... :console :input ...)

and I'm now running lw-dev to compile stuff:

    lw-dev -init compile-my-system.lisp

then I want it to be able to open a console to print some message
during the processing of compile-my-system.lisp.

What I've tried is something like:

   (listen *terminal-io*)
   (format *terminal-io* ...)

But this seems not to work - it either hangs (having opened a
console), or dies horribly.

I'm running the compilation process under cygwin if that matters
(which it may, I think).

The obvious answer of `don't do that then, dump the initial image with
a console' is what I'm doing now, and it's a fine solution, I was just
morbidly curious if there was anything else I could do.

--tim

Simon Katz | 5 Jun 12:49 2003

Re: Forcing a console window to open (in windows)

> From: "Tim Bradshaw" <tfb <at> cley.com>
>
> If I have an image dumped in such a way that it doesn't normally
> open
> a console, is there an easy way to force one to open (if I want to
> show a message or something) during init-file processing?

You can call DBG::BRING-CONSOLE-TO-FRONT.

(I've a feeling that a little while ago someone described another way
that didn't use non-exported things, but I can't find it.)

Nick Levine | 5 Jun 13:38 2003

Re: Forcing a console window to open (in windows)

Just a little warning for emacs users, particularly those compiling
type-libraries ...

   > From: "Tim Bradshaw" <tfb <at> cley.com>
   >
   > If I have an image dumped in such a way that it doesn't normally
   > open a console, is there an easy way to force one to open (if I
   > want to show a message or something) during init-file processing?

   You can call DBG::BRING-CONSOLE-TO-FRONT.

   (I've a feeling that a little while ago someone described another
   way that didn't use non-exported things, but I can't find it.)

If you call (dbg::bring-console-to-front) in a GUI image running
within an emacs shell, there are some odd circumstances in which the
process will hang and have to be killed externally. According to
lisp-support, it's because the pipes used by emacs confuse the VC++
stdio implementation, so now you know.

For instance, this one got me every time.

    (dbg::bring-console-to-front)

    (defsystem libraries ()
      :members (
		("WombatLib" :type :midl-type-library-file)
		))

    (compile-system 'libraries :load t :force t)

    ---------

    .... lots of patch and lisp library loading stuff, followed by

	;; Creating system LIBRARIES

	;;; Compiling type library WombatLib.tlb.

    ... and the lisp hangs (inevitably) & has to be killed externally.

The fix was to save an image with :CONSOLE :INPUT and always use that
for my builds.

- nick

Marc Battyani | 16 Jun 09:58 2003

timers

Hello,

I'm calling a C program from a timer. This C programm is Lisp friendly and
outputs its result as an sexpr so I just have to call read to get it.

Here is the function I use for this.

(defun exec-kof (command)
  (let ((stream (system:open-pipe *kof-exe*))
 (result nil))
    (when stream
      (unwind-protect
    (setf result (read stream))
 (close stream)))
    result))

The problem is that READ is a blocking call and that the LW IDE is frozen
each time the timer fires. And if I try to open a LW menu, the IDE is
completely frozen and I have to kill the process.

Any ideas to do this ?
Are timers real processes or should I manually start a process to do this ?
Is there a better way to do this ?

I could try to open the pipe in a timer call then read the data in the next
timer call but it's not very clean.

Marc


Gmane