Hola
¿A una función hecha en QUÉ LENGUAJE?]
Escrita en AutoIt.
La función "eciRegisterCallback" de ECI.dll, necesita que se le pase la función que hará de callback:
eciRegisterCallback
Registers your callback function with an ECI instance.
Syntax
void eciRegisterCallback(
ECIHand hEngine,
ECICallback *pCallback
void* data
);
Parameters
hEngine
Handle to the speech synthesis engine instance. This is the value returned by eciNew or eciNewEx.
pCallback
Pointer to the ECICallback function. Can be NULL.
data
Pointer to an arbitrary value, or a key to the size of a void pointer. All values are allowed.
Return Values
None.
Remarks
This function registers your callback function with an ECI instance. If pCallback is NULL, the current
callback is removed. The supplied data pointer is associated with your callback. It is passed back to
your callback function on entry, so that your function can use it, if desired, for identification purposes,
such as a class pointer or an instance reference. Only one callback function can be registered at a time
with each ECI instance. ECI functions may not be called from within a callback.
Your callback must be registered with eciRegisterCallback before any function that creates messages
is called. The functions that cause messages to be sent to your callback are eciGeneratePhonemes, eciInsertIndex, and eciSetOutputBuffer, and setting eciWantPhonemeIndices to 1 with
eciSetParam.
For any given ECI instance, your callback will be called from the same thread on which your
application calls ECI. This is achieved by passing control from your application to ECI. When you call
eciSynchronize, ECI will retrieve all messages and execute your callback for each one, until synthesis
is complete. If you call eciSpeaking, ECI will retrieve just those messages that are ready, execute your
callback for each one, and then return. If you choose to use eciSpeaking, instead of eciSynchronize,
you must keep calling it until it returns false.
eciRegisterCallback may not be called while synthesis is in progress.
The syntax of your callback is as follows:
ECICallbackReturn callback(
ECIHand hEngine,
ECIMessage msg,
long lparam,
void* data
);
Callback Function Parameters
hEngine
Handle to the speech synthesis engine instance. This is the value returned by eciNew or eciNewEx.
msg
Enumeration indicating the type of message (see Data Types):
eciWaveformBuffer
eciPhonemeBuffer
eciIndexReply
eciPhonemeIndexReply
eciWordIndexReply
lparam
A long whose value and interpretation depends on the ECIMessage type. See discussion below.
data
An arbitrary value which is the size of a void pointer. You specify this value in your call to
eciRegisterCallback. All values are allowed, including pointers.
Callback Function Return Values
eciDataProcessed
You have processed the message and any associated data in your output buffer. Subsequent
messages may be sent to your callback.
eciDataNotProcessed
You could not process the message or associated data in your output buffer. The same message will
be sent to your callback later.
If your callback processes the ECIMessage, and does not wish to see that same message again, it
should return eciDataProcessed. If your callback function cannot process the message, and would like
to see the same message again, it should return eciDataNotProcessed; your callback will be called
with the same message at a later time. This is particularly useful if an eciWaveformBuffer message
cannot be processed because the buffer you are writing to is temporarily full. No new ECIMessage
will be sent if eciDataNotProcessed is returned. If your application continues to return
eciDataNotProcessed, synthesis will stop, aslo, eciDataAbort will stop sythesis and clear the text
buffer.
All callbacks should return quickly to ensure that there is no interruption of output. The value and
interpretation of lparam is dependent on ECIMessage.
ECIMessage eciWaveformBuffer
lparam indicates the number of samples (not bytes) that have just been added to your output buffer.
Your output buffer is specified in a call to eciSetOutputBuffer.
When phoneme indices are also being generated, this message is sent for the samples for each
phoneme.
Samples are 16-bit signed PCM values and are centered at 0.
Once your callback returns eciDataProcessed, the data in your output buffer is no longer protected;
therefore, your callback should only return eciDataProcessed when it has processed all the data in your
buffer. No more data will be added to your buffer until eciDataProcessed is returned.
ECIMessage eciPhonemeBuffer
The lparam parameter indicates the number of characters (bytes) that have just been added to your
phoneme buffer. Your phoneme buffer address was given to the ECI instance in your call to
eciGeneratePhonemes.
Once your callback returns eciDataProcessed, the data in your phoneme buffer is no longer protected;
therefore, your callback should only return eciDataProcessed when it has processed all the data in the
buffer. More data will not be added to your phoneme buffer until eciDataProcessed is returned.
ECIMessage eciIndexReply
lparam is an index that was reached during synthesis and playback of the input text buffer. Indices are
inserted into the input text buffer with eciInsertIndex.
Your callback should return immediately to ensure that there is no interruption of output.
Receiving index notifications is useful for synchronizing text with user-defined events, for example,
word highlighting or simultaneous display of related graphics in a slideshow-style presentation.
ECIMessage eciPhonemeIndexReply
lparam is a pointer to an ECIMouthData structure.
This message is sent only when the eciWantPhonemeIndices environment parameter is set to 1. One of
these messages is sent for each phoneme spoken, just before the phoneme starts playing on the audio
device (or just before the associated waveform audio is placed in your output buffer, if you have called
eciSetOutputBuffer).
In addition to the language-specific phoneme symbols, the symbol ¤ (0xA4) is used to indicate the end
of an utterance, and is sent with a set of neutral mouth position parameters.
Receiving phoneme notifications this way is appropriate for synchronizing facial animation or other
graphics with the speech output. If your application only needs to synchronize with individual words
or larger units, use word indices (eciIndexReply messages). To convert text to phonemes, use the
eciGeneratePhonemes function and the eciPhonemeBuffer message will be sent.
As with other messages, your callback function must return quickly. If significant processing is
required, as with complex graphics, your application should spawn a new thread, and marshal the
callback messages to the new thread. Your application is responsible for skipping messages, if it
receives them faster than it can process them.
Me parece que estás usando una DLL con una API pensada para linkar con C. Si estás pensando en pasar un puntero a una función de AutoIT no sólo no se puede sino que no tiene sentido, ¡la dll no sabría qué hacer con esa función! ¡no puede ejecutarla aunque tuviera el puntero a la misma!
Yo pensaba que sí, al menos con las apis de Windows sí se puede, y están más pensadas para usarse en C u otro lenguaje compilado que en AutoIt. Por ejemplo, las funciones de la librería Timers.au3, que hacen uso de las apis de timers de Windows...
(Claro, que quizá no funciona así exactamente).
además, la función "DllCallbackRegister"
hace lo mismo ¿no? (registrar un callback) que digo yo, que se usará normalmente en apis...
Si alguna DLL te devuelve un puntero a función quizás puedas pasarlo a otra DLL usando un parámetro "ptr"...
¿El puntero no podría obtenerse con "DllCallbackGetPtr" ¿verdad??
Porque la ayuda dice que hay que pasar "un apuntador DllCallback devuelto a partir de DllCallbackRegister".
Salu2!