home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / DC-POS24.LZX / pOS / pOS_RKRM.lzx / pOS_RKRM / pAudio / Beep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-18  |  3.7 KB  |  141 lines

  1.  
  2. /*******************************************************************
  3.  $CRT 17 Dec 1996 : hb
  4.  
  5.  $AUT Holger Burkarth
  6.  $DAT >>Beep.c<<   26 Jan 1997    13:18:42 - (C) ProDAD
  7. *******************************************************************/
  8.  
  9. //##ex mcpp:cppc -gs -o pos:pos/Ex/Beep p:pLib/StartCode.o p:/pOS_RKRM/pAudio/Beep.c p:pLib/StdIO.o -l pOSStub -l pOS
  10.  
  11. /***********************************************************
  12.   pOS programing example - Copyright (C) 1995-97 proDAD
  13.  
  14.   This code was written as an easy to understand example,
  15.   how to program pOS features. It is provided 'as-is',
  16.   without any express or implied warranty.
  17.  
  18.   Permission is hereby granted to use, copy and modify
  19.   this source code for any purpose, without fee, subject
  20.   to the following conditions:
  21.  
  22.     (1) This notice may not be removed or altered from any
  23.         source distribution.
  24.  
  25.     (2) Altered source versions must be plainly marked as
  26.         such, and must not be misrepresented as being
  27.         the original source code.
  28.  
  29.     (3) If only executable code is distributed, then the
  30.         accompanying documentation have to state that
  31.         "this software is based in part on examples of
  32.         the pOS developer packet".
  33.  
  34.     (4) Permission for use of this code is granted only
  35.         if the user accepts full responsibility for any
  36.         undesirable consequences. proDAD accept NO LIABILITY
  37.         for damages of any kind.
  38.  
  39.   ©proDAD
  40. ***********************************************************/
  41.  
  42. /*\
  43. *** Example:
  44. ***
  45. \*/
  46.  
  47.  
  48. #define __COMPUTER_AMIGA 1
  49. #define NOMYDEBUG
  50.  
  51. #include "p:pExec/Types.h"
  52. #include "p:pDOS/ArgTags.h"
  53. #include "p:pDOS/DosSig.h"
  54. #include "p:pDOS/DosErrors.h"
  55. #include "p:pAudio/Audio.h"
  56. #include "p:pAudio/AudioTags.h"
  57. #include "p:pAudio/InfoData.h"
  58. #include "p:pAudio/StdAMap.h"
  59.  
  60. #include "p:proto/pLibExt.h"
  61. #include "p:proto/pExec2.h"
  62. #include "p:proto/pDOS2.h"
  63. #include "p:proto/pAudio2.h"
  64.  
  65. #ifdef _____ME_____
  66.   #include "grund/inc_string.h"
  67.   #include "grund/inc_stdio.h"
  68. #else
  69.  #ifdef __cplusplus
  70.  extern "C" {
  71.  #endif
  72.   #include <string.h>
  73.   #include <stdio.h>
  74.  #ifdef __cplusplus
  75.  }
  76.  #endif
  77. #endif
  78.  
  79.  
  80. const CHAR *HelpText=
  81. ""
  82. ;
  83.  
  84. const CHAR *PrgHeader=
  85. "";
  86.  
  87. const CHAR *PrgVerText=
  88. "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
  89.  
  90.  
  91. struct pOS_AudioDevice *gb_AudioBase;
  92.  
  93. /*----------------------------------
  94. -----------------------------------*/
  95. #ifdef __cplusplus
  96. extern "C"
  97. #endif
  98.  
  99. VOID main()
  100. {
  101.   struct pOS_DosArgs* Args;
  102.   UWORD Err=0;
  103.   ULONG Ops[3]={0xffff,3000,30};
  104.  
  105.   Args=pOS_ReadDosArgs(
  106. //  0                    1               2
  107. "VOLUME=VOL/K/N, FREQUENCE=FRQ/K/N, CYCLES=CYC/K/N",
  108. Ops,sizeof(Ops)/sizeof(ULONG),
  109.  
  110.     ARGTAG_PrgHeaderText, (ULONG)PrgHeader,    /* kurze Programm-Beschreibung */
  111.     ARGTAG_HelpText,      (ULONG)HelpText,     /* Help-Texte */
  112.     ARGTAG_PrgVerText,    (ULONG)PrgVerText,   /* VER-String */
  113.     TAG_END);
  114.  
  115.   if(Args) {
  116.     gb_AudioBase=(pOS_AudioDevice*)pOS_OpenLibrary("pAudio.library",0);
  117.  
  118.     if(gb_AudioBase) {
  119.       static SBYTE Sample[]={0,10,20,30,40,50,60,70,80,90,100,110,120,0};
  120.       pOS_Std8AudioMap Map={0};
  121.       Map.bam_Audio.am_Type=AUDIOMAPTYP_Std8Bit;
  122.       Map.bam_Audio.am_Frequence=100; // Default
  123.       Map.bam_Length=sizeof(Sample)/sizeof(SBYTE);
  124.       Map.bam_Sample=Sample;
  125.  
  126.       pOS_PlayChannel(&Map.bam_Audio,
  127.            AUDIOTAG_Volume,    *((ULONG*)Ops[0]),
  128.            AUDIOTAG_Frequence, *((ULONG*)Ops[1]),
  129.            AUDIOTAG_Cycles,    *((ULONG*)Ops[2]),
  130.            TAG_END);
  131.  
  132.       pOS_CloseLibrary((pOS_Library*)gb_AudioBase);
  133.     }
  134.     else printf("Cannot open audio.library\n");
  135.     pOS_DeleteDosArgs(Args);  /* Args freigeben */
  136.   }
  137.   else Err=DOSFAIL_FAIL;  /* vollkommen fehlgeschlagen */
  138.  
  139.   pOS_SetShellFail(Err);
  140. }
  141.