home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 14 / 14.iso / s / s005 / 25.ddi / PACK0.PK1 / RECORD.CMD < prev    next >
Encoding:
Text File  |  1993-04-26  |  4.2 KB  |  161 lines

  1. /*-----------------------------------------------------------------------------
  2.  
  3.   Name:                   record.cmd
  4.   Date Created:    12/27/92
  5.                 Copyright (c) IBM Corporation  1992, 1993
  6.                           All Rights Reserved
  7.  
  8.   OS/2 REXX command file that uses MultiMedia REXX API's
  9.   to record a wave file with the default settings of the audio
  10.   card from the microphone in jack.
  11.  
  12. -----------------------------------------------------------------------------*/
  13.  
  14. address cmd      /* Send commands to OS/2 command processor.  */
  15. signal on error   /* When commands fail, call "error" routine. */
  16.  
  17. trace off
  18. /*trace ?r */
  19.  
  20.  
  21. parse arg WaveFileName              /* Fetch command line parms */
  22.  
  23. if WaveFileName='' | WaveFileName='?' then
  24.    do
  25.      call Help
  26.      exit 0
  27.    end
  28.  
  29. /* Load the DLL, initialize MCI REXX support */
  30. rc = RXFUNCADD('mciRxInit','MCIAPI','mciRxInit')
  31. InitRC = mciRxInit()
  32.  
  33. /*
  34. ** Open the instance.
  35. */
  36. MciCmd = 'open' WaveFileName 'alias rexxalias type waveaudio wait'
  37. MacRC = SendString(''MciCmd'')       /* Put double single quotes around the command */
  38. if MacRC <> 0 then signal ErrExit
  39.  
  40. MacRC = SendString("delete rexxalias from 0 wait")
  41. if MacRC <> 0 then signal ErrExit
  42.  
  43. /*
  44. ** Exercise mciRxGetDeviceID function
  45. */
  46. DeviceID = mciRxGetDeviceID(""rexxalias"")
  47.  
  48. /*
  49. ** Get the connector.
  50. */
  51. MacRC = SendString("connection rexxalias query type wave stream alias rexxmic wait")
  52. if MacRC <> 0 then signal ErrExit
  53.  
  54. /*
  55. ** Set the monitor attribute to off.
  56. */
  57. MacRC = SendString("set rexxmic monitor off wait")
  58. if MacRC <> 0 then signal ErrExit
  59.  
  60. /*
  61. ** Get the microphone connection.
  62. */
  63. MacRC = SendString("connector rexxmic enable type microphone wait")
  64. if MacRC <> 0 then signal ErrExit
  65.  
  66. /*
  67. ** Start the record operation.
  68. */
  69. MacRC = SendString("record rexxalias")
  70. if MacRC <> 0 then signal ErrExit
  71. /*
  72. ** Notify users that recording is in progress.
  73. */
  74. say 'Record operation is now in progress.'
  75. say '<Press Enter to stop recording.>'
  76.  
  77. /*
  78. ** Wait for a key to be pressed:
  79.  */
  80.    pull trash
  81.  
  82. /*
  83. ** Stop recording
  84. */
  85. MacRC = SendString("stop rexxalias wait")
  86. if MacRC <> 0 then signal ErrExit
  87.  
  88. /*
  89. ** Save the file
  90. */
  91. MacRC = SendString("save rexxalias wait")
  92. if MacRC <> 0 then signal ErrExit
  93.  
  94. /*
  95. ** Close the instance
  96. */
  97. MacRC = SendString("close rexxalias wait")
  98. if MacRC <> 0 then signal ErrExit
  99.  
  100. /*
  101. ** Exit, return code = 0.
  102. */
  103. exit 0
  104.  
  105. /*   --- SendString --
  106. ** Call DLL function.  Pass the command to process and the
  107. ** name of a REXX variable that will recieve textual return
  108. ** information.
  109. */
  110. SendString:
  111.    arg CmndTxt
  112.    /* Last two parameters are reserved, must be set to 0           */
  113.    /* Future use of last two parms are for notify window handle    */
  114.    /* and userparm.                                                 */
  115.    MacRC = mciRxSendString(CmndTxt, 'RetSt', '0', '0')
  116.    if MacRC<>0 then
  117.       do
  118.       ErrRC = MacRC
  119.       say 'MciCmd=' CmndTxt
  120.       say 'Err:mciRxSendString RC=' ErrRC RetSt
  121.       MacRC = mciRxGetErrorString(ErrRC, 'ErrStVar')
  122.       say 'mciRxGetErrorString('ErrRC') =' ErrStVar
  123.       MacRC = ErrRC /* return the error rc */
  124.       end
  125.    return MacRC
  126.  
  127.  
  128. /*  -- help --
  129. ** Display help text
  130. */
  131. Help:
  132.    say
  133.    say 'This command file records a wave file using the MultiMedia'
  134.    say 'REXX string interface.'
  135.    say
  136.    say 'record filename'
  137.    say
  138.    return
  139.  
  140. /*  --- ErrExit --
  141. ** Common routine for error clean up/program exit.
  142. ** Gets called when commands to DLL fail.
  143. */
  144. ErrExit:
  145.    MacRC = mciRxExit()   /* Tell the DLL we're going away        */
  146.    exit 1;               /* exit, tell caller things went poorly */
  147.  
  148.  
  149. /*   ---- error --
  150. ** Routine gets control when any command to the external
  151. ** environment (usually OS/2) returns a non-zero RC.
  152. ** This routine does not get called when the macapi.dll
  153. ** returns non-zero as it is a function provider rather
  154. ** than a command environment.
  155. */
  156. error:
  157.    ErrRC = rc
  158.    say 'Error' ErrRC 'at line' sigl ', sourceline:' sourceline(sigl)
  159.    MacRC = mciRxExit()       /* Tell the DLL we're going away */
  160.    exit ErrRC                /* exit, tell caller things went poorly */
  161.