home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume28 / cdreader / patch01 < prev    next >
Text File  |  1992-03-15  |  16KB  |  489 lines

  1. Newsgroups: comp.sources.misc
  2. From: pwolfe@blizzard.kai.com (Patrick Wolfe)
  3. Subject:  v28i099:  cdreader - Audio CD player for SGI's, Patch01
  4. Message-ID: <1992Mar14.221525.3352@sparky.imd.sterling.com>
  5. X-Md4-Signature: 90770a30788cc7840f041609f6f8c498
  6. Date: Sat, 14 Mar 1992 22:15:25 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: pwolfe@blizzard.kai.com (Patrick Wolfe)
  10. Posting-number: Volume 28, Issue 99
  11. Archive-name: cdreader/patch01
  12. Environment: SGI
  13. Patch-To: cdreader: Volume 28, Issue 82
  14.  
  15. The following patch creates cdreader version 1.5 from version 1.4 as posted to
  16. comp.sources.misc recently.  Just feed this file to "patch"!
  17.  
  18. Version 1.5 adds a scrollbar to control the Indigo speaker/headphone volume,
  19. so you don't have to run the Audio Control Panel just to adjust the volume.
  20.  
  21.         Patrick Wolfe  (pwolfe@kai.com, uunet!kailand!pwolfe)
  22.         System Programmer/Operations Manager, Kuck & Associates
  23.  
  24. --- cut here --- cut here --- cut here --- cut here --- cut here ---
  25. *** ../cdreader-1.4/cdreader.c    Thu Mar 12 16:36:21 1992
  26. --- cdreader.c    Wed Mar 11 20:06:05 1992
  27. ***************
  28. *** 9,15 ****
  29.    *    See the end of this file for the complete copyright notice.
  30.    */
  31.   
  32. ! #define VERSION "1.4"
  33.   
  34.   #include <stdio.h>
  35.   #include <stdlib.h>
  36. --- 9,15 ----
  37.    *    See the end of this file for the complete copyright notice.
  38.    */
  39.   
  40. ! #define VERSION "1.5"
  41.   
  42.   #include <stdio.h>
  43.   #include <stdlib.h>
  44. ***************
  45. *** 39,44 ****
  46. --- 39,45 ----
  47.   #include <Xm/RowColumn.h>
  48.   #include <Xm/MessageB.h>
  49.   #include <Xm/Form.h>
  50. + #include <Xm/ScrollBar.h>
  51.   
  52.   #ifdef WATCH_ABUF
  53.       /* for setitimer */
  54. ***************
  55. *** 48,53 ****
  56. --- 49,56 ----
  57.   int total_samps = 0;        /* number of samples the audio buffer will hold */
  58.   #endif /* WATCH_ABUF */
  59.   
  60. + #define MAX_VALUE(a,b) (a > b ? a : b)
  61.   /*
  62.    *    Most of the common messages are here, for easy customization and
  63.    *    translation for foreign languages.  We're not ALL ignorant bastards.
  64. ***************
  65. *** 106,120 ****
  66.   
  67.       /* audio stuff */
  68.   ALport audio_port = NULL;
  69.   CDPLAYER *cd_device = NULL;
  70.   CDPARSER *cd_parser = NULL;
  71.   CDFRAME *cd_buffer = NULL;
  72. -     /* cd stuff */
  73.   struct cdinformation {
  74.       short length_min;            /* track length */
  75.       short length_sec;
  76.       } track_info[MAX_TRACK_INFO];
  77.   int first_track = 0;                /* first track on the disk */
  78.   int last_track = 0;                /* index into track_info for entry AFTER last one we have info for */
  79.   int current_track = -1;                /* number of track currently playing */
  80. --- 109,125 ----
  81.   
  82.       /* audio stuff */
  83.   ALport audio_port = NULL;
  84. + long audio_param_buf[6];
  85. +     /* cd stuff */
  86.   CDPLAYER *cd_device = NULL;
  87.   CDPARSER *cd_parser = NULL;
  88.   CDFRAME *cd_buffer = NULL;
  89.   struct cdinformation {
  90.       short length_min;            /* track length */
  91.       short length_sec;
  92.       } track_info[MAX_TRACK_INFO];
  93.   int first_track = 0;                /* first track on the disk */
  94.   int last_track = 0;                /* index into track_info for entry AFTER last one we have info for */
  95.   int current_track = -1;                /* number of track currently playing */
  96. ***************
  97. *** 130,135 ****
  98. --- 135,141 ----
  99.   XtAppContext    appcon;
  100.   Widget    main_window,
  101.       label,
  102. +     volume_scrollbar,
  103.       play_button,
  104.       prev_button,
  105.       pause_button,
  106. ***************
  107. *** 139,147 ****
  108. --- 145,160 ----
  109.       info_button,
  110.       stop_button,
  111.       eject_button;
  112.   static XmStringCharSet charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
  113.   
  114. + void volume_callback();
  115. + static XtCallbackRec volume_callback_list[] = {
  116. +     { volume_callback, NULL},
  117. +     { NULL, NULL}
  118. +     };
  119.   
  120.   Display_Warning (message)
  121.   char *message;
  122.   {
  123. ***************
  124. *** 597,622 ****
  125.   register int n;
  126.   
  127.   (void) sprintf (message, "\
  128. ! Cdreader V%s plays an audio compact disc loaded in an SGI cdrom drive through\n\
  129.   the Audio Processor.\n\n\
  130. ! To get started, load an audio CD in the caddy, and insert it into your cd drive\n\
  131. ! with the clear side of the caddy facing up.\n\n\
  132.   The buttons function as follows:\n\
  133. ! \tPlay    - plays an audio disk\n\
  134. ! \tShuffle - plays the whole disk in a random order\n\
  135. ! \tStop    - stops playback\n\
  136. ! \tPause   - suspends playback - press Play to continue\n\
  137. ! \tNext    - selects the next track\n\
  138. ! \tPrev    - selects the previous track\n\
  139. ! \tTracks  - displays a table of tracks and their lengths\n\n\
  140. ! \tEject   - ejects the disk from the cdrom drive\n\
  141.   The buttons are context sensitive, for example, the eject button won't function\n\
  142.   unless the program is in the \"Stopped\" state.  Buttons are are not active will\n\
  143.   appear dimly shaded.\n\n\
  144.   Near the top of the window is a menu bar.  On the bar are three buttons:\n\
  145. ! \tQuit    - terminates the program\n\
  146. ! \tInfo    - give the author some credit!\n\
  147. ! \tHelp    - uh, you're looking at it\n\
  148.   ", VERSION);
  149.   
  150.   message_string = XmStringCreateLtoR (message, charset);
  151. --- 610,639 ----
  152.   register int n;
  153.   
  154.   (void) sprintf (message, "\
  155. ! \tCdreader V%s - Copyright (c) 1992 by Patrick J. Wolfe\n\n\
  156. ! Cdreader plays an audio compact disc loaded in an SGI cdrom drive through\n\
  157.   the Audio Processor.\n\n\
  158. ! To get started, load an audio CD in the cd caddy, and insert the caddy into \n\
  159. ! your SGI cdrom drive, with the clear side of the caddy facing up.  Wait until\n\
  160. ! the little yellow light stops blinking, and press the Play button.\n\n\
  161.   The buttons function as follows:\n\
  162. !     Play    - plays an audio disk\n\
  163. !     Shuffle - plays the whole disk in a random order\n\
  164. !     Stop    - stops playback\n\
  165. !     Pause   - suspends playback - press Play to continue\n\
  166. !     Next    - selects the next track\n\
  167. !     Prev    - selects the previous track\n\
  168. !     Eject   - ejects the disk from the cdrom drive\n\
  169. !     Tracks  - displays a table of tracks and their lengths\n\n\
  170.   The buttons are context sensitive, for example, the eject button won't function\n\
  171.   unless the program is in the \"Stopped\" state.  Buttons are are not active will\n\
  172.   appear dimly shaded.\n\n\
  173.   Near the top of the window is a menu bar.  On the bar are three buttons:\n\
  174. !     Quit    - terminates the program\n\
  175. !     Info    - give the author some credit!\n\
  176. !     Help    - uh, you're looking at it\n\n\
  177. ! The scrollbar at the bottom controls the Audio Processor speaker/headphone volume.\n\n\
  178. !     Enjoy!\n\
  179.   ", VERSION);
  180.   
  181.   message_string = XmStringCreateLtoR (message, charset);
  182. ***************
  183. *** 639,644 ****
  184. --- 656,683 ----
  185.   }
  186.   
  187.   
  188. + /* called by moving the volume scrollbar */
  189. + void
  190. + volume_callback (w, client_data, call_data)
  191. + Widget w;
  192. + caddr_t client_data;    /* unused */
  193. + caddr_t call_data;    /* unused */
  194. + {
  195. + int volume;
  196. + Arg arg;
  197. + XtSetArg (arg, XmNvalue, &volume);
  198. + XtGetValues (volume_scrollbar, &arg, 1);
  199. + /* set the audio processor output volume */
  200. + audio_param_buf[0] = AL_LEFT_SPEAKER_GAIN;
  201. + audio_param_buf[2] = AL_RIGHT_SPEAKER_GAIN;
  202. + audio_param_buf[1] = audio_param_buf[3] = volume;
  203. + ALsetparams (AL_DEFAULT_DEVICE, audio_param_buf, 4);
  204. + }
  205.   /* called only when the program (track) number changes */
  206.   void
  207.   cd_pnum_callback (arg, type, data)
  208. ***************
  209. *** 683,689 ****
  210.   init_audio ()
  211.   {
  212.   ALconfig aconfig;
  213. ! long pvbuf[6];
  214.   
  215.   if (audio_port == NULL) {
  216.       /* initialize the audio port */
  217. --- 722,728 ----
  218.   init_audio ()
  219.   {
  220.   ALconfig aconfig;
  221. ! int volume, slider_size, increment, page_increment;
  222.   
  223.   if (audio_port == NULL) {
  224.       /* initialize the audio port */
  225. ***************
  226. *** 717,728 ****
  227.           Display_Warning ("Could not open a port to the Audio Processor!");
  228.           return (1);
  229.           }
  230. -     /* set audio port output sampling rate to 44.1 kHz */
  231. -     pvbuf[0] = AL_OUTPUT_RATE;
  232. -     pvbuf[1] = AL_RATE_44100;
  233. -     ALsetparams (AL_DEFAULT_DEVICE, pvbuf, 2);
  234.       }
  235.   return (0);
  236.   }
  237.   
  238. --- 756,782 ----
  239.           Display_Warning ("Could not open a port to the Audio Processor!");
  240.           return (1);
  241.           }
  242.       }
  243. + /* set audio port output sampling rate to 44.1 kHz */
  244. + audio_param_buf[0] = AL_OUTPUT_RATE;
  245. + audio_param_buf[1] = AL_RATE_44100;
  246. + ALsetparams (AL_DEFAULT_DEVICE, audio_param_buf, 2);
  247. + /* get current scrollbar values */
  248. + XmScrollBarGetValues (volume_scrollbar, &volume,
  249. +     &slider_size, &increment, &page_increment);
  250. + /* set the volume scrollbar to the current volume */
  251. + audio_param_buf[0] = AL_LEFT_SPEAKER_GAIN;
  252. + audio_param_buf[2] = AL_RIGHT_SPEAKER_GAIN;
  253. + ALgetparams (AL_DEFAULT_DEVICE, audio_param_buf, 4);
  254. + volume = MAX_VALUE(audio_param_buf[1], audio_param_buf[3]);
  255. + /* set the scrollbar to the current value */
  256. + XmScrollBarSetValues (volume_scrollbar, volume,
  257. +     slider_size, increment, page_increment, 0);
  258.   return (0);
  259.   }
  260.   
  261. ***************
  262. *** 744,750 ****
  263.       cd_parser = CDcreateparser ();
  264.       if (cd_parser == NULL) {
  265.           Display_Warning ("SERIOUS ERROR!\nCDcreateparser failed");
  266. !         return (1);
  267.           }
  268.   
  269.       /* initialize parser structure */
  270. --- 798,804 ----
  271.       cd_parser = CDcreateparser ();
  272.       if (cd_parser == NULL) {
  273.           Display_Warning ("SERIOUS ERROR!\nCDcreateparser failed");
  274. !         return (2);
  275.           }
  276.   
  277.       /* initialize parser structure */
  278. ***************
  279. *** 821,826 ****
  280. --- 875,881 ----
  281.   XtSetArg (args[ctr], XmNwidth, 230); ctr++;
  282.   XtSetArg (args[ctr], XmNheight, 35); ctr++;
  283.   XtSetArg (args[ctr], XmNrecomputeSize, False); ctr++;
  284. + /* set location inside the form */
  285.   XtSetArg (args[ctr], XmNleftAttachment, XmATTACH_FORM); ctr++;
  286.   XtSetArg (args[ctr], XmNrightAttachment, XmATTACH_FORM); ctr++;
  287.   XtSetArg (args[ctr], XmNtopAttachment, XmATTACH_FORM); ctr++;
  288. ***************
  289. *** 833,843 ****
  290.   XtSetArg (args[ctr], XmNmarginHeight, 2); ctr++;
  291.   XtSetArg (args[ctr], XmNshadowThickness, 1); ctr++;
  292.   XtSetArg (args[ctr], XmNshadowType, XmSHADOW_OUT); ctr++;
  293.   XtSetArg (args[ctr], XmNleftAttachment, XmATTACH_FORM); ctr++;
  294.   XtSetArg (args[ctr], XmNrightAttachment, XmATTACH_FORM); ctr++;
  295.   XtSetArg (args[ctr], XmNtopAttachment, XmATTACH_WIDGET); ctr++;
  296.   XtSetArg (args[ctr], XmNtopWidget, label); ctr++;
  297. - XtSetArg (args[ctr], XmNbottomAttachment, XmATTACH_FORM); ctr++;
  298.   frame = XmCreateFrame (form, "frame", args, ctr);
  299.   XtManageChild (frame);
  300.   
  301. --- 888,898 ----
  302.   XtSetArg (args[ctr], XmNmarginHeight, 2); ctr++;
  303.   XtSetArg (args[ctr], XmNshadowThickness, 1); ctr++;
  304.   XtSetArg (args[ctr], XmNshadowType, XmSHADOW_OUT); ctr++;
  305. + /* set location inside the form */
  306.   XtSetArg (args[ctr], XmNleftAttachment, XmATTACH_FORM); ctr++;
  307.   XtSetArg (args[ctr], XmNrightAttachment, XmATTACH_FORM); ctr++;
  308.   XtSetArg (args[ctr], XmNtopAttachment, XmATTACH_WIDGET); ctr++;
  309.   XtSetArg (args[ctr], XmNtopWidget, label); ctr++;
  310.   frame = XmCreateFrame (form, "frame", args, ctr);
  311.   XtManageChild (frame);
  312.   
  313. ***************
  314. *** 912,917 ****
  315. --- 967,994 ----
  316.   XtManageChild (eject_button);
  317.   XtAddCallback (eject_button, XmNarmCallback, eject_callback, NULL);
  318.   XmStringFree (label_string);
  319. + /* get the current volume */
  320. + audio_param_buf[0] = AL_LEFT_SPEAKER_GAIN;
  321. + audio_param_buf[2] = AL_RIGHT_SPEAKER_GAIN;
  322. + ALgetparams (AL_DEFAULT_DEVICE, audio_param_buf, 4);
  323. + /* create scrollbar */
  324. + ctr = 0;
  325. + XtSetArg (args[ctr], XmNheight, 20); ctr++;
  326. + XtSetArg (args[ctr], XmNorientation, XmHORIZONTAL); ctr++;
  327. + XtSetArg (args[ctr], XmNprocessingDirection, XmMAX_ON_RIGHT); ctr++;
  328. + XtSetArg (args[ctr], XmNmaximum, 255); ctr++;
  329. + XtSetArg (args[ctr], XmNvalue, MAX_VALUE(audio_param_buf[1], audio_param_buf[3])); ctr++;
  330. + XtSetArg (args[ctr], XmNvalueChangedCallback, volume_callback_list); ctr++;
  331. + /* set location inside the form */
  332. + XtSetArg (args[ctr], XmNleftAttachment, XmATTACH_FORM); ctr++;
  333. + XtSetArg (args[ctr], XmNrightAttachment, XmATTACH_FORM); ctr++;
  334. + XtSetArg (args[ctr], XmNtopAttachment, XmATTACH_WIDGET); ctr++;
  335. + XtSetArg (args[ctr], XmNtopWidget, frame); ctr++;
  336. + XtSetArg (args[ctr], XmNbottomAttachment, XmATTACH_FORM); ctr++;
  337. + volume_scrollbar = XmCreateScrollBar (form, "scrollbar", args, ctr);
  338. + XtManageChild (volume_scrollbar);
  339.   
  340.   /* set MainWindow areas */
  341.   XmMainWindowSetAreas (main_window, menu_bar, NULL, NULL, NULL, form);
  342. *** ../cdreader-1.4/Makefile    Thu Mar 12 16:36:22 1992
  343. --- Makefile    Wed Mar 11 20:00:01 1992
  344. ***************
  345. *** 26,32 ****
  346.   #XLIBS = -lXm -lXt -lX11 -lPW
  347.   
  348.   LIBS = $(XLIBS) $(CDLIBS) $(AUDIOLIBS) -lc_s
  349. ! FILES = Readme cdreader.c Makefile cdreader.icon cdreader.1
  350.   BIN = /usr/local/bin
  351.   ICONDIR = /usr/lib/images
  352.   MANDIR = /usr/catman/local/man1
  353. --- 26,33 ----
  354.   #XLIBS = -lXm -lXt -lX11 -lPW
  355.   
  356.   LIBS = $(XLIBS) $(CDLIBS) $(AUDIOLIBS) -lc_s
  357. ! SHARFILES = Readme cdreader.c Makefile cdreader.icon cdreader.1
  358. ! TARFILES = README.1st Readme cdreader.c Makefile cdreader.icon cdreader.1 cdreader cdreader.shared_libs
  359.   BIN = /usr/local/bin
  360.   ICONDIR = /usr/lib/images
  361.   MANDIR = /usr/catman/local/man1
  362. ***************
  363. *** 66,78 ****
  364.   lint:
  365.       lint -uvxz cdreader.c
  366.   
  367. ! shar: $(FILES)
  368.       rm -f cdreader.shar
  369. !     shar $(FILES) > cdreader.shar
  370.       ls -l cdreader.shar
  371.   
  372.   clean:
  373. !     rm -f a.out core mklog cdreader cdreader.shar *.o
  374.   
  375.   #
  376.   # Original Author:  Patrick Wolfe  (pwolfe@kai.com, uunet!kailand!pwolfe)
  377. --- 67,85 ----
  378.   lint:
  379.       lint -uvxz cdreader.c
  380.   
  381. ! shar: $(SHARFILES)
  382.       rm -f cdreader.shar
  383. !     shar $(SHARFILES) > cdreader.shar
  384.       ls -l cdreader.shar
  385.   
  386. + tar: $(TARFILES)
  387. +     rm -f cdreader.tar*
  388. +     tar cvf cdreader.tar $(TARFILES)
  389. +     compress cdreader.tar
  390. +     ls -l cdreader.tar*
  391.   clean:
  392. !     rm -f a.out core mklog cdreader cdreader.shared_libs cdreader.shar *.o
  393.   
  394.   #
  395.   # Original Author:  Patrick Wolfe  (pwolfe@kai.com, uunet!kailand!pwolfe)
  396. *** ../cdreader-1.4/cdreader.1    Thu Mar 12 16:36:22 1992
  397. --- cdreader.1    Wed Mar 11 19:39:36 1992
  398. ***************
  399. *** 1,4 ****
  400. ! .TH CDREADER 1 "V1.4" "Usenet Software" "Usenet software"
  401.   
  402.   .SH NAME
  403.   cdreader \- play an audio compact disc through the audio processor
  404. --- 1,5 ----
  405. ! ...
  406. ! .TH CDREADER 1 "V1.5" "Usenet Software" "Usenet software"
  407.   
  408.   .SH NAME
  409.   cdreader \- play an audio compact disc through the audio processor
  410. ***************
  411. *** 14,20 ****
  412.   It opens a window with several buttons, whose function is similar to those on a
  413.   audio CD player.  Above the buttons is a message display, where the state of
  414.   the program is displayed.  When playing music, the track number and length
  415. ! appear here.
  416.   
  417.   .B Cdreader
  418.   performs much better when installed setuid root, or if you
  419. --- 14,21 ----
  420.   It opens a window with several buttons, whose function is similar to those on a
  421.   audio CD player.  Above the buttons is a message display, where the state of
  422.   the program is displayed.  When playing music, the track number and length
  423. ! appear here.  Below the buttons is a horizontal scrollbar, which is used to
  424. ! control the speaker/headphone volume of the audio processor.
  425.   
  426.   .B Cdreader
  427.   performs much better when installed setuid root, or if you
  428. *** ../cdreader-1.4/Readme    Thu Mar 12 16:36:20 1992
  429. --- Readme    Wed Mar 11 19:43:00 1992
  430. ***************
  431. *** 5,11 ****
  432.   Audio Processor (the SGI Indigo, for example).  Cdreader compiles only under
  433.   release 4.0.1 (or later) of the Irix operating system.
  434.   
  435. ! Version 1.4 sports an X11/Motif interface, and a new "shuffle" function.
  436.   
  437.   This is NOT just like SGI's "cdplayer" program, which simply commands the CD
  438.   drive to play an audio CD, and sits back to watch.  In that case, the digital
  439. --- 5,11 ----
  440.   Audio Processor (the SGI Indigo, for example).  Cdreader compiles only under
  441.   release 4.0.1 (or later) of the Irix operating system.
  442.   
  443. ! Version 1.5 adds a scrollbar to control the speaker/headphone volume.
  444.   
  445.   This is NOT just like SGI's "cdplayer" program, which simply commands the CD
  446.   drive to play an audio CD, and sits back to watch.  In that case, the digital
  447. ***************
  448. *** 48,53 ****
  449. --- 48,57 ----
  450.   
  451.   ------------------------------------------------------------------------------
  452.               RELEASE NOTES:
  453. + VERSION 1.5:
  454. + Added horizontal scrollbar to control the Indigo speaker/headphone volume.
  455.   
  456.   VERSION 1.4:
  457.   
  458. --- cut here --- cut here --- cut here --- cut here --- cut here ---
  459.  
  460. -- 
  461.  
  462.         Patrick Wolfe  (pwolfe@kai.com, uunet!kailand!pwolfe)
  463.         System Programmer/Operations Manager, Kuck & Associates
  464.  
  465.  
  466. exit 0 # Just in case...
  467.