home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume28 / cdreader / patch02 < prev    next >
Encoding:
Text File  |  1992-03-21  |  6.8 KB  |  245 lines

  1. Newsgroups: comp.sources.misc
  2. From: pwolfe@blizzard.kai.com (Patrick Wolfe)
  3. Subject:  v28i119:  cdreader - Audio CD player for SGI's, Patch02
  4. Message-ID: <1992Mar22.044159.10022@sparky.imd.sterling.com>
  5. X-Md4-Signature: ef01d4a6d4b498aeaee2a054021b75b8
  6. Date: Sun, 22 Mar 1992 04:41:59 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: pwolfe@blizzard.kai.com (Patrick Wolfe)
  10. Posting-number: Volume 28, Issue 119
  11. Archive-name: cdreader/patch02
  12. Environment: SGI
  13. Patch-To: cdreader: Volume 28, Issue 82
  14.  
  15. Enclosed is a short patch which upgrades my cdreader program from version 1.5
  16. to verson 1.5.1, fixing a bug in the "shuffle" mode, and improving the
  17. random-ness of the shuffle mode play list order.  The bug was that cdreader
  18. always stopped after playing the last track on the disc, but in shuffle mode,
  19. the last track on the disc was rarely the last track on the play list.  Thank
  20. you to Brian Love for the bug report.
  21.  
  22. The most recent version of the source, as well as a pre-compiled executable is
  23. available for anonymous ftp from ftp.uu.net (137.39.1.9), directory "/tmp",
  24. file "cdreader-1.5.1.tar.Z".  Remember to use "binary" mode when fetching it.
  25.  
  26.         Patrick Wolfe  (pwolfe@kai.com, uunet!kailand!pwolfe)
  27.         System Programmer/Operations Manager, Kuck & Associates
  28.  
  29. ------------------------------------------------------------------------------
  30.  
  31. *** ../cdreader-1.5/cdreader.c    Wed Mar 11 20:06:05 1992
  32. --- cdreader.c    Wed Mar 18 12:37:53 1992
  33. ***************
  34. *** 9,15 ****
  35.    *    See the end of this file for the complete copyright notice.
  36.    */
  37.   
  38. ! #define VERSION "1.5"
  39.   
  40.   #include <stdio.h>
  41.   #include <stdlib.h>
  42. --- 9,15 ----
  43.    *    See the end of this file for the complete copyright notice.
  44.    */
  45.   
  46. ! #define VERSION "1.5.1"
  47.   
  48.   #include <stdio.h>
  49.   #include <stdlib.h>
  50. ***************
  51. *** 20,25 ****
  52. --- 20,29 ----
  53.   #include <signal.h>
  54.       /* for getopt() */
  55.   #include <getopt.h>
  56. +     /* for [ls]rand48() */
  57. + #include <math.h>
  58. +     /* for time() */
  59. + #include <time.h>
  60.       /* for CD*() routines */
  61.   #include <cdaudio.h>
  62.       /* for AL*() routines */
  63. ***************
  64. *** 41,46 ****
  65. --- 45,51 ----
  66.   #include <Xm/Form.h>
  67.   #include <Xm/ScrollBar.h>
  68.   
  69.   #ifdef WATCH_ABUF
  70.       /* for setitimer */
  71.   #include <sys/time.h>
  72. ***************
  73. *** 105,111 ****
  74.   
  75.   /* maximum number of tracks to store info for */
  76.   /* I *have* seen up to 28 tracks on a single CD, but none longer */
  77. ! #define MAX_TRACK_INFO    64
  78.   
  79.       /* audio stuff */
  80.   ALport audio_port = NULL;
  81. --- 110,117 ----
  82.   
  83.   /* maximum number of tracks to store info for */
  84.   /* I *have* seen up to 28 tracks on a single CD, but none longer */
  85. ! /* someone told me of a sound effects cd that has over 100 tracks - sigh */
  86. ! #define MAX_TRACK_INFO    128
  87.   
  88.       /* audio stuff */
  89.   ALport audio_port = NULL;
  90. ***************
  91. *** 441,447 ****
  92.       return;
  93.       }
  94.   
  95. ! m = last_track - 1;
  96.   
  97.   /* initialize played array to -1's, indicating track hasn't been selected to play yet */
  98.   for (i = first_track; i < last_track; i++) {
  99. --- 447,453 ----
  100.       return;
  101.       }
  102.   
  103. ! m = last_track - first_track;
  104.   
  105.   /* initialize played array to -1's, indicating track hasn't been selected to play yet */
  106.   for (i = first_track; i < last_track; i++) {
  107. ***************
  108. *** 448,463 ****
  109.       played[i] = 0;
  110.       }
  111.   
  112. ! /* seed is our process id */
  113. ! srand ((u_int) getpid());
  114.   
  115.   for (i = first_track; i < last_track; i++) {
  116. !     j = rand( );
  117. !     jdb = (double)j / (double)(RAND_MAX + 1);
  118. !     j = (int)(jdb * m) + 1;
  119.       for (; played[j]; j += d) {
  120.           if (j < first_track) {
  121. !             j = last_track;
  122.               }
  123.           else if (j >= last_track) {
  124.               j = first_track;
  125. --- 454,470 ----
  126.       played[i] = 0;
  127.       }
  128.   
  129. ! /* set the seed for our random numbers */
  130. ! srand48 (time(0));
  131.   
  132.   for (i = first_track; i < last_track; i++) {
  133. !     jdb = drand48(); /* returns between 0 and 1 */
  134. !     jdb = jdb * m;
  135. !     j = (int) jdb;
  136. !     j++;
  137.       for (; played[j]; j += d) {
  138.           if (j < first_track) {
  139. !             j = last_track - 1;
  140.               }
  141.           else if (j >= last_track) {
  142.               j = first_track;
  143. ***************
  144. *** 1219,1225 ****
  145.           if (status == PLAYING) {
  146.               frames_to_play = CDreadda (cd_device, &cd_buffer[0], cd_readsize);
  147.               if (frames_to_play < 1) {    /* end of disc */
  148. !                 status = STOPPING;
  149.                   }
  150.               }
  151.   
  152. --- 1226,1239 ----
  153.           if (status == PLAYING) {
  154.               frames_to_play = CDreadda (cd_device, &cd_buffer[0], cd_readsize);
  155.               if (frames_to_play < 1) {    /* end of disc */
  156. !                 if ((play_index > -1) && (play_index < last_track)) {    /* shuffling - play next track in the list */
  157. !                     play_index++;
  158. !                     current_track = play_list[play_index];
  159. !                     status = START_TRACK;
  160. !                     }
  161. !                 else    {    /* end of disc - stop */
  162. !                     status = STOPPING;
  163. !                     }
  164.                   }
  165.               }
  166.   
  167. *** ../cdreader-1.5/Readme    Wed Mar 11 19:43:00 1992
  168. --- Readme    Wed Mar 18 13:07:56 1992
  169. ***************
  170. *** 3,9 ****
  171.   
  172.   Cdreader plays an audio compact disc on Silicon Graphics workstations with an
  173.   Audio Processor (the SGI Indigo, for example).  Cdreader compiles only under
  174. ! release 4.0.1 (or later) of the Irix operating system.
  175.   
  176.   Version 1.5 adds a scrollbar to control the speaker/headphone volume.
  177.   
  178. --- 3,10 ----
  179.   
  180.   Cdreader plays an audio compact disc on Silicon Graphics workstations with an
  181.   Audio Processor (the SGI Indigo, for example).  Cdreader compiles only under
  182. ! release 4.0.1 (or later) of the Irix operating system, and you must have the
  183. ! X11, Motif and cdrom development packages installed.
  184.   
  185.   Version 1.5 adds a scrollbar to control the speaker/headphone volume.
  186.   
  187. ***************
  188. *** 48,53 ****
  189. --- 49,61 ----
  190.   
  191.   ------------------------------------------------------------------------------
  192.               RELEASE NOTES:
  193. + VERSION 1.5.1:
  194. + Fixed a bug in the "shuffle" mode, and improved the random-ness of the play
  195. + list generator.  The bug was that cdreader always stopped after playing the
  196. + last track on the disc, but in shuffle mode, the last track on the disc was
  197. + rarely the last track on the play list.
  198.   
  199.   VERSION 1.5:
  200.   
  201. *** ../cdreader-1.5/cdreader.1    Wed Mar 11 19:39:36 1992
  202. --- cdreader.1    Wed Mar 18 13:09:04 1992
  203. ***************
  204. *** 1,5 ****
  205.   ...
  206. ! .TH CDREADER 1 "V1.5" "Usenet Software" "Usenet software"
  207.   
  208.   .SH NAME
  209.   cdreader \- play an audio compact disc through the audio processor
  210. --- 1,5 ----
  211.   ...
  212. ! .TH CDREADER 1 "V1.5.1" "Usenet Software" "Usenet software"
  213.   
  214.   .SH NAME
  215.   cdreader \- play an audio compact disc through the audio processor
  216. ***************
  217. *** 77,83 ****
  218.   displays an online help window
  219.   
  220.   .SH "SEE ALSO"
  221. ! cdplayer(1), apanel(1)
  222.   
  223.   .SH "AUTHOR"
  224.   .B Cdreader
  225. --- 77,83 ----
  226.   displays an online help window
  227.   
  228.   .SH "SEE ALSO"
  229. ! cdplayer(1), apanel(1), cdaudio(3), cdframe(4)
  230.   
  231.   .SH "AUTHOR"
  232.   .B Cdreader
  233. ------------------------------------------------------------------------------
  234.  
  235. -- 
  236.  
  237.         Patrick Wolfe  (pwolfe@kai.com, uunet!kailand!pwolfe)
  238.         System Programmer/Operations Manager, Kuck & Associates
  239.  
  240.  
  241. exit 0 # Just in case...
  242.