Skip to content

Commit 91a557d

Browse files
committed
This fixes a problem with nyquist's TRIGGER retaining samples (see comment 2, Bug #2698). This version of samples.c was accidentally omitted from an earlier commit.
1 parent f1395ff commit 91a557d

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

lib-src/libnyquist/nyquist/nyqsrc/samples.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "sound.h"
1414
#include "falloc.h"
1515
#include "samples.h"
16+
#include <limits.h>
1617

1718

1819
LVAL s_next = NULL;
@@ -115,10 +116,16 @@ LVAL snd_samples(sound_type s, int64_t len)
115116
long vx = 0;
116117
int blocklen;
117118
register double scale_factor = s->scale;
118-
len = (long) snd_length(s, len);
119+
len = snd_length(s, len);
119120
s = sound_copy(s);
120121

121122
xlsave1(v);
123+
124+
// xlisp's maximum vector size is limited. If we exceed the limit,
125+
// we'll return a shorter array of samples than requested.
126+
if (len > INT_MAX / sizeof(LVAL)) {
127+
len = INT_MAX / sizeof(LVAL);
128+
}
122129
v = newvector(len);
123130

124131
while (len > 0) {

lib-src/libnyquist/nyquist/nyqsrc/trigger.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ the previous value so re-reading will not re-trigger.)
4848
#include "cext.h"
4949
#include "assert.h"
5050

51-
#define TRIGGERDBG 1
51+
#define TRIGGERDBG 0
5252
#define D if (TRIGGERDBG)
5353

5454
/* Note: this structure is identical to an add_susp structure up

nyquist/nyquist.lsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ loop
668668
(ny:error "SAMPLER" 2 '((SOUND) "modulation") modulation))
669669
(ny:assert-sample "SAMPLER" 3 "table" sample)
670670
(ny:typecheck (not (integerp npoints))
671-
(ny:error "BUZZ" 3 '((INTEGER) "npoints") npoints))
671+
(ny:error "SAMPLER" 3 '((INTEGER) "npoints") npoints))
672672
(let ((samp (car sample))
673673
(samp-pitch (cadr sample))
674674
(samp-loop-start (caddr sample))

nyquist/seq.lsp

+2-3
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,8 @@
199199
;; a more helpful stack trace for SAL.
200200
(defmacro trigger (input beh)
201201
`(let* ((nyq%environment (nyq:the-environment))
202-
(gate%signal (force-srate *sound-srate* ,input))
203-
(s%rate (snd-srate gate%signal)))
204-
(snd-trigger gate%signal
202+
(s%rate *sound-srate*))
203+
(snd-trigger (force-srate *sound-srate* ,input)
205204
#'(lambda (t0) (eval-seq-behavior ,beh "TRIGGER")))))
206205

207206

0 commit comments

Comments
 (0)