| 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 |
;; This code is broken in the following ways: |
| 81 |
;; it tries to run gnuplot even when plotting can be done by NyquistIDE |
| 82 |
;; it plots "points.dat", but "points.dat" may not be correct |
| 83 |
;; (see *default-plot-file*) |
| 84 |
;; it assumes the plot file is in the current directory, but it |
| 85 |
;; by default goes to the sound file directory |
| 86 |
;; |
| 87 |
;; Fix this code or complain if you want to plot with gnuplot while |
| 88 |
;; running ny (or even NyquistIDE (jny) if you want). Otherwise, use |
| 89 |
;; NyquistIDE to get s-plot to work. |
| 90 |
;; |
| 91 |
;(setf *runtime-path* (current-path)) |
| 92 |
;(display "system.lsp" *runtime-path*) |
| 93 |
; |
| 94 |
;(setfn standard-s-plot s-plot) |
| 95 |
; |
| 96 |
;(defun s-plot (s &optional (dur 2.0) (n 1000)) |
| 97 |
; (let (plot-file) |
| 98 |
; (standard-s-plot s dur n) ;; this calculates the data points |
| 99 |
; (setf plot-file (strcat *runtime-path* "nyquist-plot.txt")) |
| 100 |
; (system (strcat "gnuplot -persist " plot-file)))) |
| 101 |
|