OSDN Git Service

2007-01-28 Keishi Suenaga <skeishi@yahoo.co.jp>
authorKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Sat, 27 Jan 2007 20:19:09 +0000 (20:19 +0000)
committerKeishi Suenaga <s_keishi@mutt.freemail.ne.jp>
Sat, 27 Jan 2007 20:19:09 +0000 (20:19 +0000)
* interface/rtsyn_common.c: fix sysex check
* timidity/portaudio_a.c    small fix for compiling
* timidity/timidity.c       w32 cfg file sequence changed
                            option > exe dir > win dir
* timidity/w32_a.c          small fix for compiling
* windrv/Makefile.am        re-add add timidity.idl
* windrv/timiditydrv.c      re-add MIDIOUTCAPS2A(W)
* windrv/timiditydrv.idl    re-add

ChangeLog
interface/rtsyn_common.c
timidity/portaudio_a.c
timidity/timidity.c
timidity/w32_a.c
windrv/Makefile.am
windrv/timiditydrv.c
windrv/timiditydrv.idl [new file with mode: 0755]

index 8199c1c..98be361 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-01-28  Keishi Suenaga <skeishi@yahoo.co.jp>
+\r
+       * interface/rtsyn_common.c: fix sysex check \r
+       * timidity/portaudio_a.c    small fix for compiling\r
+       * timidity/timidity.c       w32 cfg file sequence changed
+                                   option > exe dir > win dir\r
+       * timidity/w32_a.c          small fix for compiling\r
+       * windrv/Makefile.am        re-add add timidity.idl\r
+       * windrv/timiditydrv.c      re-add MIDIOUTCAPS2A(W)\r
+       * windrv/timiditydrv.idl    re-add
+
 2007-01-14  Keishi Suenaga <skeishi@yahoo.co.jp>
 
     * timidity/flac_a.c
index eea80dc..e544724 100644 (file)
@@ -479,18 +479,20 @@ void rtsyn_play_one_sysex (char *sysexbuffer, int exlen, double event_time ){
        
        event_time = event_time + rtsyn_latency;
 
-       if(sysexbuffer[exlen-1] == '\xf7'){            // I don't konw why this need
-               for(i=0;i<EX_RESET_NO;i++){
-                       chk=0;
-                       for(j=0;(j<exlen)&&(j<11);j++){
-                               if(chk==0 && sysex_resets[i][j]!=sysexbuffer[j]){
-                                       chk=~0;
-                               }
-                       }
-                       if(chk==0){
-                                rtsyn_server_reset();
+       if(   ((sysexbuffer[0] != '\xf0') && (sysexbuffer[0] != '\xf7')) ||
+       ((sysexbuffer[0] == '\xf0') && (sysexbuffer[exlen-1] != '\xf7'))  ) return ;
+
+       for(i=0;i<EX_RESET_NO;i++){
+               chk=0;
+               for(j=0;(j<exlen)&&(j<11);j++){
+                       if(chk==0 && sysex_resets[i][j]!=sysexbuffer[j]){
+                               chk=~0;
                        }
                }
+               if(chk==0){
+                        rtsyn_server_reset();
+               }
+       }
 
 /*
                printf("SyeEx length=%x bytes \n", exlen);
@@ -499,19 +501,19 @@ void rtsyn_play_one_sysex (char *sysexbuffer, int exlen, double event_time ){
                }
                printf("\n");
 */
-               if(parse_sysex_event(sysexbuffer+1,exlen-1,&ev)){
-                       if(ev.type==ME_RESET && rtsyn_system_mode!=DEFAULT_SYSTEM_MODE){
-                               ev.a=rtsyn_system_mode;
-                               change_system_mode(rtsyn_system_mode);
-                               rtsyn_play_event_time(&ev, event_time);
-                       }else{
-                               rtsyn_play_event_time(&ev, event_time);
-                       }
+       if(parse_sysex_event(sysexbuffer+1,exlen-1,&ev)){
+               if(ev.type==ME_RESET && rtsyn_system_mode!=DEFAULT_SYSTEM_MODE){
+                       ev.a=rtsyn_system_mode;
+                       change_system_mode(rtsyn_system_mode);
+                       rtsyn_play_event_time(&ev, event_time);
+               }else{
+                       rtsyn_play_event_time(&ev, event_time);
                }
-               if(ne=parse_sysex_event_multi(sysexbuffer+1,exlen-1, evm)){
-                       for (i = 0; i < ne; i++){
-                                       rtsyn_play_event_time(&evm[i], event_time);
-                       }
+       }
+       if(ne=parse_sysex_event_multi(sysexbuffer+1,exlen-1, evm)){
+               for (i = 0; i < ne; i++){
+                       rtsyn_play_event_time(&evm[i], event_time);
                }
        }
+       
 }
index 9d5ec17..be2bc17 100644 (file)
@@ -337,7 +337,8 @@ static int open_output(void)
        }
 #ifdef PORTAUDIO_V19
 #ifdef AU_PORTAUDIO_DLL
-       PaHostApiIndex i, ApiCount;
+       {       
+        PaHostApiIndex i, ApiCount;
        i = 0;
        ApiCount = Pa_GetHostApiCount();
        do{
@@ -349,6 +350,7 @@ static int open_output(void)
        
        DeviceIndex = HostApiInfo->defaultOutputDevice;
        if(DeviceIndex==paNoDevice) goto error;
+        }
 #else
        DeviceIndex = Pa_GetDefaultOutputDevice();
        if(DeviceIndex==paNoDevice) goto error;
index d39404f..fe2ec17 100644 (file)
@@ -5246,15 +5246,6 @@ MAIN_INTERFACE int timidity_pre_load_configuration(void)
       strcat(ConfigFile, "\\TIMIDITY.CFG");
     }
     strncpy(local, ConfigFile, sizeof(local) - 1);
-#else
-    /* !IA_W32GUI */
-    GetWindowsDirectory(local, 1023 - 13);
-    strcat(local, "\\TIMIDITY.CFG");
-#endif
-
-    /* First, try read system configuration file.
-     * Default is C:\WINDOWS\TIMIDITY.CFG
-     */
     if((check = open(local, 0)) >= 0)
     {
        close(check);
@@ -5263,8 +5254,9 @@ MAIN_INTERFACE int timidity_pre_load_configuration(void)
                return 0;
        }
     }
+#endif
 
-    /* Next, try read configuration file which is in the
+       /* First, try read configuration file which is in the
      * TiMidity directory.
      */
     if(GetModuleFileName(NULL, local, 1023))
@@ -5283,6 +5275,22 @@ MAIN_INTERFACE int timidity_pre_load_configuration(void)
                }
            }
        }
+#if !defined ( IA_W32GUI ) && !defined ( IA_W32G_SYN )
+    /* Next, try read system configuration file.
+     * Default is C:\WINDOWS\TIMIDITY.CFG
+     */
+    GetWindowsDirectory(local, 1023 - 13);
+    strcat(local, "\\TIMIDITY.CFG");
+    if((check = open(local, 0)) >= 0)
+    {
+       close(check);
+       if(!read_config_file(local, 0)) {
+           got_a_configuration = 1;
+               return 0;
+       }
+    }
+#endif
+
     }
 
 #else
@@ -5735,7 +5743,7 @@ int main(int argc, char **argv)
                        argv[c] = p;
                }
 #endif /* IA_W32GUI || IA_W32G_SYN */
-#if defined(IA_WINSYN) || defined(IA_PORTMIDISYN) || defined(IA_W32G_SYN)
+#ifdef __WIN32__
        opt_sf_close_each_file = 0;
 #else
        if ((err = timidity_pre_load_configuration()) != 0)
@@ -5748,7 +5756,7 @@ int main(int argc, char **argv)
        while ((c = getopt_long(argc, argv, optcommands, longopts, &longind)) > 0)
                if ((err = set_tim_opt_long(c, optarg, longind)) != 0)
                        break;
-#if defined(IA_WINSYN) || defined(IA_PORTMIDISYN) || defined(IA_W32G_SYN)
+#ifdef __WIN32__
        if (got_a_configuration != 1)
                if ((err = timidity_pre_load_configuration()) != 0)
                        return err;
index 57c93a2..326fde9 100644 (file)
@@ -45,6 +45,8 @@ extern CRITICAL_SECTION critSect;
 
 int opt_wmme_device_id = -1;
 
+UINT uDeviceID;
+
 /*****************************************************************************************************************************/
 
 #if defined(__CYGWIN32__) || defined(__MINGW32__)
@@ -293,7 +295,6 @@ static int open_output(void)
 
                hDevice = 0;
 
-       UINT uDeviceID;
        if (opt_wmme_device_id == -1){
                uDeviceID = WAVE_MAPPER;
     }else{
index d6086dc..d00f297 100755 (executable)
@@ -44,7 +44,8 @@ libtimiditydrv_a_SOURCES = \
 SYSEXTRAS: timiditydrv.h
 
 EXTRA_DIST = \
-        timiditydrv.inf  
+        timiditydrv.inf  \
+        timiditydrv.idl
 
 
 
index f6fde39..ab6728c 100644 (file)
@@ -38,7 +38,58 @@ void _endthreadex( unsigned retval );
 #include <windows.h>
 #include "mmddk.h"  
 #include <mmsystem.h>
+#if defined(__DMC__) || defined(__MINGW32__)
+//following codes are from wine's mmsystem.h 
+typedef struct tagMIDIOUTCAPS2A {
+    WORD       wMid;
+    WORD       wPid;
+    MMVERSION  vDriverVersion;
+    CHAR       szPname[MAXPNAMELEN];
+    WORD       wTechnology;
+    WORD       wVoices;
+    WORD       wNotes;
+    WORD       wChannelMask;
+    DWORD      dwSupport;
+    GUID       ManufacturerGuid;
+    GUID       ProductGuid;
+    GUID       NameGuid;
+} MIDIOUTCAPS2A, *LPMIDIOUTCAPS2A;
+
+typedef struct tagMIDIOUTCAPS2W {
+    WORD       wMid;
+    WORD       wPid;
+    MMVERSION  vDriverVersion;
+    WCHAR      szPname[MAXPNAMELEN];
+    WORD       wTechnology;
+    WORD       wVoices;
+    WORD       wNotes;
+    WORD       wChannelMask;
+    DWORD      dwSupport;
+    GUID       ManufacturerGuid;
+    GUID       ProductGuid;
+    GUID       NameGuid;
+} MIDIOUTCAPS2W, *LPMIDIOUTCAPS2W;
+
+//DECL_WINELIB_TYPE_AW(MIDIOUTCAPS2)
+//DECL_WINELIB_TYPE_AW(LPMIDIOUTCAPS2)
+#endif
+
+#include <process.h>
 
+// GUID definitions from wine's guiddef.h
+#ifndef GUID_DEFINED
+#define GUID_DEFINED
+typedef struct _GUID
+{
+    unsigned long  Data1;
+    unsigned short Data2;
+    unsigned short Data3;
+    unsigned char  Data4[ 8 ];
+} GUID;
+
+#endif
+//GUID numbers are generated by timiditydrv.idl
+const GUID CLSID_tim_synth = {0x0FEC4C35,0xA705,0x41d7,{0xA3,0xBB,0xD5,0x87,0xA2,0x31,0x04,0x5A}};
 
 #include "config.h"
 #include "sysdep.h"
@@ -118,6 +169,9 @@ STDAPI_(LONG) DriverProc(DWORD dwDriverId, HDRVR hdrvr, UINT msg, LONG lParam1,
 HRESULT modGetCaps(PVOID capsPtr, DWORD capsSize) {
        MIDIOUTCAPSA * myCapsA;
        MIDIOUTCAPSW * myCapsW;
+       MIDIOUTCAPS2A * myCaps2A;
+       MIDIOUTCAPS2W * myCaps2W;
+       
        CHAR synthName[] = "Timidity++ Driver\0";
        WCHAR synthNameW[] = L"Timidity++ Driver\0";
        
@@ -150,6 +204,38 @@ HRESULT modGetCaps(PVOID capsPtr, DWORD capsSize) {
                return MMSYSERR_NOERROR;
 
                break;
+       case (sizeof(MIDIOUTCAPS2A)):
+               myCaps2A = (MIDIOUTCAPS2A *)capsPtr;
+               myCaps2A->wMid = 0xffff;
+               myCaps2A->wPid = 0xffff;
+               memcpy(myCaps2A->szPname, synthName, sizeof(synthName));
+               myCaps2A->wTechnology = MOD_MIDIPORT;
+               myCaps2A->vDriverVersion = 0x0090;
+               myCaps2A->wVoices = 0;
+               myCaps2A->wNotes = 0;
+               myCaps2A->wChannelMask = 0xffff;
+               myCaps2A->dwSupport = 0;
+               myCaps2A->ManufacturerGuid = CLSID_tim_synth;
+               myCaps2A->ProductGuid = CLSID_tim_synth;
+               myCaps2A->NameGuid = CLSID_tim_synth;
+               return MMSYSERR_NOERROR;
+
+       case (sizeof(MIDIOUTCAPS2W)):
+               myCaps2W = (MIDIOUTCAPS2W *)capsPtr;
+               myCaps2W->wMid = 0xffff;
+               myCaps2W->wPid = 0xffff;
+               memcpy(myCaps2W->szPname, synthNameW, sizeof(synthNameW));
+               myCaps2W->wTechnology = MOD_MIDIPORT;
+               myCaps2W->vDriverVersion = 0x0090;
+               myCaps2W->wVoices = 0;
+               myCaps2W->wNotes = 0;
+               myCaps2W->wChannelMask = 0xffff;
+               myCaps2W->dwSupport = 0;
+               myCaps2W->ManufacturerGuid = CLSID_tim_synth;
+               myCaps2W->ProductGuid = CLSID_tim_synth;
+               myCaps2W->NameGuid = CLSID_tim_synth;
+               return MMSYSERR_NOERROR;
+               
        default:
                return MMSYSERR_ERROR;
 
@@ -328,7 +414,7 @@ STDAPI_(LONG) modMessage(UINT uDeviceID, UINT uMsg, DWORD dwUser, DWORD dwParam1
                IIMidiHdr = (MIDIHDR *) dwParam1;
                exlen=(int)IIMidiHdr->dwBufferLength;
                if( NULL == (sysexbuffer = (char *)malloc(exlen * sizeof(char)))){
-                       exlen = 0;
+                       return MMSYSERR_NOMEM;
                }else{
                        memcpy(sysexbuffer,IIMidiHdr->lpData,exlen);
 #ifdef DEBUG
@@ -365,7 +451,7 @@ STDAPI_(LONG) modMessage(UINT uDeviceID, UINT uMsg, DWORD dwUser, DWORD dwParam1
        case MODM_CLOSE:
                if ( stop_rtthread != 0 || stop_thread != 0 ) return MIDIERR_STILLPLAYING;
                --OpenCount;
-               if( OpenCount == 1){
+               if( OpenCount == 0){
                        int maxloop=1000;
                        
                        stop_thread = 1;
diff --git a/windrv/timiditydrv.idl b/windrv/timiditydrv.idl
new file mode 100755 (executable)
index 0000000..4b4af2b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+    TiMidity++ -- MIDI to WAVE converter and player
+    Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
+    Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    aRts_a.c by Peter L Jones <peter@drealm.org.uk>
+    based on esd_a.c
+
+    Functions to play sound through aRts
+*/\r
+
+// This file will be processed by the MIDL tool to\r
+// produce the type library (timiditydrv.tlb) and marshalling code.\r
+\r
+//import "oaidl.idl";\r
+//import "ocidl.idl";\r
+       \r
+       [\r
+               object,\r
+               uuid(D908258C-4B41-41f0-AAD9-684FDAA84C75),\r
+               dual,\r
+               helpstring("Itim_synth Interface"),\r
+               pointer_default(unique)\r
+       ]\r
+       interface Itim_synth : IDispatch\r
+       {\r
+       };
+\r
+[\r
+       uuid(6D98B569-D56A-4fff-870A-F2E27052A0DE),\r
+       version(1.0),\r
+       helpstring("timiditydrv 1.0 Type Library")\r
+]\r
+library TIM_DRVLib\r
+{\r
+       importlib("stdole32.tlb");\r
+       importlib("stdole2.tlb");\r
+\r
+       \r
+       [\r
+               uuid(0FEC4C35-A705-41d7-A3BB-D587A231045A),\r
+               helpstring("tim_synth Class")\r
+       ]\r
+       coclass tim_synth\r
+       {\r
+               [default] interface Itim_synth;\r
+       };\r
+};\r