Changeset 58


Ignore:
Timestamp:
Aug 7, 2023, 10:30:22 PM (2 years ago)
Author:
gyoung
Message:

Changes to get the TimidityMCD plugin working

Location:
trunk/classes/c/c_audio
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/classes/c/c_audio/cwaudio.c

    r4 r58  
    6262#include "sys_funcs.h"
    6363
    64 
     64#if 0
     65#define  _PMPRINTF_
     66#include "PMPRINTF.H"
     67#endif
    6568/* Redefine function names */
    6669#define cwGetStringFromEA EARestoreString
     
    12411244              SOMClass* mmMIDIClass=somGetSomClass("MMMIDI");
    12421245              MMAudioData *somThis = MMAudioGetData(thisPtr);
    1243                    
    1244               if(_somIsA(thisPtr, mmMIDIClass))
    1245                 strncpy(chrDevice,"SEQUENCER", sizeof(chrDevice));
    1246               else
    1247                 strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice));
    1248                    
     1246                   
    12491247              ulNameSize=sizeof(name);
    12501248              _wpQueryRealName(thisPtr, name, &ulNameSize, TRUE);
    1251              
    1252               /* Start audio file */ 
    1253               sprintf(chrCommand,"open \"%s\"  type %s alias wave%d SHAREABLE wait",name, chrDevice, thisPtr);
    1254               rc = mciSendString( chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
    1255               if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
    1256                 WinPostMsg(hwnd,WM_QUIT,0,0);
    1257                 return MRFALSE;
    1258               }
    1259 
    1260               /* Set time format */
    1261               sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", thisPtr);
    1262               rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
    1263               if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
    1264                 WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
    1265                 return MRFALSE;
    1266               }
    1267                    
    1268               sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", thisPtr);
    1269               rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
    1270               if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
    1271                 WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
    1272                 return MRFALSE;
    1273               }
    1274                    
    1275               iTime=atoi(retMsg);
    1276                    
    1277               //   sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY %d NOTIFY", thisPtr, 3000);
    1278               //   rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
    1279                    
    1280               if(iTime>1100)
    1281                 iTime-=700;
    1282               else
    1283                 iTime-=300;
    1284                    
    1285               if(iTime<=0)
    1286                 iTime=100;
    1287                    
    1288               sprintf(chrCommand,"SETCUEPOINT wave%d ON at %d WAIT", thisPtr, iTime);
    1289               rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
    1290               if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
    1291                 WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
    1292                 return MRFALSE;
    1293               }
    1294                
    1295               /* Set volume */
    1296               sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", thisPtr, globalClassVolume);
    1297               rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
    1298               /* Not able to set the volume isn't that bad so don't quit in case of an error. */
    1299 #if 0
    1300               if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
    1301                 WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
    1302                 return MRFALSE;
    1303               }
    1304 #endif
    1305 
    1306               WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 100);
    1307                    
    1308               sprintf(chrCommand,"play wave%d ", thisPtr);
    1309               rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
    1310               if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
    1311                 WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
    1312                 return MRFALSE;
    1313               }
    1314                    
    1315               /* Set Time in icon title to 00:00 */
    1316               strncpy(chrCommand, _wpQueryTitle(thisPtr), CCHMAXPATH);
    1317               if(_ulPlaySecs) {
    1318                 sprintf(retMsg, "%02d:%02d", _ulPlaySecs/60, _ulPlaySecs%60);                 
    1319                 strncat(chrCommand,"\n00:00 / ",sizeof(chrCommand)-1-strlen(chrCommand));
    1320                 strncat(chrCommand, retMsg,sizeof(chrCommand)-1-strlen(chrCommand));
    1321               }
    1322               else
    1323                 strncat(chrCommand,"\n00:00", sizeof(chrCommand)-1-strlen(chrCommand));
    1324 
    1325               _cwmmSetRecordTitles(thisPtr, chrCommand, FALSE);
    1326               WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 1000);
    1327               __set_ulTrackStatus( thisPtr,TRACK_STATUS_PLAYING);
    1328               break;
     1249
     1250              if(_somIsA(thisPtr, mmMIDIClass)) {
     1251                strncpy(chrDevice,"sequencer", sizeof(chrDevice));
     1252                /* Start audio file */
     1253                sprintf(chrCommand,"open \"%s\" type %s alias wave%d shareable wait", name, chrDevice, thisPtr);
     1254                rc = mciSendString( chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
     1255                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1256                  WinPostMsg(hwnd,WM_QUIT,0,0);
     1257                  return MRFALSE;
     1258                }
     1259
     1260                /* Set time format */
     1261                sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", thisPtr);
     1262                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1263                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1264                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1265                  return MRFALSE;
     1266                }
     1267
     1268                sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", thisPtr);
     1269                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1270                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1271                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1272                  return MRFALSE;
     1273                }
     1274
     1275                iTime=atoi(retMsg);
     1276                     
     1277                //   sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY %d NOTIFY", thisPtr, 3000);
     1278                //   rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
     1279                     
     1280                if(iTime>1100)
     1281                  iTime-=700;
     1282                else
     1283                  iTime-=300;
     1284                     
     1285                if(iTime<=0)
     1286                  iTime=10;
     1287                     
     1288                sprintf(chrCommand,"SETCUEPOINT wave%d ON at %d WAIT", thisPtr, iTime);
     1289                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
     1290                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1291                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1292                  return MRFALSE;
     1293                }
     1294                 
     1295
     1296                /* Set volume */
     1297                sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", thisPtr, globalClassVolume);
     1298                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1299                /* Not able to set the volume isn't that bad so don't quit in case of an error. */
     1300  #if 0
     1301                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1302                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1303                  return MRFALSE;
     1304                }
     1305  #endif
     1306 
     1307                WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 100);
     1308
     1309                sprintf(chrCommand,"play wave%d", thisPtr);
     1310                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1311                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1312                  WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1313                  return MRFALSE;
     1314                }
     1315
     1316                /* Set Time in icon title to 00:00 */
     1317                strncpy(chrCommand, _wpQueryTitle(thisPtr), CCHMAXPATH);
     1318                if(_ulPlaySecs) {
     1319                  sprintf(retMsg, "%02d:%02d", _ulPlaySecs/60, _ulPlaySecs%60);                 
     1320                  strncat(chrCommand,"\n00:00 / ",sizeof(chrCommand)-1-strlen(chrCommand));
     1321                  strncat(chrCommand, retMsg,sizeof(chrCommand)-1-strlen(chrCommand));
     1322                 }
     1323                 else
     1324                   strncat(chrCommand,"\n00:00", sizeof(chrCommand)-1-strlen(chrCommand));
     1325   
     1326                 _cwmmSetRecordTitles(thisPtr, chrCommand, FALSE);
     1327                 WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 1000);
     1328                 __set_ulTrackStatus( thisPtr,TRACK_STATUS_PLAYING);
     1329
     1330              }
     1331              else {
     1332                strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice));
     1333                /* Start audio file */
     1334                sprintf(chrCommand,"open \"%s\"  type %s alias wave%d SHAREABLE wait",name, chrDevice, thisPtr);
     1335                rc = mciSendString( chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
     1336                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1337                  WinPostMsg(hwnd,WM_QUIT,0,0);
     1338                  return MRFALSE;
     1339                }
     1340 
     1341                /* Set time format */
     1342                sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", thisPtr);
     1343                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1344                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1345                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1346                  return MRFALSE;
     1347                }
     1348                     
     1349                sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", thisPtr);
     1350                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1351                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1352                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1353                  return MRFALSE;
     1354                }
     1355                     
     1356                iTime=atoi(retMsg);
     1357                     
     1358                //   sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY %d NOTIFY", thisPtr, 3000);
     1359                //   rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
     1360                     
     1361                if(iTime>1100)
     1362                  iTime-=700;
     1363                else
     1364                  iTime-=300;
     1365                     
     1366                if(iTime<=0)
     1367                  iTime=100;
     1368                     
     1369                sprintf(chrCommand,"SETCUEPOINT wave%d ON at %d WAIT", thisPtr, iTime);
     1370                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
     1371                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1372                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1373                  return MRFALSE;
     1374                }
     1375                 
     1376                /* Set volume */
     1377                sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", thisPtr, globalClassVolume);
     1378                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1379                /* Not able to set the volume isn't that bad so don't quit in case of an error. */
     1380  #if 0
     1381                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1382                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1383                  return MRFALSE;
     1384                }
     1385  #endif
     1386 
     1387                WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 100);
     1388                     
     1389                sprintf(chrCommand,"play wave%d ", thisPtr);
     1390                rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
     1391                if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
     1392                  WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
     1393                  return MRFALSE;
     1394                }
     1395                     
     1396                /* Set Time in icon title to 00:00 */
     1397                strncpy(chrCommand, _wpQueryTitle(thisPtr), CCHMAXPATH);
     1398                if(_ulPlaySecs) {
     1399                  sprintf(retMsg, "%02d:%02d", _ulPlaySecs/60, _ulPlaySecs%60);                 
     1400                  strncat(chrCommand,"\n00:00 / ",sizeof(chrCommand)-1-strlen(chrCommand));
     1401                  strncat(chrCommand, retMsg,sizeof(chrCommand)-1-strlen(chrCommand));
     1402                }
     1403                else
     1404                  strncat(chrCommand,"\n00:00", sizeof(chrCommand)-1-strlen(chrCommand));
     1405 
     1406                _cwmmSetRecordTitles(thisPtr, chrCommand, FALSE);
     1407                WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 1000);
     1408                __set_ulTrackStatus( thisPtr,TRACK_STATUS_PLAYING);
     1409              }
     1410              break;
    13291411            }/* somIsObj(thisPtr) */
    13301412          }
     
    13561438                    unsigned char chrCommand[CCHMAXPATH];
    13571439                    char retMsg[20];
    1358                                      
     1440
    13591441                    WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1 );
    13601442                   
     
    17921874          strncpy(chrTitle, _wpQueryTitle(somSelf), sizeof(chrTitle));
    17931875          chrTitle[sizeof(chrTitle)-1]=0;
    1794           if(!getMessage(chrText, IDSTR_STARTINGTRACK, sizeof(chrText), queryResModuleHandle(), HWND_DESKTOP))
    1795             strcpy(chrText, "Starting Track...");;
     1876          if(!getMessage(chrText, IDSTR_STARTINGTRACK, sizeof(chrText), queryResModuleHandle(), HWND_DESKTOP)) {
     1877            strcpy(chrText, "Starting Track...");
     1878          }
    17961879          strncat(chrTitle,"\n", sizeof(chrTitle)-1-strlen(chrTitle));
    17971880          strncat(chrTitle, chrText, sizeof(chrTitle)-1-strlen(chrTitle));
     
    28682951              Workaround for WPS chrash with Timidity: Open 'ID_MENU_START' disabled.
    28692952             */
    2870             if(globalHaveTimidity && somObjectIsA(somSelf, "MMMidi"))
    2871               return NULLHANDLE,
     2953            //if(globalHaveTimidity && somObjectIsA(somSelf, "MMMidi"))
     2954            //  return NULLHANDLE,
    28722955            /* Another audio file running */
    28732956            iRunningAudioFiles++;
    28742957
    28752958            __set_ulPreviousView(somSelf, _wpQueryDefaultView(somSelf));/* Save the view set by the user                  */
    2876             _cwmmPlayTrack(somSelf, hwndCnr, TRUE);      /* Start playing                                  */
     2959            _cwmmPlayTrack(somSelf, hwndCnr, TRUE);      /* Start playing
    28772960            _wpSetDefaultView(somSelf, ID_MENU_STOP);    /* Set new view so doubleclick stops the playing. */
    28782961          }
     
    30083091        break;
    30093092      }
    3010     return (MMAudio_parent_CWMMDataFile_wpOpen(somSelf, hwndCnr, ulView,
    3011                                           param));
     3093    return (MMAudio_parent_CWMMDataFile_wpOpen(somSelf, hwndCnr, ulView, param));
    30123094}
    30133095
     
    34483530      menu isn't available then (see cwmidi.c).
    34493531     */
    3450     if(globalHaveTimidity && somObjectIsA(somSelf, "M_MMMidi"))
    3451       return ID_MENU_PLAYER;
     3532    //if(globalHaveTimidity && somObjectIsA(somSelf, "M_MMMidi"))
     3533      //return ID_MENU_PLAYER;
    34523534
    34533535    return ID_MENU_START;
  • trunk/classes/c/c_audio/cwmidi.c

    r2 r58  
    7878
    7979     */
    80     if(globalHaveTimidity)
     80    /*if(globalHaveTimidity)
    8181      {
    8282        WinSendMsg(hwndMenu, MM_DELETEITEM, MPFROM2SHORT( ID_MENU_START, TRUE), 0L);
    83       }
     83      }*/
    8484    WinSendMsg(hwndMenu, MM_DELETEITEM, MPFROM2SHORT( ID_MENU_CONVERT, FALSE), 0L);
    8585    return bRC;
Note: See TracChangeset for help on using the changeset viewer.