source: plugins/audacity/audacity-nyquist.diff @ c218821

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since c218821 was 96fb8ad, checked in by Paul Brossier <piem@altern.org>, 20 years ago

import 0.1.7.1

  • Property mode set to 100644
File size: 22.3 KB
  • nyquist/misc.lsp

    old new  
    7474                  (setf fullpath ":")))
    7575           fullpath)
    7676          (t nil))))
    77          
    78 ;; real-random -- pick a random real from a range
    79 ;;
    80 (defun real-random (from to)
    81   (cond ((= from to) from)
    82           (t
    83          (+ from
    84            (* (random 10000)
    85               0.0001
    86               (- to from))))))
    87 
    88 ;; power -- raise a number to some power x^y
    89 ;;
    90 (defun power (x y)
    91   (exp (* (log (float x)) y)))
    92  
  • nyquist/nyinit.lsp

    old new  
    2626(setf *WATCH* NIL)
    2727
    2828(format t "~%Nyquist -- A Language for Sound Synthesis and Composition~%")
    29 (format t "    Copyright (c) 1991-2003 by Roger B. Dannenberg~%")
     29(format t "    Copyright (c) 1991,1992,1995 by Roger B. Dannenberg~%")
    3030(format t "    Version 2.29~%~%")
    3131
    3232(setf *gc-flag* t)
  • nyquist/nyquist.lsp

    old new  
    66;;;   ###########################################################
    77;;;
    88
    9 ;;;   
    10 ;;;   Modifications for using Nyquist within Audacity
    11 ;;;   by Dominic Mazzoni
    12 ;;;
     9(load "fileio.lsp")
    1310
    1411(prog ()
    1512   (setq lppp -12.0) (setq lpp -9.0)  (setq lp -6.0)    (setq lmp -3.0)
     
    217214    (cond ((> hz (/ *SOUND-SRATE* 2))
    218215           (format t "Warning: buzz nominal frequency (~A hz) will alias at current sample rate (~A hz).\n"
    219216                   hz *SOUND-SRATE*)))
    220     (setf n (min n 1)) ; avoid divide by zero problem
     217    (setf n (max n 1)) ; avoid divide by zero problem
    221218    (scale-db (get-loud)
    222219              (snd-buzz n                   ; number of harmonics
    223220                        *SOUND-SRATE*       ; output sample rate
     
    344341    d                   ; duration
    345342    phase)))            ; phase
    346343
     344
    347345;; FMLFO -- like LFO but uses frequency modulation
    348346;;
    349347(defun fmlfo (freq &optional (sound *SINE-TABLE*) (phase 0.0))
     
    358356          (t
    359357           (error "frequency must be a number or sound")))))
    360358
     359
    361360;; OSC - table lookup oscillator
    362361;;
    363362(defun osc (pitch &optional (duration 1.0)
     
    761760      ,s))
    762761
    763762
     763;; COMPUTE-DEFAULT-SOUND-FILE -- construct and set *default-sound-file*
     764;;
     765;; (this is harder than it might seem because the default place for
     766;;  sound files is in /tmp, which is shared by users, so we'd like to
     767;;  use a user-specific name to avoid collisions)
     768;;
     769(defun compute-default-sound-file ()
     770  (let (inf user extension)
     771      ; the reason for the user name is that if UserA creates a temp file,
     772      ; then UserB will not be able to overwrite it. The user name is a
     773      ; way to give each user a unique temp file name. Note that we don't
     774      ; want each session to generate a unique name because Nyquist doesn't
     775      ; delete the sound file at the end of the session.
     776    (system "echo $USER > ny_username.tmp")
     777    (setf inf (open "ny_username.tmp"))
     778    (cond (inf
     779           (setf user (read inf))
     780       (close inf)
     781       (system "rm ny_username.tmp"))
     782      (t        ; must not be unix, make up a generic name
     783       (setf user 'nyquist)))
     784    (cond ((null user)           
     785       (format t
     786"Please type your user-id so that I can construct a default
     787sound-file name.  To avoid this message in the future, add
     788this to your .login file:
     789    setenv USER <your id here>
     790or add this to your init.lsp file:
     791    (setf *default-sound-file* \"<your filename here>\")
     792    (setf *default-sf-dir* \"<full pathname of desired directory here>\")
     793
     794Your id please: ")
     795       (setf user (read))))
     796    ; now compute the extension based on *default-sf-format*
     797    (cond ((= *default-sf-format* snd-head-AIFF)
     798           (setf extension ".aif"))
     799          ((= *default-sf-format* snd-head-Wave)
     800           (setf extension ".wav"))
     801          (t
     802           (setf extension ".snd")))
     803    (setf *default-sound-file*
     804      (strcat (string-downcase (symbol-name user)) "-temp" extension))
     805    (format t "Default sound file is ~A.~%" *default-sound-file*)))
     806
     807
    764808;; CONTROL-WARP -- apply a warp function to a control function
    765809;;
    766810(defun control-warp (warp-fn control &optional wrate)
     
    792836         (snd-srate sound)
    793837         (local-to-global 0) *START* *STOP* (db-to-linear (get-loud))))
    794838
     839; (s-plot (progv '(*TIME* *START*)'(0.0 0.5)(cue (snd-sine 20 1 100 1)))1000)
     840;(s-plot(progv'(*TIME* *START*)'(0.0 0.5)(cue(cue (snd-sine 20 1 100 1))))1000)
     841
    795842;; (sound sound)
    796843;;    Same as (cue sound), except also warps the sound.
    797844;; Note that the *WARP* can change the pitch of the
     
    861908(setfn control sound)
    862909
    863910
     911;; (cue-file string)
     912;;    Loads a sound file with the given name, returning a sound which is
     913;; transformed to the current environment.
     914;(defun cue-file (name)
     915;   (cue (snd-load  name *SOUND-SRATE*)))
     916
     917
    864918;; (env t1 t2 t4 l1 l2 l3 &optional duration)
    865919;; Creates a 4-phase envelope.
    866920;;      tN is the duration of phase N, and lN is the final level of
     
    13271381;
    13281382(load "seq" :verbose NIL)
    13291383
     1384;(defmacro with%environment (env &rest expr)
     1385;  `(progv ',*environment-variables* ',env ,@expr))
     1386;
     1387;(defmacro seq (&rest list)
     1388;  (display "seq" list)
     1389;  (cond ((null list)
     1390;         (snd-zero *time* *sound-srate*))
     1391;        ((null (cdr list))
     1392;         (car list))
     1393;       ((null (cddr list))
     1394;        `(let* ((first%sound ,(car list))
     1395;                (s%rate (snd-srate first%sound)))
     1396;           (snd-seq first%sound
     1397;                    #'(lambda (t0)
     1398;                        (with%environment
     1399;                          ,(the%environment) (setf *time* t0)     
     1400;                          (force-srate s%rate ,(cadr list)))))))
     1401;       (t
     1402;        `(let* ((first%sound ,(car list))
     1403;                (s%rate (snd-srate first%sound)))
     1404;           (snd-seq first%sound
     1405;                    #'(lambda (t0)
     1406;                        (format t "snd-seq applying lambda")
     1407;                        (with%environment
     1408;                          ,(the%environment) (setf *time* t0)     
     1409;                          (seq (force-srate s%rate ,(cadr list))
     1410;                               ,@(cddr list))))) ))))
     1411;
     1412;
     1413;(defmacro seqrep (pair sound)
     1414;  `(let ((,(car pair) 0)
     1415;         ($loop-count (1- ,(cadr pair))))
     1416;     (cond ((< 0 $loop-count)
     1417;            (seqrep2 ,(car pair) ,sound))
     1418;           ((= 0 $loop-count)
     1419;            ,sound)
     1420;           (t
     1421;            (snd-zero *time* *sound-srate*)))))
     1422;
     1423;
     1424;(defmacro seqrep2 (var sound)
     1425;  `(cond ((< ,var $loop-count)
     1426;          (seq (prog1 ,sound (setf ,var (1+ ,var)))
     1427;               (seqrep2 ,var ,sound)))
     1428;         ((= ,var $loop-count)
     1429;          ,sound)))
     1430
     1431
    13301432; set-logical-stop - modify the sound and return it, time is shifted and
    13311433;                        stretched
    13321434(defun set-logical-stop (snd tim)
     
    15321634(defun osc-pulse (hz bias &optional (compare-shape *step-shape*))
    15331635  (compare bias (osc-tri hz) compare-shape))
    15341636
    1535 (setf NY:ALL 1000000000)
     1637
  • nyquist/seq.lsp

    old new  
    176176             (error (format nil "Negative stretch factor in TIMED-SEQ: ~A" event)))
    177177            (t
    178178             (setf start-time (car event)))))
    179     (cond ((null score) (s-rest 0))
    180           (t
    181            (at (caar score)
    182                (seqrep (i (length score))
    183                  (cond ((cdr score)
    184                         (let (event)
    185                           (prog1
    186                             (set-logical-stop
    187                               (stretch (cadar score)
    188                               (setf event (eval (caddar score))))
    189                             (- (caadr score) (caar score)))
    190 ;                           (display "timed-seq" (caddar score) (local-to-global 0))
    191                             (setf score (cdr score)))))
    192                          (t
    193                           (stretch (cadar score) (eval (caddar score)))))))))))
     179    (at (caar score)
     180        (seqrep (i (length score))
     181           (cond ((cdr score)
     182                  (let (event)
     183                   (prog1
     184                    (set-logical-stop (stretch (cadar score)
     185                                               (setf event (eval (caddar score))))
     186                                      (- (caadr score) (caar score)))
     187;                   (display "timed-seq" (caddar score) (local-to-global 0))
     188                    (setf score (cdr score)))))
     189                 (t
     190                  (stretch (cadar score) (eval (caddar score)))))))))
    194191
    195192
    196193
  • nyquist/system.lsp

    old new  
    1 ; system.lsp -- machine/system-dependent definitions
     1;; system.lsp -- system-dependent lisp code
    22
    3 ;; default behavior is to call SETUP-CONSOLE to get large white typescript
    4 ;;
    5 ;; set *setup-console* to nil in your personal init.lsp to override this behavior
    6 ;; (this may be necessary to work with emacs)
    7 ;;
    8 (if (not (boundp '*setup-console*)) (setf *setup-console* t))
    9 (if *setup-console* (setup-console))
     3; local definition for play
     4;  this one is for Linux:
    105
    116(setf ny:bigendianp nil)
    127
    138(if (not (boundp '*default-sf-format*))
    14     (setf *default-sf-format* snd-head-Wave))
     9    (setf *default-sf-format* snd-head-wave))
    1510
    16 ;(if (not (boundp '*default-sound-file*))
    17 ;    (setf *default-sound-file* "temp.wav"))
     11(if (not (boundp '*default-sound-file*))
     12    (compute-default-sound-file))
    1813
    19 ;(if (not (boundp '*default-sf-dir*))
    20 ;    (setf *default-sf-dir* ""))
     14(if (not (boundp '*default-sf-dir*))
     15    (setf *default-sf-dir* "./"))
    2116
    2217(if (not (boundp '*default-sf-mode*))
    2318    (setf *default-sf-mode* snd-head-mode-pcm))
     
    2520(if (not (boundp '*default-sf-bits*))
    2621    (setf *default-sf-bits* 16))
    2722
    28 ;(if (not (boundp '*default-plot-file*))
    29 ;    (setf *default-plot-file* "points.dat"))
    30 
    31 ;(if (not (boundp '*plotscript-file*))
    32 ;    (setf *plotscript-file* "sys/unix/rs6k/plotscript"))
    33 
    34 ; local definition for play
    35 ;(defmacro play (expr)
    36 ;  `(s-save-autonorm ,expr NY:ALL *default-sound-file* :play *soundenable*))
    37 
    38 
    39 ;(defun r ()
    40 ;  (s-save (s-read *default-sound-file*) NY:ALL "" :play t)
    41 ;)
    42 
    43 
    44 ; PLAY-FILE -- play a file
    45 ;(defun play-file (name)
    46 ;  (s-save (s-read name) NY:ALL "" :play t))
     23(if (not (boundp '*default-plot-file*))
     24    (setf *default-plot-file* "points.dat"))
    4725
    4826
    4927; FULL-NAME-P -- test if file name is a full path or relative path
     
    5129; (otherwise the *default-sf-dir* will be prepended
    5230;
    5331(defun full-name-p (filename)
    54   (or (eq (char filename 0) #\\)
    55       (eq (char filename 0) #\.)
    56       (and (> (length filename) 2)
    57          (both-case-p (char filename 0))
    58        (equal (char filename 1) #\:))))
     32  (or (eq (char filename 0) #\/)
     33      (eq (char filename 0) #\.)))
    5934
    60 (setf *file-separator* #\\)
    6135
    62 ;(defun ny:load-file () (load "*.*"))
    63 ;(defun ny:reload-file () (load "*"))
     36(setf *file-separator* #\/)
    6437
    6538
    66 ; save the standard function to write points to a file
    67 ;
    68 ;(setfn s-plot-points s-plot)
     39;; PLAY-FILE - play a sound file
     40;;
     41(defun play-file (name)
     42;;  (system (strcat "sndplay " (soundfilename name))))
     43  (system (strcat "play " (soundfilename name) )))
     44
     45;; R - replay last file written with PLAY
     46(defun r () (play-file *default-sound-file*))
     47
     48;;;; use this old version if you want to use sndplay to play
     49;;;; the result file rather than play the samples as they
     50;;;; are computed. This version does not autonormalize.
     51;; PLAY - write value of an expression to file and play it
     52;;
     53;(defmacro play (expr)
     54;  `(prog (specs)
     55;        (setf specs (s-save (force-srate *sound-srate* ,expr)
     56;                          1000000000 *default-sound-file*))
     57;        (r)))
     58;;;;
    6959
    70 ;(defun array-max-abs (points)
    71 ;  (let ((m 0.0))
    72 ;        (dotimes (i (length points))
    73 ;          (setf m (max m (abs (aref points i)))))
    74 ;        m))
    75 
    76 ;(setf graph-width 600)
    77 ;(setf graph-height 220)
    78 
    79 ;(defun s-plot (snd &optional (n 600))
    80 ;  (show-graphics)
    81 ;  (clear-graphics)
    82 ;  (cond ((soundp snd)
    83 ;               (s-plot-2 snd n (/ graph-height 2) graph-height))
    84 ;              (t
    85 ;               (let ((gh (/ graph-height (length snd)))
    86 ;                     hs)
    87 ;                 (dotimes (i (length snd))
    88 ;                   (setf hs (s-plot-2 (aref snd i) n (+ (/ gh 2) (* i gh)) gh hs)))))))
    89 ;
    90 ;
    91 ;(defun s-plot-2 (snd n y-offset graph-height horizontal-scale)
    92 ;  (prog ((points (snd-samples snd n))
    93 ;                   maxpoint horizontal-scale vertical-scale)
    94 ;    (setf maxpoint (array-max-abs points))
    95 ;    (moveto 0 y-offset)
    96 ;    (lineto graph-width y-offset)
    97 ;    (moveto 0 y-offset)
    98 ;    (cond ((null horizontal-scale)
    99 ;               (setf horizontal-scale (/ (float graph-width) (length points)))))
    100 ;    (setf vertical-scale (- (/ (float graph-height) 2 maxpoint)))
    101 ;    (dotimes (i (length points))
    102 ;      (lineto (truncate (* horizontal-scale i))
    103 ;              (+ y-offset (truncate (* vertical-scale (aref points i))))))
    104 ;    (format t "X Axis: ~A to ~A (seconds)\n" (snd-t0 snd) (/ (length points) (snd-srate snd)))
    105 ;    (format t "Y Axis: ~A to ~A\n" (- maxpoint) maxpoint)
    106 ;    (format t "~A samples plotted.\n" (length points))
    107 ;    (return horizontal-scale)
    108 ;    ))
    109 ;
    110 ; S-EDIT - run the audio editor on a sound
    111 ;
    112 ;(defmacro s-edit (&optional expr)
    113 ;  `(prog ()
    114 ;         (if ,expr (s-save ,expr 1000000000 *default-sound-file*))
    115 ;         (system (format nil "audio_editor ~A &"
    116 ;                         (soundfilename *default-sound-file*)))))
     60; local definition for play
     61(defmacro play (expr)
     62  `(s-save-autonorm ,expr NY:ALL *default-sound-file* :play *soundenable*))
     63
     64;; for Linux, modify s-plot (defined in nyquist.lsp) by saving s-plot
     65;; in standard-s-plot, then call gnuplot to display the points.
     66;;
     67;; we also need to save the location of this file so we can find
     68;; nyquist-plot.txt, the command file for gnuplot
     69;;
     70(setf *runtime-path* (current-path))
     71(display "system.lsp" *runtime-path*)
     72
     73(setfn standard-s-plot s-plot)
     74
     75(defun s-plot (s)
     76  (let (plot-file)
     77    (standard-s-plot s) ;; this calculates the data points
     78    (setf plot-file (strcat *runtime-path* "nyquist-plot.txt"))
     79    (system (strcat "gnuplot -persist " plot-file))))
    11780
  • nyquist/fileio.lsp

    old new  
     1;; s-save -- saves a file
     2(setf NY:ALL 1000000000)        ; 1GIG constant for maxlen
     3(defmacro s-save (expression &optional (maxlen NY:ALL) filename
     4                  &key (format '*default-sf-format*)
     5                  (mode '*default-sf-mode*) (bits '*default-sf-bits*)
     6                  (endian NIL) ; nil, :big, or :little -- specifies file format
     7                  (play nil))
     8  `(let ((ny:fname ,filename)
     9         (ny:maxlen ,maxlen)
     10         (ny:endian ,endian)
     11         (ny:swap 0))
     12     ; allow caller to omit maxlen, in which case the filename will
     13     ; be a string in the maxlen parameter position and filename will be null
     14     (cond ((null ny:fname)
     15                 (cond ((stringp ny:maxlen)
     16                            (setf ny:fname ny:maxlen)
     17                            (setf ny:maxlen NY:ALL))
     18                           (t
     19                            (setf ny:fname *default-sound-file*)))))
     20     
     21     (cond ((equal ny:fname "")
     22                 (cond ((not ,play)
     23                       (format t "s-save: no file to write! play option is off!\n"))))
     24           (t
     25            (setf ny:fname (soundfilename ny:fname))
     26            (format t "Saving sound file to ~A~%" ny:fname)))
     27     (cond ((eq ny:endian :big)
     28            (setf ny:swap (if ny:bigendianp 0 1)))
     29           ((eq ny:endian :little)
     30            (setf ny:swap (if ny:bigendianp 1 0))))
     31     (snd-save ',expression ny:maxlen ny:fname ,format ,mode ,bits ny:swap ,play)))
     32
     33(defmacro s-save-autonorm (expression &rest arglist)
     34  `(let ((peak (s-save (scale *autonorm* ,expression) ,@arglist)))
     35     (autonorm-update peak)))
     36
     37;; The "AutoNorm" facility: when you play something, the Nyquist play
     38;; command will automatically compute what normalization factor you
     39;; should have used. If you play the same thing again, the normalization
     40;; factor is automatically applied.
     41;;
     42;; Call AUTONORM-OFF to turn off this feature, and AUTONORM-ON to turn
     43;; it back on.
     44;;
     45;; *autonorm-target* is the peak value we're aiming for (it's set below 1
     46;; so allow the next signal to get slightly louder without clipping)
     47;;
     48(setf *autonorm-target* 0.9)
     49
     50(defun autonorm-on ()
     51  (setf *autonorm* 1.0)
     52  (setf *autonorm-previous-peak* 1.0)
     53  (setf *autonormflag* t)
     54  (format t "AutoNorm feature is on.~%"))
     55
     56(if (not (boundp '*autonormflag*)) (autonorm-on))
     57
     58(defun autonorm-off ()
     59  (setf *autonormflag* nil)
     60  (setf *autonorm* 1.0)
     61  (format t "AutoNorm feature is off.~%"))
     62
     63(defun autonorm-update (peak)
     64  (cond ((and *autonormflag* (> peak 0.0))
     65           (setf *autonorm-previous-peak* (/ peak *autonorm*))
     66         (setf *autonorm* (/ *autonorm-target* *autonorm-previous-peak*))
     67         (format t "AutoNorm: peak was ~A,~%" *autonorm-previous-peak*)
     68         (format t "     peak after normalization was ~A,~%" peak)
     69         (format t "     new normalization factor is ~A~%" *autonorm*)
     70         *autonorm-previous-peak*
     71        )
     72        (t peak)
     73  ))
     74
     75;; s-read -- reads a file
     76(defun s-read (filename &key (time-offset 0) (srate *sound-srate*)
     77        (dur 10000.0) (nchans 1) (format *default-sf-format*)
     78        (mode *default-sf-mode*) (bits *default-sf-bits*) (endian NIL))
     79  (let ((swap 0))
     80    (cond ((eq endian :big)
     81           (setf swap (if ny:bigendianp 0 1)))
     82          ((eq endian :little)
     83           (setf swap (if ny:bigendianp 1 0))))
     84    (snd-read (soundfilename filename) time-offset
     85            (local-to-global 0) format nchans mode bits swap srate
     86            dur)))
     87
     88;; SF-INFO -- print sound file info
     89;;
     90(defun sf-info (filename)
     91  (let (s format channels mode bits srate dur flags)
     92    (format t "~A:~%" (soundfilename filename))
     93    (setf s (s-read filename))
     94    (setf format (car *rslt*))
     95    (setf channels (cadr *rslt*))
     96    (setf mode (caddr *rslt*))
     97    (setf bits (cadddr *rslt*))
     98    (setf *rslt* (cddddr *rslt*))
     99    (setf srate (car *rslt*))
     100    (setf dur (cadr *rslt*))
     101    (setf flags (caddr *rslt*))
     102    (format t "Format: ~A~%"
     103            (nth format '("none" "AIFF" "IRCAM" "NeXT" "Wave")))
     104    (cond ((setp (logand flags snd-head-channels))
     105           (format t "Channels: ~A~%" channels)))
     106    (cond ((setp (logand flags snd-head-mode))
     107           (format t "Mode: ~A~%"
     108                   (nth mode '("ADPCM" "PCM" "uLaw" "aLaw" "Float" "UPCM")))))
     109    (cond ((setp (logand flags snd-head-bits))
     110           (format t "Bits/Sample: ~A~%" bits)))
     111    (cond ((setp (logand flags snd-head-srate))
     112           (format t "SampleRate: ~A~%" srate)))
     113    (cond ((setp (logand flags snd-head-dur))
     114           (format t "Duration: ~A~%" dur)))
     115    ))
     116
     117;; SETP -- tests whether a bit is set (non-zero)
     118;
     119(defun setp (bits) (not (zerop bits)))
     120
     121;; SOUNDFILENAME -- add default directory to name to get filename
     122;;
     123(defun soundfilename (filename)
     124  (cond ((= 0 (length filename))
     125         (break "filename must be at least one character long" filename))
     126        ((full-name-p filename))
     127        (t
     128         ; if sf-dir nonempty and does not end with filename separator,
     129         ; append one
     130         (cond ((and (< 0 (length *default-sf-dir*))
     131                     (not (eq (char *default-sf-dir*
     132                                    (1- (length *default-sf-dir*)))
     133                              *file-separator*)))
     134                (setf *default-sf-dir* (strcat *default-sf-dir* (string *file-separator*)))
     135                (format t "Warning: appending \"~A\" to *default-sf-dir*~%"
     136                        *file-separator*)))
     137         (setf filename (strcat *default-sf-dir* (string filename)))))
     138  filename)
     139
     140
     141(setfn s-read-format car)
     142(setfn s-read-channels cadr)
     143(setfn s-read-mode caddr)
     144(setfn s-read-bits cadddr)
     145(defun s-read-swap (rslt) (car (cddddr rslt)))
     146(defun s-read-srate (rslt) (cadr (cddddr rslt)))
     147(defun s-read-dur (rslt) (caddr (cddddr rslt)))
     148(defun s-read-byte-offset (rslt) (car (cddddr (cddddr rslt))))
     149(defun round (x) (truncate (+ 0.5 x)))
     150
     151;; change defaults for PLAY macro:
     152(setf *soundenable* t)
     153(defun sound-on () (setf *soundenable* t))
     154(defun sound-off () (setf *soundenable* nil))
     155
     156(defmacro s-add-to (expr maxlen filename &optional time-offset)
     157  `(let ((ny:fname (soundfilename ,filename))
     158         ny:input ny:rslt ny:offset
     159         )
     160     (cond ((setf ny:input (s-read ny:fname :time-offset ,time-offset))
     161            (setf ny:rslt *rslt*)
     162            (format t "Adding sound to ~A at offset ~A~%"
     163                    ny:fname ,time-offset)
     164            (setf ny:offset (s-read-byte-offset ny:rslt))
     165
     166            (snd-overwrite '(let ((ny:addend ,expr))
     167                              (sum (snd-coterm
     168                                    (s-read ny:fname :time-offset ,time-offset)
     169                                    ny:addend)
     170                                 ny:addend))
     171                           ,maxlen ny:fname ny:offset
     172                           (s-read-mode ny:rslt) (s-read-bits ny:rslt)
     173                           (s-read-srate ny:rslt) (s-read-channels ny:rslt))
     174            (format t "Duration written: ~A~%" (car *rslt*)))
     175           ((setf ny:input (s-read ny:fname :time-offset 0))
     176            (format t "Could not open ~A at time offset ~A~%"
     177                    ny:fname ,time-offset))
     178           (t
     179            (format t "Could not open ~A~%" ny:fname)))))
     180
     181
     182(defmacro s-overwrite (expr maxlen filename &optional time-offset)
     183  `(let ((ny:fname (soundfilename ,filename))
     184         ny:input ny:rslt ny:offset)
     185         (setf ny:offset ,time-offset)
     186         (cond ((null ny:offset) (setf ny:offset 0)))
     187     (cond ((setf ny:input (s-read ny:fname :time-offset ny:offset))
     188            (setf ny:rslt *rslt*)
     189            (format t "Overwriting ~A at offset ~A~%" ny:fname ny:offset)
     190            (setf ny:offset (s-read-byte-offset ny:rslt))
     191                (display "s-overwrite" ny:offset)
     192            (snd-overwrite `,expr ,maxlen ny:fname ny:offset
     193                           (s-read-format ny:rslt)
     194                           (s-read-mode ny:rslt) (s-read-bits ny:rslt)
     195                           (s-read-swap ny:rslt)
     196                           (s-read-srate ny:rslt) (s-read-channels ny:rslt))
     197            (format t "Duration written: ~A~%" (car *rslt*)))
     198           ((s-read ny:fname :time-offset 0)
     199            (format t "Could not open ~A at time offset ~A~%"
     200                    ny:fname ,time-offset))
     201           (t
     202            (format t "Could not open ~A~%" ny:fname)))))
     203
     204
  • nyquist/nyquist-plot.txt

    old new  
     1set nokey
     2plot "points.dat" with lines
     3
Note: See TracBrowser for help on using the repository browser.