home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 February / MAC_easy_02_2010.iso / Software / Multimedia / audacity-macosx-ub-1.3.11.dmg / nyquist / system.lsp < prev    next >
Encoding:
Lisp/Scheme  |  2010-01-16  |  2.6 KB  |  91 lines

  1. ;; system.lsp -- system-dependent lisp code
  2.  
  3. ; local definition for play
  4. ;  this one is for Linux:
  5.  
  6. (if (not (boundp '*default-sf-format*))
  7.     (setf *default-sf-format* snd-head-wave))
  8.  
  9. (if (not (boundp '*default-sound-file*))
  10.     (compute-default-sound-file))
  11.  
  12. (if (not (boundp '*default-sf-dir*))
  13.     (setf *default-sf-dir* "./"))
  14.  
  15. (if (not (boundp '*default-sf-mode*))
  16.     (setf *default-sf-mode* snd-mode-pcm))
  17.  
  18. (if (not (boundp '*default-sf-bits*))
  19.     (setf *default-sf-bits* 16))
  20.  
  21. (if (not (boundp '*default-plot-file*))
  22.     (setf *default-plot-file* (strcat (get-user) "-points.dat")))
  23.  
  24.  
  25. ; FULL-NAME-P -- test if file name is a full path or relative path
  26. ;
  27. ; (otherwise the *default-sf-dir* will be prepended
  28. ;
  29. (defun full-name-p (filename)
  30.   (or (eq (char filename 0) #\/)
  31.       (eq (char filename 0) #\.)))
  32.  
  33. ; RELATIVE-PATH-P -- test if filename or path is a relative path
  34. ;
  35. (defun relative-path-p (filename)
  36.   (not (eq (char filename 0) #\/)))
  37.  
  38. (setf *file-separator* #\/)
  39.  
  40.  
  41. ;; PLAY-FILE - play a sound file
  42. ;;
  43. (defun play-file (name)
  44. ;;
  45. ;; WARNING: if you invoke an external program to play files, 
  46. ;; but Nyquist uses internal (portaudio) interface to
  47. ;; play synthesized sound, Nyquist may fail to open the
  48. ;; sound device while it is playing a sound file and then
  49. ;; refuse to play anything. -RBD dec05
  50. ;;  (system (strcat "sndplay " (soundfilename name))))
  51. ;;  (system (strcat "play " (soundfilename name) )))
  52. ;;
  53.   (play (s-read (soundfilename name))))
  54.  
  55. ;; R - replay last file written with PLAY
  56. (defun r () (play-file *default-sound-file*))
  57.  
  58. ;;;; use this old version if you want to use sndplay to play
  59. ;;;; the result file rather than play the samples as they
  60. ;;;; are computed. This version does not autonormalize.
  61. ;; PLAY - write value of an expression to file and play it
  62. ;;
  63. ;(defmacro play (expr)
  64. ;  `(prog (specs)
  65. ;     (setf specs (s-save (force-srate *sound-srate* ,expr) 
  66. ;               1000000000 *default-sound-file*))
  67. ;     (r)))
  68. ;;;;
  69.  
  70. ; local definition for play
  71. (defmacro play (expr)
  72.   `(s-save-autonorm ,expr NY:ALL *default-sound-file* :play *soundenable*))
  73.  
  74. ;; for Linux, modify s-plot (defined in nyquist.lsp) by saving s-plot
  75. ;; in standard-s-plot, then call gnuplot to display the points.
  76. ;;
  77. ;; we also need to save the location of this file so we can find
  78. ;; nyquist-plot.txt, the command file for gnuplot
  79. ;;
  80. (setf *runtime-path* (current-path))
  81. (display "system.lsp" *runtime-path*)
  82.  
  83. (setfn standard-s-plot s-plot)
  84.  
  85. (defun s-plot (s &optional (n 1000) (dur 2.0))
  86.   (let (plot-file)
  87.     (standard-s-plot s n dur) ;; this calculates the data points
  88.     (setf plot-file (strcat *runtime-path* "nyquist-plot.txt"))
  89.     (system (strcat "gnuplot -persist " plot-file))))
  90.  
  91.