home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 Christmas / macformat-045.iso / Shareware Plus / Developers / NGL1.5.0E(fat)DEMO / Audio Sample(PPC) / Audio_Sample(PPC).c < prev   
Encoding:
C/C++ Source or Header  |  1996-07-19  |  1.6 KB  |  76 lines  |  [TEXT/CWIE]

  1. /*============================================================
  2.  
  3.                   N-Music/Sound Sample program
  4.                     
  5. ============================================================*/
  6.  
  7. #include    "N_Library.h"
  8.  
  9. WindowPtr     CreateWindow         (Str255 name);
  10.  
  11.  
  12. #define        WindowSizeX        320
  13. #define        WindowSizeY        240
  14.  
  15. short        NewWindowX;
  16. short        NewWindowY;
  17.  
  18. short        Data_Rsrc = 0;
  19. long        wait;
  20.  
  21. short        Sounds[] = { 1000,1001,0 };                        //'SND'resource id
  22. short        Music1[] = { 1000,1001,-1 };                    //music 1 block (1000,1001,1001,1001,,,,)
  23.  
  24. void main(void)
  25. {
  26.     WindowPtr    window;
  27.  
  28.     ToolboxInit();
  29.     ColorCheck();
  30.     window = CreateWindow("\pN Game Library <Audio Sample>");
  31.  
  32.     Open_Resource_File(128,1,&Data_Rsrc);
  33.     N_Pict_Draw(128,0,0,(GrafPtr)window,true);
  34.     N_Sound_Load(&Sounds[0]);                                //open sound channels and read 'SND'
  35.     Close_Resource_File(&Data_Rsrc);
  36.     N_Music_Set(1,&Music1[0]);                                //set up music1 blocks
  37.     N_Music_Play(1);                                        //play music1
  38.  
  39.     do
  40.     {
  41.     }
  42.     while (!Button());
  43.  
  44.     N_Music_Out(180);                                        //Fade out
  45.     do
  46.     {
  47.     }
  48.     while (FO_Flag == true);
  49.  
  50.     N_Music_Kill();
  51.     N_Sound_Close();                                        //close sounds channels
  52.     ColorRevert();
  53.  
  54. }
  55.  
  56. WindowPtr CreateWindow (Str255 name)
  57. {
  58.     WindowPtr    window;
  59.     short        centerX,centerY;
  60.     short        windowWidth,windowHeight;
  61.  
  62.  
  63.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  64.     centerX  = (qd.screenBits.bounds.right -qd.screenBits.bounds.left)/2;
  65.     centerY  = (qd.screenBits.bounds.bottom -qd.screenBits.bounds.top)/2;
  66.     SetWTitle(window,name);
  67.     MoveWindow(window,NewWindowX=centerX-(WindowSizeX/2),NewWindowY=centerY-(WindowSizeY/2),false);
  68.     SizeWindow(window,WindowSizeX,WindowSizeY,TRUE);
  69.  
  70.     ShowWindow(window);
  71.     SetPort((GrafPtr)window );
  72.     return (WindowPtr)window;
  73. }
  74.     
  75.  
  76.