From sumomo ¡÷ users.sourceforge.jp Fri Nov 6 13:47:47 2009
From: sumomo ¡÷ users.sourceforge.jp (sumomo ¡÷ users.sourceforge.jp)
Date: Fri, 06 Nov 2009 13:47:47 +0900
Subject: [Julius-cvs 494] CVS update: julius4/msvc/SampleApp
Message-ID: <1257482867.644072.19944.nullmailer@users.sourceforge.jp>
Index: julius4/msvc/SampleApp/Julius.cpp
diff -u julius4/msvc/SampleApp/Julius.cpp:1.5 julius4/msvc/SampleApp/Julius.cpp:1.6
--- julius4/msvc/SampleApp/Julius.cpp:1.5 Tue Oct 27 23:56:58 2009
+++ julius4/msvc/SampleApp/Julius.cpp Fri Nov 6 13:47:47 2009
@@ -44,10 +44,13 @@
size_t size = 0;
WPARAM wparam = 0;
_locale_t locale;
+ unsigned int code;
r = j->getRecog()->process_list;
if (! r->live) return;
+
if (r->result.status < 0) { /* no results obtained */
+
switch(r->result.status) {
case J_RESULT_STATUS_REJECT_POWER:
strcpy(str, "");
@@ -68,15 +71,18 @@
strcpy(str, "");
break;
}
- return;
- }
+ code = (- r->result.status);
- winfo = r->lm->winfo;
- s = &(r->result.sent[0]);
- seq = s->word;
- seqnum = s->word_num;
- str[0] = '\0';
- for(i=0;iwoutput[seq[i]]);
+ } else {
+
+ winfo = r->lm->winfo;
+ s = &(r->result.sent[0]);
+ seq = s->word;
+ seqnum = s->word_num;
+ str[0] = '\0';
+ for(i=0;iwoutput[seq[i]]);
+ code = 0;
+ }
// convert to wide char
//mbstowcs_s( &size, wstr, str, strlen(str)+1);
@@ -86,7 +92,7 @@
// set status parameter
- wparam = (r->result.status << 16) + JEVENT_RESULT_FINAL;
+ wparam = (code << 16) + JEVENT_RESULT_FINAL;
// send message
SendMessage(j->getWindow(), WM_JULIUS, wparam, (LPARAM)wstr);
Index: julius4/msvc/SampleApp/SampleApp.cpp
diff -u julius4/msvc/SampleApp/SampleApp.cpp:1.3 julius4/msvc/SampleApp/SampleApp.cpp:1.4
--- julius4/msvc/SampleApp/SampleApp.cpp:1.3 Fri Oct 23 09:31:12 2009
+++ julius4/msvc/SampleApp/SampleApp.cpp Fri Nov 6 13:47:47 2009
@@ -182,7 +182,7 @@
case JEVENT_RESULT_PASS1: DebugOut(hWnd, L"Result Pass1"); break;
case JEVENT_RESULT_FINAL: DebugOut(hWnd, L"Result Final");
jResultId = HIWORD(wParam);
- if (jResultId < 0) {
+ if (jResultId != 0) {
DebugOut(hWnd, L"No result");
} else {
DebugOut(hWnd, (wchar_t *)lParam);
From sumomo ¡÷ users.sourceforge.jp Thu Nov 12 11:03:49 2009
From: sumomo ¡÷ users.sourceforge.jp (sumomo ¡÷ users.sourceforge.jp)
Date: Thu, 12 Nov 2009 11:03:49 +0900
Subject: [Julius-cvs 495] CVS update: julius4/msvc/SampleApp
Message-ID: <1257991429.773140.5993.nullmailer@users.sourceforge.jp>
Index: julius4/msvc/SampleApp/Julius.cpp
diff -u julius4/msvc/SampleApp/Julius.cpp:1.6 julius4/msvc/SampleApp/Julius.cpp:1.7
--- julius4/msvc/SampleApp/Julius.cpp:1.6 Fri Nov 6 13:47:47 2009
+++ julius4/msvc/SampleApp/Julius.cpp Thu Nov 12 11:03:49 2009
@@ -10,12 +10,13 @@
#include
#include "Julius.h"
+#include "process.h"
// -----------------------------------------------------------------------------
// JuliusLib callback functions
//
-#define JCALLBACK(A, B) static void A (Recog *recog, void *data) { cJulius *j = (cJulius *) data; SendMessage(j->getWindow(), WM_JULIUS, B, 0L);}
+#define JCALLBACK(A, B) static void A (Recog *recog, void *data) { cJulius *j = (cJulius *) data; PostMessage(j->getWindow(), WM_JULIUS, B, 0L);}
JCALLBACK(callback_engine_active, JEVENT_ENGINE_ACTIVE)
JCALLBACK(callback_engine_inactive, JEVENT_ENGINE_INACTIVE)
@@ -95,7 +96,7 @@
wparam = (code << 16) + JEVENT_RESULT_FINAL;
// send message
- SendMessage(j->getWindow(), WM_JULIUS, wparam, (LPARAM)wstr);
+ PostMessage(j->getWindow(), WM_JULIUS, wparam, (LPARAM)wstr);
}
// callbackk for pause
@@ -116,13 +117,13 @@
#endif
// main function for the engine thread
-DWORD WINAPI recogThreadMain(LPVOID vdParam)
+unsigned __stdcall recogThreadMain( void *param )
{
int ret;
- Recog *recog = (Recog *)vdParam;
+ Recog *recog = (Recog *)param;
ret = j_recognize_stream(recog);
- if (ret == -1) ExitThread(FALSE);
- ExitThread(TRUE);
+ _endthreadex(ret);
+ return(ret);
}
//-----------------------------------------------------------------------------------------
@@ -355,8 +356,8 @@
return false;
}
// create recognition thread
- m_threadHandle = CreateThread(NULL, 0, ::recogThreadMain, (LPVOID)m_recog, 0, &m_threadId);
- if (m_threadHandle == NULL) {
+ m_threadHandle = (HANDLE)_beginthreadex(NULL, 0, ::recogThreadMain, m_recog, 0, NULL);
+ if (m_threadHandle == 0) {
j_close_stream(m_recog);
return false;
}
@@ -490,7 +491,7 @@
/* make sure this process will be activated */
r->active = 1;
- SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
+ PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
return true;
}
@@ -526,7 +527,7 @@
/* tell engine to update at requested timing */
schedule_grammar_update(m_recog);
- SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
+ PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
return true;
}
@@ -557,7 +558,7 @@
}
/* tell engine to update at requested timing */
schedule_grammar_update(m_recog);
- SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
+ PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
return true;
}
@@ -588,7 +589,7 @@
}
/* tell engine to update at requested timing */
schedule_grammar_update(m_recog);
- SendMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
+ PostMessage(getWindow(), WM_JULIUS, JEVENT_GRAM_UPDATE, 0L);
return true;
}
Index: julius4/msvc/SampleApp/Julius.h
diff -u julius4/msvc/SampleApp/Julius.h:1.4 julius4/msvc/SampleApp/Julius.h:1.5
--- julius4/msvc/SampleApp/Julius.h:1.4 Tue Oct 27 23:56:58 2009
+++ julius4/msvc/SampleApp/Julius.h Thu Nov 12 11:03:49 2009
@@ -47,7 +47,6 @@
bool m_opened;
FILE *m_fpLogFile;
HANDLE m_threadHandle;
- DWORD m_threadId;
HWND m_hWnd;
_locale_t m_modelLocale;
#ifdef APP_ADIN
From sumomo ¡÷ users.sourceforge.jp Sat Nov 14 14:09:44 2009
From: sumomo ¡÷ users.sourceforge.jp (sumomo ¡÷ users.sourceforge.jp)
Date: Sat, 14 Nov 2009 14:09:44 +0900
Subject: [Julius-cvs 496] CVS update: julius4/libsent/src/adin
Message-ID: <1258175384.409436.12292.nullmailer@users.sourceforge.jp>
Index: julius4/libsent/src/adin/adin_mic_darwin_coreaudio.c
diff -u julius4/libsent/src/adin/adin_mic_darwin_coreaudio.c:1.4 julius4/libsent/src/adin/adin_mic_darwin_coreaudio.c:1.5
--- julius4/libsent/src/adin/adin_mic_darwin_coreaudio.c:1.4 Fri Jul 3 02:05:20 2009
+++ julius4/libsent/src/adin/adin_mic_darwin_coreaudio.c Sat Nov 14 14:09:44 2009
@@ -29,7 +29,7 @@
* @author Masatomo Hashimoto
* @date Wed Oct 12 11:31:27 2005
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
*/
@@ -44,12 +44,13 @@
*
*/
-/* $Id: adin_mic_darwin_coreaudio.c,v 1.4 2009/07/02 17:05:20 sumomo Exp $ */
+/* $Id: adin_mic_darwin_coreaudio.c,v 1.5 2009/11/14 05:09:44 sumomo Exp $ */
#include
#include
#include
#include
+#include
#include
#include
From sumomo ¡÷ users.sourceforge.jp Sat Nov 14 14:09:44 2009
From: sumomo ¡÷ users.sourceforge.jp (sumomo ¡÷ users.sourceforge.jp)
Date: Sat, 14 Nov 2009 14:09:44 +0900
Subject: [Julius-cvs 497] CVS update: julius4/plugin
Message-ID: <1258175384.519348.12300.nullmailer@users.sourceforge.jp>
Index: julius4/plugin/fvin.c
diff -u julius4/plugin/fvin.c:1.2 julius4/plugin/fvin.c:1.3
--- julius4/plugin/fvin.c:1.2 Wed Mar 18 16:05:31 2009
+++ julius4/plugin/fvin.c Sat Nov 14 14:09:44 2009
@@ -12,7 +12,7 @@
* @author Akinobu Lee
* @date Mon Aug 11 17:05:17 2008
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
*/
@@ -349,7 +349,7 @@
/* read one vector from the input */
if (0/* error */) return ADIN_ERROR;
if (0/* input should be segmented here */) return ADIN_SEGMENT;
- if (0/* EOF */) return ADIN_ERROR;
+ if (0/* EOF */) return ADIN_EOF;
return(0); /* success */
}
From sumomo ¡÷ users.sourceforge.jp Wed Nov 25 16:42:25 2009
From: sumomo ¡÷ users.sourceforge.jp (sumomo ¡÷ users.sourceforge.jp)
Date: Wed, 25 Nov 2009 16:42:25 +0900
Subject: [Julius-cvs 498] CVS update: julius4/libsent/src/adin
Message-ID: <1259134945.720481.3163.nullmailer@users.sourceforge.jp>
Index: julius4/libsent/src/adin/adin_portaudio.c
diff -u julius4/libsent/src/adin/adin_portaudio.c:1.9 julius4/libsent/src/adin/adin_portaudio.c:1.10
--- julius4/libsent/src/adin/adin_portaudio.c:1.9 Tue Oct 27 13:31:21 2009
+++ julius4/libsent/src/adin/adin_portaudio.c Wed Nov 25 16:42:25 2009
@@ -44,7 +44,7 @@
* @author Akinobu LEE
* @date Mon Feb 14 12:03:48 2005
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
*/
/*
@@ -68,15 +68,15 @@
/**
* Define this to choose which audio device to open by querying the
- * device API type in the following order:
+ * device API type in the following order in Windows:
*
- * ASIO -> DirectSound -> MME -> Others (OSS,...)
+ * WASAPI -> ASIO -> DirectSound -> MME
*
* This will be effective when using portaudio library with multiple
* Host API support, in which case Pa_OpenDefaultStream() will open
* the first found one (not the one with the optimal performance)
*
- * (may not work on OLDVER)
+ * (not work on OLDVER)
*
*/
#ifndef OLDVER
@@ -87,9 +87,14 @@
* Maximum Data fragment Length in msec. Input can be delayed to this time.
* You can override this value by specifying environment valuable
* "LATENCY_MSEC".
+ *
+ * This is not used in the new V19, it uses default value given by the library.
+ * At the new V19, you can force latency by PA_MIN_LATENCY_MSEC instead of LATENCY_MSEC.
*
*/
+#ifdef OLDVER
#define MAX_FRAGMENT_MSEC 128
+#endif
/* temporal buffer */
static SP16 *speech; ///< cycle buffer for incoming speech data
@@ -193,8 +198,8 @@
adin_mic_standby(int sfreq, void *dummy)
{
PaError err;
- int frames_per_buffer;
#ifdef OLDVER
+ int frames_per_buffer;
int num_buffer;
#endif
int latency;
@@ -211,6 +216,8 @@
jlog("Error: adin_portaudio: SP16 != paInt16 !!\n");
return FALSE;
}
+ /* set buffer parameter*/
+ frames_per_buffer = 256;
#endif
/* allocate and init */
@@ -218,17 +225,18 @@
speech = (SP16 *)mymalloc(sizeof(SP16) * cycle_buffer_len);
buffer_overflowed = FALSE;
- /* set buffer parameter*/
- frames_per_buffer = 256;
+ /* get user-specified latency parameter */
+ latency = 0;
if ((p = getenv("LATENCY_MSEC")) != NULL) {
latency = atoi(p);
jlog("Stat: adin_portaudio: setting latency to %d msec (obtained from LATENCY_MSEC)\n", latency);
- } else {
+ }
+#ifdef OLDVER
+ if (latency == 0) {
latency = MAX_FRAGMENT_MSEC;
jlog("Stat: adin_portaudio: setting latency to %d msec\n", latency);
}
-#ifdef OLDVER
num_buffer = sfreq * latency / (frames_per_buffer * 1000);
jlog("Stat: adin_portaudio: framesPerBuffer=%d, NumBuffers(guess)=%d\n",
frames_per_buffer, num_buffer);
@@ -237,7 +245,7 @@
(frames_per_buffer * num_buffer));
#endif
- /* initialize device and open stream */
+ /* initialize device */
err = Pa_Initialize();
if (err != paNoError) {
jlog("Error: adin_portaudio: failed to initialize: %s\n", Pa_GetErrorText(err));
@@ -248,8 +256,8 @@
{
// choose a device to open
- // preference order is: ASIO > DirectSound > MME > other
- // On the selected API, the first device will be opened.
+ // For win32, preference order is WASAPI > ASIO > DirectSound > MME
+ // If several device matches the first found one will be used.
int devId;
PaDeviceIndex numDevice = Pa_GetDeviceCount(), i;
const PaDeviceInfo *deviceInfo;
@@ -258,13 +266,15 @@
char *devname;
static char buf[256];
#ifdef _WIN32
- // at win32, force prefer order to ASIO > DirectSound > MME
- int iMME = -1, iDS = -1, iASIO = -1, iOther = -1;
+ // at win32, force preference order: iWASAPI > ASIO > DirectSound > MME > Other
+ int iMME = -1, iDS = -1, iASIO = -1, iWASAPI = -1;
#endif
+ // if PORTAUDIO_DEV is specified, match it against available APIs
devname = getenv("PORTAUDIO_DEV");
devId = -1;
+ // get list of available capture devices
jlog("Stat: adin_portaudio: available capture devices:\n");
for(i=0;iname, deviceInfo->name);
buf[255] = '\0';
jlog(" #%d [%s]\n", i+1, buf);
- if (devname && strmatch(devname, buf)) {
+ if (devname && !strncmp(devname, buf, strlen(devname))) {
+ // device name (partially) matches PORTAUDIO_DEV
devId = i;
}
#ifdef _WIN32
+ // store the device ID for each API
switch(apiInfo->type) {
+ case paWASAPI: if (iWASAPI < 0) iWASAPI = i; break;
case paMME:if (iMME < 0) iMME = i; break;
case paDirectSound:if (iDS < 0) iDS = i; break;
case paASIO:if (iASIO < 0) iASIO = i; break;
@@ -291,15 +304,23 @@
}
#ifdef _WIN32
if (devId == -1) {
- if (iASIO >= 0) devId = iASIO;
+ // if PORTAUDIO_DEV not specified or not matched, use device in the preference order.
+ if (iWASAPI >= 0) devId = iWASAPI;
+ else if (iASIO >= 0) devId = iASIO;
else if (iDS >= 0) devId = iDS;
else if (iMME >= 0) devId = iMME;
else devId = -1;
}
#endif
- if (devId == -1) {
+ if (devId == -1) {
+ // No device has been found, try to get the default input device
devId = Pa_GetDefaultInputDevice();
+ if (devId == paNoDevice) {
+ jlog("Error: adin_portaudio: no default input device is available or an error was encountered\n");
+ return FALSE;
+ }
}
+ // output device information
deviceInfo = Pa_GetDeviceInfo(devId);
apiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
snprintf(buf, 255, "%s: %s", apiInfo->name, deviceInfo->name);
@@ -307,42 +328,40 @@
jlog("Stat: adin_portaudio: get input from: [%s]\n", buf);
jlog("Info: adin_portaudio: set \"PORTAUDIO_DEV\" to the string in \"[]\" above to change\n");
- if (devId == -1) {
- err = Pa_OpenDefaultStream(&stream, 1, 0, paInt16, sfreq,
- frames_per_buffer,
- Callback, NULL);
- if (err != paNoError) {
- jlog("Error: adin_portaudio: error in opening stream: %s\n", Pa_GetErrorText(err));
- return(FALSE);
- }
- } else {
+ // open the device
memset( ¶m, 0, sizeof(param));
param.channelCount = 1;
param.device = devId;
param.sampleFormat = paInt16;
- //param.suggestedLatency = Pa_GetDeviceInfo(devId)->defaultLowInputLatency;
- param.suggestedLatency = latency / 1000.0;
+ if (latency == 0) {
+ param.suggestedLatency = Pa_GetDeviceInfo(devId)->defaultLowInputLatency;
+ jlog("Stat: adin_portaudio: try to set default low latency from portaudio: %d msec\n", param.suggestedLatency * 1000.0);
+ } else {
+ param.suggestedLatency = latency / 1000.0;
+ jlog("Stat: adin_portaudio: try to set latency to %d msec\n", param.suggestedLatency * 1000.0);
+ }
err = Pa_OpenStream(&stream, ¶m, NULL, sfreq,
- frames_per_buffer, paNoFlag,
+ 0, paNoFlag,
Callback, NULL);
if (err != paNoError) {
jlog("Error: adin_portaudio: error in opening stream: %s\n", Pa_GetErrorText(err));
return(FALSE);
}
- }
{
const PaStreamInfo *stinfo;
stinfo = Pa_GetStreamInfo(stream);
- jlog("Stat: adin_portaudio: latency was set to %.0f msec\n", stinfo->inputLatency * 1000.0);
+ jlog("Stat: adin_portaudio: latency was set to %f msec\n", stinfo->inputLatency * 1000.0);
}
}
#else
err = Pa_OpenDefaultStream(&stream, 1, 0, paInt16, sfreq,
- frames_per_buffer,
#ifdef OLDVER
+ frames_per_buffer,
num_buffer,
+#else
+ 0,
#endif
Callback, NULL);
if (err != paNoError) {
From sumomo ¡÷ users.sourceforge.jp Wed Nov 25 16:42:25 2009
From: sumomo ¡÷ users.sourceforge.jp (sumomo ¡÷ users.sourceforge.jp)
Date: Wed, 25 Nov 2009 16:42:25 +0900
Subject: [Julius-cvs 499] CVS update: julius4/libsent/src/adin/pa
Message-ID: <1259134945.802118.3172.nullmailer@users.sourceforge.jp>
Index: julius4/libsent/src/adin/pa/pa_win_wmme.c
diff -u julius4/libsent/src/adin/pa/pa_win_wmme.c:1.1.1.1 julius4/libsent/src/adin/pa/pa_win_wmme.c:1.2
--- julius4/libsent/src/adin/pa/pa_win_wmme.c:1.1.1.1 Fri Sep 28 11:50:56 2007
+++ julius4/libsent/src/adin/pa/pa_win_wmme.c Wed Nov 25 16:42:25 2009
@@ -1,5 +1,5 @@
/*
- * $Id: pa_win_wmme.c,v 1.1.1.1 2007/09/28 02:50:56 sumomo Exp $
+ * $Id: pa_win_wmme.c,v 1.2 2009/11/25 07:42:25 sumomo Exp $
* pa_win_wmme.c
* Implementation of PortAudio for Windows MultiMedia Extensions (WMME)
*
@@ -182,8 +182,8 @@
#define PaDeviceIdToWinId(id) (((id) < sNumInputDevices) ? (id - 1) : (id - sNumInputDevices - 1))
/************************************************* Prototypes **********/
-void Pa_InitializeNumDevices( void );
-PaError Pa_AllocateDevicePtrs( void );
+static void Pa_InitializeNumDevices( void );
+static PaError Pa_AllocateDevicePtrs( void );
static void CALLBACK Pa_TimerCallback(UINT uID, UINT uMsg,
DWORD dwUser, DWORD dw1, DWORD dw2);