Update nyquist to SVN r331 (r3.16+)

------------------------------------------------------------------------
   r331 | rbd | 2020-10-13 12:40:12 -0500 (Tue, 13 Oct 2020) | 2 lines

   Also forgot to install NyquistWords.txt

   ------------------------------------------------------------------------
   r330 | rbd | 2020-10-13 12:34:06 -0500 (Tue, 13 Oct 2020) | 2 lines

   Forgot to move nyquistman.pdf from docsrc/s2h to release

   ------------------------------------------------------------------------
   r329 | rbd | 2020-10-13 11:32:33 -0500 (Tue, 13 Oct 2020) | 2 lines

   Updated some version numbers for 3.16.

   ------------------------------------------------------------------------
   r328 | rbd | 2020-10-13 11:20:52 -0500 (Tue, 13 Oct 2020) | 2 lines

   Fixed NyquistIDE antialiasing for plot text, fix format of message.

   ------------------------------------------------------------------------
   r327 | rbd | 2020-10-12 21:01:53 -0500 (Mon, 12 Oct 2020) | 2 lines

   Fixed a couple of format problems in manual. This version of Nyquist has been tested wtih macOS, Linux, 32&64-bit Windows.

   ------------------------------------------------------------------------
   r326 | rbd | 2020-10-12 20:21:38 -0500 (Mon, 12 Oct 2020) | 1 line

   Modified WIN32 32-bit XLisp to use 64-bit FIXNUMs. This allows XLisp and Nyquist to handle big sounds even on 32-bit machines. Probably at some cost, but inner loops are mostly float and int32, and the Nyquist release is 64-bit anyway. Maybe we'll have to run some benchmarks on Audacity, which is still 32-bit on Windows.
   ------------------------------------------------------------------------
   r325 | rbd | 2020-10-12 13:16:57 -0500 (Mon, 12 Oct 2020) | 1 line

   Win64 passes bigfiletest.lsp now. This version should work on all 64-bit systems now. These changes untested on Linux and macOS.
   ------------------------------------------------------------------------
   r324 | rbd | 2020-10-11 21:31:53 -0500 (Sun, 11 Oct 2020) | 2 lines

   I couldn't free enough space on my linux box, so I adjusted the bigfiletest to write 8-bit ulaw. It's still >4GB and >4G samples. Works on Linux.

   ------------------------------------------------------------------------
   r323 | rbd | 2020-10-11 19:41:25 -0500 (Sun, 11 Oct 2020) | 2 lines

   Missing file from last commit.

   ------------------------------------------------------------------------
   r322 | rbd | 2020-10-11 19:36:08 -0500 (Sun, 11 Oct 2020) | 1 line

   Found another case where WIN64 needs int64_t instead of long for sample count.
   ------------------------------------------------------------------------
   r321 | rbd | 2020-10-11 19:33:25 -0500 (Sun, 11 Oct 2020) | 3 lines

   Fixed s-save to	handle optional	and keyword parameters (which should never have	been mixed in the first	place).	Documentation cleanup - should be final for this version.

   ------------------------------------------------------------------------
   r320 | rbd | 2020-10-11 14:44:37 -0500 (Sun, 11 Oct 2020) | 2 lines

   Fixes to handle IRCAM sound format and tests for big file io working on macOS.

   ------------------------------------------------------------------------
   r319 | rbd | 2020-10-10 21:31:58 -0500 (Sat, 10 Oct 2020) | 2 lines

   Changes for linux and to avoid compiler warnings on linux.

   ------------------------------------------------------------------------
   r318 | rbd | 2020-10-10 20:50:23 -0500 (Sat, 10 Oct 2020) | 1 line

   This is the test used for Win64 version.
   ------------------------------------------------------------------------
   r317 | rbd | 2020-10-10 20:34:34 -0500 (Sat, 10 Oct 2020) | 1 line

   This version works on Win64. Need to test changes on macOS and linux.
   ------------------------------------------------------------------------
   r316 | rbd | 2020-10-10 19:59:15 -0500 (Sat, 10 Oct 2020) | 2 lines

   PWL changes to avoid compiler warning.

   ------------------------------------------------------------------------
   r315 | rbd | 2020-10-10 19:34:04 -0500 (Sat, 10 Oct 2020) | 2 lines

   A few more changes for 64-bit sample counts on Win64

   ------------------------------------------------------------------------
   r314 | rbd | 2020-10-10 13:19:42 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed int64_t declaration in gate.alg

   ------------------------------------------------------------------------
   r313 | rbd | 2020-10-10 12:07:40 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixes to gate for long sounds

   ------------------------------------------------------------------------
   r312 | rbd | 2020-10-10 11:47:29 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed sound_save types for intgen

   ------------------------------------------------------------------------
   r311 | rbd | 2020-10-10 11:09:01 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed a 64-bit sample count problem in siosc.alg

   ------------------------------------------------------------------------
   r310 | rbd | 2020-10-10 11:03:12 -0500 (Sat, 10 Oct 2020) | 2 lines

   Fixed sndmax to handle 64-bit sample counts.

   ------------------------------------------------------------------------
   r309 | rbd | 2020-10-10 10:57:04 -0500 (Sat, 10 Oct 2020) | 2 lines

   Forgot to re-translate all tran/*.alg files with fix for int64 cast to int32. This version compiles on macOS and ready for test on Win64.

   ------------------------------------------------------------------------
   r308 | rbd | 2020-10-10 10:16:05 -0500 (Sat, 10 Oct 2020) | 2 lines

   Everything seems to compile and run on macOS now. Moving changes to Windows for test.

   ------------------------------------------------------------------------
   r307 | rbd | 2020-10-10 09:23:45 -0500 (Sat, 10 Oct 2020) | 1 line

   Added casts to avoid compiler warnings and to review changes to support 64-bit sample counts on Windows. Still not complete, and waiting to regenerate and compile tran directory code after updates to translation code that will insert more casts.
   ------------------------------------------------------------------------
   r306 | rbd | 2020-10-09 21:55:15 -0500 (Fri, 09 Oct 2020) | 2 lines

   Rebuilt seqfnint.c from header files.

   ------------------------------------------------------------------------
   r305 | rbd | 2020-10-09 21:53:33 -0500 (Fri, 09 Oct 2020) | 1 line

   Changed some FIXNUMS to LONG to avoid compiler warnings in seqfnint.c
   ------------------------------------------------------------------------
   r304 | rbd | 2020-10-09 21:44:03 -0500 (Fri, 09 Oct 2020) | 2 lines

   I discovered forgotten regression-test.lsp and added test that requires 64-bit sample counts to pass. Fixed a few bugs revealed by running the type-checking regression tests.

   ------------------------------------------------------------------------
   r303 | rbd | 2020-10-09 12:28:58 -0500 (Fri, 09 Oct 2020) | 2 lines

   Changes for 64-bit sample counts broke mult-channel s-save. Fixed in the commit for macOS.

   ------------------------------------------------------------------------
   r302 | rbd | 2020-10-09 10:03:39 -0500 (Fri, 09 Oct 2020) | 2 lines

   Changed snd-play to return samples computed and used that to make a test for computing long sounds that would overflow 32-bit length counts.

   ------------------------------------------------------------------------
   r301 | rbd | 2020-10-09 09:11:26 -0500 (Fri, 09 Oct 2020) | 2 lines

   corrected mistake in delaycv.alg and re-translated

   ------------------------------------------------------------------------
   r300 | rbd | 2020-10-09 09:09:06 -0500 (Fri, 09 Oct 2020) | 2 lines

   Fix to delaycv.alg -- "s" changed to "input" to avoid matching "s" in "sample_type".

   ------------------------------------------------------------------------
   r299 | rbd | 2020-10-09 09:03:33 -0500 (Fri, 09 Oct 2020) | 4 lines

   To avoid compiler warnings, XLisp interfaces to C int and long are now
   specified as LONG rather than FIXNUM, and the stubs that call the C
   functions cast FIXNUMs from XLisp into longs before calling C functions.

   ------------------------------------------------------------------------
   r298 | rbd | 2020-10-08 22:20:26 -0500 (Thu, 08 Oct 2020) | 2 lines

   This commit has many more fixes to handle long (64-bit) sounds, including a lot of fixes for warnings by Visual Studio assigning int64_t to long (works on macOS, doesn't work on VS). This was compiled and tested on macOS, and even computed a 27.1-hour sound using OSC, LP, SUM and MULT (haven't tested I/O yet).

   ------------------------------------------------------------------------
   r297 | rbd | 2020-10-07 13:04:02 -0500 (Wed, 07 Oct 2020) | 2 lines

   This is a major cleanup. It started with the goal of changing long to int64_t for sample counts so that on 64-bit windows, where long is only 32-bits, the sample counts would nevertheless be 64-bit allowing long sounds, which was a limitation for long recordings in Audacity. Since I was using compiler warnings to track possible loss-of-precision conversions from 64-bit sample counts, and there were *many* warnings, I started cleaning up *all* the warnings and ended up with a very large set of changes, including "modernizing" C declarations that date back to XLisp and CMU MIDI Toolkit code and were never changed. This version runs all the examples.sal code on macOS, but will surely have problems on Windows and Linux given the number of changes.

   ------------------------------------------------------------------------
   r296 | rbd | 2020-10-06 13:34:20 -0500 (Tue, 06 Oct 2020) | 2 lines

   More changes from long to int64_t for sample counts.

   ------------------------------------------------------------------------
   r295 | rbd | 2020-10-06 11:53:49 -0500 (Tue, 06 Oct 2020) | 2 lines

   More work on using 64-bit sample counts. Changed MAX_STOP from 32-bit to 64-bit limit.

   ------------------------------------------------------------------------
   r294 | rbd | 2020-10-06 11:48:05 -0500 (Tue, 06 Oct 2020) | 2 lines

   Made some changes so that sample counts are int64_t (for windows) instead of long to support sample counts above 31 bits.

   ------------------------------------------------------------------------
   r293 | rbd | 2020-10-04 21:30:55 -0500 (Sun, 04 Oct 2020) | 2 lines

   Fixed a few minor things for Linux and tested on Linux.

   ------------------------------------------------------------------------
   r292 | rbd | 2020-10-04 21:00:28 -0500 (Sun, 04 Oct 2020) | 2 lines

   Update extensions: all are minor changes.

   ------------------------------------------------------------------------
   r291 | rbd | 2020-09-24 13:59:31 -0500 (Thu, 24 Sep 2020) | 2 lines

   New implementation of seq and seqrep, added get-real-time, documented get-real-time, fixed examples.sal and examples.lsp which are now in lib rather than extensions (so they are now back in the basic installation), other cleanup.

   ------------------------------------------------------------------------
   r290 | rbd | 2020-08-16 16:24:52 -0500 (Sun, 16 Aug 2020) | 2 lines

   Fixed bug in snd-gate, revised GATE and NOISE-GATE to handle multi-channel sound. RMS now handles multi-channel input. S-AVG added to take multichannel input (but not used, because RMS could not be written without making SND-SRATE convert multichannel sound to vector of floats. That seems to be going toward a fully vectorized model. Not going there for now.

   ------------------------------------------------------------------------
   r289 | rbd | 2020-07-09 16:27:45 -0500 (Thu, 09 Jul 2020) | 2 lines

   Added GET-REAL-TIME function to XLISP. May not work yet on Windows. Various fixes for compiler warnings. I noticed FLAC doesn't work (I guess it never did) and I cannot figure out how this even links because flac_min seems to be undefined. Something to look at later.
This commit is contained in:
Leland Lucius 2021-01-27 23:45:25 -06:00
parent 5aa5b0df6d
commit 15b9bb96cd
232 changed files with 14750 additions and 14290 deletions

View File

@ -1,5 +1,5 @@
README file for Nyquist Version 3.15
11 Sep 2018
README file for Nyquist Version 3.16
13 Oct 2020
Roger B. Dannenberg
LICENSE: see license.txt
@ -27,6 +27,11 @@ and other versions of Unix. For details, see one of these files:
IMPLEMENTATION STATUS
=====================
Version 3.16 provides:
Long sounds: sample counts are consistently 64-bit.
Details in documentation on avoiding accumulating computed samples in memory
some fixes in code to eliminate the same.
Win32 32-bit implementation makes Nyquist FIXNUMs 64-bit.
Version 3.15 provides:
Fix to retain selected nyquist directory
Fix for NyquistIDE in paths with spaces

View File

@ -182,17 +182,10 @@ MALLOC is not defined!
#endif
#define ROUND32(x) ((int) ((x) + 0.5))
// on 32-bit machines, ROUNDBIG rounds to int32_t
// on 64-bit architectures, ROUNDBIG rounds to int64_t
#define ROUNDBIG(x) ((intptr_t) ((x) + 0.5))
/* obsolete: ROUND is needed for both ints, e.g. sample rates,
and big ints, e.g. sample counts, so we have two ROUND
functions. We use intptr_t for ROUNDBIG because long on
Windows is only 32 bits, while intptr_t is 64 bits.
With the addition of these 2 functions, we never
#define ROUNDBIG(x) ((int64_t) ((x) + 0.5))
/* With the addition of these 2 functions, we never
"NEED_ROUND" and trying to use round will cause an error.
*/
/* for compatibility */
#ifdef NEED_ROUND
// #define round ROUND
#define round you should not use round

View File

@ -112,10 +112,10 @@ private boolean cl_rdy = FALSE; /* set to TRUE when initialized */
/*****************************************************************************
* Routines local to this module
*****************************************************************************/
private char *cl_search();
private int find_string();
private char *cl_search(char *name, int opt_sw, int n);
private int find_string(char *s, boolean *abbr);
private void indirect_command(char *filename, char *oldarg0);
private void ready_check();
private void ready_check(void);
/****************************************************************
* cl_arg
@ -194,9 +194,7 @@ void cl_help()
* TRUE if syntax checks OK, otherwise false
*****************************************************************************/
boolean cl_init(av, ac)
char *av[];
int ac;
boolean cl_init(char *av[], int ac)
{
argv = av;
argc = ac;
@ -257,10 +255,7 @@ long cl_int_option(name, deflt)
* not start with "-"
*****************************************************************/
private char *cl_search(name, opt_sw, n)
char *name;
int opt_sw;
int n; /* if opt_sw is cl_ARG, n > 0 tells which one */
private char *cl_search(char *name, int opt_sw, int n)
{
register int i = 1; /* index into command line */
boolean abbr;
@ -365,9 +360,7 @@ boolean cl_syntax(char *s)
* 0 = FALSE = not found, 1 = cl_OPT = option, 2 = cl_SW = switch
*****************************************************************/
private int find_string(s, abbr)
char *s;
boolean *abbr;
private int find_string(char *s, boolean *abbr)
{
int found_it = FALSE;
int i;
@ -425,9 +418,7 @@ private int find_string(s, abbr)
/* get_arg -- get an argument from a file */
/**/
boolean get_arg(file, arg)
FILE *file;
char *arg;
boolean get_arg(FILE *file, char *arg)
{
int c;
while ((c = getc(file)) != EOF && isspace(c)) ;
@ -443,9 +434,7 @@ boolean get_arg(file, arg)
/* indirect_command -- get argv, argc from a file */
/**/
private void indirect_command(filename, oldarg0)
char *filename;
char *oldarg0;
private void indirect_command(char *filename, char *oldarg0)
{
FILE *argfile = NULL;
if (ok_to_open(filename, "r"))
@ -478,7 +467,7 @@ private void indirect_command(filename, oldarg0)
* Effect:
* Halt program if cl_rdy is not true.
*****************************************************************/
private void ready_check()
private void ready_check(void)
{
if (!cl_rdy) {
gprintf(ERROR,

View File

@ -6,45 +6,43 @@
#include "exec/types.h"
#include "exec/exec.h"
#endif
#include "cmtcmd.h"
#include "cext.h"
#include "midifns.h"
#include "timebase.h"
#include "moxc.h"
#include "seq.h"
#include "cmtcmd.h"
#include "userio.h"
#include "string.h"
#define HASHELEM(p) ((p).symbol_name)
#define HASHVAL 50
#define HASHENTRIES 50
#define HASHENTER hash_lookup
#define HASHENTER lookup
#define HASHNOCOPY
#include "hashrout.h"
void defvar(name, addr)
char *name;
int *addr;
void defvar(char *name, int *addr)
{
int i = hash_lookup(name);
intptr_t i = lookup(name);
HASHENTRY(i).symb_type = var_symb_type;
HASHENTRY(i).ptr.intptr = addr;
}
void defun(name, addr)
char *name;
int (*addr)();
void defun(char *name, seq_cmd_fn addr)
{
int i = hash_lookup(name);
intptr_t i = lookup(name);
HASHENTRY(i).symb_type = fn_symb_type;
HASHENTRY(i).ptr.routine = addr;
}
void defvec(name, addr, size)
char *name;
int *addr;
int size;
void defvec(char *name, int *addr, int size)
{
int i = hash_lookup(name);
intptr_t i = lookup(name);
HASHENTRY(i).symb_type = vec_symb_type;
HASHENTRY(i).size = size;
HASHENTRY(i).ptr.intptr = addr;

View File

@ -21,15 +21,15 @@ typedef struct symb_descr {
int size; /* for array bounds checking */
union {
int *intptr;
int (*routine)();
seq_cmd_fn routine;
} ptr;
} symb_descr_node;
int hash_lookup(char *s);
intptr_t lookup(char *s);
void defvar(char *name, int *addr);
void defvec(char *name, int *addr, int size);
typedef int (*defun_type)();
void defun(char *name, defun_type addr);
/* former defun_type replaced by seq_cmd_fn */
void defun(char *name, seq_cmd_fn addr);
#define HASHTYPE symb_descr_node
#include "hash.h"

View File

@ -1,7 +1,7 @@
#define NOCHAR -2
extern int IOinputfd;
extern int IOnochar;
int IOinputfd;
int IOnochar;
int IOsetup(int inputfd);
int IOcleanup(void);

View File

@ -144,7 +144,7 @@ extern COUNTER;
#ifdef HASHPOINT
HASHTYPE *
#else
int
intptr_t
#endif
HASHENTER (s)
char *s;
@ -158,63 +158,63 @@ char *s;
* I haven't bothered.
*/
for(i = 0, hash = 0; s[i] != '\0' && i < 15; i++)
hash += (i + 1) * s[i];
hash %= HASHVAL;
for (i = 0, hash = 0; s[i] != '\0' && i < 15; i++)
hash += (i + 1) * s[i];
hash %= HASHVAL;
/*
* search for s in the table
/*
* search for s in the table
*/
for(elem = hashtab[hash]; elem != NULL; elem = elem->h_next)
if(strcmp(s, HASHELEM((elem->h_elem))) == 0) { /* found it */
for (elem = hashtab[hash]; elem != NULL; elem = elem->h_next)
if (strcmp(s, HASHELEM((elem->h_elem))) == 0) { /* found it */
#ifdef HASHPOINT
return(&elem->h_elem);
return &elem->h_elem;
#else
return(elem - hashfirstchunk);
return (int) (elem - hashfirstchunk);
#endif
}
}
if(hashindex >= HASHENTRIES) {
if (hashindex >= HASHENTRIES) {
#ifdef HASHPOINT
char *calloc();
char *calloc();
hashindex = 0;
hashchunk = (hashelem *) calloc(HASHENTRIES, sizeof(hashelem));
if(hashchunk == NULL) {
gprintf(FATAL, "No mem for hash symbol table\n");
EXIT(1);
hashindex = 0;
hashchunk = (hashelem *) calloc(HASHENTRIES, sizeof(hashelem));
if (hashchunk == NULL) {
gprintf(FATAL, "No mem for hash symbol table\n");
EXIT(1);
#ifdef COUNTER
COUNTER++; /* optional symbol counter */
COUNTER++; /* optional symbol counter */
#endif
}
#else
gprintf(FATAL, "No hash table space, increase HASHENTRIES\n");
EXIT(1);
#endif
}
#else
gprintf(FATAL, "No hash table space, increase HASHENTRIES\n");
EXIT(1);
#endif
}
/*
* Splice a new entry into the list and fill in the string field
/*
* Splice a new entry into the list and fill in the string field
*/
elem = &hashchunk[hashindex++];
elem->h_next = hashtab[hash];
hashtab[hash] = elem;
elem = &hashchunk[hashindex++];
elem->h_next = hashtab[hash];
hashtab[hash] = elem;
#ifdef HASHNOCOPY
HASHELEM((elem->h_elem)) = s;
HASHELEM((elem->h_elem)) = s;
#else
{
char *strcpy();
HASHELEM((elem->h_elem)) = memget((strlen(s) + 1));
strcpy(HASHELEM((elem->h_elem)), s);
}
{
char *strcpy();
HASHELEM((elem->h_elem)) = memget((strlen(s) + 1));
strcpy(HASHELEM((elem->h_elem)), s);
}
#endif
#ifdef HASHPOINT
return(&elem->h_elem);
return &elem->h_elem;
#else
return(elem - hashfirstchunk);
return (int) (elem - hashfirstchunk);
#endif
}

View File

@ -379,7 +379,7 @@ int c;
}
static void
metaevent(type)
metaevent(int type)
{
int leng = msgleng();
char *m = msg();
@ -509,7 +509,7 @@ readvarinum()
}
static long
to32bit(c1,c2,c3,c4)
to32bit(int c1, int c2, int c3, int c4)
{
long value = 0L;
@ -521,8 +521,7 @@ to32bit(c1,c2,c3,c4)
}
static int
to16bit(c1,c2)
int c1, c2;
to16bit(int c1, int c2)
{
return ((c1 & 0xff ) << 8) + (c2 & 0xff);
}

View File

@ -331,10 +331,10 @@ private ulong ticksAtStart = 0L;
*
****************************************************************************/
private void fixup();
private void midi_init();
extern boolean check_ascii(); /*userio.c*/
private void musicterm();
private void fixup(void);
private void midi_init(void);
extern boolean check_ascii(void); /*userio.c*/
private void musicterm(void);
/****************************************************************************
@ -347,7 +347,7 @@ private void musicterm();
#define ALL_NOTES_OFF 0x7B /*DMH: from macmidi.c*/
void alloff()
void alloff(void)
{
int c;
@ -371,8 +371,7 @@ void alloff()
***************************************************************/
#ifdef UNIX_ITC
void eventwait(timeout)
long timeout;
void eventwait(long timeout)
{
struct timeval unix_timeout;
struct timeval *waitspec = NULL;
@ -422,8 +421,7 @@ void eventwait(timeout)
}
#else
#ifdef BUFFERED_SYNCHRONOUS_INPUT
void eventwait(timeout)
long timeout;
void eventwait(long timeout)
{
struct timeval unix_timeout;
struct timeval *waitspec = NULL;
@ -433,10 +431,11 @@ void eventwait(timeout)
timeout -= gettime(); /* convert to millisecond delay */
unix_timeout.tv_sec = timeout / 1000;
/* remainder become microsecs: */
unix_timeout.tv_usec = (timeout - (unix_timeout.tv_sec * 1000)) * 1000;
unix_timeout.tv_usec = (int)
(timeout - (unix_timeout.tv_sec * 1000)) * 1000;
waitspec = &unix_timeout;
getrlimit(RLIMIT_NOFILE, &file_limit);
select(file_limit.rlim_max+1, 0, 0, 0, waitspec);
select((int) (file_limit.rlim_max+1), 0, 0, 0, waitspec);
} else {
int c = getc(stdin);
ungetc(c, stdin);
@ -444,8 +443,7 @@ void eventwait(timeout)
return;
}
#else
void eventwait(timeout)
long timeout;
void eventwait(long timeout)
{
struct timeval unix_timeout;
struct timeval *waitspec = NULL;
@ -473,8 +471,7 @@ void eventwait(timeout)
#else
#ifndef UNIX /* since I couldn't use an else above, have to check UNIX here */
#ifdef WINDOWS
void eventwait(timeout)
long timeout;
void eventwait(long timeout)
{
if (timeout >= 0) {
gprintf(TRANS, "eventwait: not implemented\n");
@ -528,7 +525,7 @@ void exclusive(boolean onflag)
* Print error message and call musicinit
****************************************************************************/
private void fixup()
private void fixup(void)
{
gprintf(ERROR, "You forgot to call musicinit. I'll do it for you.\n");
musicinit();
@ -730,7 +727,7 @@ private void setup_sysex(MDevent *event, u_char *buffer)
sysex_n = event->msglen;
}
private void flush_sysex()
private void flush_sysex(void)
{
mdFree(sysex_p);
sysex_p = 0;
@ -740,7 +737,7 @@ private void flush_sysex()
#ifdef MACINTOSH_OR_DOS
#ifndef WINDOWS
public boolean check_midi()
public boolean check_midi(void)
{
if (buffhead == bufftail) return FALSE;
else return TRUE;
@ -808,7 +805,7 @@ short getkey(boolean waitflag)
* fakes it
****************************************************************************/
ulong gettime() /*DMH: ulong is from mpu->midifns conversion, for Mac*/
ulong gettime(void) /*DMH: ulong is from mpu->midifns conversion, for Mac*/
{
#if HAS_GETTIMEOFDAY
struct timeval timeval;
@ -864,8 +861,7 @@ ulong gettime() /*DMH: ulong is from mpu->midifns conversion, for Mac*/
* Waits until the amount of time specified has lapsed
****************************************************************************/
void l_rest(time)
long time;
void l_rest(long time)
{
if (!initialized) fixup();
l_restuntil(time + gettime());
@ -879,8 +875,7 @@ long time;
* Waits until the specified time has been reached (absolute time)
****************************************************************************/
void l_restuntil(time)
long time;
void l_restuntil(long time)
{
#ifdef MACINTOSH
ulong now = gettime();
@ -1598,7 +1593,7 @@ void musicinit()
* Miscellaneous cleanup of things done by musicinit.
****************************************************************************/
private void musicterm()
private void musicterm(void)
{
if (musictrace) gprintf(TRANS, "musicterm()\n");
initialized = FALSE;
@ -1778,7 +1773,7 @@ private int atox(char *t)
#endif /* def DOS */
private void midi_init()
private void midi_init(void)
{
#ifdef UNIX_IRIX_MIDIFNS
#define PBUFLEN 4

View File

@ -106,7 +106,7 @@ void midi_clock(void);
void midi_cont(boolean onflag);
void midi_ctrl(int channel, int control, int value);
void midi_exclusive(unsigned char *msg);
void midi_flush();
void midi_flush(void);
void midi_note(int channel, int pitch, int velocity);
void midi_program(int channel, int program);
void midi_real(boolean onflag);

View File

@ -112,9 +112,9 @@ struct MsgPort pub_port;
* Routines local to this module
*****************************************************************************/
private void callrun();
private void decode();
private void moxcterm();
private void callrun(void);
private void decode(void);
private void moxcterm(void);
/****************************************************************************
* callallcancel
@ -127,7 +127,7 @@ private void moxcterm();
* (not necessarily the timebase) and repeat.
****************************************************************************/
void callallcancel()
void callallcancel(void)
{
if (moxcdebug) gprintf(GDEBUG, "cancel all calls\n");
while (timebase_queue) {
@ -142,7 +142,7 @@ void callallcancel()
/* catchup -- bring current timebase up to date by running its calls */
/**/
void catchup()
void catchup(void)
{
register call_type call;
/* Remember where we're going in virtual time because setting the
@ -310,7 +310,7 @@ void causepri(delay_type delay, int pri, void (*routine)(call_args_type args), c
* executes the previously scheduled call call and deallocates it
****************************************************************************/
private void callrun()
private void callrun(void)
{
call_type call;
if (moxcdebug) {
@ -326,7 +326,7 @@ private void callrun()
/* remove first call from timebase */
call = remove_call(timebase);
if (debug) gprintf(TRANS, "callrun call %lx\n", (ulong)call);
if (debug) gprintf(TRANS, "callrun call %p\n", call);
insert_base(timebase);
virttime = call->u.e.time; /* virtual time of the call */
if (moxcdebug) callshow(call);
@ -461,7 +461,7 @@ void moxcwait(dateoftimeout)
* Effect: dispatch on user inputs, cause calls
****************************************************************************/
private void decode()
private void decode(void)
{
/* It is important that midi_data is on a word boundary because we
copy to it by doing a word transfer.
@ -658,7 +658,7 @@ void moxcrun()
/* moxcterm -- clean up after moxcinit */
/**/
private void moxcterm()
private void moxcterm(void)
{
#ifdef AMIGA
FreeSignal((long) pub_port_signal);

View File

@ -81,15 +81,15 @@ private boolean fixed_octave; /* used to avoid many error messages */
/****************************************************************************
* Routines local to this module
****************************************************************************/
private void bend_filter();
private void byteorder();
private void ctrl_filter();
private int event_bend();
private void filter();
private long getdur();
private long getnext();
private char map_ctrl();
private void output();
private void bend_filter(note_type note, note_type last, long now);
private void byteorder(void);
private void ctrl_filter(note_type note, note_type last, long now);
private int event_bend(note_type note);
private void filter(note_type last);
private long getdur(int i, note_type last, int ped, long now);
private long getnext(int i, note_type last, long now);
private char map_ctrl(int control);
private void output(FILE *fp, note_type last, boolean absflag);
/****************************************************************************
* bend_filter
@ -105,10 +105,7 @@ private void output();
* the time.
****************************************************************************/
private void bend_filter(note, last, now)
note_type note; /* current note */
note_type last; /* the last recorded event */
long now; /* the current time */
private void bend_filter(note_type note, note_type last, long now)
{
/* first see if there is another bend in this time
* slot.
@ -132,7 +129,7 @@ long now; /* the current time */
* check out assumptions about byte order and placement
****************************************************************************/
private void byteorder()
private void byteorder(void)
{
note_node test_event;
if ((sizeof(test_event) != 4) ||
@ -166,10 +163,7 @@ private void byteorder()
* the time.
****************************************************************************/
private void ctrl_filter(note, last, now)
note_type note; /* the current note */
note_type last; /* the last recorded event */
long now; /* the current time */
private void ctrl_filter(note_type note, note_type last, long now)
{
/* see if there is another control change in this time
* slot.
@ -196,8 +190,7 @@ long now; /* the current time */
* returns int: an 8 bit pitch bend number
****************************************************************************/
private int event_bend(note)
note_type note;
private int event_bend(note_type note)
{
return((int) (((note->n[1]) >> 6) + ((note->n[2]) << 1)));
}
@ -212,8 +205,7 @@ note_type note;
* noop data (the current time is used as a noop)
****************************************************************************/
private void filter(last)
note_type last;
private void filter(note_type last)
{
note_type note; /* loop control variable */
long now=0; /* last time seen */
@ -263,11 +255,7 @@ note_type last;
* pressed (this event will also start another note).
****************************************************************************/
private long getdur(i, last, ped, now)
int i;
note_type last;
int ped;
long now;
private long getdur(int i, note_type last, int ped, long now)
{
int key = TRUE; /* flag that says if note is on */
long start = now;
@ -316,10 +304,7 @@ long now;
* (returns time of last event if nothing else is found)
****************************************************************************/
private long getnext(i, last, now)
int i; /* the index of the current note */
note_type last; /* pointer to last valid data */
long now; /* the current time */
private long getnext(int i, note_type last, long now)
{
i++; /* advance to next item */
for (; event_buff + i < last; i++) {
@ -352,8 +337,7 @@ long now; /* the current time */
* MODWHEEL, FOOT
****************************************************************************/
private char map_ctrl(control)
int control;
private char map_ctrl(int control)
{
switch (control) {
/* 'J' is no longer code for PORTARATE
@ -389,10 +373,7 @@ int control;
* clock tick for each continuous change parameter
****************************************************************************/
private void output(fp, last, absflag)
FILE *fp;
note_type last;
boolean absflag;
private void output(FILE *fp, note_type last, boolean absflag)
{
int i; /* loop counter */
int command; /* the current command */
@ -400,7 +381,8 @@ boolean absflag;
int last_velocity = -1; /* used to filter repeated Lnn attributes */
int last_voice = 0; /* the default adagio channel (1) */
int ped = FALSE; /* flag maintains state of pedal */
int how_many = last - event_buff;
/* size of event_buff is seems to be about 20000 events */
int how_many = (int) (last - event_buff);
long now=0; /* the time of the next event */
if (fp == NULL) {
@ -583,7 +565,7 @@ boolean rec_init(boolean bender)
MIN((biggestChunk - SPACE_FOR_PLAY), ENOUGH_ROOM);
/* leave SPACE_FOR_PLAY contiguous bytes of memory */
}
max_notes = spaceForRecord / sizeof(note_node);
max_notes = (long) (spaceForRecord / sizeof(note_node));
/* gprintf(GDEBUG,"max_notes = %d\n", max_notes);*/
event_buff = (note_type) MALLOC(spaceForRecord);
if (event_buff == NULL) {
@ -650,4 +632,4 @@ overflow:
return FALSE;
}
#endif
#endif

View File

@ -106,7 +106,8 @@ chunk_type chunk_create(boolean first_flag)
private void clock_tick(call_args_type args)
{
seq_type seq = (seq_type) args->arg[0];
time_type fraction = (time_type) args->arg[1];
// double cast to avoid pointer-to-long truncation on WIN64
time_type fraction = (time_type) ((intptr_t) args->arg[1]);
int delay;
fraction += clock_ticksize;
delay = fraction >> 16;
@ -171,14 +172,8 @@ private event_type event_create(seq, size, etime, eline)
/* insert_call -- add a call event to the seq */
/**/
event_type insert_call(seq, ctime, cline, voice, addr, value, n)
seq_type seq;
time_type ctime;
int cline;
int voice;
int (*addr)();
long value[SEQ_MAX_PARMS];
int n;
event_type insert_call(seq_type seq, time_type ctime, int cline, int voice,
int (*addr)(seq_arg_t args), long value[SEQ_MAX_PARMS], int n)
{
int i;
register event_type event = event_create(seq, callsize, ctime, cline);
@ -227,13 +222,8 @@ event_type insert_clock(seq, ctime, cline, ticksize)
/* insert_ctrl -- add a control to the seq */
/**/
event_type insert_ctrl(seq, ctime, cline, ctrl, voice, value)
seq_type seq;
time_type ctime;
int cline;
int ctrl;
int voice;
int value;
event_type insert_ctrl(seq_type seq, time_type ctime,
int cline, int ctrl, int voice, int value)
{
register event_type event = event_create(seq, ctrlsize, ctime, cline);
if (seq_print) {
@ -299,7 +289,7 @@ def_type insert_def(seq, symbol, definition, deflen)
{
int i;
def_type defn = (def_type) chunk_alloc(seq, sizeof(def_node));
defn->symbol = chunk_alloc(seq, strlen(symbol) + 1);
defn->symbol = chunk_alloc(seq, (int) strlen(symbol) + 1);
defn->definition = (unsigned char *) chunk_alloc(seq, deflen);
strcpy(defn->symbol, symbol);
for (i = 0; i < deflen; i++) {
@ -718,7 +708,8 @@ private void ramp_event(call_args_type args)
unsigned int to_value = (unsigned int) ((size_t) args->arg[3]);
/* increment is also a fixed-point fraction, so int is fine */
int increment = (int) ((size_t) args->arg[4]);
time_type step = (time_type) args->arg[5];;
/* double cast to avoid pointer to long truncation warning in WIN64: */
time_type step = (time_type) ((intptr_t) args->arg[5]);
/* n is the number of steps remaining. int is big enough. */
int n = (int) ((size_t) args->arg[6]);

View File

@ -71,12 +71,17 @@ struct seti_struct {
#define SEQ_MAX_PARMS 8
typedef struct seq_arg_struct {
long a[SEQ_MAX_PARMS];
} seq_arg_t;
typedef int (*seq_cmd_fn)(seq_arg_t args);
struct cause_struct {
int (*routine)();
seq_cmd_fn routine;
/* make a structure so we can copy by value */
struct seq_arg_struct {
long a[SEQ_MAX_PARMS];
} args;
seq_arg_t args;
};
@ -228,16 +233,16 @@ chunk_type chunk_create(boolean first_flag);
extern boolean seq_print; /* debugging switch */
void seq_extensions(void); /* to be defined outside of seq -- user dependent */
event_type insert_call(seq_type seq, time_type ctime, int cline,
int voice, int (*addr)(), long value[], int n);
event_type insert_call(seq_type seq, time_type ctime, int cline, int voice,
int (*addr)(seq_arg_t args), long value[SEQ_MAX_PARMS], int n);
event_type insert_clock(seq_type seq, time_type ctime, int cline,
time_type ticksize);
event_type insert_ctrl(seq_type seq, time_type ctime, int cline, int ctrl,
int voice, int value);
/* LISP: (SEQ-INSERT-CTRL SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */
/* LISP: (SEQ-INSERT-CTRL SEQ LONG LONG LONG LONG LONG) */
event_type insert_ctrlramp(seq_type seq, time_type rtime, int rline, int voice,
time_type step, time_type dur, int ctrl, int v1, int v2);
/* LISP: (SEQ-INSERT-RAMP SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */
/* LISP: (SEQ-INSERT-RAMP SEQ LONG LONG LONG LONG LONG LONG LONG LONG) */
def_type insert_def(seq_type seq, char *symbol, unsigned char *definition,
int deflen);
event_type insert_deframp(seq_type seq, time_type rtime, int rline, int voice,
@ -245,12 +250,12 @@ event_type insert_deframp(seq_type seq, time_type rtime, int rline, int voice,
int nparms, short parms[], int parm_num, int to_value);
event_type insert_macctrl(seq_type seq, time_type ctime, int cline, int ctrl,
int voice, int value);
/* LISP: (SEQ-INSERT-MACCTRL SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */
/* LISP: (SEQ-INSERT-MACCTRL SEQ LONG LONG LONG LONG LONG) */
event_type insert_macro(seq_type seq, time_type ctime, int cline,
def_type def, int voice, int nparms, short *parms);
event_type insert_note(seq_type seq, time_type ntime, int nline, int voice,
int pitch, time_type dur, int loud);
/* LISP: (SEQ-INSERT-NOTE SEQ FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM FIXNUM) */
/* LISP: (SEQ-INSERT-NOTE SEQ LONG LONG LONG LONG LONG LONG) */
event_type insert_seti(seq_type seq, time_type stime, int sline, int voice,
int *addr, int value);
void noop(seq_type seq);

View File

@ -31,10 +31,10 @@
#include "midifile.h"
#include "tempomap.h"
int filegetc();
void initfuncs();
void prtime();
void snding_free();
int filegetc(void);
void initfuncs(void);
void prtime(void);
void snding_free(void);
typedef struct snding_struct {
struct snding_struct *next;

View File

@ -43,20 +43,21 @@ extern time_type clock_ticksize; /* millisec per tick shifted 16 bits */
extern boolean clock_running; /* TRUE if clock is running */
extern boolean use_midi_clock;
private void smfw_bend();
private void smfw_bend(seq_type seq, int voice, int value);
private void smfw_cause_noteoff(seq_type seq, time_type delay, int voice,
int pitch);
private void smfw_ctrl();
private void smfw_deltatime();
private void smfw_dotrack();
private void smfw_exclusive();
private void smfw_ctrl(seq_type seq, int voice, int ctrl_name, int value);
private void smfw_deltatime(void);
private void smfw_dotrack(seq_type seq);
private void smfw_exclusive(int length, unsigned char *msg);
private void smfw_noteoff(call_args_type args);
private void smfw_noteon();
private void smfw_noteon(seq_type seq, int voice, int pitch, int vel);
private void smfw_process_event(call_args_type args);
private void smfw_ramp_event(call_args_type args);
private void smfw_send_macro();
private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[],
int parm_num, int value);
private void smfw_touch(seq_type seq, int voice, int value);
private void writevarlen();
private void writevarlen(long value);
/* smfw_bend -- write a pitch bend to a midi file */
@ -97,8 +98,8 @@ private void smfw_cause_noteoff(seq_type seq, time_type delay, int voice,
private void smfw_clock_event(call_args_type args)
{
time_type old_ticksize = (time_type)(args->arg[0]);
time_type new_ticksize = (time_type)(args->arg[1]);
time_type old_ticksize = (time_type) ((intptr_t) args->arg[0]);
time_type new_ticksize = (time_type)((intptr_t) args->arg[1]);
time_type temp_ticksize = new_ticksize;
new_ticksize = scale(new_ticksize, 375L, 1024L);
/* (new_ticksize >> 16) * 24000 ms/clock becomes us/midiquarter */
@ -362,7 +363,7 @@ private void smfw_process_event(call_args_type args)
break;
case ESC_CTRL:
switch (event->value) {
time_type this_event;
/* called routine will write to midifile in execution: */
case CALL_VALUE:
sequence = seq;
@ -388,7 +389,7 @@ private void smfw_process_event(call_args_type args)
/* set new ticksize: */
last_tick_size = clock_ticksize;
} else { /*not on tempo track*/
this_event = ((virttime - last_clock_event) *
long this_event = ((virttime - last_clock_event) *
((2500L << 16) / last_tick_size)) / 100;
if (debug) gprintf(TRANS,
"track != 0: Lastev: %ld Thisev: %ld NewLast: %ld\n",
@ -519,14 +520,10 @@ private void smfw_ramp_event(call_args_type args)
/* smfw_send_macro -- write msg to midi file from a seq "macro" event */
/**/
private void smfw_send_macro(ptr, voice, parameter, parm_num, value)
register unsigned char *ptr;
int voice;
short parameter[];
int parm_num;
int value;
private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[],
int parm_num, int value)
{
register unsigned char code, *loc;
unsigned char code, *loc;
while ((code = *ptr++)) {
loc = ptr + *ptr;
ptr++;
@ -682,9 +679,8 @@ void seq_write_smf(seq, outfile)
/* writevarlen -- write a variable length integer to midi file */
/**/
private void writevarlen(value)
register long value;
{
private void writevarlen(long value)
{
register ulong buffer;
if (debug) gprintf(TRANS, "variable length quantity...");

View File

@ -116,40 +116,40 @@ extern int abort_flag;
/****************************************************************************
* Routines local to this module:
****************************************************************************/
private void do_a_rest();
private time_type doabsdur();
private int doabspitch();
private void doclock();
private void docomment();
private void doctrl();
private void dodef();
private time_type dodur();
private void doerror();
private int doloud();
void domacro();
private void donextdur();
private int dopitch();
private void doprogram();
private void dorate();
private void doset();
private void dospecial();
private time_type dosymdur();
private void dotempo();
private void dotime();
private void dovoice();
private void fferror();
private void init();
private int issymbol();
private void marker();
private void parseend();
private void parsefield();
private boolean parsenote();
private boolean parseparm();
private int scan();
private int scan1();
private long scanint();
private void scansymb();
private long scansgnint();
private void do_a_rest(void);
private time_type doabsdur(void);
private int doabspitch(void);
private void doclock(void);
private void docomment(void);
private void doctrl(int n);
private void dodef(void);
private time_type dodur(void);
private void doerror(void);
private int doloud(void);
void domacro(void);
private void donextdur(void);
private int dopitch(void);
private void doprogram(void);
private void dorate(void);
private void doset(boolean vecflag);
private void dospecial(void);
private time_type dosymdur(void);
private void dotempo(void);
private void dotime(void);
private void dovoice(void);
private void fferror(char *s);
private void init(void);
private int issymbol(void);
private void marker(int count);
private void parseend(void);
private void parsefield(void);
private boolean parsenote(void);
private boolean parseparm(long *valptr);
private int scan(void);
private int scan1(char *start);
private long scanint(void);
private void scansymb(char *);
private long scansgnint(void);
/****************************************************************************
* data structures for parser lookup tables
@ -313,10 +313,7 @@ private seq_type the_score; /* this is the score we are parsing */
* where the parameter should be substituted
* and length is the number of data bytes
*/
boolean def_append(def, nparms, data)
unsigned char def[];
int nparms;
int data;
boolean def_append(unsigned char def[], int nparms, int data)
{
int base = (nparms << 1) + 1; /* this byte is the length */
/* first parameter has to be able to reference last byte: */
@ -329,8 +326,7 @@ boolean def_append(def, nparms, data)
}
def_type def_lookup(symbol)
char *symbol;
def_type def_lookup(char *symbol)
{
def_type defn = seq_dictionary(the_score);
while (defn) {
@ -343,10 +339,7 @@ def_type def_lookup(symbol)
}
void def_parm(def, nparms, code)
unsigned char def[];
int nparms;
int code;
void def_parm(unsigned char def[], int nparms, int code)
{
int i, j;
/* in order to insert a 2-byte parameter descriptor, the offsets from
@ -373,7 +366,7 @@ void def_parm(def, nparms, code)
* Effect: parses a rest (R) command
****************************************************************************/
private void do_a_rest()
private void do_a_rest(void)
{
if (token[fieldx])
fferror("Nothing expected after rest");
@ -385,7 +378,7 @@ private void do_a_rest()
* Effect: parses an absolute dur (U) command
****************************************************************************/
private time_type doabsdur()
private time_type doabsdur(void)
{
time_type result=1000L;
register char c;
@ -405,7 +398,7 @@ private time_type doabsdur()
* Effect: parses an absolute pitch (P) command
****************************************************************************/
private int doabspitch()
private int doabspitch(void)
{
int result = 60;
int startx = fieldx;
@ -441,7 +434,7 @@ private int doabspitch()
is applied to the final computed duration after all
other scaling is applied.
*/
private void doartic()
private void doartic(void)
{
if (isdigit(token[fieldx])) {
artic = (int) scanint();
@ -453,7 +446,7 @@ private void doartic()
/* docall -- parse a call in the form !CALL fn(p1,p2,p3) */
/**/
private void docall()
private void docall(void)
{
boolean error_flag = TRUE;
ndurp = FALSE;
@ -471,7 +464,7 @@ private void docall()
if (fieldx == 1) fferror("Routine name expected");
else if (token[fieldx] != '(') fferror("Open paren expected");
else {
desc = &HASHENTRY(hash_lookup(symbol));
desc = &HASHENTRY(lookup(symbol));
if (!desc->symb_type) {
fieldx = 0;
fferror("Function not defined");
@ -538,9 +531,9 @@ private void docall()
* ticksize = (beattime / 24) = ((60sec/tempo)/24) =
* ((60000ms/tempo)/24) = (60000/24)/tempo = 2500/tempo
*/
private void doclock()
private void doclock(void)
{
int oldticksize = ticksize;
long oldticksize = ticksize;
ticksize = (2500L << 16) / tempo;
insert_clock(the_score, seqround(thetime) - (oldticksize >> 17),
lineno, ticksize);
@ -552,7 +545,7 @@ private void doclock()
* Effect: parses a comment (*) command
****************************************************************************/
private void docomment()
private void docomment(void)
{
line[linex] = '\n'; /* force end of line to skip comment line */
line[linex+1] = EOS;
@ -565,8 +558,7 @@ private void docomment()
* Effect: parses a control (K, M, O, X, or Y) command
****************************************************************************/
private void doctrl(n)
int n;
private void doctrl(int n)
{
ctrlval[n] = (int) scanint();
if (token[fieldx]) {
@ -578,7 +570,7 @@ int n;
}
private void dodef()
private void dodef(void)
{
/* maximum def size is 256 + 9 parms * 2 + 2 = 276 */
unsigned char def[280];
@ -667,7 +659,7 @@ private void dodef()
*
* Returns: duration in "precise" units
****************************************************************************/
private time_type dodur()
private time_type dodur(void)
{
time_type result = 0L;
symbolic_dur_flag = TRUE;
@ -689,7 +681,7 @@ private time_type dodur()
* Effect: parse an unrecognized field by reporting an error
****************************************************************************/
private void doerror()
private void doerror(void)
{
fieldx = 0;
fferror("Bad field");
@ -700,8 +692,9 @@ private void doerror()
* Effect: parse a loudness (L) command
****************************************************************************/
private int doloud()
private int doloud(void)
{
size_t ii;
int i, j;
int result;
int oldfieldx = fieldx;
@ -732,13 +725,13 @@ private int doloud()
}
scansymb(symbol);
newfieldx = fieldx;
if ((i = strlen(symbol)) > 3 ) { /* maximum is 3, e.g. "ppp" */
if ((ii = strlen(symbol)) > 3 ) { /* maximum is 3, e.g. "ppp" */
fieldx = oldfieldx;
fferror("Loudness field too long");
fieldx = newfieldx;
return 100;
}
symbol[i + 1] = '\0'; /* pad short symbols with 0 */
symbol[ii + 1] = '\0'; /* pad short symbols with 0 */
/* e.g. "p\0" -> "p\0\0" */
for (i = 0; i <= 7; i++) { /* loop through possibilities */
for (j = 0; j <= 2; j++) { /* test 3 characters */
@ -756,7 +749,7 @@ private int doloud()
}
void domacro()
void domacro(void)
{
int control_num;
int value;
@ -827,7 +820,7 @@ void domacro()
* The form N<digits> is parsed directly with scanint().
****************************************************************************/
private void donextdur()
private void donextdur(void)
{
ndurp = TRUE; /* flag that N was given */
if (isdigit(token[fieldx])) {
@ -846,7 +839,7 @@ private void donextdur()
* Effect: parses a pitch command
****************************************************************************/
private int dopitch()
private int dopitch(void)
{
int p, octave=0;
int octflag = FALSE; /* set if octave is specified */
@ -893,7 +886,7 @@ private int dopitch()
* Effect: parses a program change (Z) command
****************************************************************************/
private void doprogram()
private void doprogram(void)
{
register int program = (int) scanint();
ctrlflag[PROGRAM_CTRL] = ctrlflag[0] = TRUE;
@ -912,7 +905,7 @@ private void doprogram()
}
private void doramp()
private void doramp(void)
{
int values[2];
time_type stepsize = 100L; /* default 10 per second */
@ -1008,7 +1001,7 @@ private void doramp()
* Effect: parses a !rate command
****************************************************************************/
private void dorate()
private void dorate(void)
{
linex += scan();
if (!token[0])
@ -1031,14 +1024,13 @@ private void dorate()
}
private void doset(vec_flag)
boolean vec_flag;
private void doset(boolean vec_flag)
{
ndurp = FALSE;
linex += scan();
if (!token[0]) fferror("Variable name expected");
else {
struct symb_descr *desc = &HASHENTRY(hash_lookup(token));
struct symb_descr *desc = &HASHENTRY(lookup(token));
if (!desc->symb_type) fferror("Called function not defined");
else if (vec_flag && (desc->symb_type != vec_symb_type)) {
fferror("This is not an array");
@ -1079,7 +1071,7 @@ private void doset(vec_flag)
default:
fieldx++;
if (i < numargs) {
value[i++] = seqround(dodur());
value[i++] = (int) seqround(dodur());
} else fferror(too_many_error);
break;
}
@ -1110,7 +1102,7 @@ private void doset(vec_flag)
* Effect: parses special (those starting with "!") commands
****************************************************************************/
private void dospecial()
private void dospecial(void)
{
switch (issymbol()) {
case sym_tempo:
@ -1160,7 +1152,7 @@ private void dospecial()
* Effect: parses a duration (^, %, S, I, Q, H, or W) command
****************************************************************************/
private time_type dosymdur()
private time_type dosymdur(void)
{
int i, dotcnt = 0;
long dotfactor;
@ -1213,7 +1205,7 @@ private time_type dosymdur()
* Effect: parses a !tempo command
****************************************************************************/
private void dotempo()
private void dotempo(void)
{
linex += scan();
if (!token[0])
@ -1243,7 +1235,7 @@ private void dotempo()
* Implementation: see implementation of donextdur()
****************************************************************************/
private void dotime()
private void dotime(void)
{
if (isdigit(token[fieldx])) {
thetime = precise(scanint());
@ -1262,7 +1254,7 @@ private void dotime()
* Effect: parse a voice (V) command (the voice is the MIDI channel)
****************************************************************************/
private void dovoice()
private void dovoice(void)
{
if (isdigit(token[fieldx])) {
voice = (int) scanint();
@ -1296,11 +1288,10 @@ private void dovoice()
* carat will point to the first character in the field.
****************************************************************************/
private void fferror(s)
char *s;
private void fferror(char *s)
{
gprintf(ERROR, "%3d | %s", lineno, line);
marker(linex-strlen(token)+fieldx+1+6);
marker((int) (linex - strlen(token) + fieldx + 1 + 6));
gprintf(ERROR, "Error: %s.\n", s);
}
@ -1310,7 +1301,7 @@ private void fferror(s)
* initializes the state variables
****************************************************************************/
private void init()
private void init(void)
{
int i;
@ -1354,7 +1345,7 @@ private void init()
* with note-ons.
****************************************************************************/
private boolean ins_a_note()
private boolean ins_a_note(void)
{
long the_dur = (trunc(dur) * artic + 50) / 100;
int the_pitch = pitch;
@ -1377,7 +1368,7 @@ private boolean ins_a_note()
* insert one control change for each ctrlflag[i] that is TRUE
****************************************************************************/
private boolean ins_ctrls()
private boolean ins_ctrls(void)
{
int i;
event_type ctrl;
@ -1400,7 +1391,7 @@ private boolean ins_ctrls()
* Assumes: token[1] has the symbol to look up (token[0] == '!')
****************************************************************************/
private int issymbol()
private int issymbol(void)
{
int i, symb_num;
char *sym;
@ -1426,8 +1417,7 @@ private int issymbol()
* prints a carat (^) at the position specified on file stderr
****************************************************************************/
private void marker(count)
int count;
private void marker(int count)
{
int i;
char s[128];
@ -1444,7 +1434,7 @@ int count;
*
****************************************************************/
private void parseend()
private void parseend(void)
{
boolean done = FALSE;
while (!done) {
@ -1477,7 +1467,7 @@ private void parseend()
*
****************************************************************************/
private void parsefield()
private void parsefield(void)
{
fieldx = 1;
switch (token[0]) {
@ -1566,7 +1556,7 @@ private void parsefield()
* line contains a string to be parsed
****************************************************************************/
private boolean parsenote()
private boolean parsenote(void)
{
boolean out_of_memory = FALSE;
int i;
@ -1629,8 +1619,7 @@ private boolean parsenote()
}
private boolean parseparm(valptr)
long *valptr;
private boolean parseparm(long *valptr)
{
register char c = token[fieldx];
if (isdigit(c) || c == '-') {
@ -1717,7 +1706,7 @@ public time_type scale(x, n, d)
* scanning stops on delimiter: one of space, tab, newline, semicolon
****************************************************************************/
private int scan()
private int scan(void)
{
char *start = line + linex;
register char c;
@ -1755,8 +1744,7 @@ private int scan()
* copies one char from start into token, converting to upper case
****************************************************************************/
private int scan1(start)
char *start;
private int scan1(char *start)
{
int i = 0;
@ -1780,7 +1768,7 @@ char *start;
* fieldx is incremented to end of the integer
****************************************************************************/
private long scanint()
private long scanint(void)
{
long i = 0;
char c;
@ -1793,7 +1781,7 @@ private long scanint()
return i;
}
private long scansgnint()
private long scansgnint(void)
{
if (token[fieldx] == '-') {
fieldx++;
@ -1809,8 +1797,7 @@ private long scansgnint()
/* scansymb -- scan a symbol from the token */
/**/
private void scansymb(str)
char *str;
private void scansymb(char *str)
{
char c;
while ((c = token[fieldx])) {

View File

@ -20,12 +20,13 @@
#include "userio.h"
#include "record.h"
private boolean next_event_time();
private void write_event();
private boolean next_event_time(event_type event, time_type *next_time);
private void write_event(seq_type seq, event_type event, FILE *f,
boolean abs_flag);
private void write_velocity(FILE *f, int velocity);
private void write_voice();
private void write_voice(FILE *f, int voice);
private void write_rest(FILE *f, event_type ev, boolean abs_flag);
private void write_time();
private void write_time(FILE *f, event_type event, boolean abs_flag);
private boolean clock_started;
private long clock_half_tick;
@ -46,9 +47,7 @@ private int last_voice = seq_dflt_voice;
/*
* NOTE: clock events are ignored (unless this is the first clock event)
*/
private boolean next_event_time(event, next_time)
event_type event;
time_type *next_time;
private boolean next_event_time(event_type event, time_type *next_time)
{
while (event) {
if (vc_ctrl(event->nvoice) == ESC_CTRL &&
@ -101,11 +100,8 @@ private char ctrl_letter[] = "?KMOXYZ";
/* write_event -- write a single event to a file */
/**/
private void write_event(seq, event, f, abs_flag)
seq_type seq;
event_type event;
FILE *f;
boolean abs_flag;
private void write_event(seq_type seq, event_type event, FILE *f,
boolean abs_flag)
{
int voice = vc_voice(event->nvoice);
@ -231,10 +227,7 @@ private void write_rest(FILE *f, event_type ev, boolean abs_flag)
/* write_time -- write the final field on the line with N or T command */
/**/
private void write_time(f, event, abs_flag)
FILE *f;
event_type event;
boolean abs_flag;
private void write_time(FILE *f, event_type event, boolean abs_flag)
{
time_type next_time;
@ -271,9 +264,7 @@ private void write_velocity(FILE *f, int velocity)
/* write_voice -- write the voice field */
/**/
private void write_voice(f, voice)
FILE *f;
int voice;
private void write_voice(FILE *f, int voice)
{
if (last_voice != voice) {
last_voice = voice;

View File

@ -13,7 +13,7 @@
#include "seq.h"
#include "tempomap.h"
static time_type elapsed_time();
static time_type elapsed_time(long tempo, long beat);
/* tempomap_create -- create a tempomap */
/**/
@ -116,9 +116,7 @@ time_type tempomap_lookup(tempomap, beat)
/*
* the time returned is in units of 4us.
*/
static time_type elapsed_time(tempo, beat)
long tempo;
long beat;
static time_type elapsed_time(long tempo, long beat)
{
return (time_type)((tempo * beat) >> 2);
}

View File

@ -21,7 +21,7 @@
timebase_type timebase_queue = NULL; /* waiting to run timebase queue */
call_type callfree = NULL; /* free list */
private void fatal();
private void fatal(const char *msg);
/****************************************************************************
@ -124,9 +124,9 @@ void callshow(call)
call_type call;
{
int i;
gprintf(TRANS,"address: %lx\n", (ulong)call);
gprintf(TRANS,"address: %p\n", call);
gprintf(TRANS,"time: %ld\n", call->u.e.time);
gprintf(TRANS,"routine: %lx\n", (ulong)call->u.e.routine);
gprintf(TRANS,"routine: %p\n", call->u.e.routine);
gprintf(TRANS,"parameters:");
for (i = 0; i < MAX_CALL_ARGS; i++) {
gprintf(TRANS, " %p", call->u.e.p.arg[i]);
@ -141,8 +141,7 @@ void callshow(call)
* Effect: print message and exit program
***************************************************************/
private void fatal(msg)
char *msg;
private void fatal(const char *msg)
{
gprintf(FATAL, msg);
EXIT(1);

View File

@ -16,7 +16,7 @@ typedef struct call {
struct {
time_type time; /* virtual time of this call */
int priority; /* an 8-bit the priority, low priority first */
void (*routine)(); /* who to call */
void (*routine)(call_args_type args); /* who to call */
call_args_node p; /* what to pass */
} e;
struct call *p; /* used to link free calls */

View File

@ -153,10 +153,6 @@ extern int debug;
#include "xlisp.h"
#endif
int IOinputfd; /* input file descriptor (usually 0) */
int IOnochar; /* Value to be returned by IOgetchar()
where there is no input to be had */
/****************************************************************************
*
@ -164,8 +160,8 @@ int IOnochar; /* Value to be returned by IOgetchar()
*
****************************************************************************/
int GetReadFileName();
int GetWriteFileName();
int GetReadFileName(void);
int GetWriteFileName(void);
#ifdef MACINTOSH
private void PtoC_StrCopy(char *p1, char *p2);
@ -192,7 +188,7 @@ public int abort_flag; /* control C or control G equivalent */
public int redirect_flag; /* check whether the I/O has been redirected--
Added by Ning Hu Apr.2001*/
/* extern void musicterm(); */ /*DMH: from macmidi.c, to allow abort_check*/
public boolean ascii_input();
public boolean ascii_input(char *c);
/****************************************************************************
*
@ -811,7 +807,7 @@ void readln(fp)
#ifdef DOTS_FOR_ARGS
/* define with ... in arg list and use vsnprintf to get temp1 */
public void gprintf(long where, char *format, ...)
public void gprintf(long where, const char *format, ...)
{
char temp1[GPRINTF_MESSAGE_LEN];
#ifdef AMIGA
@ -1106,8 +1102,7 @@ char *c;
#endif
#ifdef UNIX
public boolean ascii_input(c)
char *c;
public boolean ascii_input(char *c)
{
#ifdef UNIX_MACH
/*
@ -1159,7 +1154,7 @@ public void unget_ascii(char c)
}
public boolean check_ascii()
public boolean check_ascii(void)
{
char c;
@ -1249,7 +1244,7 @@ public int wait_ascii()
FD_SET(IOinputfd, &readfds);
gflush();
getrlimit(RLIMIT_NOFILE, &file_limit);
select(file_limit.rlim_max+1, &readfds, 0, 0, NULL);
select((int) (file_limit.rlim_max+1), &readfds, 0, 0, NULL);
#endif /* !__APPLE__ */
#endif /* ifdef UNIX */
}

View File

@ -52,7 +52,7 @@ extern int redirect_flag; /* added by Ning Hu, Apr 2001 */
boolean get_ascii(char *c); /* polls for an ascii character */
#ifdef DOTS_FOR_ARGS
/* was (defined(ITC_MACH) && defined(__STDC__)) || defined(MACINTOSH) || defined(AZTEC) || (defined(AMIGA) && defined(LATTICE)) || defined(UNIX_ITC) */
void gprintf(long where, char *format, ...); /* general printf */
void gprintf(long where, const char *format, ...); /* general printf */
#else
void gprintf();
#endif
@ -70,7 +70,7 @@ FILE *fileopen(char *deflt, char *extension, char *mode, char *prompt);
void readln(FILE *fp);
void gflush(void);
int gputchar(int c);
int ggetchar();
int ggetchar(void);
char *ggets(char *str);
boolean ascii_input(char *c);
void unget_ascii(char c);

View File

@ -430,7 +430,10 @@ void pv_initialize(Phase_vocoder x)
pv->pos_buffer_rear = pv->pos_buffer;
}
// make sure tables are constructed before we start real-time processing
int fft_error_sign = fftInit(pv->log2_fft); // target fftInit
#ifndef NDEBUG
int fft_error_sign =
#endif
fftInit(pv->log2_fft); // target fftInit
assert(!fft_error_sign);
pv->phase = PV_START;
@ -550,7 +553,8 @@ int pv_get_input_count(Phase_vocoder x)
return need;
}
#pragma warning(disable: 4715 4068) // return type and unknown pragma
#pragma clang diagnostic ignored "-Wreturn-type"
double pv_get_effective_pos(Phase_vocoder x)
{
PV *pv = (PV*)x;
@ -594,9 +598,8 @@ double pv_get_effective_pos(Phase_vocoder x)
assert(pv->first_time);
assert(pv->output_total == 0);
return -(pv->ratio * pv->fftsize / 2.0);
} else { // I can't think of any other case.
assert(FALSE);
}
} // I can't think of any other case.
assert(FALSE);
}
@ -972,15 +975,16 @@ float *pv_get_output(Phase_vocoder x)
{
PV *pv = (PV *)x;
assert(pv->phase == PV_GOT_INPUT);
#ifndef NDEBUG
long blocksize = pv->blocksize;
float *out_next = pv->out_next;
#endif
int fftsize = pv->fftsize;
int frames_to_compute = pv->frames_to_compute;
int syn_hopsize = pv->syn_hopsize;
float *ana_win = pv->ana_win;
float ratio = pv->ratio;
float *input_head = pv->input_head;
float *out_next = pv->out_next;
float *ana_frame = pv->ana_frame;
float *ana_center;

View File

@ -8,6 +8,7 @@
fftInit every time you call ffts. For example you could have someting like:
#define FFT(a,n) if(!fftInit(roundtol(LOG2(n)))) ffts(a,roundtol(LOG2(n)),1);else printf("fft error\n");
*******************************************************************/
#include <stdint.h>
#include <stdlib.h>
#include "fftlib.h"
#include "matlib.h"
@ -39,7 +40,8 @@ if ((M >= 0) && (M < 8*sizeof(long))){
}
if (M > 1){
if (BRLowArray[M/2] == 0){ // init bit reversed table for cmplx fft
BRLowArray[M/2] = (short *) malloc( POW2(M/2-1)*sizeof(short) );
// coercion avoids compiler warning about 32-bit shift:
BRLowArray[M/2] = (short *) malloc( (int64_t) POW2(M/2-1)*sizeof(short) );
if (BRLowArray[M/2] == 0)
theError = 2;
else{
@ -49,7 +51,8 @@ if ((M >= 0) && (M < 8*sizeof(long))){
}
if (M > 2){
if (BRLowArray[(M-1)/2] == 0){ // init bit reversed table for real fft
BRLowArray[(M-1)/2] = (short *) malloc( POW2((M-1)/2-1)*sizeof(short) );
// coercion avoids compiler warning about 32-bit shift:
BRLowArray[(M-1)/2] = (short *) malloc( (int64_t) POW2((M-1)/2-1)*sizeof(short) );
if (BRLowArray[(M-1)/2] == 0)
theError = 2;
else{

View File

@ -16,7 +16,7 @@ int fftInit(long M);
/* OUTPUTS */
/* private cosine and bit reversed tables */
void fftFree();
void fftFree(void);
// release storage for all private cosine and bit reversed tables
void ffts(float *data, long M, long Rows);

View File

@ -3,6 +3,8 @@ lower level fft stuff including routines called in fftext.c and fft2d.c
*******************************************************************/
/* inline declarations modified by RBD for C99 compiler */
#include <stdint.h>
#include "fftlib.h"
#include <math.h>
#define MCACHE (11-(sizeof(float)/8)) // fft's with M bigger than this bust primary cache
@ -107,7 +109,7 @@ posB = posA + 2;
posBi = posB + 1;
iolimit = ioptr + Nrems2;
for (; ioptr < iolimit; ioptr += POW2(M/2+1)){
for (; ioptr < iolimit; ioptr += (int64_t) POW2(M/2+1)){
for (Colstart = Nroot_1; Colstart >= 0; Colstart--){
iCol = Nroot_1;
p0r = ioptr+ Nroot_1_ColInc + BRLow[Colstart]*4;
@ -420,7 +422,7 @@ float *p0r, *p1r, *p2r, *p3r;
float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i;
float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i;
const float Two = 2.0;
/* UNUSED: const float Two = 2.0; */
pinc = NDiffU * 2; // 2 floats per complex
pnext = pinc * 4;
@ -528,7 +530,7 @@ unsigned long SameUCnt;
float *pstrt;
float *p0r, *p1r, *p2r, *p3r;
float w1r = 1.0/MYROOT2; /* cos(pi/4) */
float w1r = 1.0F/MYROOT2; /* cos(pi/4) */
float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i;
float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i;
float t1r, t1i;
@ -981,7 +983,7 @@ for (; StageCnt > 0 ; StageCnt--){
w1r = *u1r;
w1i = *u1i;
if (DiffUCnt <= NDiffU/2)
if ((long) DiffUCnt <= NDiffU/2)
w0r = -w0r;
t0r = f0r - f4r * w2r - f4i * w2i;
@ -1171,7 +1173,7 @@ posB = posA + 2;
posBi = posB + 1;
iolimit = ioptr + Nrems2;
for (; ioptr < iolimit; ioptr += POW2(M/2+1)){
for (; ioptr < iolimit; ioptr += (int64_t) POW2(M/2+1)){
for (Colstart = Nroot_1; Colstart >= 0; Colstart--){
iCol = Nroot_1;
p0r = ioptr+ Nroot_1_ColInc + BRLow[Colstart]*4;
@ -1352,7 +1354,7 @@ ioptr[7] = scale*f3i;
//inline void ifft8pt(float *ioptr, float scale);
static inline void ifft8pt(float *ioptr, float scale){
/*** RADIX 8 ifft ***/
float w0r = 1.0/MYROOT2; /* cos(pi/4) */
float w0r = 1.0F/MYROOT2; /* cos(pi/4) */
float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i;
float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i;
float t0r, t0i, t1r, t1i;
@ -1484,7 +1486,7 @@ float *p0r, *p1r, *p2r, *p3r;
float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i;
float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i;
const float Two = 2.0;
/* UNUSED: const float Two = 2.0; */
pinc = NDiffU * 2; // 2 floats per complex
pnext = pinc * 4;
@ -1592,7 +1594,7 @@ unsigned long SameUCnt;
float *pstrt;
float *p0r, *p1r, *p2r, *p3r;
float w1r = 1.0/MYROOT2; /* cos(pi/4) */
float w1r = 1.0F/MYROOT2; /* cos(pi/4) */
float f0r, f0i, f1r, f1i, f2r, f2i, f3r, f3i;
float f4r, f4i, f5r, f5i, f6r, f6i, f7r, f7i;
float t1r, t1i;
@ -2048,7 +2050,7 @@ for (; StageCnt > 0 ; StageCnt--){
w1r = *u1r;
w1i = *u1i;
if (DiffUCnt <= NDiffU/2)
if ((long) DiffUCnt <= NDiffU/2)
w0r = -w0r;
t0r = f0r - f4r * w2r + f4i * w2i;
@ -2501,9 +2503,9 @@ posi = pos + 1;
p0r = ioptr;
p1r = ioptr + pos/2;
u0r = Utbl + POW2(M-3);
u0r = Utbl + (int) POW2(M-3);
w0r = *u0r,
w0r = *u0r;
f0r = *(p0r);
f0i = *(p0r + 1);
@ -2541,7 +2543,7 @@ f5i = *(p1r + posi);
u0r = Utbl + 1;
u0i = Utbl + (POW2(M-2)-1);
w0r = *u0r,
w0r = *u0r;
w0i = *u0i;
p0r = (ioptr + 2);
@ -2992,9 +2994,9 @@ posi = pos + 1;
p0r = ioptr;
p1r = ioptr + pos/2;
u0r = Utbl + POW2(M-3);
u0r = Utbl + (int) POW2(M-3);
w0r = *u0r,
w0r = *u0r;
f0r = *(p0r);
f0i = *(p0r + 1);
@ -3032,7 +3034,7 @@ f5i = *(p1r + posi);
u0r = Utbl + 1;
u0i = Utbl + (POW2(M-2)-1);
w0r = *u0r,
w0r = *u0r;
w0i = *u0i;
p0r = (ioptr + 2);

View File

@ -46,15 +46,17 @@ factor, ADD will create a rescaling of the operand.
#include "add.h"
#include "assert.h"
#pragma warning(disable: 4068) // unknown pragma (MSVS)
#pragma clang diagnostic ignored "-Wunreachable-code"
#define debugA 0
#define A if (debugA)
/* I don't know how these debug switches (A and D) differ: */
#define D A
#define D if (debugA)
/* switch B is/was to look for a particular zero block length bug */
#define debugB 0
#define B if (debugB | debugA)
#define debugB debugA
#define B if (debugB)
/* #define GC_DEBUG 1 */
@ -79,7 +81,7 @@ void add_s1_s2_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list)
falloc_sample_block(out, "add_s1_s2_nn_fetch");
snd_list->block = out;
out_ptr = out->samples;
A nyquist_printf("add[%p,%p] (s1_s2_nn) %p new block %p\n",
A nyquist_printf("add[%p,%p] (s1_s2_nn) %p new block %p\n",
susp->s1, susp->s2, susp, out);
/* fill up the new block */
@ -95,7 +97,7 @@ A nyquist_printf("add[%p,%p] (s1_s2_nn) %p starting outer loop, cnt %d\n",
A nyquist_printf("add[%p,%p]: look for samples (for s1) \n", susp->s1, susp->s2);
/* if (!susp->s1->list->block) watch_susp(susp->s1->list->u.susp); */
susp_check_term_log_block_samples(s1, s1_bptr, s1_ptr, s1_cnt, 1, 3);
A nyquist_printf("add[%p,%p]: found samples (for s1) s1_cnt=%d\n",
A nyquist_printf("add[%p,%p]: found samples (for s1) s1_cnt=%d\n",
susp->s1, susp->s2, (int)susp->s1_cnt);
togo = MIN(togo, susp->s1_cnt);
if (susp->terminate_bits & 1) {
@ -104,12 +106,12 @@ A nyquist_printf("add[%p,%p]: terminate bits on (for s1) togo=%d\n",
}
/* don't run past the s2 input sample block: */
A nyquist_printf("add[%p,%p]: look for samples (for s2) \n", susp->s1, susp->s2);
A nyquist_printf("add[%p,%p]: look for samples (for s2) \n", susp->s1, susp->s2);
susp_check_term_log_block_samples(s2, s2_bptr, s2_ptr, s2_cnt, 2, 3);
A nyquist_printf("add[%p,%p]: found samples (for s2) s2_cnt=%d\n",
A nyquist_printf("add[%p,%p]: found samples (for s2) s2_cnt=%d\n",
susp->s1, susp->s2, (int)susp->s2_cnt);
togo = MIN(togo, susp->s2_cnt);
A if (susp->terminate_bits & 2) {
A if (susp->terminate_bits & 2) {
nyquist_printf("add[%p,%p]: terminate bits on (for s2) togo=%d\n",
susp->s1, susp->s2, togo);
}
@ -117,16 +119,18 @@ A if (susp->terminate_bits & 2) {
/* don't run past logical stop time (need to check this even
* if a sound has terminated)
*/
A nyquist_printf(
"add[%p,%p] (s1_s2_nn) %p: logically_stopped %d, logical_stop_cnt %d, s1 logical_stop_cnt %ld, s2 logical_stop_cnt %ld \n",
susp->s1, susp->s2, susp, susp->logically_stopped,
(int) susp->susp.log_stop_cnt,
susp->s1->logical_stop_cnt,
susp->s2->logical_stop_cnt);
A nyquist_printf("add[%p,%p] (s1_s2_nn) %p: logically_stopped %d, "
"logical_stop_cnt %d, s1 logical_stop_cnt %" PRId64
", s2 logical_stop_cnt %" PRId64 "\n",
susp->s1, susp->s2, susp, susp->logically_stopped,
(int) susp->susp.log_stop_cnt,
susp->s1->logical_stop_cnt, susp->s2->logical_stop_cnt);
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN &&
(susp->logical_stop_bits == 3)) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
A nyquist_printf("add[%p,%p]: to_stop = %d\n", susp->s1, susp->s2, to_stop);
int to_stop = (int) (susp->susp.log_stop_cnt -
(susp->susp.current + cnt));
A nyquist_printf("add[%p,%p]: to_stop = %d\n", susp->s1, susp->s2,
to_stop);
/* logical stops have to be indicated on block boundaries */
if (to_stop < togo) {
if (to_stop == 0) {
@ -152,7 +156,8 @@ A nyquist_printf("add[%p,%p]: to_stop = %d\n", susp->s1, susp->s2, to_stop);
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
togo = (int) (susp->terminate_cnt -
(susp->susp.current + cnt));
D nyquist_printf("add[%p,%p]: togo = %d\n", susp->s1, susp->s2, togo);
if (togo == 0) break;
}
@ -263,7 +268,8 @@ void add_s1_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
add_susp_type susp = (add_susp_type) a_susp;
/* expansion of add_s_nn_fetch(snd_list,s1,s2,1); follows: */
int togo, s2_start=0;
int togo;
int64_t s2_start = 0;
int n;
sample_block_type out;
register sample_block_values_type out_ptr;
@ -292,9 +298,9 @@ B if (togo == 0) stdputstr("togo is zero at checkpoint 1\n");
/* if (susp->s1_ptr == zero_block->samples) { -sep21 RBD*/
if (susp->terminate_bits & 1) {
if (susp->s2) {
s2_start = (long) ((susp->s2->t0 - susp->susp.t0) *
susp->s2->sr + 0.5);
D nyquist_printf("add_s_nn_fetch: s2_start %d\n", s2_start);
s2_start = (int64_t) ((susp->s2->t0 - susp->susp.t0) *
susp->s2->sr + 0.5);
D nyquist_printf("add_s_nn_fetch: s2_start %" PRId64 "\n", s2_start);
}
togo = 0;
B if (togo == 0) stdputstr("togo is zero at checkpoint 2\n");
@ -331,14 +337,15 @@ D nyquist_printf("add_s_nn_fetch: special return, susp %p\n", susp);
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN &&
susp->logical_stop_bits == 3) {
int to_stop = susp->susp.log_stop_cnt - susp->susp.current;
int64_t to_stop = susp->susp.log_stop_cnt - susp->susp.current;
if (to_stop < togo) {
if (to_stop == 0) {
susp->logically_stopped = true;
} else togo = to_stop;
} else togo = (int) to_stop;
}
B if (togo == 0) stdputstr("togo is zero at checkpoint 3\n");
D nyquist_printf("add_s1_nn_fetch: to_stop %d togo %d\n", to_stop, togo);
D nyquist_printf("add_s1_nn_fetch: to_stop %" PRId64 " togo %d\n",
to_stop, togo);
}
/* consider other signal? don't run past its start time... */
@ -346,7 +353,7 @@ D nyquist_printf("add_s1_nn_fetch: to_stop %d togo %d\n", to_stop, togo);
s2_start = ROUND32((susp->s2->t0 - susp->susp.t0) *
susp->s2->sr);
if (s2_start < susp->susp.current + togo)
togo = MIN(togo, s2_start - susp->susp.current);
togo = (int) MIN(togo, s2_start - susp->susp.current);
B if (togo == 0) stdputstr("togo is zero at checkpoint 4\n");
}
@ -427,12 +434,15 @@ D sound_print_tree(susp->s1);
falloc_sample_block(out, "add_s1_nn_fetch");
snd_list->block = out;
out_ptr = out->samples;
B nyquist_printf("add[%p,%p] (s1_nn) %p new block %p, s1_ptr %p block %p s1_cnt %d togo %d\n", susp->s1, susp->s2, susp, out, susp->s1_ptr, susp->s1_bptr->samples, (int)susp->s1_cnt, togo);
B nyquist_printf("add[%p,%p] (s1_nn) %p new block %p, s1_ptr %p "
"block %p s1_cnt %d togo %d\n", susp->s1, susp->s2,
susp, out, susp->s1_ptr, susp->s1_bptr->samples,
(int)susp->s1_cnt, togo);
n = togo;
B if (togo == 0) stdputstr("togo is zero at checkpoint 5\n");
B if (togo == 0) nyquist_printf(
"add[%p,%p] (s%d_nn) %p starting copy loop, togo %d\n",
susp->s1, susp->s2, 1, susp, togo);
B if (togo == 0) nyquist_printf(
"add[%p,%p] (s%d_nn) %p starting copy loop, togo %d\n",
susp->s1, susp->s2, 1, susp, togo);
while (n--) { /* the inner sample computation loop */
/* scale? */
*out_ptr++ = *(susp->s1_ptr++);
@ -460,9 +470,10 @@ D stdputstr("add_s_nn_fetch: add_s1_s2_fetch installed\n");
/* s2 finished and s1 stops */
/* go to terminal state */
susp->s1 = NULL;
D nyquist_printf("add_s_nn_fetch: go to terminal state. susp->s2 %p, \
susp->susp.current %d, s2_start %d, susp->s1->list %p, \
zero_snd_list %p\n", susp->s2, (int)susp->susp.current,
D nyquist_printf("add_s_nn_fetch: go to terminal state. susp->s2 %p, "
"susp->susp.current %" PRId64 ", s2_start %" PRId64
", susp->s1->list %p, zero_snd_list %p\n",
susp->s2, susp->susp.current,
s2_start, susp->s1->list, zero_snd_list);
/* !!! free resources and set up pointers to terminal snd_list */
/* !!! logically stopped? */
@ -555,10 +566,10 @@ D nyquist_printf("add_s_nn_fetch: special return, susp %p\n", susp);
/* check if we've seen the logical stop from s2. If so then
log_stop_cnt is max of s1 and s2 stop times */
(susp->logical_stop_bits & 2)) {
int to_stop;
D nyquist_printf("add_s2_nn_fetch: susp->susp.log_stop_cnt %ld\n",
int64_t to_stop;
D nyquist_printf("add_s2_nn_fetch: susp->susp.log_stop_cnt %" PRId64 "\n",
susp->susp.log_stop_cnt);
D nyquist_printf("add_s2_nn_fetch: susp->susp.current %ld\n",
D nyquist_printf("add_s2_nn_fetch: susp->susp.current %" PRId64 "\n",
susp->susp.current);
to_stop = susp->susp.log_stop_cnt - susp->susp.current;
// to_stop can be less than zero if we've been adding in sounds with
@ -578,10 +589,11 @@ D nyquist_printf("add_s2_nn_fetch: susp->susp.current %ld\n",
if (to_stop < togo) {
if (to_stop == 0) {
susp->logically_stopped = true;
} else togo = to_stop;
} else togo = (int) to_stop;
}
B if (togo == 0) stdputstr("togo is zero at checkpoint 3\n");
D nyquist_printf("add_s2_nn_fetch: to_stop %d togo %d\n", to_stop, togo);
D nyquist_printf("add_s2_nn_fetch: to_stop %" PRId64 " togo %d\n",
to_stop, togo);
}
/* consider other signal? don't run past its start time... */
@ -589,7 +601,7 @@ D nyquist_printf("add_s2_nn_fetch: to_stop %d togo %d\n", to_stop, togo);
s1_start = ROUND32((susp->s1->t0 - susp->susp.t0) *
susp->s1->sr);
if (s1_start < susp->susp.current + togo)
togo = MIN(togo, s1_start - susp->susp.current);
togo = (int) MIN(togo, s1_start - susp->susp.current);
assert(togo > 0);
}
@ -614,12 +626,12 @@ D nyquist_printf("add_s2_nn_fetch: to_stop %d togo %d\n", to_stop, togo);
*/
/* just fetch and pass blocks on */
D nyquist_printf("add[%p,%p] (s%d_nn) %p starting uncopy, togo %d\n", susp->s2, susp->s1,
2, susp, togo);
D nyquist_printf("add[%p,%p] (s%d_nn) %p starting uncopy, togo %d\n",
susp->s2, susp->s1, 2, susp, togo);
snd_list->block = susp->s2_bptr;
(susp->s2_bptr->refcnt)++;
D nyquist_printf("add[%p,%p] (s%d_nn) %p shared block %p zero_block %p\n",susp->s2, susp->s1,
2, susp, susp->s2_bptr, zero_block);
D nyquist_printf("add[%p,%p] (s%d_nn) %p shared block %p zero_block %p\n",
susp->s2, susp->s1, 2, susp, susp->s2_bptr, zero_block);
susp_took(s2_cnt, togo);
snd_list->block_len = togo;
@ -657,7 +669,7 @@ D sound_print_tree(susp->s2);
snd_list->u.next = addend_list;
return;
} else {
D nyquist_printf("s1 == NULL, but no collapse, lsc %ld\n",
D nyquist_printf("s1 == NULL, but no collapse, lsc %" PRId64 "\n",
susp->s2->logical_stop_cnt);
}
} else {
@ -694,7 +706,7 @@ B nyquist_printf(
/* add a new snd_list for the susp */
susp->susp.current += togo;
if (0) stdputstr("testing...");
if (/* DISABLES CODE */ (0)) stdputstr("testing...");
/*
* test for termination or change of state,
* note s1_start computed earlier
@ -728,7 +740,7 @@ D stdputstr("add_s_nn_fetch: snd_list->logically_stopped\n");
D stdputstr("add_s_nn_fetch: susp->logically_stopped\n");
susp->logically_stopped = true;
}
if (0) {
if (/* DISABLES CODE */ (0)) {
if (susp->logically_stopped || snd_list->logically_stopped)
stdputstr("STOPPED\n");
else
@ -748,18 +760,19 @@ void add_zero_fill_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list)
#endif
togo = max_sample_block_len;
if (0) fprintf(STDERR, "add_zero_fill_nn_fetch, susp.current %d\n",
if (/* DISABLES CODE */ (0)) fprintf(STDERR,
"add_zero_fill_nn_fetch, susp.current %d\n",
(int)susp->susp.current);
/* don't run past start time ... */
if (susp->s1) {
s_start = ROUND32((susp->s1->t0 - susp->susp.t0) * susp->s1->sr);
if (s_start < susp->susp.current + togo) {
togo = s_start - susp->susp.current;
togo = (int) (s_start - susp->susp.current);
}
} else if (susp->s2) {
s_start = ROUND32((susp->s2->t0 - susp->susp.t0) * susp->s2->sr);
if (s_start < susp->susp.current + togo) {
togo = s_start - susp->susp.current;
togo = (int) (s_start - susp->susp.current);
}
}

View File

@ -4,15 +4,15 @@ typedef struct add_susp_struct {
snd_susp_node susp;
boolean started;
int terminate_bits;
long terminate_cnt;
int64_t terminate_cnt;
int logical_stop_bits;
boolean logically_stopped;
sound_type s1;
long s1_cnt;
int s1_cnt;
sample_block_type s1_bptr; /* block pointer */
sample_block_values_type s1_ptr;
sound_type s2;
long s2_cnt;
int s2_cnt;
sample_block_type s2_bptr; /* block pointer */
sample_block_values_type s2_ptr;
@ -27,7 +27,7 @@ typedef struct add_susp_struct {
#endif
/* pointer used to synchronize adds in multiseq */
struct multiseq_struct *multiseq;
long s1_prepend; /* offset to susp.current */
int64_t s1_prepend; /* offset to susp.current */
} add_susp_node, *add_susp_type;
sound_type snd_make_add(sound_type s1, sound_type s2);

View File

@ -15,16 +15,18 @@
*/
void avg_free();
void avg_free(snd_susp_type a_susp);
typedef sample_type (*process_block_type)(/* struct avg_susp_struct *susp */);
struct avg_susp_struct;
typedef sample_type (*process_block_type)(struct avg_susp_struct *susp);
typedef struct avg_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type s;
long s_cnt;
int s_cnt;
sample_block_values_type s_ptr;
/* blocksize is how many input samples to process for an output sample */
long blocksize;
@ -77,7 +79,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
avg_susp_type susp = (avg_susp_type) a_susp;
int cnt = 0; /* how many samples computed */
int togo = 0;
int64_t togo = 0;
int n;
sample_block_type out;
register sample_block_values_type out_ptr;
@ -109,7 +111,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
/* break if to_stop == 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the
* output block).
@ -131,7 +133,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
}
}
n = togo;
n = (int) togo;
s_ptr_reg = susp->s_ptr;
fillptr_reg = susp->fillptr;
if (n) do { /* the inner sample computation loop */
@ -146,7 +148,7 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* using s_ptr_reg is a bad idea on RS/6000: */
susp->s_ptr += togo;
susp->fillptr = fillptr_reg;
susp_took(s_cnt, togo);
susp_took(s_cnt, (int) togo);
} /* outer loop */
/* test for termination */
@ -168,23 +170,23 @@ void avg_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
void avg_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
avg_susp_type susp = (avg_susp_type) a_susp;
long final_count = MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
int64_t final_count = MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
time_type final_time = susp->susp.t0 + final_count / susp->susp.sr;
long n;
int64_t n;
/* fetch samples from s up to final_time for this block of zeros */
while (((long) ((final_time - susp->s->t0) * susp->s->sr + 0.5)) >=
susp->s->current)
susp_get_samples(s, s_ptr, s_cnt);
while ((ROUNDBIG((final_time - susp->s->t0) * susp->s->sr)) >=
susp->s->current)
susp_get_samples(s, s_ptr, s_cnt);
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
if (final_count == susp->susp.toss_cnt) {
n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr -
(susp->s->current - susp->s_cnt));
susp->s_ptr += n;
susp_took(s_cnt, n);
susp->susp.fetch = susp->susp.keep_fetch;
n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr -
(susp->s->current - susp->s_cnt));
susp->s_ptr += n;
susp_took(s_cnt, (int) n);
susp->susp.fetch = susp->susp.keep_fetch;
}
snd_list->block_len = (short) (final_count - susp->susp.current);
susp->susp.current = final_count;

View File

@ -1,6 +1,6 @@
sound_type snd_make_avg(sound_type s, long blocksize, long stepsize, long op);
sound_type snd_avg(sound_type s, long blocksize, long stepsize, long op);
/* LISP: (snd-avg SOUND FIXNUM FIXNUM FIXNUM) */
/* LISP: (snd-avg SOUND LONG LONG LONG) */
#define op_average 1
#define op_peak 2
/* LISP-SRC: (setf OP-AVERAGE 1) (setf OP-PEAK 2) */

View File

@ -14,22 +14,22 @@
* 28Apr03 dm changes for portability and fix compiler warnings
*/
void compose_free();
void compose_free(snd_susp_type a_susp);
typedef struct compose_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type f;
long f_cnt;
int f_cnt;
sample_block_values_type f_ptr;
sample_type f_prev;
double f_time;
double f_time_increment;
boolean started;
sound_type g;
long g_cnt;
int g_cnt;
sample_block_values_type g_ptr;
} compose_susp_node, *compose_susp_type;
@ -110,14 +110,15 @@ void compose_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo == 0) break;
}
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
if (to_stop < togo && ((togo = to_stop) == 0)) break;
int64_t to_stop = susp->susp.log_stop_cnt -
(susp->susp.current + cnt);
if (to_stop < togo && ((togo = (int) to_stop) == 0)) break;
}
n = togo;
@ -177,8 +178,8 @@ f_out_of_samples:
void compose_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
compose_susp_type susp = (compose_susp_type) a_susp;
long final_count = MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
long final_count = (long) MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
time_type final_time = susp->susp.t0 + final_count / susp->susp.sr;
long n;
@ -193,12 +194,12 @@ void compose_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
if (final_count == susp->susp.toss_cnt) {
n = ROUNDBIG((final_time - susp->f->t0) * susp->f->sr -
(susp->f->current - susp->f_cnt));
n = ROUND32((final_time - susp->f->t0) * susp->f->sr -
(susp->f->current - susp->f_cnt));
susp->f_ptr += n;
susp_took(f_cnt, n);
n = ROUNDBIG((final_time - susp->g->t0) * susp->g->sr -
(susp->g->current - susp->g_cnt));
n = ROUND32((final_time - susp->g->t0) * susp->g->sr -
(susp->g->current - susp->g_cnt));
susp->g_ptr += n;
susp_took(g_cnt, n);
susp->susp.fetch = susp->susp.keep_fetch;

View File

@ -83,16 +83,16 @@
#include "fftext.h"
#include "convolve.h"
void convolve_free();
void convolve_free(snd_susp_type a_susp);
typedef struct convolve_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean know_end_of_x;
boolean logically_stopped;
sound_type x_snd;
long x_snd_cnt;
int x_snd_cnt;
sample_block_values_type x_snd_ptr;
sample_type *X; // the FFTs of x_snd
@ -228,12 +228,12 @@ void convolve_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* can't use more than what's left in R. R_current is
the next sample of R, so what's left is N - (R - R_current) */
R_current = susp->R_current;
togo = min(togo, N - (R_current - R));
togo = (int) min(togo, N - (R_current - R));
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo == 0) break;
}
@ -241,9 +241,9 @@ void convolve_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
if (!susp->logically_stopped &&
susp->susp.log_stop_cnt != UNKNOWN &&
susp->susp.log_stop_cnt <= susp->susp.current + cnt + togo) {
togo = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
D printf("susp->susp.log_stop_cnt is set to %ld\n",
susp->susp.log_stop_cnt);
togo = (int) (susp->susp.log_stop_cnt - (susp->susp.current + cnt));
D printf("susp->susp.log_stop_cnt is set to %" PRId64 "\n",
susp->susp.log_stop_cnt);
if (togo == 0) break;
}
@ -287,8 +287,8 @@ void convolve_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt);
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
n = ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr -
(susp->x_snd->current - susp->x_snd_cnt));
n = (long) ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr -
(susp->x_snd->current - susp->x_snd_cnt));
susp->x_snd_ptr += n;
susp_took(x_snd_cnt, n);
susp->susp.fetch = susp->susp.keep_fetch;
@ -333,12 +333,14 @@ void fill_with_samples(sample_type *x, sound_type s, long n)
int i;
for (i = 0; i < n; i++) {
if (!s->extra) { /* this is the first call, so fix up s */
s->extra = (long *) malloc(sizeof(long) * FIELDS);
s->extra[0] = sizeof(long) * FIELDS;
s->extra = (int64_t *) malloc(sizeof(s->extra[0]) * FIELDS);
s->extra[0] = sizeof(s->extra[0]) * FIELDS;
s->CNT = s->INDEX = 0;
}
if (s->CNT == s->INDEX) {
sound_get_next(s, &(s->CNT));
int icnt = (int) s->CNT; /* need this to be int type */
if (icnt == s->INDEX) {
sound_get_next(s, &icnt);
s->CNT = icnt; /* save the count back into s->extra */
s->INDEX = 0;
}
x[i] = s->SAMPLES[s->INDEX++] * s->scale;
@ -353,7 +355,7 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd)
time_type t0 = x_snd->t0;
sample_type scale_factor = 1.0F;
time_type t0_min = t0;
long h_len;
int64_t h_len;
int i;
// assume fft_size is maximal. We fix this later if it is wrong
long fft_size = 1 << MAX_LOG_FFT_SIZE;
@ -372,8 +374,8 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd)
* the FFT size is at least double that */
if (h_len <= fft_size / 4) {
/* compute log-base-2(h_len): */;
double log_len = log(h_len) / M_LN2;
int log_len_int = log_len;
double log_len = log((double) h_len) / M_LN2;
int log_len_int = (int) log_len;
if (log_len_int != log_len) log_len_int++; /* round up to power of 2 */
susp->M = log_len_int + 1;
} else {
@ -383,11 +385,11 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd)
D printf("fft_size %ld\n", fft_size);
susp->N = fft_size / 2;
// round h_len up to multiple of susp->N and multiply by 2
susp->h_snd_len = h_len;
susp->h_snd_len = (int) h_len;
h_len = ((h_len + susp->N - 1) / susp->N) * susp->N * 2;
susp->L = h_len / fft_size;
susp->L = (int) (h_len / fft_size);
// allocate memory
susp->H = (sample_type *) calloc(h_len, sizeof(susp->H[0]));
susp->H = (sample_type *) calloc((size_t) h_len, sizeof(susp->H[0]));
if (!susp->H) {
xlfail("memory allocation failure in convolve");
}
@ -413,7 +415,7 @@ sound_type snd_make_convolve(sound_type x_snd, sound_type h_snd)
for (i = 0; i < susp->L; i++) {
rffts(susp->H + i * susp->N * 2, susp->M, 1);
}
susp->X = (sample_type *) calloc(h_len, sizeof(susp->X[0]));
susp->X = (sample_type *) calloc((size_t) h_len, sizeof(susp->X[0]));
susp->R = (sample_type *) calloc(fft_size, sizeof(susp->R[0]));
susp->Y = (sample_type *) calloc(fft_size, sizeof(susp->Y[0]));
if (!susp->X || !susp->R || !susp->Y) {

View File

@ -151,10 +151,10 @@ void print_sound_type(sound_type s)
nyquist_printf("\t(0x%p:0x%p)->", list, list->block);
while (list->block) {
list = list->u.next;
if (blockcount < 5) {
nyquist_printf("(0x%p:0x%p)->", list, list->block);
if (blockcount < 50) {
nyquist_printf("(0x%p block 0x%p)->", list, list->block);
}
else if (blockcount == 5) {
else {
stdputstr(" ... ");
break;
}

View File

@ -28,7 +28,6 @@ typedef struct partial_susp_struct {
#endif
extern sound_type watch_table_sound;
extern int table_ptr_check_enable;
void print_sound_type(sound_type s);
void print_sample_block_type(char *label,
@ -40,7 +39,6 @@ void watch_snd_list(snd_list_type s);
void dbg_mem_allocated(void *p, char *who);
void dbg_mem_freed(void *p, char *who);
void dbg_mem_print(char *msg, void *p);
void table_ptr_check();
/* #define TRACESNDGC */
#define DEBUG_H

View File

@ -23,10 +23,10 @@ void down_free(snd_susp_type a_susp);
typedef struct down_susp_struct {
snd_susp_node susp;
boolean started;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type s;
long s_cnt;
int s_cnt;
sample_block_values_type s_ptr;
/* support for interpolation of s */
@ -35,8 +35,9 @@ typedef struct down_susp_struct {
double s_pHaSe_iNcR;
/* support for ramp between samples of s */
/*can we delete these?
double output_per_s;
long s_n;
long s_n; */
} down_susp_node, *down_susp_type;
@ -78,7 +79,7 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo <= 0) {
togo = 0;
break;
@ -87,7 +88,7 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
/* break if to_stop == 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the
* output block).
@ -105,7 +106,7 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list)
} else /* limit togo so we can start a new
* block at the LST
*/
togo = to_stop;
togo = (int) to_stop;
}
}
@ -197,8 +198,8 @@ void down_i_fetch(snd_susp_type a_susp, snd_list_type snd_list)
void down_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
down_susp_type susp = (down_susp_type) a_susp;
long final_count = MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
int64_t final_count = MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
time_type final_time = susp->susp.t0 + final_count / susp->susp.sr;
long n;
@ -209,8 +210,8 @@ void down_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
if (final_count == susp->susp.toss_cnt) {
n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr -
(susp->s->current - susp->s_cnt));
n = (long) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr -
(susp->s->current - susp->s_cnt));
susp->s_ptr += n;
susp_took(s_cnt, n);
susp->susp.fetch = susp->susp.keep_fetch;
@ -289,8 +290,8 @@ sound_type snd_make_down(rate_type sr, sound_type s)
susp->s_cnt = 0;
susp->s_pHaSe = 0.0;
susp->s_pHaSe_iNcR = s->sr / sr;
susp->s_n = 0;
susp->output_per_s = sr / s->sr;
//susp->s_n = 0;
//susp->output_per_s = sr / s->sr;
return sound_create((snd_susp_type)susp, t0, sr, scale_factor);
}

View File

@ -1,3 +1,3 @@
sound_type snd_make_down();
sound_type snd_down();
sound_type snd_make_down(rate_type sr, sound_type s);
sound_type snd_down(rate_type sr, sound_type s);
/* LISP: (snd-down ANYNUM SOUND) */

View File

@ -134,6 +134,6 @@ float best_f0(float *samples, int n, int m, float threshold, int Tmax)
best_f0=f0;
}
}
delete[] results;
delete[](results);
return best_f0;
}

View File

@ -45,8 +45,7 @@ int npools = 0;
CQUE *pools = NULL;
#endif
void sound_already_free_test(s)
sound_type s;
void sound_already_free_test(sound_type s)
{
sound_type sp;
for (sp = (sound_type) sound_free; sp; sp = (sound_type) ((CQUE *) sp)->qnext) {
@ -235,7 +234,8 @@ void falloc_gc()
tlist = tsave;
/* Maintain stats */
sample_block_total -= (tsiz / round_size(sizeof(sample_block_node)));
sample_block_total -= (int)
(tsiz / round_size(sizeof(sample_block_node)));
npools--;
/* If this is the active pool, then reset current pointers */

View File

@ -92,7 +92,7 @@ extern int sample_blocks_since_gc;
#if defined(TRACK_POOLS) && TRACK_POOLS
// extern CQUE *pools;
void falloc_gc();
void falloc_gc(void);
#endif
void falloc_init(void);

View File

@ -82,7 +82,7 @@ void fft_shift(float *x, int len)
void n_samples_from_sound(sound_type s, long n, float *table)
{
long blocklen;
int blocklen;
sample_type scale_factor = s->scale;
s = sound_copy(s);
while (n > 0) {
@ -112,7 +112,7 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval)
if (!s->extra) { /* this is the first call, so fix up s */
sound_type w = NULL;
long bytes = sizeof(long) * OFFSET + sizeof(float) * 3 * len;
long bytes = sizeof(s->extra[0]) * OFFSET + sizeof(float) * 3 * len;
if (winval) {
if (soundp(winval)) {
w = getsound(winval);
@ -137,7 +137,7 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval)
* really necessary).
*/
s->extra = (long *) malloc(bytes);
s->extra = (int64_t *) malloc(bytes);
s->extra[0] = bytes;
s->CNT = s->INDEX = s->FILLCNT = 0;
s->TERMCNT = -1;
@ -152,7 +152,8 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval)
n_samples_from_sound(w, len, window);
}
} else {
maxlen = (s->extra[0] - sizeof(long) * OFFSET) / (sizeof(float) * 3);
maxlen = (long) ((s->extra[0] - sizeof(s->extra[0]) * OFFSET) /
(sizeof(float) * 3));
if (maxlen != len) xlfail("len changed from initial value");
float_base = (float *) &(s->extra[OFFSET]);
}
@ -161,10 +162,12 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval)
// this code computes window location
window = float_base + 2 * len;
/* step 1: refill buffer with samples */
fillptr = s->FILLCNT;
fillptr = (long) s->FILLCNT;
while (fillptr < maxlen) {
if (s->INDEX == s->CNT) {
sound_get_next(s, &(s->CNT));
int icnt = (int) s->CNT; /* need this to be type int */
if (s->INDEX == icnt) {
sound_get_next(s, &icnt);
s->CNT = icnt; /* save the count back to s->extra */
if (s->SAMPLES == zero_block->samples) {
if (s->TERMCNT < 0) s->TERMCNT = fillptr;
}
@ -197,6 +200,9 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval)
}
/* perform the fft: */
m = ROUND32(log(len) / M_LN2); /* compute log-base-2(len) */
if (m > 27) { /* 27 comes from fftext.c and seems big enough */
xlfail("FFT len greater than 2^27");
}
if (1 << m != len) {
xlfail("FFT len is not a power of two");
}
@ -231,13 +237,15 @@ LVAL snd_fft(sound_type s, long len, long step, LVAL winval)
*/
skip = step - maxlen;
while (skip > 0) {
long remaining = s->CNT - s->INDEX;
long remaining = (long) (s->CNT - s->INDEX);
if (remaining >= skip) {
s->INDEX += skip;
skip = 0;
} else {
skip -= remaining;
sound_get_next(s, &(s->CNT));
int icnt = (int) s->CNT; /* need this to be type int */
sound_get_next(s, &icnt);
s->CNT = icnt; /* save count back into s->extra */
s->INDEX = 0;
}
}

View File

@ -3,4 +3,4 @@
void fft_shift(float *x, int len);
LVAL snd_fft(sound_type s, long len, long step, LVAL w);
/* LISP: (SND-FFT SOUND FIXNUM FIXNUM ANY) */
/* LISP: (SND-FFT SOUND LONG LONG ANY) */

View File

@ -6,7 +6,7 @@ char *app_syntax = "";
/* note -- a simple way to make a midi note on channel 1 */
/**/
void note(pitch, dur)
void note(int pitch, int dur)
{
}

View File

@ -17,15 +17,15 @@
#include "falloc.h"
#include "inverse.h"
void inverse_free();
void inverse_free(snd_susp_type a_susp);
typedef struct inverse_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type s;
long s_cnt;
int s_cnt;
sample_block_values_type s_ptr;
double s_prev;
double s_time;
@ -93,7 +93,7 @@ void inverse_fetch(snd_susp_type a_susp, snd_list_type snd_list)
susp->terminate_cnt <= susp->susp.current + out_cnt) {
/* pretend like we computed the correct number of samples */
togo = 0;
out_cnt = susp->terminate_cnt - susp->susp.current;
out_cnt = (long) (susp->terminate_cnt - susp->susp.current);
/* exit the loop to complete the termination */
break;
}
@ -132,8 +132,8 @@ void inverse_fetch(snd_susp_type a_susp, snd_list_type snd_list)
void inverse_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
inverse_susp_type susp = (inverse_susp_type) a_susp;
long final_count = MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
int64_t final_count = MIN(susp->susp.current + max_sample_block_len,
susp->susp.toss_cnt);
time_type final_time = susp->susp.t0 + final_count / susp->susp.sr;
long n;
@ -144,8 +144,8 @@ void inverse_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
if (final_count == susp->susp.toss_cnt) {
n = ROUNDBIG((final_time - susp->s->t0) * susp->s->sr -
(susp->s->current - susp->s_cnt));
n = (long) ROUNDBIG((final_time - susp->s->t0) * susp->s->sr -
(susp->s->current - susp->s_cnt));
susp->s_ptr += n;
susp_took(s_cnt, n);
susp->susp.fetch = susp->susp.keep_fetch;

View File

@ -1,3 +1,12 @@
// localdefs.h -- additional declarations needed for XLisp extensions
// this file is for Nyquist
/* include actual local file headers: */
#include "sndfnintdefs.h"
#include "seqfnintdefs.h"
/* from sndsliders.c */
LVAL xslider_read(void);

View File

@ -1,4 +1,4 @@
/* lpanal.h -- LPC analysis */
LVAL snd_lpanal(LVAL v, long P);
/* LISP: (SND-LPANAL ANY FIXNUM) */
/* LISP: (SND-LPANAL ANY LONG) */

View File

@ -139,20 +139,20 @@ void multiread_fetch(snd_susp_type a_susp, snd_list_type snd_list)
while (true) {
/* compute how many frames to read to fill sample blocks */
long frame_count = max_sample_block_len - frames_read;
long actual; /* how many frames actually read */
int frame_count = max_sample_block_len - frames_read;
int actual; /* how many frames actually read */
/* make sure frames will fit in buffer */
if (frame_count * file_frame_size > input_buffer_samps) {
frame_count = input_buffer_samps / file_frame_size;
}
actual = sf_readf_float(susp->sndfile, input_buffer, frame_count);
actual = (int) sf_readf_float(susp->sndfile, input_buffer, frame_count);
n = actual;
/* don't read too many */
if (n > (susp->cnt - susp->susp.current)) {
n = susp->cnt - susp->susp.current;
n = (int) (susp->cnt - susp->susp.current);
}
/* process one channel at a time, multiple passes through input */
@ -268,7 +268,7 @@ void multiread_free(snd_susp_type a_susp)
}
if (!active) {
/* stdputstr("all channels freed, freeing susp now\n"); */
read_free(susp);
read_free(a_susp);
}
}

View File

@ -19,6 +19,7 @@
#include "scale.h"
#include "extern.h"
#include "cext.h"
#include "sndseq.h"
/* #define MULTISEQ_GC_DEBUG */
#ifdef MULTISEQ_GC_DEBUG
@ -344,7 +345,7 @@ void multiseq_convert(multiseq_type ms)
for (i = 0; i < ms->nchans; i++) {
snd_list_type snd_list = ms->chans[i];
add_susp_type susp = (add_susp_type) snd_list->u.susp;
long sother_start;
int64_t sother_start;
/* remove backpointer to ms */
susp->multiseq = NULL;
@ -361,8 +362,8 @@ void multiseq_convert(multiseq_type ms)
}
sother_start = ROUNDBIG((susp->s2->t0 - susp->susp.t0) * susp->s2->sr);
D nyquist_printf("sother_start computed for %p: %d\n",
susp, (int)sother_start);
D nyquist_printf("sother_start computed for %p: %" PRId64 "\n",
susp, sother_start);
if (sother_start > susp->susp.current) {
D nyquist_printf("susp %p using add_s1_nn_fetch\n", susp);
susp->susp.fetch = add_s1_nn_fetch;
@ -605,7 +606,11 @@ D nyquist_printf("ms->t0 == %g\n", ms->t0);
}
/* note: snd_multiseq is a noop, just call snd_make_multiseq */
LVAL snd_multiseq(LVAL snd, LVAL closure)
{
return snd_make_multiseq(sound_array_copy(snd), closure);
}
void multiseq_free(snd_susp_type a_susp)
{

View File

@ -15,5 +15,5 @@ typedef struct multiseq_struct {
LVAL snd_make_multiseq(LVAL s1, LVAL closure);
LVAL snd_multiseq(LVAL s1, LVAL closure);
/* LISP: (SND-MULTISEQ ANY ANY) */

View File

@ -11,10 +11,10 @@ typedef unsigned int UWORD;
#ifdef DEBUG
#define INLINE
#else /* DEBUG */
#else DEBUG
/* #define INLINE inline */
#define INLINE
#endif /* DEBUG */
#endif DEBUG
/*
* FilterUp() - Applies a filter to a given sample when up-converting.

View File

@ -74,7 +74,11 @@ int nosc_init()
lo_server_add_method(the_server, "/slider", "if", slider_handler, NULL);
lo_server_add_method(the_server, "/wii/orientation", "ff",
wii_orientation_handler, NULL);
lo_fd = lo_server_get_socket_fd(the_server);
/* On Win64 this is technically incorrect because socket_type is 64 bits,
but *currently* the high-order WIN64 handle bits are zero and this
works. It is likely to continue working because changing it would cause
many failures. */
lo_fd = (int) lo_server_get_socket_fd(the_server);
nosc_enabled = true;
}
return 0;

View File

@ -5,6 +5,6 @@
* Created by Roger Dannenberg
*/
int nosc_init();
int nosc_poll();
void nosc_finish();
int nosc_init(void);
int nosc_poll(void);
void nosc_finish(void);

File diff suppressed because it is too large Load Diff

View File

@ -169,17 +169,17 @@ what do we do?
#include "cmupv.h"
typedef struct pvstate_struct {
long f_count; /* how many samples have we taken from f? */
long g_count; /* how many samples have we taken from g? */
int64_t f_count; /* how many samples have we taken from f? */
int64_t g_count; /* how many samples have we taken from g? */
double g_prev; /* the previous value of g (at g_count - 2) */
double g_next; /* the current value of g (at g_count - 1) */
long sample_count; /* how many total samples computed, specifically
int64_t sample_count; /* how many total samples computed, specifically
* the number of samples copied into Nyquist
* sample blocks via *out++ = pvs->output[index++];
*/
Phase_vocoder *pv; /* the phase vocoder object */
sample_type *input; /* a frame of samples to go into fft */
long input_count; /* sample number of first sample in input */
int64_t input_count; /* sample number of first sample in input */
sample_type *output; /* output from phase vocoder */
long output_count; /* since we deliver samples on demand,
output_count keeps track of how much is left in output.
@ -188,17 +188,17 @@ typedef struct pvstate_struct {
int hopsize; /* the hopsize -- not used */
int mode; /* the mode -- see cmupv.h */
/* data to compute logical stop time */
long t0; /* output sample count of previous frame */
int64_t t0; /* output sample count of previous frame */
double g0; /* input time of previous frame center */
/* data to detect termination */
long f_terminated; /* set when f terminates */
long f_terminate_count; /* sample count of f when it terminates */
int64_t f_terminate_count; /* sample count of f when it terminates */
long g_terminated; /* set when g terminates */
long g_terminate_count; /* sample count of g when it terminates */
int64_t g_terminate_count; /* sample count of g when it terminates */
/* return values from pv_callback */
long flags; /* logical stop and terminate flags */
long logical_stop_count; /* sample count of output logical stop */
long terminate_count; /* sample count of output terminate time */
int64_t logical_stop_count; /* sample count of output logical stop */
int64_t terminate_count; /* sample count of output terminate time */
} pvstate_node, *pvstate_type;
#define OUTPUT_SIZE 256
@ -216,7 +216,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock)
* interpolation math work right */
double g_count = out_time * susp->g->sr + 1.0;
double g; /* the value of g at g_count which is at the time of out_count */
long f_start; /* the start sample of input f for the next frame */
int64_t f_start; /* the start sample of input f for the next frame */
int hop; /* the hopsize from the previous frame to this frame, thus the
offset into input buffer of the data we want to keep */
int got_from_f; /* samples already in input */
@ -224,7 +224,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock)
sample_type *input = pvs->input;
int i;
int f_logically_stopped = FALSE;
long f_logical_stop_count;
int64_t f_logical_stop_count;
pvs->flags = 0;
/* before loop:
* pvs->g_count <= g_count,
@ -257,7 +257,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock)
/* f_start is now the first sample position of the window */
/* (4) shift INPUT */
hop = f_start - pvs->input_count;
hop = (int) (f_start - pvs->input_count);
if (hop < 0) {
hop = 0;
}
@ -311,7 +311,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock)
/* new window is all zero, so output terminates soon ... */
pvs->flags |= PVSHELL_FLAG_TERMINATE;
pvs->terminate_count = out_count - hop + pvs->fftsize / 2;
printf("pv_callback terminated by f at %ld\n", pvs->terminate_count);
/* printf("pv_callback terminated by f at %ld\n", pvs->terminate_count); */
}
pvs->t0 = out_count;
pvs->g0 = g;
@ -335,12 +335,12 @@ int pv_callback(long out_count, float *samples, int len, void *rock)
(See comments at top of file for more about the computation here.)
*/
if (f_logically_stopped && !pvs->g_terminated) {
pvs->logical_stop_count = pvs->t0 + (out_count - pvs->t0) *
((f_logical_stop_count / susp->f->sr - pvs->g0) / (g - pvs->g0));
pvs->logical_stop_count = (int64_t) (pvs->t0 + (out_count - pvs->t0) *
((f_logical_stop_count / susp->f->sr - pvs->g0) / (g - pvs->g0)));
}
if (pvs->g_terminated) {
long term_cnt_from_g = ROUNDBIG((pvs->g_terminate_count / susp->g->sr) *
susp->f->sr);
int64_t term_cnt_from_g =
ROUNDBIG((pvs->g_terminate_count / susp->g->sr) * susp->f->sr);
if (f_logically_stopped) { /* take min of g and f log. stop cnt */
pvs->logical_stop_count = MIN(pvs->logical_stop_count,
term_cnt_from_g);
@ -377,7 +377,7 @@ int pv_callback(long out_count, float *samples, int len, void *rock)
*/
long pv_fetch(pvshell_type susp,
sample_block_values_type out, long *n,
long sample_count)
int64_t sample_count)
{
pvstate_type pvs = (pvstate_type) susp->state;
int i;
@ -408,8 +408,8 @@ long pv_fetch(pvshell_type susp,
if (take > remaining) take = remaining;
if (pvs->flags) {
if (pvs->flags & PVSHELL_FLAG_TERMINATE) {
int to_term = pvs->terminate_count - sample_count;
if (to_term < take) take = to_term;
int64_t to_term = pvs->terminate_count - sample_count;
if (to_term < take) take = (int) to_term;
if (take == 0) {
/* we want to set the terminate flag at the beginning
of the sample block, i.e. only if count == 0; if
@ -422,7 +422,7 @@ long pv_fetch(pvshell_type susp,
}
}
if (pvs->flags & PVSHELL_FLAG_LOGICAL_STOP) {
int to_stop = pvs->logical_stop_count - sample_count;
int64_t to_stop = pvs->logical_stop_count - sample_count;
/* if we're exactly at the logical stop block, then
set the logical stop flag and compute the block as
normal. Otherwise, if we have not reached the logical
@ -433,7 +433,7 @@ long pv_fetch(pvshell_type susp,
if (to_stop == 0 && count == 0) {
flags |= PVSHELL_FLAG_LOGICAL_STOP;
} else if (to_stop > 0 && to_stop < take) {
take = to_stop;
take = (int) to_stop;
}
}
}

View File

@ -3,4 +3,4 @@
*/
sound_type snd_phasevocoder(sound_type f, sound_type g, long fftsize, long hopsize, long mode);
/* LISP: (snd-phasevocoder SOUND SOUND FIXNUM FIXNUM FIXNUM) */
/* LISP: (snd-phasevocoder SOUND SOUND LONG LONG LONG) */

View File

@ -28,7 +28,7 @@
* 28Apr03 dm changes for portability and fix compiler warnings
*/
void pvshell_free();
void pvshell_free(snd_susp_type a_susp);
typedef struct pvshell_susp_struct {

View File

@ -28,16 +28,16 @@ struct pvshell_struct;
typedef long (*h_fn_type)(struct pvshell_struct *susp,
sample_block_values_type out, long *n,
long sample_count);
int64_t sample_count);
typedef void (*pvs_free_fn_type)(struct pvshell_struct *susp);
typedef struct pvshell_struct {
sound_type f;
long f_cnt;
int f_cnt;
sample_block_values_type f_ptr;
sound_type g;
long g_cnt;
int g_cnt;
sample_block_values_type g_ptr;
long flags; /* for terminated and logically stopped flags */

View File

@ -63,14 +63,14 @@ samples). When downsampling, the filter is stretched by 1/factor
*/
void resample_free();
void resample_free(snd_susp_type a_susp);
typedef struct resample_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type s;
long s_cnt;
int s_cnt;
sample_block_values_type s_ptr;
float *X;
long Xsize;
@ -118,7 +118,7 @@ static int SrcUp(float X[], float Y[], double factor, double *Time,
*Y++ = (float) v;
*Time += dt; /* Move to next sample by time increment */
}
return (Y - Ystart); /* Return the number of output samples */
return (int) (Y - Ystart); /* Return the number of output samples */
}
@ -152,7 +152,7 @@ static int SrcUD(float X[], float Y[], double factor, double *Time,
*Y++ = (float) v;
*Time += dt; /* Move to next sample by time increment */
}
return (Y - Ystart); /* Return the number of output samples */
return (int) (Y - Ystart); /* Return the number of output samples */
}
@ -199,13 +199,13 @@ samples need to be shifted from the end of X to the beginning.
while (susp->Xp < susp->Xsize) { /* outer loop */
/* read samples from susp->s into X */
togo = susp->Xsize - susp->Xp;
togo = (int) (susp->Xsize - susp->Xp);
/* don't run past the s input sample block. If termination or
* logical stop info become available, translate to susp->terminate_cnt
* and susp->log_stop_cnt.
*/
susp_check_term_log_samples(s, s_ptr, s_cnt);
togo = MIN(togo, susp->s_cnt);
togo = (int) MIN(togo, susp->s_cnt);
memcpy(susp->X + susp->Xp, susp->s_ptr, togo * sizeof(sample_type));
susp->s_ptr += togo;
@ -221,15 +221,15 @@ samples need to be shifted from the end of X to the beginning.
togo = max_sample_block_len;
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + max_sample_block_len) {
togo = susp->terminate_cnt - susp->susp.current;
togo = (int) (susp->terminate_cnt - susp->susp.current);
}
if (!susp->logically_stopped &&
susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - susp->susp.current;
int64_t to_stop = susp->susp.log_stop_cnt - susp->susp.current;
assert(to_stop >= 0);
if (to_stop < togo) {
if (to_stop == 0) susp->logically_stopped = true;
else togo = to_stop;
else togo = (int) to_stop;
}
}
if (togo == 0) {

View File

@ -60,14 +60,14 @@
typedef struct resamplev_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type f;
long f_cnt;
int f_cnt;
sample_block_values_type f_ptr;
sound_type g;
long g_cnt;
int g_cnt;
sample_block_values_type g_ptr;
double prev_g; /* data for interpolation: */
double next_g;
@ -97,7 +97,7 @@ typedef struct resamplev_susp_struct {
int Xoff; /* number of extra samples at beginning and end of X */
} resamplev_susp_node, *resamplev_susp_type;
void resamplev_free();
void resamplev_free(snd_susp_type a_susp);
void resampv_refill(resamplev_susp_type susp);
/* Sampling rate conversion subroutine

View File

@ -18,7 +18,7 @@
LVAL s_next = NULL;
LVAL s_send;
void samples_symbols()
void samples_symbols(void)
{
s_next = xlenter(":NEXT");
s_send = xlenter("SEND");
@ -64,10 +64,10 @@ sound_type snd_from_array(double t0, double sr, LVAL array)
/* snd_length -- count how many samples are in a sound */
/**/
long snd_length(sound_type s, long len)
int64_t snd_length(sound_type s, int64_t len)
{
long total = 0;
long blocklen;
int64_t total = 0;
int blocklen;
s = sound_copy(s);
if (len > s->stop) len = s->stop;
@ -87,7 +87,7 @@ long snd_length(sound_type s, long len)
double snd_maxsamp(sound_type s)
{
sample_type result = 0.0F;
long blocklen;
int blocklen;
s = sound_copy(s);
while (true) {
@ -113,9 +113,9 @@ LVAL snd_samples(sound_type s, long len)
{
LVAL v;
long vx = 0;
long blocklen;
int blocklen;
register double scale_factor = s->scale;
len = snd_length(s, len);
len = (long) snd_length(s, len);
s = sound_copy(s);
xlsave1(v);
@ -155,14 +155,16 @@ LVAL snd_samples(sound_type s, long len)
LVAL snd_fetch(sound_type s)
{
if (!s->extra) { /* this is the first call, so fix up s */
s->extra = (long *) malloc(sizeof(long) * FIELDS);
s->extra[0] = sizeof(long) * FIELDS;
s->extra = (int64_t *) malloc(sizeof(s->extra[0]) * FIELDS);
s->extra[0] = sizeof(s->extra[0]) * FIELDS;
s->CNT = s->INDEX = 0;
} else if (s->extra[0] != sizeof(long) * FIELDS) {
} else if (s->extra[0] != sizeof(s->extra[0]) * FIELDS) {
xlfail("sound in use by another iterator");
}
if (s->CNT == s->INDEX) {
sound_get_next(s, &(s->CNT));
int icnt = (int) s->CNT; /* need this to be type int */
if (icnt == s->INDEX) {
sound_get_next(s, &icnt);
s->CNT = icnt; /* save the count back to s->extra */
s->INDEX = 0;
}
if (s->SAMPLES == zero_block->samples) {
@ -205,6 +207,7 @@ LVAL snd_fetch(sound_type s)
#define TERMCNT extra[4]
#define OFFSET 5
/* array size is limited by 32-bit len (on Windows) */
LVAL snd_fetch_array(sound_type s, long len, long step)
{
long i, maxlen, skip, fillptr;
@ -217,23 +220,25 @@ LVAL snd_fetch_array(sound_type s, long len, long step)
if (len < 1) xlfail("len < 1");
if (!s->extra) { /* this is the first call, so fix up s */
s->extra = (long *) malloc(sizeof(long) * (len + OFFSET));
s->extra = (int64_t *) malloc(sizeof(int64_t) * (len + OFFSET));
s->extra[0] = sizeof(long) * (len + OFFSET);
s->CNT = s->INDEX = s->FILLCNT = 0;
s->TERMCNT = -1;
maxlen = len;
} else {
maxlen = (s->extra[0] / sizeof(long)) - OFFSET;
maxlen = (long) ((s->extra[0] / sizeof(long)) - OFFSET);
if (maxlen < 1) xlfail("sound in use by another iterator");
if (maxlen < len) xlfail("len grew");
}
samples = (float *) &(s->extra[OFFSET]);
/* step 1: refill buffer with samples */
fillptr = s->FILLCNT;
fillptr = (long) s->FILLCNT; /* cast is for Win64 where long is 32-bit */
while (fillptr < maxlen) {
int icnt = (int) s->CNT; /* need this to be type int */
if (s->INDEX == s->CNT) {
sound_get_next(s, &(s->CNT));
sound_get_next(s, &icnt);
s->CNT = icnt; /* save count back to s->extra */
if (s->SAMPLES == zero_block->samples) {
setvalue(rslt_symbol, cvfixnum(fillptr));
if (s->TERMCNT < 0) s->TERMCNT = fillptr;
@ -283,13 +288,15 @@ LVAL snd_fetch_array(sound_type s, long len, long step)
*/
skip = step - maxlen;
while (skip > 0) {
long remaining = s->CNT - s->INDEX;
int remaining = (int) (s->CNT - s->INDEX);
if (remaining >= skip) {
s->INDEX += skip;
skip = 0;
} else {
skip -= remaining;
sound_get_next(s, &(s->CNT));
int icnt = (int) s->CNT; /* need to have type int */
sound_get_next(s, &icnt);
s->CNT = icnt; /* save count back in s->extra */
s->INDEX = 0;
}
}

View File

@ -4,17 +4,17 @@
extern LVAL s_next;
extern LVAL s_send;
void samples_symbols();
void samples_symbols(void);
sound_type snd_from_array(double t0, double sr, LVAL array);
/* LISP: (SND-FROM-ARRAY ANYNUM ANYNUM ANY) */
LVAL snd_samples(sound_type s, long len); /* LISP: (SND-SAMPLES SOUND FIXNUM) */
long snd_length(sound_type s, long len); /* LISP: (SND-LENGTH SOUND FIXNUM) */
LVAL snd_samples(sound_type s, long len); /* LISP: (SND-SAMPLES SOUND LONG) */
int64_t snd_length(sound_type s, int64_t len); /* LISP: (SND-LENGTH SOUND FIXNUM) */
double snd_maxsamp(sound_type s); /* LISP: (SND-MAXSAMP SOUND) */
LVAL snd_fetch(sound_type s); /* LISP: (SND-FETCH SOUND) */
LVAL snd_fetch_array(sound_type s, long len, long step);
/* LISP: (SND-FETCH-ARRAY SOUND FIXNUM FIXNUM) */
/* LISP: (SND-FETCH-ARRAY SOUND LONG LONG) */

View File

@ -31,12 +31,11 @@ LVAL s_seq;
xtype_desc seq_desc;
static void xlseq_print();
static void xlseq_print(LVAL fptr, void *sequence);
void nop() {}
void nop(void) {}
boolean seqp(s)
LVAL s;
boolean seqp(LVAL s)
{
return exttypep(s, s_seq);
}

View File

@ -1,9 +1,9 @@
/* seqext.h -- header for seq extensions for xlisp */
void seqext_init();
void seqext_symbols();
boolean seqp();
void seqext_init(void);
void seqext_symbols(void);
boolean seqp(LVAL s);
extern xtype_desc seq_desc;
extern LVAL s_seq;

View File

@ -18,7 +18,6 @@ extern LVAL s_true;
extern LVAL RSLT_sym;
#include "seqdecls.h"
#include "seqext.h"
@ -42,11 +41,11 @@ LVAL xlc_seq_reset(void)
LVAL xlc_seq_insert_ctrl(void)
{
seq_type arg1 = getseq(xlgaseq());
long arg2 = getfixnum(xlgafixnum());
long arg3 = getfixnum(xlgafixnum());
long arg4 = getfixnum(xlgafixnum());
long arg5 = getfixnum(xlgafixnum());
long arg6 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
long arg6 = (long) getfixnum(xlgafixnum());
xllastarg();
insert_ctrl(arg1, arg2, arg3, arg4, arg5, arg6);
@ -59,14 +58,14 @@ LVAL xlc_seq_insert_ctrl(void)
LVAL xlc_seq_insert_ramp(void)
{
seq_type arg1 = getseq(xlgaseq());
long arg2 = getfixnum(xlgafixnum());
long arg3 = getfixnum(xlgafixnum());
long arg4 = getfixnum(xlgafixnum());
long arg5 = getfixnum(xlgafixnum());
long arg6 = getfixnum(xlgafixnum());
long arg7 = getfixnum(xlgafixnum());
long arg8 = getfixnum(xlgafixnum());
long arg9 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
long arg6 = (long) getfixnum(xlgafixnum());
long arg7 = (long) getfixnum(xlgafixnum());
long arg8 = (long) getfixnum(xlgafixnum());
long arg9 = (long) getfixnum(xlgafixnum());
xllastarg();
insert_ctrlramp(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
@ -79,11 +78,11 @@ LVAL xlc_seq_insert_ramp(void)
LVAL xlc_seq_insert_macctrl(void)
{
seq_type arg1 = getseq(xlgaseq());
long arg2 = getfixnum(xlgafixnum());
long arg3 = getfixnum(xlgafixnum());
long arg4 = getfixnum(xlgafixnum());
long arg5 = getfixnum(xlgafixnum());
long arg6 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
long arg6 = (long) getfixnum(xlgafixnum());
xllastarg();
insert_macctrl(arg1, arg2, arg3, arg4, arg5, arg6);
@ -96,12 +95,12 @@ LVAL xlc_seq_insert_macctrl(void)
LVAL xlc_seq_insert_note(void)
{
seq_type arg1 = getseq(xlgaseq());
long arg2 = getfixnum(xlgafixnum());
long arg3 = getfixnum(xlgafixnum());
long arg4 = getfixnum(xlgafixnum());
long arg5 = getfixnum(xlgafixnum());
long arg6 = getfixnum(xlgafixnum());
long arg7 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
long arg6 = (long) getfixnum(xlgafixnum());
long arg7 = (long) getfixnum(xlgafixnum());
xllastarg();
insert_note(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
@ -154,13 +153,13 @@ LVAL xlc_seq_next(void)
LVAL xlc_seq_get(void)
{
seq_type arg1 = getseq(xlgaseq());
long arg2 = 0;
long arg3 = 0;
long arg4 = 0;
long arg5 = 0;
long arg6 = 0;
long arg7 = 0;
long arg8 = 0;
long arg2 = (long) 0;
long arg3 = (long) 0;
long arg4 = (long) 0;
long arg5 = (long) 0;
long arg6 = (long) 0;
long arg7 = (long) 0;
long arg8 = (long) 0;
LVAL result;
xllastarg();
@ -186,8 +185,6 @@ LVAL xlc_seq_get(void)
}
#include "seqmwrite.h"
/* xlc_seq_write_smf -- interface to C routine seq_xlwrite_smf */
/**/
LVAL xlc_seq_write_smf(void)
@ -216,6 +213,8 @@ LVAL xlc_seq_read_smf(void)
}
#include "seqmwrite.h"
#include "seqread.h"
/* xlc_seq_read -- interface to C routine seq_read */

View File

@ -25,8 +25,8 @@ boolean seq_next(seq_type seq)
/* seq_get -- get event data for the current event */
/**/
void seq_get(seq_type seq, long *eventtype, long *ntime, long *line, long *chan,
long *value1, long *value2, long *dur)
void seq_get(seq_type seq, long *eventtype, long *ntime, long *line, long *chan,
long *value1, long *value2, long *dur)
{
event_type ev = seq->current;
if (!ev) *eventtype = SEQ_DONE;

View File

@ -3,7 +3,7 @@
boolean seq_next(seq_type seq); /* LISP: (SEQ-NEXT SEQ) */
void seq_get(seq_type seq, long *eventtype, long *time, long *line, long *chan,
long *value1, long *value2, long *dur);
/* LISP: (SEQ-GET SEQ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^ FIXNUM^) */
/* LISP: (SEQ-GET SEQ LONG^ LONG^ LONG^ LONG^ LONG^ LONG^ LONG^) */
/* LISP-SRC:
(setfn seq-tag first)
(setfn seq-time second)

View File

@ -56,7 +56,9 @@ error here
/* LISP-SRC: (setf snd-head-raw 20) */
#define SND_HEAD_OGG 21
/* LISP-SRC: (setf snd-head-OGG 21) */
#define SND_NUM_HEADS 22
#define SND_HEAD_WAVEX 22
/* LISP-SRC: (setf snd-head-WAVEX 22) */
#define SND_NUM_HEADS 23
/* bitfields for soundheaders */
#define SND_HEAD_CHANNELS (1<<0)

View File

@ -54,7 +54,6 @@ extern LVAL s_true;
extern LVAL RSLT_sym;
#include "sndfile.h"
#include "sound.h"
@ -63,8 +62,8 @@ extern LVAL RSLT_sym;
/**/
LVAL xlc_snd_set_max_audio_mem(void)
{
long arg1 = getfixnum(xlgafixnum());
long result;
int64_t arg1 = getfixnum(xlgafixnum());
int64_t result;
xllastarg();
result = snd_set_max_audio_mem(arg1);
@ -239,7 +238,7 @@ LVAL xlc_snd_xform(void)
/**/
LVAL xlc_block_watch(void)
{
long arg1 = getfixnum(xlgafixnum());
int64_t arg1 = getfixnum(xlgafixnum());
xllastarg();
block_watch(arg1);
@ -252,8 +251,8 @@ LVAL xlc_block_watch(void)
LVAL xlc_sound_nth_block(void)
{
sound_type arg1 = getsound(xlgasound());
long arg2 = getfixnum(xlgafixnum());
long result;
long arg2 = (long) getfixnum(xlgafixnum());
int64_t result;
xllastarg();
result = sound_nth_block(arg1, arg2);
@ -279,7 +278,7 @@ LVAL xlc_snd_copy(void)
LVAL xlc_snd_print(void)
{
LVAL arg1 = xlgetarg();
long arg2 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
xllastarg();
sound_print(arg1, arg2);
@ -292,10 +291,11 @@ LVAL xlc_snd_print(void)
LVAL xlc_snd_play(void)
{
LVAL arg1 = xlgetarg();
int64_t result;
xllastarg();
sound_play(arg1);
return NIL;
result = sound_play(arg1);
return cvfixnum(result);
}
@ -386,9 +386,9 @@ LVAL xlc_snd_add(void)
LVAL xlc_snd_avg(void)
{
sound_type arg1 = getsound(xlgasound());
long arg2 = getfixnum(xlgafixnum());
long arg3 = getfixnum(xlgafixnum());
long arg4 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -452,8 +452,8 @@ LVAL xlc_snd_down(void)
LVAL xlc_snd_fft(void)
{
sound_type arg1 = getsound(xlgasound());
long arg2 = getfixnum(xlgafixnum());
long arg3 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
LVAL arg4 = xlgetarg();
LVAL result;
@ -487,7 +487,7 @@ LVAL xlc_snd_inverse(void)
LVAL xlc_snd_lpanal(void)
{
LVAL arg1 = xlgetarg();
long arg2 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
LVAL result;
xllastarg();
@ -498,7 +498,7 @@ LVAL xlc_snd_lpanal(void)
#include "multiseq.h"
/* xlc_snd_multiseq -- interface to C routine snd_make_multiseq */
/* xlc_snd_multiseq -- interface to C routine snd_multiseq */
/**/
LVAL xlc_snd_multiseq(void)
{
@ -507,7 +507,7 @@ LVAL xlc_snd_multiseq(void)
LVAL result;
xllastarg();
result = snd_make_multiseq(arg1, arg2);
result = snd_multiseq(arg1, arg2);
return (result);
}
@ -522,9 +522,9 @@ LVAL xlc_snd_phasevocoder(void)
{
sound_type arg1 = getsound(xlgasound());
sound_type arg2 = getsound(xlgasound());
long arg3 = getfixnum(xlgafixnum());
long arg4 = getfixnum(xlgafixnum());
long arg5 = getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -588,7 +588,7 @@ LVAL xlc_snd_from_array(void)
LVAL xlc_snd_samples(void)
{
sound_type arg1 = getsound(xlgasound());
long arg2 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
LVAL result;
xllastarg();
@ -602,8 +602,8 @@ LVAL xlc_snd_samples(void)
LVAL xlc_snd_length(void)
{
sound_type arg1 = getsound(xlgasound());
long arg2 = getfixnum(xlgafixnum());
long result;
int64_t arg2 = getfixnum(xlgafixnum());
int64_t result;
xllastarg();
result = snd_length(arg1, arg2);
@ -642,8 +642,8 @@ LVAL xlc_snd_fetch(void)
LVAL xlc_snd_fetch_array(void)
{
sound_type arg1 = getsound(xlgasound());
long arg2 = getfixnum(xlgafixnum());
long arg3 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
LVAL result;
xllastarg();
@ -661,7 +661,7 @@ LVAL xlc_snd_fetch_array(void)
LVAL xlc_snd_max(void)
{
LVAL arg1 = xlgetarg();
long arg2 = getfixnum(xlgafixnum());
int64_t arg2 = getfixnum(xlgafixnum());
double result;
xllastarg();
@ -679,20 +679,19 @@ LVAL xlc_snd_read(void)
unsigned char * arg1 = getstring(xlgastring());
double arg2 = testarg2(xlgaanynum());
double arg3 = testarg2(xlgaanynum());
long arg4 = getfixnum(xlgafixnum());
long arg5 = getfixnum(xlgafixnum());
long arg6 = getfixnum(xlgafixnum());
long arg7 = getfixnum(xlgafixnum());
long arg8 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
long arg6 = (long) getfixnum(xlgafixnum());
long arg7 = (long) getfixnum(xlgafixnum());
long arg8 = (long) getfixnum(xlgafixnum());
double arg9 = testarg2(xlgaanynum());
double arg10 = testarg2(xlgaanynum());
long arg11 = 0;
long arg12 = 0;
long arg11 = (long) 0;
LVAL result;
xllastarg();
xlprot1(result);
result = snd_make_read(arg1, arg2, arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11, &arg12);
result = snd_make_read(arg1, arg2, arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, &arg10, &arg11);
{ LVAL *next = &getvalue(RSLT_sym);
*next = cons(NIL, NIL);
car(*next) = cvfixnum(arg4); next = &cdr(*next);
@ -709,9 +708,7 @@ LVAL xlc_snd_read(void)
*next = cons(NIL, NIL);
car(*next) = cvflonum(arg10); next = &cdr(*next);
*next = cons(NIL, NIL);
car(*next) = cvfixnum(arg11); next = &cdr(*next);
*next = cons(NIL, NIL);
car(*next) = cvfixnum(arg12);
car(*next) = cvfixnum(arg11);
}
xlpop();
return (result);
@ -740,7 +737,7 @@ LVAL xlc_snd_seq(void)
/**/
LVAL xlc_snd_slider(void)
{
long arg1 = getfixnum(xlgafixnum());
long arg1 = (long) getfixnum(xlgafixnum());
double arg2 = testarg2(xlgaanynum());
double arg3 = testarg2(xlgaanynum());
double arg4 = testarg2(xlgaanynum());
@ -792,7 +789,7 @@ LVAL xlc_snd_yin(void)
sound_type arg1 = getsound(xlgasound());
double arg2 = testarg2(xlgaanynum());
double arg3 = testarg2(xlgaanynum());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
LVAL result;
xllastarg();
@ -933,7 +930,7 @@ LVAL xlc_snd_areson(void)
sound_type arg1 = getsound(xlgasound());
double arg2 = testarg2(xlgaanynum());
double arg3 = testarg2(xlgaanynum());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -951,7 +948,7 @@ LVAL xlc_snd_aresoncv(void)
sound_type arg1 = getsound(xlgasound());
double arg2 = testarg2(xlgaanynum());
sound_type arg3 = getsound(xlgasound());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -969,7 +966,7 @@ LVAL xlc_snd_aresonvc(void)
sound_type arg1 = getsound(xlgasound());
sound_type arg2 = getsound(xlgasound());
double arg3 = testarg2(xlgaanynum());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -987,7 +984,7 @@ LVAL xlc_snd_aresonvv(void)
sound_type arg1 = getsound(xlgasound());
sound_type arg2 = getsound(xlgasound());
sound_type arg3 = getsound(xlgasound());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -1056,7 +1053,7 @@ LVAL xlc_snd_biquad(void)
/**/
LVAL xlc_snd_buzz(void)
{
long arg1 = getfixnum(xlgafixnum());
long arg1 = (long) getfixnum(xlgafixnum());
double arg2 = testarg2(xlgaanynum());
double arg3 = testarg2(xlgaanynum());
double arg4 = testarg2(xlgaanynum());
@ -1288,7 +1285,7 @@ LVAL xlc_snd_follow(void)
double arg2 = testarg2(xlgaanynum());
double arg3 = testarg2(xlgaanynum());
double arg4 = testarg2(xlgaanynum());
long arg5 = getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -1360,7 +1357,7 @@ LVAL xlc_snd_ifft(void)
double arg1 = testarg2(xlgaanynum());
double arg2 = testarg2(xlgaanynum());
LVAL arg3 = xlgetarg();
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
LVAL arg5 = xlgetarg();
sound_type result;
@ -1378,7 +1375,7 @@ LVAL xlc_snd_bandedwg(void)
{
double arg1 = testarg2(xlgaanynum());
sound_type arg2 = getsound(xlgasound());
long arg3 = getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
double arg4 = testarg2(xlgaanynum());
sound_type result;
@ -1565,7 +1562,7 @@ LVAL xlc_snd_modalbar(void)
{
double arg1 = testarg2(xlgaanynum());
double arg2 = testarg2(xlgaanynum());
long arg3 = getfixnum(xlgafixnum());
long arg3 = (long) getfixnum(xlgafixnum());
double arg4 = testarg2(xlgaanynum());
double arg5 = testarg2(xlgaanynum());
sound_type result;
@ -1846,7 +1843,7 @@ LVAL xlc_snd_pwl(void)
LVAL xlc_snd_quantize(void)
{
sound_type arg1 = getsound(xlgasound());
long arg2 = getfixnum(xlgafixnum());
long arg2 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -1879,7 +1876,7 @@ LVAL xlc_snd_reson(void)
sound_type arg1 = getsound(xlgasound());
double arg2 = testarg2(xlgaanynum());
double arg3 = testarg2(xlgaanynum());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -1897,7 +1894,7 @@ LVAL xlc_snd_resoncv(void)
sound_type arg1 = getsound(xlgasound());
double arg2 = testarg2(xlgaanynum());
sound_type arg3 = getsound(xlgasound());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -1915,7 +1912,7 @@ LVAL xlc_snd_resonvc(void)
sound_type arg1 = getsound(xlgasound());
sound_type arg2 = getsound(xlgasound());
double arg3 = testarg2(xlgaanynum());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -1933,7 +1930,7 @@ LVAL xlc_snd_resonvv(void)
sound_type arg1 = getsound(xlgasound());
sound_type arg2 = getsound(xlgasound());
sound_type arg3 = getsound(xlgasound());
long arg4 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -1955,7 +1952,7 @@ LVAL xlc_snd_sampler(void)
double arg5 = testarg2(xlgaanynum());
double arg6 = testarg2(xlgaanynum());
sound_type arg7 = getsound(xlgasound());
long arg8 = getfixnum(xlgafixnum());
long arg8 = (long) getfixnum(xlgafixnum());
sound_type result;
xllastarg();
@ -2187,7 +2184,7 @@ LVAL xlc_snd_stkpitshift(void)
/**/
LVAL xlc_snd_stkrev(void)
{
long arg1 = getfixnum(xlgafixnum());
long arg1 = (long) getfixnum(xlgafixnum());
sound_type arg2 = getsound(xlgasound());
double arg3 = testarg2(xlgaanynum());
double arg4 = testarg2(xlgaanynum());
@ -2227,20 +2224,21 @@ LVAL xlc_snd_stkchorus(void)
LVAL xlc_snd_save(void)
{
LVAL arg1 = xlgetarg();
long arg2 = getfixnum(xlgafixnum());
int64_t arg2 = getfixnum(xlgafixnum());
unsigned char * arg3 = getstring(xlgastring());
long arg4 = getfixnum(xlgafixnum());
long arg5 = getfixnum(xlgafixnum());
long arg6 = getfixnum(xlgafixnum());
long arg7 = getfixnum(xlgafixnum());
long arg4 = (long) getfixnum(xlgafixnum());
long arg5 = (long) getfixnum(xlgafixnum());
long arg6 = (long) getfixnum(xlgafixnum());
long arg7 = (long) getfixnum(xlgafixnum());
double arg8 = 0.0;
long arg9 = 0;
long arg9 = (long) 0;
double arg10 = 0.0;
LVAL arg11 = xlgetarg();
int64_t arg12 = getfixnum(xlgafixnum());
double result;
xllastarg();
result = sound_save(arg1, arg2, arg3, arg4, arg5, arg6, arg7, &arg8, &arg9, &arg10, arg11);
result = sound_save(arg1, arg2, arg3, arg4, arg5, arg6, arg7, &arg8, &arg9, &arg10, arg11, arg12);
{ LVAL *next = &getvalue(RSLT_sym);
*next = cons(NIL, NIL);
car(*next) = cvflonum(arg8); next = &cdr(*next);
@ -2258,21 +2256,18 @@ LVAL xlc_snd_save(void)
LVAL xlc_snd_overwrite(void)
{
LVAL arg1 = xlgetarg();
long arg2 = getfixnum(xlgafixnum());
int64_t arg2 = getfixnum(xlgafixnum());
unsigned char * arg3 = getstring(xlgastring());
double arg4 = testarg2(xlgaanynum());
long arg5 = getfixnum(xlgafixnum());
long arg6 = getfixnum(xlgafixnum());
long arg7 = getfixnum(xlgafixnum());
long arg8 = getfixnum(xlgafixnum());
double arg9 = 0.0;
double arg5 = 0.0;
int64_t arg6 = getfixnum(xlgafixnum());
double result;
xllastarg();
result = sound_overwrite(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, &arg9);
result = sound_overwrite(arg1, arg2, arg3, arg4, &arg5, arg6);
{ LVAL *next = &getvalue(RSLT_sym);
*next = cons(NIL, NIL);
car(*next) = cvflonum(arg9);
car(*next) = cvflonum(arg5);
}
return cvflonum(result);
}

View File

@ -48,6 +48,8 @@
(setf snd-head-OGG 21)
(setf snd-head-WAVEX 22)
(setf snd-head-channels 1)
(setf snd-head-mode 2)

View File

@ -18,11 +18,11 @@
#include "sndmax.h"
#include "extern.h"
double sound_max(LVAL snd_expr, long n)
double sound_max(LVAL snd_expr, int64_t n)
{
LVAL s_as_lval;
sound_type s = NULL;
long blocklen;
int blocklen;
sample_block_values_type sbufp;
register double maximum = 0;
@ -53,7 +53,7 @@ double sound_max(LVAL snd_expr, long n)
if (sampblock == zero_block || blocklen == 0) {
break;
}
togo = MIN(blocklen, n);
togo = (long) MIN(blocklen, n);
sbufp = sampblock->samples;
for (j = 0; j < togo; j++) {
register double samp = *sbufp++;

View File

@ -1,4 +1,4 @@
/* sndmax.h -- header to write sounds to files */
double sound_max(LVAL snd_expr, long n);
double sound_max(LVAL snd_expr, int64_t n);
/* LISP: (SND-MAX ANY FIXNUM) */

View File

@ -60,13 +60,14 @@ void read__fetch(snd_susp_type a_susp, snd_list_type snd_list)
out_ptr = out->samples;
snd_list->block = out;
in_count = sf_readf_float(susp->sndfile, out_ptr, max_sample_block_len);
in_count = (long) sf_readf_float(susp->sndfile, out_ptr,
max_sample_block_len);
n = in_count;
/* don't read too many */
if (n > (susp->cnt - susp->susp.current)) {
n = susp->cnt - susp->susp.current;
n = (long) (susp->cnt - susp->susp.current);
}
snd_list->block_len = (short) n;
@ -110,8 +111,7 @@ LVAL snd_make_read(
long *swap, /* swap bytes */
double *srate, /* srate: sample rate */
double *dur, /* duration (in seconds) to read */
long *flags, /* which parameters have been set */
long *byte_offset) /* byte offset in file of first sample */
long *flags) /* which parameters have been set */
{
register read_susp_type susp;
/* srate specified as input parameter */
@ -161,11 +161,12 @@ LVAL snd_make_read(
/* write the code so it will only compile if one and only one
ENDIAN setting is defined */
#ifdef XL_LITTLE_ENDIAN
susp->sf_info.format |= SF_ENDIAN_BIG;
long format = SF_ENDIAN_BIG;
#endif
#ifdef XL_BIG_ENDIAN
susp->sf_info.format |= SF_ENDIAN_LITTLE;
long format = SF_ENDIAN_LITTLE;
#endif
susp->sf_info.format |= format;
}
susp->sndfile = NULL;
@ -175,8 +176,8 @@ LVAL snd_make_read(
if (!susp->sndfile) {
char error[240];
snprintf(error, 240, "SND-READ: Cannot open file '%s' because of %s", filename,
sf_strerror(susp->sndfile));
snprintf(error, 240, "SND-READ: Cannot open file '%s' because of %s",
filename, sf_strerror(susp->sndfile));
xlfail(error);
}
if (susp->sf_info.channels < 1) {
@ -191,7 +192,7 @@ LVAL snd_make_read(
*srate = susp->sf_info.samplerate;
}
/* compute dur */
frames = sf_seek(susp->sndfile, 0, SEEK_END);
frames = susp->sf_info.frames;
actual_dur = ((double) frames) / *srate;
if (offset < 0) offset = 0;
/* round offset to an integer frame count */
@ -205,7 +206,6 @@ LVAL snd_make_read(
if (actual_dur < *dur) *dur = actual_dur;
sf_seek(susp->sndfile, frames, SEEK_SET); /* return to read loc in file */
/* initialize susp state */
susp->susp.sr = *srate;
susp->susp.t0 = t0;
@ -215,16 +215,16 @@ LVAL snd_make_read(
susp->susp.log_stop_cnt = UNKNOWN;
/* watch for overflow */
if (*dur * *srate + 0.5 > (unsigned long) 0xFFFFFFFF) {
susp->cnt = 0x7FFFFFFF;
susp->cnt = 0x7FFFFFFFFFFFFFFF;
} else {
susp->cnt = ROUNDBIG((*dur) * *srate);
}
switch (susp->sf_info.format & SF_FORMAT_TYPEMASK) {
case SF_FORMAT_WAV: *format = SND_HEAD_WAVE; break;
case SF_FORMAT_AIFF: *format = SND_HEAD_AIFF; break;
case SF_FORMAT_IRCAM: *format = SND_HEAD_IRCAM; break;
case SF_FORMAT_AU: *format = SND_HEAD_NEXT; break;
case SF_FORMAT_RAW: *format = SND_HEAD_RAW; break;
case SF_FORMAT_WAV: *format = SND_HEAD_WAVE; break;
case SF_FORMAT_PAF: *format = SND_HEAD_PAF; break;
case SF_FORMAT_SVX: *format = SND_HEAD_SVX; break;
case SF_FORMAT_NIST: *format = SND_HEAD_NIST; break;
@ -237,11 +237,12 @@ LVAL snd_make_read(
case SF_FORMAT_HTK: *mode = SND_HEAD_HTK; break;
case SF_FORMAT_SDS: *mode = SND_HEAD_SDS; break;
case SF_FORMAT_AVR: *mode = SND_HEAD_AVR; break;
case SF_FORMAT_WAVEX: *format = SND_HEAD_WAVE; break;
case SF_FORMAT_SD2: *format = SND_HEAD_SD2; break;
case SF_FORMAT_FLAC: *format = SND_HEAD_FLAC; break;
case SF_FORMAT_CAF: *format = SND_HEAD_CAF; break;
case SF_FORMAT_RAW: *format = SND_HEAD_RAW; break;
case SF_FORMAT_OGG: *format = SND_HEAD_OGG; break;
case SF_FORMAT_WAVEX: *format = SND_HEAD_WAVEX; break;
default: *format = SND_HEAD_NONE; break;
}
*channels = susp->sf_info.channels;

View File

@ -7,14 +7,14 @@ typedef struct read_susp_struct {
snd_susp_node susp;
SNDFILE *sndfile;
SF_INFO sf_info;
snd_list_type *chan; /* array of back pointers */
long cnt; /* how many sample frames to read */
snd_list_type *chan; /* array of back pointers */
int64_t cnt; /* how many sample frames to read */
} read_susp_node, *read_susp_type;
LVAL snd_make_read(unsigned char *filename, time_type offset, time_type t0,
long *format, long *channels, long *mode, long *bits, long *swap,
double *srate, double *dur, long *flags, long *byte_offset);
/* LISP: (SND-READ STRING ANYNUM ANYNUM FIXNUM* FIXNUM* FIXNUM* FIXNUM* FIXNUM* ANYNUM* ANYNUM* FIXNUM^ FIXNUM^) */
double *srate, double *dur, long *flags);
/* LISP: (SND-READ STRING ANYNUM ANYNUM LONG* LONG* LONG* LONG* LONG* ANYNUM* ANYNUM* LONG^) */
void read_free();
void read_free(snd_susp_type a_susp);

View File

@ -19,6 +19,7 @@
#include "extern.h"
#include "cext.h"
#include "assert.h"
#include "sndseq.h"
#define SNDSEQDBG 0
#define D if (SNDSEQDBG)
@ -30,20 +31,20 @@
(sndseq_free) or else we'll leak memory.
*/
typedef struct sndseq_susp_struct {
snd_susp_node susp;
boolean started;
snd_susp_node susp;
boolean started;
int terminate_bits;
long terminate_cnt;
int64_t terminate_cnt;
int logical_stop_bits;
boolean logically_stopped;
sound_type s1;
long s1_cnt;
sample_block_type s1_bptr; /* block pointer */
sample_block_values_type s1_ptr;
sound_type s2;
long s2_cnt;
sample_block_type s2_bptr; /* block pointer */
sample_block_values_type s2_ptr;
boolean logically_stopped;
sound_type s1;
int s1_cnt;
sample_block_type s1_bptr; /* block pointer */
sample_block_values_type s1_ptr;
sound_type s2;
int s2_cnt;
sample_block_type s2_bptr; /* block pointer */
sample_block_values_type s2_ptr;
/* support for interpolation of s2 */
sample_type s2_x1_sample;
@ -65,11 +66,106 @@ void sndseq_free(snd_susp_type susp);
extern LVAL s_stdout;
void print_closure(LVAL val);
#ifdef SNDSEQDBG
LVAL print_stack[100];
int print_stack_index = 0;
#define ps_push(x) print_stack[print_stack_index++] = x
#define ps_pop(x) print_stack_index--
int in_cycle(LVAL x)
{
for (int i = 0; i < print_stack_index; i++) {
if (print_stack[i] == x) {
return TRUE;
}
}
return FALSE;
}
/* print_closure -- show everything for debugging */
void print_lval(LVAL x)
{
LVAL next;
if (!x) {
printf("NIL");
return;
}
if (in_cycle(x)) {
printf("<CYCLE>");
return;
}
ps_push(x);
switch (ntype(x)) {
case CONS:
printf("(");
for (LVAL nptr = x; nptr != NIL; nptr = next) {
print_lval(car(nptr));
if ((next = cdr(nptr))) {
if (consp(next)) printf(" ");
else {
printf(" . ");
print_lval(next);
break;
}
}
}
printf(")");
break;
case SYMBOL:
printf("%s", getstring(getpname(x)));
break;
case FIXNUM:
printf(IFMT, getfixnum(x));
break;
case FLONUM:
printf("%g", getflonum(x));
break;
case EXTERN:
printf("<%s:%p>", getdesc(x)->type_name, getinst(x));
break;
case CLOSURE:
printf("<CLOSURE:%p>\n", x);
print_closure(x);
break;
default:
printf("<type %d>", ntype(x));
break;
}
ps_pop(x);
}
void print_closure(LVAL val)
{
printf("Name: "); print_lval(getname(val));
printf("\nType: "); print_lval(gettype(val));
printf("\nLambda: "); print_lval(getlambda(val));
printf("\nArgs: "); print_lval(getargs(val));
printf("\nOargs: "); print_lval(getoargs(val));
printf("\nRest: "); print_lval(getrest(val));
printf("\nKargs: "); print_lval(getkargs(val));
printf("\nAargs: "); print_lval(getaargs(val));
printf("\nBody: "); print_lval(getbody(val));
printf("\nEnv: "); print_lval(closure_getenv(val));
printf("\nFenv: "); print_lval(getfenv(val));
printf("\n");
}
#endif
void sndseq_mark(snd_susp_type a_susp)
{
D nyquist_printf("sndseq_mark: marking susp %p\n", a_susp);
sndseq_susp_type susp = (sndseq_susp_type) a_susp;
sound_xlmark(susp->s1);
if (susp->closure) mark(susp->closure);
if (susp->closure) {
D nyquist_printf("sndseq_mark: marking closure %p\n", susp->closure);
D print_closure(susp->closure);
mark(susp->closure);
}
}
@ -100,7 +196,7 @@ void sndseq_fetch(snd_susp_type a_susp, snd_list_type snd_list)
if (susp->s1_ptr == zero_block->samples) {
susp->terminate_bits = 1; /* mark s1 as terminated */
}
/* nyquist_printf("sndseq_fetch: s1-lsc %d, current %d cnt %d\n",
/* nyquist_printf("sndseq_fetch: s1-lsc %d, current %d cnt %d\n",
susp->s1->logical_stop_cnt, susp->s1->current, susp->s1_cnt); */
}
@ -109,14 +205,19 @@ void sndseq_fetch(snd_susp_type a_susp, snd_list_type snd_list)
time_type now = susp->susp.t0 + susp->susp.current / susp->susp.sr;
/* note: cons args are protected from GC: */
LVAL result;
long delay; /* sample delay to s2 */
/* stats();gc();stats();*/
int64_t delay; /* sample delay to s2 */
/* stats();gc();stats();*/
xlsave1(result);
D nyquist_printf("sndseq_fetch: about to eval closure at %g, "
"susp->susp.t0 %g, susp.current %d:\n",
now, susp->susp.t0, (int)susp->susp.current);
D nyquist_printf("::::sndseq_fetch: about to eval closure at %g, "
"susp->susp.t0 %g, susp.current %d:\n",
now, susp->susp.t0, (int)susp->susp.current);
D nyquist_printf(" susp@%p(%s)\n", susp, susp->susp.name);
D (*susp->susp.print_tree)((snd_susp_type) susp, 4);
D nyquist_printf(" EVALUATE CLOSURE: ");
D print_lval(susp->closure);
D printf("\n");
result = xleval(cons(susp->closure, consa(cvflonum(now))));
susp->logical_stop_bits = 1; /* mark s1 as logically stopped */
@ -157,9 +258,9 @@ D nyquist_printf("in sndseq: logically stopped; "
} else {
susp->susp.fetch = add_s2_nn_fetch;
susp->susp.name = "sndseq:add_s2_nn_fetch";
}
}
} else if (delay > 0) { /* fill hole between s1 and s2 */
D stdputstr("using add_s1_nn_fetch\n");
D stdputstr("using add_s1_nn_fetch\n");
susp->susp.fetch = add_s1_nn_fetch;
susp->susp.name = "sndseq:add_s1_nn_fetch";
} else {
@ -173,7 +274,7 @@ D stdputstr("using add_s1_nn_fetch\n");
D stdputstr("in sndseq: calling add's fetch\n");
(*(susp->susp.fetch))(a_susp, snd_list);
D stdputstr("in sndseq: returned from add's fetch\n");
/* gc();*/
/* gc();*/
xlpop();
return;
}
@ -185,13 +286,13 @@ D stdputstr("in sndseq: returned from add's fetch\n");
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + togo) {
togo = susp->terminate_cnt - susp->susp.current;
togo = (int) (susp->terminate_cnt - susp->susp.current);
}
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - susp->susp.current;
togo = MIN(togo, to_stop);
int64_t to_stop = susp->susp.log_stop_cnt - susp->susp.current;
togo = (int) MIN(togo, to_stop);
}
assert(togo >= 0);
@ -216,7 +317,7 @@ D stdputstr("in sndseq: returned from add's fetch\n");
*/
/* just fetch and pass blocks on */
/* nyquist_printf("sndseq (s1_nn) %x starting uncopy, togo %d\n", susp, togo); */
/* nyquist_printf("sndseq (s1_nn) %x starting uncopy, togo %d\n", susp, togo); */
snd_list->block = susp->s1_bptr;
/* the zero_block indicates termination, don't copy it! Use
* internal_zero_block instead. It is also filled with zeros,
@ -227,7 +328,7 @@ D stdputstr("in sndseq: returned from add's fetch\n");
if (snd_list->block == zero_block)
snd_list->block = internal_zero_block;
(snd_list->block->refcnt)++;
/* nyquist_printf("sndseq (s1_nn) %x shared block %x\n", susp, susp->s1_bptr);*/
/* nyquist_printf("sndseq (s1_nn) %x shared block %x\n", susp, susp->s1_bptr);*/
susp_took(s1_cnt, togo);
snd_list->block_len = togo;
@ -274,11 +375,21 @@ void sndseq_print_tree(snd_susp_type a_susp, int n)
indent(n);
stdputstr("s1:");
sound_print_tree_1(susp->s1, n);
D { indent(n);
nyquist_printf("closure %p stored at %p\n",
susp->closure, &susp->closure);
}
D if (susp->closure && closurep(susp->closure)) {
LVAL body = getbody(susp->closure);
LVAL lambda = getlambda(susp->closure);
LVAL args = getargs(susp->closure);
nyquist_printf(" closure args@%p: ", args); stdprint(args);
nyquist_printf(" closure lambda@%p: ", lambda); stdprint(lambda);
nyquist_printf(" closure body@%p: ", body); stdprint(body);
}
indent(n);
stdputstr("closure:");
stdprint(susp->closure);
indent(n);
stdputstr("s2:");
sound_print_tree_1(susp->s2, n);
@ -287,11 +398,9 @@ void sndseq_print_tree(snd_susp_type a_susp, int n)
sound_type snd_make_sndseq(s1, closure)
sound_type s1;
LVAL closure;
sound_type snd_make_sndseq(sound_type s1, LVAL closure)
{
register sndseq_susp_type susp;
sndseq_susp_type susp;
/* t0 specified as input parameter */
sample_type scale_factor = 1.0F;
sound_type result;
@ -329,20 +438,45 @@ sound_type snd_make_sndseq(s1, closure)
susp->s2 = NULL;
susp->s2_cnt = 0;
susp->s2_phase = 0.0;
/* susp->s2_phase_incr = ??
susp->output_per_s2 = ?? */
susp->closure = closure;
result = sound_create((snd_susp_type)susp, susp->susp.t0, susp->susp.sr, scale_factor);
result = sound_create((snd_susp_type)susp, susp->susp.t0,
susp->susp.sr, scale_factor);
D nyquist_printf("Created sndseq: ");
D sound_print_tree_1(result, 2);
xlpopn(1);
return result;
}
sound_type snd_sndseq(s1, closure)
sound_type s1;
LVAL closure;
/* This was going to support a new construct, SEQV, but it was just a bad idea.
void change_seqclosure(LVAL snd, LVAL vars, LVAL closure)
{
sound_type s1_copy;
s1_copy = sound_copy(s1);
return snd_make_sndseq(s1_copy, closure);
if (listp(vars)) { // modify the closure
LVAL newenv;
LVAL binding;
LVAL envsublist; // don't save, always points into env
xlstkcheck(2);
xlsave(newenv); // initially just ((var . val) ...)
xlsave(binding);
while (vars) { // for each var in environment
LVAL var = car(vars);
// get value of sym in env:
binding = cons(var, xlgetvalue(var));
newenv = cons(binding, newenv);
vars = cdr(vars);
}
newenv = consa(newenv);
if (null(snd)) { // first sound gets to see all local variables
cdr(newenv) = closure_getenv(closure);
}
setenv(closure, newenv);
xlpopn(2);
}
}
*/
sound_type snd_sndseq(sound_type snd, LVAL closure)
{
return snd_make_sndseq(sound_copy(snd), closure);
}

View File

@ -1,3 +1,4 @@
sound_type snd_make_sndseq();
sound_type snd_sndseq();
sound_type snd_make_sndseq(sound_type s1, LVAL closure);
sound_type snd_sndseq(sound_type s1, LVAL closure);
/* LISP: (SND-SEQ SOUND ANY) */

View File

@ -14,7 +14,7 @@
LVAL xslider_read(void)
{
LVAL arg = xlgafixnum();
int index = getfixnum(arg);
int index = (int) getfixnum(arg);
xllastarg();
if (index >= 0 && index < SLIDERS_MAX) {
return cvflonum(slider_array[index]);
@ -46,12 +46,12 @@ LVAL xosc_enable(void)
}
void slider_free();
void slider_free(snd_susp_type a_susp);
typedef struct slider_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
int index;
} slider_susp_node, *slider_susp_type;
@ -86,7 +86,7 @@ void slider__fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo == 0) break;
}

View File

@ -3,8 +3,7 @@
* Jan 2013
*/
/* access from Nyquist unit generators to shared data */
sound_type snd_make_slider(int index, time_type t0, rate_type sr, time_type d);
sound_type snd_slider(int index, time_type t0, rate_type sr, time_type d);
/* LISP: (SND-SLIDER FIXNUM ANYNUM ANYNUM ANYNUM) */
/* LISP: (SND-SLIDER LONG ANYNUM ANYNUM ANYNUM) */

View File

@ -375,7 +375,7 @@ cvtfn_type find_cvt_to_fn(snd_type snd, char *buf)
sample_type sound_save_sound(LVAL s_as_lval, long n, snd_type snd,
char *buf, long *ntotal, snd_type player)
{
long blocklen;
int blocklen;
long buflen;
sound_type s;
long debug_unit; /* print messages at intervals of this many samples */
@ -634,7 +634,7 @@ D nyquist_printf("save scale factor %d = %g\n", (int)i, state[i].scale);
* would be a bug.)
*/
free(state);
xlpop();
xlpopn(2);
return max_sample;
}

View File

@ -1,12 +1,11 @@
/* sndwrite.h -- header to write sounds to files */
double sound_save(LVAL snd_expr, long n,
unsigned char *filename, long format,
long mode, long bits, long swap, double *sr, long *nchans,
double *duration, LVAL play);
/* LISP: (SND-SAVE ANY FIXNUM STRING FIXNUM FIXNUM FIXNUM FIXNUM ANYNUM^ FIXNUM^ ANYNUM^ ANY) */
double sound_save(LVAL snd_expr, int64_t n,
unsigned char *filename, long format,
long mode, long bits, long swap, double *sr, long *nchans,
double *duration, LVAL play, int64_t progress);
/* LISP: (SND-SAVE ANY FIXNUM STRING LONG LONG LONG LONG ANYNUM^ LONG^ ANYNUM^ ANY FIXNUM) */
double sound_overwrite(LVAL snd_expr, long n,
unsigned char *filename, double offset_secs, long format,
long mode, long bits, long swap, double *duration);
/* LISP: (SND-OVERWRITE ANY FIXNUM STRING ANYNUM FIXNUM FIXNUM FIXNUM FIXNUM ANYNUM^) */
double sound_overwrite(LVAL snd_expr, int64_t n, unsigned char *filename,
double offset_secs, double *duration, int64_t progress);
/* LISP: (SND-OVERWRITE ANY FIXNUM STRING ANYNUM ANYNUM^ FIXNUM) */

View File

@ -61,19 +61,19 @@
if (s > threshold) { \
if (s > max_sample) { \
max_sample = s; \
threshold = min(1.0, s); \
threshold = min(1.0F, s); \
} \
if (s > 1.0) { \
s = (sample_type) (fmod(s + 1.0, 2.0) - 1.0); \
s = (sample_type) (fmodf(s + 1.0F, 2.0F) - 1.0F); \
(x) = s; \
} \
} else if (s < -threshold) { \
if (s < -max_sample) { \
max_sample = -s; \
threshold = min(1.0, -s); \
threshold = min(1.0F, -s); \
} \
if (s < -1.0) { \
s = (sample_type) -(fmod(-s + 1.0, 2.0) - 1.0); \
s = (sample_type) -(fmodf(-s + 1.0F, 2.0F) - 1.0F); \
(x) = s; \
} \
}
@ -114,18 +114,22 @@ void portaudio_exit()
}
sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info,
SNDFILE *snd_file, float *buf, long *ntotal);
// sound_save_sound - implements s-save for mono sounds
sample_type sound_save_sound(LVAL s_as_lval, int64_t n, SF_INFO *sf_info,
SNDFILE *snd_file, float *buf, int64_t *ntotal,
int64_t progress);
sample_type sound_save_array(LVAL sa, long n, SF_INFO *sf_info,
SNDFILE *snd_file, float *buf, long *ntotal);
// sound_save_array - implements s-save for multi-channel sounds
sample_type sound_save_array(LVAL sa, int64_t n, SF_INFO *sf_info,
SNDFILE *snd_file, float *buf, int64_t *ntotal,
int64_t progress);
unsigned char st_linear_to_ulaw(int sample);/* jlh not used anywhere */
typedef struct {
sound_type sound;
long cnt;
int cnt;
sample_block_values_type ptr;
double scale;
int terminated;
@ -176,7 +180,7 @@ LVAL prepare_audio(LVAL play, SF_INFO *sf_info)
pref = getvalue(pref);
if (pref == s_unbound) pref = NULL;
if (stringp(pref)) pref_string = getstring(pref);
else if (fixp(pref)) pref_num = getfixnum(pref);
else if (fixp(pref)) pref_num = (int) getfixnum(pref);
if (!portaudio_initialized) {
if (portaudio_error(Pa_Initialize(),
@ -250,7 +254,7 @@ LVAL prepare_audio(LVAL play, SF_INFO *sf_info)
/* finish_audio -- flush the remaining samples, then close */
/**/
void finish_audio()
void finish_audio(void)
{
/* portaudio_error(Pa_StopStream(audio_stream), "could not stop stream"); */
/* write Latency frames of audio to make sure all samples are played */
@ -292,16 +296,17 @@ long lookup_format(long format, long mode, long bits, long swap)
case SND_HEAD_SD2: sf_format = SF_FORMAT_SD2; break;
case SND_HEAD_FLAC: sf_format = SF_FORMAT_FLAC; break;
case SND_HEAD_CAF: sf_format = SF_FORMAT_CAF; break;
case SND_HEAD_OGG: sf_format = SF_FORMAT_OGG; mode = SND_MODE_VORBIS; break; /* ZEYU */
case SND_HEAD_RAW:
sf_format = SF_FORMAT_RAW;
#ifdef XL_BIG_ENDIAN
sf_format |= (swap ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG);
#endif
#ifdef XL_LITTLE_ENDIAN
sf_format |= (swap ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE);
sf_format |= (swap ? SF_ENDIAN_LITTLE : SF_ENDIAN_LITTLE);
#endif
break;
case SND_HEAD_OGG: sf_format = SF_FORMAT_OGG; mode = SND_MODE_VORBIS; break;
case SND_HEAD_WAVEX: sf_format = SF_FORMAT_WAVEX; break;
default:
sf_format = SF_FORMAT_WAV;
nyquist_printf("s-save: unrecognized format, using SND_HEAD_WAVE\n");
@ -362,22 +367,15 @@ long lookup_format(long format, long mode, long bits, long swap)
}
double sound_save(
LVAL snd_expr,
long n,
unsigned char *filename,
long format,
long mode,
long bits,
long swap,
double *sr,
long *nchans,
double *duration,
LVAL play)
// sound_save - implements s-save. As files are written, the sample count
// is printed at intervals of progress. Typically every 10s of sound.
double sound_save(LVAL snd_expr, int64_t n, unsigned char *filename,
long format, long mode, long bits, long swap, double *sr,
long *nchans, double *duration, LVAL play, int64_t progress)
{
LVAL result;
float *buf = NULL;
long ntotal;
int64_t ntotal;
double max_sample;
SNDFILE *sndfile = NULL;
SF_INFO sf_info;
@ -388,7 +386,9 @@ double sound_save(
memset(&sf_info, 0, sizeof(sf_info));
sf_info.format = lookup_format(format, mode, bits, swap);
// printf("in sound_save: calling xleval on %p\n", snd_expr);
result = xleval(snd_expr);
// printf("in sound_save: got result of xleval %p\n", result);
/* BE CAREFUL - DO NOT ALLOW GC TO RUN WHILE RESULT IS UNPROTECTED */
if (vectorp(result)) {
/* make sure all elements are of type a_sound */
@ -397,7 +397,7 @@ double sound_save(
while (i > 0) {
i--;
if (!exttypep(getelement(result, i), a_sound)) {
xlerror("sound_save: array has non-sound element",
xlerror("S-SAVE: array has non-sound element",
result);
}
}
@ -426,7 +426,7 @@ double sound_save(
}
max_sample = sound_save_array(result, n, &sf_info, sndfile,
buf, &ntotal);
buf, &ntotal, progress);
*duration = ntotal / *sr;
if (sndfile) sf_close(sndfile);
if (play != NIL) finish_audio();
@ -459,13 +459,15 @@ double sound_save(
}
max_sample = sound_save_sound(result, n, &sf_info, sndfile,
buf, &ntotal);
buf, &ntotal, progress);
*duration = ntotal / *sr;
if (sndfile) sf_close(sndfile);
if (play != NIL) finish_audio();
} else {
xlprot1(result);
xlerror("sound_save: expression did not return a sound",
result);
xlpop();
max_sample = 0.0;
}
if (buf) free(buf);
@ -475,13 +477,12 @@ double sound_save(
/* open_for_write -- helper function for sound_overwrite */
/*
* if the format is RAW, then fill in sf_info according to
* sound sample rate and channels. Otherwise, open the file
* and see if the sample rate and channele match.
* open the file and prepare to read it if it matches the expected
* sample rate and number of channels
*/
SNDFILE *open_for_write(unsigned char *filename, long direction,
long format, SF_INFO *sf_info, int channels,
long srate, double offset, float **buf)
SF_INFO *sf_info, int channels, int srate,
double offset, float **buf)
/* channels and srate are based on the sound we're writing to the file */
{
SNDFILE *sndfile;
@ -489,18 +490,13 @@ SNDFILE *open_for_write(unsigned char *filename, long direction,
char error[140]; // error messages are formatted here
sf_count_t rslt; // frame count returned from sf_seek
if (format == SND_HEAD_RAW) {
sf_info->channels = channels;
sf_info->samplerate = srate;
} else {
sf_info->format = 0;
}
sndfile = NULL;
if (ok_to_open((char *) filename, "w"))
sndfile = sf_open((const char *) filename, direction, sf_info);
if (!sndfile) {
snprintf(error, sizeof(error), "snd_overwrite: cannot open file %s", filename);
snprintf(error, sizeof(error), "snd_overwrite: cannot open file %s",
filename);
xlabort(error);
}
/* use proper scale factor: 8000 vs 7FFF */
@ -515,7 +511,7 @@ SNDFILE *open_for_write(unsigned char *filename, long direction,
xlabort(error);
}
if (sf_info->channels != channels) {
snprintf(error, sizeof(error), "%s%d%s%d%s",
snprintf(error, sizeof(error), "%s%d%s%d%s",
"snd_overwrite: number of channels in sound (",
channels,
") does not match\n number of channels in file (",
@ -523,19 +519,17 @@ SNDFILE *open_for_write(unsigned char *filename, long direction,
sf_close(sndfile);
xlabort(error);
}
if (sf_info->samplerate != srate) {
snprintf(error, sizeof(error), "%s%ld%s%d%s",
snprintf(error, sizeof(error), "%s%d%s%d%s",
"snd_overwrite: sample rate in sound (",
srate,
") does not match\n sample rate in file (",
sf_info->samplerate,
")");
")");
sf_close(sndfile);
xlabort(error);
}
if ((*buf = (float *) malloc(max_sample_block_len * channels *
if ((*buf = (float *) malloc(max_sample_block_len * sf_info->channels *
sizeof(float))) == NULL) {
xlabort("snd_overwrite: couldn't allocate memory");
}
@ -543,21 +537,13 @@ SNDFILE *open_for_write(unsigned char *filename, long direction,
}
double sound_overwrite(
LVAL snd_expr,
long n,
unsigned char *filename,
double offset_secs,
long format,
long mode,
long bits,
long swap,
double *duration)
double sound_overwrite(LVAL snd_expr, int64_t n, unsigned char *filename,
double offset_secs, double *duration, int64_t progress)
{
LVAL result; // the SOUND to be evaluated
SF_INFO sf_info; // info about the sound file
double max_sample; // return value
long ntotal; // how many samples were overwritten
int64_t ntotal; // how many samples were overwritten
/*
long flags;
*/
@ -573,7 +559,6 @@ double sound_overwrite(
fclose(file);
}
memset(&sf_info, 0, sizeof(sf_info));
sf_info.format = lookup_format(format, mode, bits, swap);
result = xleval(snd_expr);
/* BE CAREFUL - DO NOT ALLOW GC TO RUN WHILE RESULT IS UNPROTECTED */
if (vectorp(result)) {
@ -589,23 +574,23 @@ double sound_overwrite(
result);
}
}
sndfile = open_for_write(filename, SFM_RDWR, format, &sf_info, channels,
sndfile = open_for_write(filename, SFM_RDWR, &sf_info, channels,
ROUND32(getsound(getelement(result, 0))->sr),
offset_secs, &buf);
max_sample = sound_save_array(result, n, &sf_info, sndfile,
buf, &ntotal);
buf, &ntotal, progress);
*duration = ntotal / (double) sf_info.samplerate;
free(buf);
sf_close(sndfile);
} else if (exttypep(result, a_sound)) {
SNDFILE *sndfile; // opened sound file
float *buf; // buffer for samples read in from sound file
sndfile = open_for_write(filename, SFM_RDWR, format, &sf_info, 1,
sndfile = open_for_write(filename, SFM_RDWR, &sf_info, 1,
ROUND32(getsound(result)->sr),
offset_secs, &buf);
max_sample = sound_save_sound(result, n, &sf_info, sndfile, buf,
&ntotal);
&ntotal, progress);
*duration = ntotal / (double) sf_info.samplerate;
free(buf);
sf_close(sndfile);
@ -625,15 +610,16 @@ int is_pcm(SF_INFO *sf_info)
}
sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info,
SNDFILE *sndfile, float *buf, long *ntotal)
sample_type sound_save_sound(LVAL s_as_lval, int64_t n, SF_INFO *sf_info,
SNDFILE *sndfile, float *buf, int64_t *ntotal,
int64_t progress)
{
long blocklen;
int blocklen;
sound_type s;
int i;
sample_type *samps;
long debug_unit; /* print messages at intervals of this many samples */
long debug_count; /* next point at which to print a message */
int64_t debug_unit; /* print messages at intervals of this many samples */
int64_t debug_count; /* next point at which to print a message */
sample_type max_sample = 0.0F;
sample_type threshold = 0.0F;
double sound_srate;
@ -659,8 +645,11 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info,
/* for debugging */
/* printing_this_sound = s;*/
debug_unit = debug_count = (long) max(sf_info->samplerate, 10000.0);
if (progress < 10000) {
progress = 10000;
}
debug_unit = debug_count =
(int64_t) max(10 * sf_info->samplerate, progress);
sound_frames = 0;
sound_srate = sf_info->samplerate;
@ -681,7 +670,7 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info,
if (sampblock == zero_block || blocklen == 0) {
break;
}
togo = min(blocklen, n);
togo = (int) min(blocklen, n);
if (s->scale != 1) { /* copy/scale samples into buf */
for (i = 0; i < togo; i++) {
buf[i] = s->scale * sampblock->samples[i];
@ -713,7 +702,7 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info,
n -= togo;
*ntotal += togo;
if (*ntotal > debug_count) {
gprintf(TRANS, " %ld ", *ntotal);
gprintf(TRANS, " %" PRId64 " ", *ntotal);
fflush(stdout);
debug_count += debug_unit;
}
@ -725,16 +714,17 @@ sample_type sound_save_sound(LVAL s_as_lval, long n, SF_INFO *sf_info,
}
sample_type sound_save_array(LVAL sa, long n, SF_INFO *sf_info,
SNDFILE *sndfile, float *buf, long *ntotal)
sample_type sound_save_array(LVAL sa, int64_t n, SF_INFO *sf_info,
SNDFILE *sndfile, float *buf, int64_t *ntotal,
int64_t progress)
{
long i, chans;
float *float_bufp;
sound_state_type state;
double start_time = HUGE_VAL;
LVAL sa_copy;
long debug_unit; /* print messages at intervals of this many samples */
long debug_count; /* next point at which to print a message */
int64_t debug_unit; /* print messages at intervals of this many samples */
int64_t debug_count; /* next point at which to print a message */
sample_type max_sample = 0.0F;
sample_type threshold = 0.0F;
double sound_srate;
@ -764,6 +754,7 @@ sample_type sound_save_array(LVAL sa, long n, SF_INFO *sf_info,
free(buf);
sf_close(sndfile);
}
// printf("DEBUG: xlstack on entry to sound_save_array: %p\n", xlstack);
xlprot1(sa);
sa_copy = newvector(chans);
xlprot1(sa_copy);
@ -795,7 +786,11 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale);
sound_prepend_zeros(state[i].sound, start_time);
}
debug_unit = debug_count = (long) max(sf_info->samplerate, 10000.0);
if (progress < 10000) {
progress = 10000;
}
debug_unit = debug_count =
(int64_t) max(10 * sf_info->samplerate, progress);
sound_frames = 0;
sound_srate = sf_info->samplerate;
@ -809,7 +804,7 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale);
loop if all sounds have terminated
*/
int terminated = true;
int togo = n;
int64_t togo = n; /* because of this, togo must be int64_t here */
int j;
oscheck();
@ -817,14 +812,16 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale);
for (i = 0; i < chans; i++) {
if (state[i].cnt == 0) {
if (sndwrite_trace) {
nyquist_printf("CALLING SOUND_GET_NEXT ON CHANNEL %ld (%p)\n",
i, state[i].sound); /* jlh 64 bit issue */
sound_print_tree(state[i].sound);
nyquist_printf("CALLING SOUND_GET_NEXT ON "
"CHANNEL %ld (%p)\n",
i, state[i].sound); /* jlh 64 bit issue */
sound_print_tree(state[i].sound);
}
state[i].ptr = sound_get_next(state[i].sound,
&(state[i].cnt))->samples;
if (sndwrite_trace) {
nyquist_printf("RETURNED FROM CALL TO SOUND_GET_NEXT ON CHANNEL %ld\n", i);
nyquist_printf("RETURNED FROM CALL TO SOUND_GET_NEXT "
"ON CHANNEL %ld\n", i);
}
if (state[i].ptr == zero_block->samples) {
state[i].terminated = true;
@ -833,6 +830,8 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale);
if (!state[i].terminated) terminated = false;
togo = min(togo, state[i].cnt);
}
/* note that now, togo is well within range of int because it is the
min of state[i].cnt */
if (terminated) break;
@ -857,7 +856,8 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale);
/* Here we have interleaved floats. Before converting to the sound
file format, call PortAudio to play them. */
if (audio_stream) {
PaError err = Pa_WriteStream(audio_stream, buf, togo);
PaError err = Pa_WriteStream(audio_stream, buf,
(unsigned long) togo);
if (err) {
printf("Pa_WriteStream error %d\n", err);
}
@ -867,7 +867,7 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale);
n -= togo;
for (i = 0; i < chans; i++) {
state[i].cnt -= togo;
state[i].cnt -= (int) togo;
}
*ntotal += togo;
if (*ntotal > debug_count) {
@ -885,7 +885,7 @@ D nyquist_printf("save scale factor %ld = %g\n", i, state[i].scale);
* would be a bug.)
*/
free(state);
xlpop();
xlpopn(2);
return max_sample;
}

View File

@ -6,6 +6,7 @@
*/
/* define size_t: */
#include <limits.h>
#ifdef UNIX
#include "sys/types.h"
#endif
@ -53,7 +54,7 @@ static void sound_xlsave(FILE *fp, void *s);
static unsigned char *sound_xlrestore(FILE *);
void sound_print_array(LVAL sa, long n);
void sound_print_sound(sound_type s, long n);
void sound_print_sound(LVAL s_as_lval, long n);
void sample_block_unref(sample_block_type sam);
#ifdef SNAPSHOTS
@ -65,10 +66,13 @@ int nosc_enabled = false;
#endif
/* m is in bytes */
long snd_set_max_audio_mem(long m)
int64_t snd_set_max_audio_mem(int64_t m)
{
long r = max_sample_blocks;
max_sample_blocks = m / (max_sample_block_len * sizeof(float));
int64_t r = max_sample_blocks;
// avoid overflow since max_sample_blocks is long
int64_t msb = m / (max_sample_block_len * sizeof(float));
if (msb > LONG_MAX) msb = LONG_MAX;
max_sample_blocks = (long) msb;
return r * max_sample_block_len * sizeof(float);
}
@ -76,7 +80,7 @@ long snd_set_max_audio_mem(long m)
double sound_latency = 0.3; /* default value */
/* these are used so get times for *AUDIO-MARKERS* */
double sound_srate = 44100.0;
long sound_frames = 0;
int64_t sound_frames = 0;
double snd_set_latency(double latency)
{
@ -86,7 +90,7 @@ double snd_set_latency(double latency)
}
long check_terminate_cnt(long tc)
int64_t check_terminate_cnt(int64_t tc)
{
if (tc < 0) {
xlfail("duration is less than 0 samples");
@ -150,7 +154,7 @@ snd_list_type gcbug_snd_list = 0;
long blocks_to_watch_len = 0;
sample_block_type blocks_to_watch[blocks_to_watch_max];
void block_watch(long sample_block)
void block_watch(int64_t sample_block)
{
if (blocks_to_watch_len >= blocks_to_watch_max) {
stdputstr("block_watch - no more space to save pointers\n");
@ -174,13 +178,14 @@ void block_watch(long sample_block)
void fetch_zeros(snd_susp_type susp, snd_list_type snd_list)
{
int len = MIN(susp->log_stop_cnt - susp->current,
max_sample_block_len);
int64_t len = MIN(susp->log_stop_cnt - susp->current,
max_sample_block_len);
/* nyquist_printf("fetch_zeros, lsc %d current %d len %d\n",
susp->log_stop_cnt, susp->current, len); */
if (len < 0) {
char error[80];
sprintf(error, "fetch_zeros susp %p (%s) len %d", susp, susp->name, len);
sprintf(error, "fetch_zeros susp %p (%s) len %" PRId64,
susp, susp->name, len);
xlabort(error);
}
if (len == 0) { /* we've reached the logical stop time */
@ -188,7 +193,7 @@ void fetch_zeros(snd_susp_type susp, snd_list_type snd_list)
susp->name, susp->log_stop_cnt); */
snd_list_terminate(snd_list);
} else {
snd_list->block_len = len;
snd_list->block_len = (short) len;
susp->current += len;
}
}
@ -199,7 +204,7 @@ void fetch_zeros(snd_susp_type susp, snd_list_type snd_list)
* NOTE: intended to be called from lisp. Lisp can then call block_watch
* to keep an eye on the block.
*/
long sound_nth_block(sound_type snd, long n)
int64_t sound_nth_block(sound_type snd, long n)
{
long i;
snd_list_type snd_list = snd->list;
@ -211,7 +216,7 @@ long sound_nth_block(sound_type snd, long n)
if (!snd_list->block) return 0;
snd_list = snd_list->u.next;
}
if (snd_list->block) return (long) snd_list->block;
if (snd_list->block) return (int64_t) snd_list->block;
else return 0;
}
@ -279,7 +284,7 @@ sound_type sound_create(
{
sound_type sound;
falloc_sound(sound, "sound_create");
if (((long) sound) & 3) errputstr("sound not word aligned\n");
if (((intptr_t) sound) & 3) errputstr("sound not word aligned\n");
last_sound = sound; /* debug */
if (t0 < 0) xlfail("attempt to create a sound with negative starting time");
/* nyquist_printf("sound_create %p gets %g\n", sound, t0); */
@ -333,7 +338,7 @@ sound_type sound_create(
*/
void sound_prepend_zeros(sound_type snd, time_type t0)
{
long n;
int64_t n;
/* first, see if we're already prepending some zeros */
if (snd->get_next != SND_get_zeros) {
@ -348,7 +353,7 @@ void sound_prepend_zeros(sound_type snd, time_type t0)
snd->get_next = SND_get_zeros;
}
n = (long) (((snd->true_t0 - t0) * snd->sr) + 0.5); /* how many samples to prepend */
n = ROUNDBIG((snd->true_t0 - t0) * snd->sr); /* how many samples to prepend */
/* add to prepend_cnt so first sample will correspond to new t0 */
snd->prepend_cnt += n;
@ -406,9 +411,9 @@ sound_type sound_copy(sound_type snd)
/**/
table_type sound_to_table(sound_type s)
{
long len = snd_length(s, max_table_len);
long len = (long) snd_length(s, max_table_len);
long tx = 0; /* table index */
long blocklen;
int blocklen;
register double scale_factor = s->scale;
sound_type original_s = s;
table_type table; /* the new table */
@ -501,12 +506,11 @@ void snd_list_ref(snd_list_type list)
}
void snd_list_terminate(snd_list)
snd_list_type snd_list;
void snd_list_terminate(snd_list_type snd_list)
{
snd_susp_type susp = snd_list->u.next->u.susp;
long lsc = susp->log_stop_cnt;
long current = susp->current;
int64_t lsc = susp->log_stop_cnt;
int64_t current = susp->current;
/* unreference the empty sample block that was allocated: */
sample_block_unref(snd_list->block);
/* use zero_block instead */
@ -541,7 +545,6 @@ void snd_list_unref(snd_list_type list)
break; // the rest of the list is shared, nothing more to free
}
next = NULL;
// list nodes either point to a block of samples or this is the
// last list node (list->block == NULL) which points to a suspension
// lists can also terminate at the zero_block, which is an infinite
@ -661,9 +664,9 @@ void snd_sort_2(sound_type *s1_ptr, sound_type *s2_ptr, rate_type sr)
double snd_sref(sound_type s, time_type t)
{
double exact_cnt; /* how many fractional samples to scan */
int cnt; /* how many samples to flush */
int64_t cnt; /* how many samples to flush */
sample_block_type sampblock = NULL;
long blocklen;
int blocklen;
sample_type x1, x2; /* interpolate between these samples */
/* changed true_t0 to just t0 based on comment that true_t0 is only
@ -673,7 +676,7 @@ double snd_sref(sound_type s, time_type t)
if (exact_cnt < 0.0) return 0.0;
s = sound_copy(s); /* don't modify s, create new reader */
cnt = (long) exact_cnt; /* rounds down */
cnt = (int64_t) exact_cnt; /* rounds down */
exact_cnt -= cnt; /* remember fractional remainder */
/* now flush cnt samples */
@ -707,7 +710,7 @@ double snd_sref_inverse(sound_type s, double val)
double exact_cnt; /* how many fractional samples to scan */
int i;
sample_block_type sampblock;
long blocklen;
int blocklen;
sample_type x1, x2; /* interpolate between these samples */
if (val < 0) {
@ -767,6 +770,14 @@ double snd_sref_inverse(sound_type s, double val)
time_type snd_stop_time(sound_type s)
{
if (s->stop == MAX_STOP) return MAX_STOP_TIME;
/* I think placing the stop time 0.5 samples later than the last
is to avoid rounding errors somewhere. Sounds are supposed
to be open-ended on the right, and I would guess s->stop
should be one greater than the actual number of samples.
Therefore, it seems that 0.5 should be 0.0 so that
converting back to sample count will round to s->stop.
I'm not changing this because it has been this way for
a long time and Nyquist seems to get it right. -RBD */
else return s->t0 + (s->stop + 0.5) / s->sr;
}
@ -805,7 +816,7 @@ sound_type snd_xform(sound_type snd,
time_type stop_time,
promoted_sample_type scale)
{
long start_cnt, stop_cnt; /* clipping samples (sample 0 at new t0) */
int64_t start_cnt, stop_cnt; /* clipping samples (sample 0 at new t0) */
/* start_cnt should reflect max of where the sound starts (t0)
* and the new start_time.
@ -814,7 +825,7 @@ sound_type snd_xform(sound_type snd,
start_cnt = 0;
} else {
double new_start_cnt = ((start_time - time) * sr) + 0.5;
start_cnt = ((new_start_cnt > 0) ? (long) new_start_cnt : 0);
start_cnt = ((new_start_cnt > 0) ? (int64_t) new_start_cnt : 0);
}
/* if (start_cnt < -(snd->current)) start_cnt = -(snd->current); */
@ -826,7 +837,7 @@ sound_type snd_xform(sound_type snd,
} else {
double new_stop_cnt = ((stop_time - time) * sr) + 0.5;
if (new_stop_cnt < MAX_STOP) {
stop_cnt = (long) new_stop_cnt;
stop_cnt = (int64_t) new_stop_cnt;
} else {
errputstr("Warning: stop count overflow in snd_xform\n");
stop_cnt = MAX_STOP;
@ -847,9 +858,8 @@ sound_type snd_xform(sound_type snd,
*/
ffree_snd_list(snd->list, "snd_xform");
snd->list = zero_snd_list;
nyquist_printf("snd_xform: (stop_time < t0 or start >= stop) "
"-> zero sound = %p\n", snd);
/* nyquist_printf("snd_xform: (stop_time < t0 or start >= stop) "
"-> zero sound = %p\n", snd); */
} else {
snd = sound_copy(snd);
snd->t0 = time;
@ -883,9 +893,9 @@ sound_type snd_xform(sound_type snd,
* non-real-time operation) and installs SND_get_next to return
* blocks normally from then on.
*/
sample_block_type SND_flush(sound_type snd, long * cnt)
sample_block_type SND_flush(sound_type snd, int *cnt)
{
long mycnt;
int mycnt;
sample_block_type block = SND_get_first(snd, &mycnt);
/* changed from < to <= because we want to read at least the first sample */
while (snd->current <= 0) {
@ -896,11 +906,11 @@ sample_block_type SND_flush(sound_type snd, long * cnt)
* is in the right place, we can do a minimal fixup and return:
*/
if (snd->current == snd->list->block_len) {
*cnt = snd->current; /* == snd->list->block_len */
*cnt = (int) snd->current; /* == snd->list->block_len */
/* snd->get_next = SND_get_next; -- done by SND_get_first */
return block;
} else /* snd->current < snd->list->block_len */ {
long i;
int64_t i;
sample_block_values_type from_ptr;
/* we have to return a partial block */
/* NOTE: if we had been smart, we would have had SND_get_next
@ -919,7 +929,7 @@ sample_block_type SND_flush(sound_type snd, long * cnt)
}
snd_list_unref(snd->list);
snd->list = snd_list;
*cnt = snd->current;
*cnt = (int) snd->current;
return snd_list->block;
}
}
@ -932,13 +942,13 @@ sample_block_type SND_flush(sound_type snd, long * cnt)
* the normal (original) get_next function.
*
*/
sample_block_type SND_get_zeros(sound_type snd, long * cnt)
sample_block_type SND_get_zeros(sound_type snd, int *cnt)
{
int len = MIN(snd->prepend_cnt, max_sample_block_len);
int64_t len = MIN(snd->prepend_cnt, max_sample_block_len);
/* stdputstr("SND_get_zeros: "); */
if (len < 0) {
char error[80];
sprintf(error, "SND_get_zeros snd %p len %d", snd, len);
sprintf(error, "SND_get_zeros snd %p len %" PRId64, snd, len);
xlabort(error);
}
if (len == 0) { /* we've finished prepending zeros */
@ -946,7 +956,7 @@ sample_block_type SND_get_zeros(sound_type snd, long * cnt)
/* stdputstr("done, calling sound_get_next\n"); fflush(stdout); */
return sound_get_next(snd, cnt);
} else {
*cnt = len;
*cnt = (int) len;
snd->current += len;
snd->prepend_cnt -= len;
/* nyquist_printf("returning internal_zero_block@%p\n", internal_zero_block);
@ -1056,14 +1066,15 @@ sample_block_type SND_get_zeros(sound_type snd, long * cnt)
* generated.
****************************************************************************/
void add_s1_s2_nn_fetch(); /* for debugging */
/* for debugging */
void add_s1_s2_nn_fetch(snd_susp_type a_susp, snd_list_type snd_list);
/* SND_get_first -- the standard fn to get a block, after returning
* the first block, plug in SND_get_next for successive blocks
*/
sample_block_type SND_get_first(sound_type snd, long * cnt)
sample_block_type SND_get_first(sound_type snd, int *cnt)
{
register snd_list_type snd_list = snd->list;
snd_list_type snd_list = snd->list;
/*
* If there is not a block of samples, we need to generate one.
*/
@ -1130,9 +1141,9 @@ sample_block_type SND_get_first(sound_type snd, long * cnt)
}
sample_block_type SND_get_next(sound_type snd, long * cnt)
sample_block_type SND_get_next(sound_type snd, int *cnt)
{
register snd_list_type snd_list = snd->list;
snd_list_type snd_list = snd->list;
/*
* SND_get_next is installed by SND_get_first, so we know
* when we are called that we are done with the current block
@ -1191,10 +1202,10 @@ sample_block_type make_zero_block(void)
* should be the MAX of logical stop times of arguments, so this routine
* would not be used.
*/
void min_cnt(long *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt)
void min_cnt(int64_t *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt)
{
long c = (long) ((((sound->current - cnt) / sound->sr + sound->t0) - susp->t0) *
susp->sr + 0.5);
int64_t c = ROUNDBIG((((sound->current - cnt) / sound->sr + sound->t0) - susp->t0) *
susp->sr);
/* if *cnt_ptr is uninitialized, just plug in c, otherwise compute min */
if ((*cnt_ptr == UNKNOWN) || (*cnt_ptr > c)) {
/* nyquist_printf("min_cnt %p: new count is %d\n", susp, c);*/
@ -1276,7 +1287,7 @@ void set_logical_stop_time(sound_type sound, time_type when)
| |
t0 when
*/
long n = (long) ((when - sound->t0) * sound->sr + 0.5);
int64_t n = ROUNDBIG((when - sound->t0) * sound->sr);
if (n < 0) {
xlcerror("retain the current logical stop",
"logical stop sample count is negative", NIL);
@ -1288,10 +1299,11 @@ void set_logical_stop_time(sound_type sound, time_type when)
/* for debugging */
/* for debugging
sound_type printing_this_sound = NULL;
void ((**watch_me)()) = NULL;
void set_watch(where)
void ((**where)());
{
@ -1300,84 +1312,128 @@ void set_watch(where)
nyquist_printf("set_watch: watch_me = %p\n", watch_me);
}
}
*/
/*
* additional routines
*/
/* snd_list_len - for debugging: how many sample blocks held? */
long snd_list_len(void *inst)
{
int i = 0;
sound_type snd = (sound_type) inst;
snd_list_type list = snd->list;
while (list->block && list->block != zero_block && list->block_len != 0) {
i++;
list = list->u.next;
}
return i;
}
/* sound_print - implement SND-PRINT, based on sound_save in sndwritepa.c */
/**/
void sound_print(snd_expr, n)
LVAL snd_expr;
long n;
{
LVAL result;
xlsave1(result);
result = xleval(snd_expr);
/* BE CAREFUL - DO NOT ALLOW GC TO RUN WHILE RESULT IS UNPROTECTED */
if (vectorp(result)) {
/* make sure all elements are of type a_sound */
long i = getsize(result);
while (i > 0) {
i--;
if (!exttypep(getelement(result, i), a_sound)) {
xlerror("sound_print: array has non-sound element",
result);
xlerror("SND-PRINT: array has non-sound element",
result);
}
}
sound_print_array(result, n);
} else if (exttypep(result, a_sound)) {
sound_print_sound(getsound(result), n);
} else if (soundp(result)) {
sound_print_sound(result, n);
} else {
xlprot1(result);
xlerror("sound_print: expression did not return a sound",
result);
xlpop();
}
xlpop();
}
void sound_print_sound(sound_type s, long n)
/* sound_print_sound - implements SND-PRINT for mono signal */
/**/
void sound_print_sound(LVAL s_as_lval, long n)
{
int ntotal = 0;
long blocklen;
sound_type s;
int blocklen;
sample_block_type sampblock;
/* for debugging */
printing_this_sound = s;
/* for debugging
printing_this_sound = s;
*/
nyquist_printf("sound_print: start at time %g\n", s->t0);
xlprot1(s_as_lval);
s = sound_copy(getsound(s_as_lval));
s_as_lval = cvsound(s); /* destroys our reference to original */
nyquist_printf("SND-PRINT: start at time %g\n", s->t0);
while (ntotal < n) {
if (s->logical_stop_cnt != UNKNOWN)
nyquist_printf("LST=%d ", (int)s->logical_stop_cnt);
if (s->logical_stop_cnt != UNKNOWN) {
nyquist_printf("logical stop time (in samples): %d ",
(int)s->logical_stop_cnt);
}
sound_print_tree(s);
sampblock = sound_get_next(s, &blocklen);
if (sampblock == zero_block || blocklen == 0) {
break;
}
print_sample_block_type("sound_print", sampblock,
print_sample_block_type("SND-PRINT", sampblock,
MIN(blocklen, n - ntotal));
ntotal += blocklen;
}
nyquist_printf("total samples: %d\n", ntotal);
xlpop();
}
void sound_print_array(LVAL sa, long n)
{
long blocklen;
long i, len;
int blocklen;
long i, chans;
LVAL sa_copy;
long upper = 0;
sample_block_type sampblock;
time_type t0, tmax;
len = getsize(sa);
if (len == 0) {
stdputstr("sound_print: 0 channels!\n");
chans = getsize(sa);
if (chans == 0) {
stdputstr("SND-PRINT: 0 channels!\n");
return;
}
xlprot1(sa);
sa_copy = newvector(chans);
xlprot1(sa_copy);
/* To be non-destructive, copy sounds from sa to sa_copy. */
for (i = 0; i < chans; i++) {
sound_type s = getsound(getelement(sa, i));
setelement(sa_copy, i, cvsound(sound_copy(s)));
}
/* If sa and sounds in sa are not accessible, we do not want to retain
* them because they will accumulate the computed samples.
*/
sa = sa_copy; /* destroy original reference to (maybe) allow GC */
/* take care of prepending zeros if necessary */
t0 = tmax = (getsound(getelement(sa, 0)))->t0;
for (i = 1; i < len; i++) {
for (i = 1; i < chans; i++) {
sound_type s = getsound(getelement(sa, i));
t0 = MIN(s->t0, t0);
tmax = MAX(s->t0, tmax);
@ -1386,7 +1442,7 @@ void sound_print_array(LVAL sa, long n)
/* if necessary, prepend zeros */
if (t0 != tmax) {
stdputstr("prepending zeros to channels: ");
for (i = 0; i < len; i++) {
for (i = 0; i < chans; i++) {
sound_type s = getsound(getelement(sa, i));
if (t0 < s->t0) {
nyquist_printf(" %d ", (int)i);
@ -1396,31 +1452,32 @@ void sound_print_array(LVAL sa, long n)
stdputstr("\n");
}
nyquist_printf("sound_print: start at time %g\n", t0);
nyquist_printf("SND-PRINT: start at time %g\n", t0);
while (upper < n) {
int i;
boolean done = true;
for (i = 0; i < len; i++) {
for (i = 0; i < chans; i++) {
sound_type s = getsound(getelement(sa, i));
long current = -1; /* always get first block */
int64_t current = -1; /* always get first block */
while (current < upper) {
sampblock = sound_get_next(s, &blocklen);
if (sampblock != zero_block && blocklen != 0) {
done = false;
done = false;
}
current = s->current - blocklen;
nyquist_printf("chan %d current %d:\n", i, (int)current);
print_sample_block_type("sound_print", sampblock,
MIN(blocklen, n - current));
print_sample_block_type("SND-PRINT", sampblock,
(int) MIN(blocklen, n - current));
current = s->current;
upper = MAX(upper, current);
upper = (long) MAX(upper, current);
}
}
if (done) break;
}
nyquist_printf("total: %d samples x %d channels\n",
(int)upper, (int)len);
(int)upper, (int)chans);
xlpopn(2); // sa and sa_copy
}
@ -1433,17 +1490,16 @@ void sound_print_array(LVAL sa, long n)
* an expression that evaluates to the sound we want. The
* expression is eval'd, the result copied (in case the
* expression was a sound or a global variable and we really
* want to preserve the sound), and then a GC is run to
* want to preserve the sound), and then GC will
* get rid of the original if there really are no other
* references. Finally, the copy is used to play the
* sounds.
* references.
*/
void sound_play(snd_expr)
int64_t sound_play(snd_expr)
LVAL snd_expr;
{
int ntotal;
long blocklen;
int64_t ntotal;
int blocklen;
sample_block_type sampblock;
LVAL result;
sound_type s;
@ -1451,24 +1507,21 @@ void sound_play(snd_expr)
xlsave1(result);
result = xleval(snd_expr);
if (!exttypep(result, a_sound)) {
xlerror("sound_play: expression did not return a sound",
xlerror("SND-PLAY: expression did not return a sound",
result);
}
ntotal = 0;
s = getsound(result);
xlpop();
/* if snd_expr was simply a symbol, then s now points to
/* if snd_expr was simply a symbol, then result now points to
a shared sound_node. If we read samples from it, then
the sound bound to the symbol will be destroyed, so
copy it first. If snd_expr was a real expression that
computed a new value, then the next garbage collection
will reclaim the sound_node. We need to explicitly
free the copy since the garbage collector cannot find
it.
will reclaim the sound_node.
*/
s = sound_copy(s);
gc();
s = sound_copy(getsound(result));
result = cvsound(s);
while (1) {
#ifdef OSC
if (nosc_enabled) nosc_poll();
@ -1480,8 +1533,9 @@ void sound_play(snd_expr)
/* print_sample_block_type("sound_play", sampblock, blocklen); */
ntotal += blocklen;
}
nyquist_printf("total samples: %d\n", ntotal);
sound_unref(s);
nyquist_printf("total samples: %" PRId64 "\n", ntotal);
xlpop();
return ntotal;
}
@ -1549,7 +1603,6 @@ void sound_print_tree_1(snd, n)
(int)snd_list->u.susp->log_stop_cnt,
snd_list->u.susp->sr,
snd_list->u.susp->t0, snd_list);
/* stdputstr("HI THERE AGAIN\n");*/
susp_print_tree(snd_list->u.susp, n + 4);
return;
}
@ -1662,8 +1715,8 @@ void sound_xlmark(void *a_sound)
stdputstr("local variable or parameter that is being passed to\n");
stdputstr("SEQ or SEQREP. The garbage collector assumes that\n");
stdputstr("sounds are not recursive or circular, and follows\n");
stdputstr("sounds to their end. After following a more nodes,\n");
stdputstr("than can exist, I'm pretty sure that there is a\n");
stdputstr("sounds to their end. After following 1M nodes,\n");
stdputstr("I'm pretty sure that there is a\n");
stdputstr("cycle here, but since this is a bug, I cannot promise\n");
stdputstr("to recover. Prepare to crash. If you cannot locate\n");
stdputstr("the cause of this, contact the author -RBD.\n");
@ -1697,8 +1750,7 @@ void sound_symbols()
/* The SOUND Type: */
boolean soundp(s)
LVAL s;
boolean soundp(LVAL s)
{
return (exttypep(s, a_sound));
}
@ -1725,8 +1777,7 @@ sound_type sound_zero(time_type t0,rate_type sr)
}
LVAL cvsound(s)
sound_type s;
LVAL cvsound(sound_type s)
{
/* nyquist_printf("cvsound(%p)\n", s);*/
return (cvextern(sound_desc, (unsigned char *) s));

View File

@ -9,7 +9,7 @@
#include "stdefs.h"
/* used for *AUDIO-MARKERS* */
extern long sound_frames;
extern int64_t sound_frames;
extern double sound_srate;
extern long max_sample_blocks;
@ -25,7 +25,7 @@ extern int nosc_enabled; /* enable polling for OSC messages */
#define PERMS 0644 /* -rw-r--r-- */
/* default stop sample count (for clipping) */
#define MAX_STOP 0x7FFFFFFF
#define MAX_STOP 0x7FFFFFFFFFFFFFFF
/* default stop time (for clipping) */
#define MAX_STOP_TIME 10E20
@ -228,7 +228,7 @@ extern int nosc_enabled; /* enable polling for OSC messages */
#define INTERP_SHIFT 2
LVAL snd_badsr(void);
long check_terminate_cnt(long tc);
int64_t check_terminate_cnt(int64_t tc);
typedef double time_type;
typedef double rate_type;
@ -248,8 +248,8 @@ typedef double promoted_sample_type;
production
*/
/* leave a few words short of 1024 in case we allocate powers of 2 */
#define max_sample_block_len 1020
/* #define max_sample_block_len 4 */
#define max_sample_block_len 1016
// #define max_sample_block_len 4
/* longest allowed sample is basically 2^31 but a bit lower to
allow for rounding */
@ -274,25 +274,18 @@ typedef struct {
/* forward declaration for circular type dependencies */
typedef struct snd_list_struct *snd_list_type;
struct snd_susp_struct;
typedef void (*snd_fetch_fn)(struct snd_susp_struct *, snd_list_type snd_list);
typedef void (*snd_free_fn)(struct snd_susp_struct *);
typedef void (*snd_mark_fn)(struct snd_susp_struct *); /* marks LVAL nodes for GC */
typedef void (*snd_print_tree_fn)(struct snd_susp_struct *, int);
typedef struct snd_susp_struct {
snd_fetch_fn fetch;
void (*fetch)(struct snd_susp_struct *, snd_list_type snd_list);
void (*keep_fetch)(struct snd_susp_struct *, snd_list_type snd_list);
snd_free_fn free;
snd_mark_fn mark;
snd_print_tree_fn print_tree; /* debugging */
void (*free)(struct snd_susp_struct *);
void (*mark)(struct snd_susp_struct *); /* marks LVAL nodes for GC */
void (*print_tree)(struct snd_susp_struct *, int); /* debugging */
char *name; /* string name for debugging */
long toss_cnt; /* return this many zeros, then compute */
long current; /* current sample number */
int64_t toss_cnt; /* return this many zeros, then compute */
int64_t current; /* current sample number */
double sr; /* sample rate */
time_type t0; /* starting time */
long log_stop_cnt; /* logical stop count */
int64_t log_stop_cnt; /* logical stop count */
/* other susp dependent stuff will be here... */
} snd_susp_node, *snd_susp_type;
@ -325,26 +318,26 @@ typedef struct table_struct {
#define UNKNOWN (-10-max_sample_block_len)
typedef struct sound_struct {
sample_block_type (*get_next)(struct sound_struct *snd, long *cnt);
sample_block_type (*get_next)(struct sound_struct *snd, int *cnt);
time_type time; /* logical starting time */
time_type t0; /* quantized time of first sample */
long stop; /* stop (clipping) sample no. */
int64_t stop; /* stop (clipping) sample no. */
time_type true_t0; /* exact time of first sample */
rate_type sr; /* sample rate */
long current; /* current sample number,
int64_t current; /* current sample number,
if negative, then the first
-current samples must be dropped
in order to find the first sample */
long logical_stop_cnt; /* log stop sample no, -1=unknwn */
int64_t logical_stop_cnt; /* log stop sample no, -1=unknwn */
snd_list_type list; /* sample block list, starting at curr. samp */
sample_type scale; /* scale factor for the result */
long prepend_cnt; /* how many zeros to prepend */
int64_t prepend_cnt; /* how many zeros to prepend */
/* function to use as get_next after prepended zeros are generated: */
sample_block_type (*after_prepend)
(struct sound_struct * snd, long * cnt);
(struct sound_struct * snd, int *cnt);
table_type table; /* pointer to table-ized version of this sound */
long *extra; /* used for extra state information, first word of extra
state should be the length of the extra state
int64_t *extra; /* used for extra state information, extra[0]
should be the length of the extra state
(see sound_unref()) */
} sound_node, *sound_type;
@ -359,7 +352,7 @@ extern snd_list_type zero_snd_list;
extern sound_type printing_this_sound; /* debugging global */
long snd_set_max_audio_mem(long m);
int64_t snd_set_max_audio_mem(int64_t m);
/* LISP: (SND-SET-MAX-AUDIO-MEM FIXNUM) */
extern double sound_latency; /* controls output latency */
@ -379,10 +372,10 @@ void snd_list_unref(snd_list_type list);
LVAL cvsound(sound_type);
extern LVAL a_sound;
sample_block_type SND_get_next(sound_type snd, long * cnt);
sample_block_type SND_get_first(sound_type snd, long * cnt);
sample_block_type SND_get_zeros(sound_type snd, long * cnt);
sample_block_type SND_flush(sound_type snd, long * cnt);
sample_block_type SND_get_next(sound_type snd, int *cnt);
sample_block_type SND_get_first(sound_type snd, int *cnt);
sample_block_type SND_get_zeros(sound_type snd, int *cnt);
sample_block_type SND_flush(sound_type snd, int *cnt);
double hz_to_step(double); /* LISP: (HZ-TO-STEP ANYNUM) */
int interp_style(sound_type s, rate_type sr);
@ -415,7 +408,7 @@ sound_type snd_xform(sound_type snd, rate_type sr, time_type time,
sound_type sound_create(snd_susp_type susp, time_type t0, rate_type sr,
promoted_sample_type scale);
void min_cnt(long *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt);
void min_cnt(int64_t *cnt_ptr, sound_type sound, snd_susp_type susp, long cnt);
void indent(int n);
void sound_prepend_zeros(sound_type snd, time_type t0);
@ -426,18 +419,20 @@ void sound_prepend_zeros(sound_type snd, time_type t0);
extern long blocks_to_watch_len;
extern sample_block_type blocks_to_watch[blocks_to_watch_max];
void block_watch(long sample_block);
void block_watch(int64_t sample_block);
/* LISP: (BLOCK-WATCH FIXNUM) */
long sound_nth_block(sound_type snd, long n);
/* LISP: (SOUND-NTH-BLOCK SOUND FIXNUM) */
int64_t sound_nth_block(sound_type snd, long n);
/* LISP: (SOUND-NTH-BLOCK SOUND LONG) */
#endif
LVAL sound_array_copy(LVAL sa);
sound_type sound_copy(sound_type snd);
/* LISP: (SND-COPY SOUND) */
void sound_xlmark(void *a_sound);
void sound_print(LVAL snd_expr, long n);
/* LISP: (SND-PRINT ANY FIXNUM) */
void sound_play(LVAL snd_expr);
/* LISP: (SND-PRINT ANY LONG) */
int64_t sound_play(LVAL snd_expr);
/* LISP: (SND-PLAY ANY) */
void stats(void);
/* LISP: (STATS) */
@ -545,32 +540,22 @@ double step_to_hz(double);
*/
#define susp_check_term_log_block_samples(sound, sample_block_ptr, sample_ptr, sample_cnt, bit, all) \
if (susp->sample_cnt == 0) { \
susp_get_block_samples(sound, sample_block_ptr, sample_ptr, sample_cnt); \
/*OLD if (susp->sound->logical_stop_cnt == \
susp->sound->current - susp->sample_cnt) { \
*/ \
susp_get_block_samples(sound, sample_block_ptr, \
sample_ptr, sample_cnt); \
if (susp->sound->logical_stop_cnt != UNKNOWN && \
!(susp->logical_stop_bits & bit)) { \
susp->logical_stop_bits |= bit; \
/*OLD \
if (susp->logical_stop_bits == all) { \
susp->susp.log_stop_cnt = (long) \
((((susp->sound->current - susp->sample_cnt) / \
susp->sound->sr + susp->sound->t0) - \
susp->susp.t0) * susp->susp.sr + 0.5); \
assert(susp->susp.log_stop_cnt >= 0); } } \
*/ \
susp->susp.log_stop_cnt = max(susp->susp.log_stop_cnt, \
susp->susp.log_stop_cnt = (int64_t) max(susp->susp.log_stop_cnt, \
(((susp->sound->logical_stop_cnt / \
susp->sound->sr + susp->sound->t0) - \
susp->susp.t0) * susp->susp.sr + 0.5)); } \
if (susp->sample_ptr == zero_block->samples) { \
susp->terminate_bits |= bit; \
if (susp->terminate_bits == all) { \
susp->terminate_cnt = (long) \
((((susp->sound->current - susp->sample_cnt) / \
susp->sound->sr + susp->sound->t0) - \
susp->susp.t0) * susp->susp.sr + 0.5); \
susp->terminate_cnt = ROUNDBIG( \
(((susp->sound->current - susp->sample_cnt) / \
susp->sound->sr + susp->sound->t0) - \
susp->susp.t0) * susp->susp.sr); \
} } }
@ -584,7 +569,7 @@ double step_to_hz(double);
*/
#define logical_stop_cnt_cvt(sound) \
(sound->logical_stop_cnt == UNKNOWN ? UNKNOWN : \
ROUND32((sound->logical_stop_cnt / sound->sr) * susp->susp.sr))
ROUNDBIG((sound->logical_stop_cnt / sound->sr) * susp->susp.sr))
/* logical_stop_test tests to see if sound has logically stopped; if so,

View File

@ -14,10 +14,10 @@ void stoponzero_free(snd_susp_type a_susp);
typedef struct stoponzero_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type s1;
long s1_cnt;
int s1_cnt;
sample_block_values_type s1_ptr;
} stoponzero_susp_node, *stoponzero_susp_type;
@ -50,7 +50,7 @@ void stoponzero_n_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo < 0) togo = 0; /* avoids rounding errros */
if (togo == 0) break;
}
@ -58,7 +58,8 @@ void stoponzero_n_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
int64_t to_stop = (susp->susp.log_stop_cnt -
(susp->susp.current + cnt));
/* break if to_stop == 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the
* output block).
@ -77,7 +78,7 @@ void stoponzero_n_fetch(snd_susp_type a_susp, snd_list_type snd_list)
} else /* limit togo so we can start a new
* block at the LST
*/
togo = to_stop;
togo = (int) to_stop;
}
}
@ -132,8 +133,8 @@ void stoponzero_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
susp_get_samples(s1, s1_ptr, s1_cnt);
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
n = ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr -
(susp->s1->current - susp->s1_cnt));
n = (int) ROUNDBIG((final_time - susp->s1->t0) * susp->s1->sr -
(susp->s1->current - susp->s1_cnt));
susp->s1_ptr += n;
susp_took(s1_cnt, n);
susp->susp.fetch = susp->susp.keep_fetch;

View File

@ -61,15 +61,15 @@ typedef struct trigger_susp_struct {
snd_susp_node susp;
boolean started;
int terminate_bits;
long terminate_cnt;
int64_t terminate_cnt;
int logical_stop_bits;
boolean logically_stopped;
sound_type s1;
long s1_cnt;
int s1_cnt;
sample_block_type s1_bptr; /* block pointer */
sample_block_values_type s1_ptr;
sound_type s2;
long s2_cnt;
int s2_cnt;
sample_block_type s2_bptr; /* block pointer */
sample_block_values_type s2_ptr;
@ -81,7 +81,7 @@ typedef struct trigger_susp_struct {
void trigger_fetch(snd_susp_type, snd_list_type);
void trigger_free();
void trigger_free(snd_susp_type a_susp);
extern LVAL s_stdout;
@ -122,7 +122,7 @@ void trigger_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo == 0) break;
}
@ -135,7 +135,7 @@ void trigger_fetch(snd_susp_type a_susp, snd_list_type snd_list)
trigger_susp_type new_trigger;
sound_type new_trigger_snd;
LVAL result;
long delay; /* sample delay to s2 */
int64_t delay; /* sample delay to s2 */
time_type now;
susp->previous = s; /* don't retrigger */
@ -275,9 +275,7 @@ void trigger_print_tree(snd_susp_type a_susp, int n)
sound_type snd_make_trigger(s1, closure)
sound_type s1;
LVAL closure;
sound_type snd_make_trigger(sound_type s1, LVAL closure)
{
register trigger_susp_type susp;
/* t0 specified as input parameter */
@ -321,9 +319,7 @@ sound_type snd_make_trigger(s1, closure)
}
sound_type snd_trigger(s1, closure)
sound_type s1;
LVAL closure;
sound_type snd_trigger(sound_type s1, LVAL closure)
{
sound_type s1_copy;
s1_copy = sound_copy(s1);

View File

@ -1,3 +1,3 @@
sound_type snd_make_trigger();
sound_type snd_trigger();
sound_type snd_make_trigger(sound_type s1, LVAL closure);
sound_type snd_trigger(sound_type s1, LVAL closure);
/* LISP: (SND-TRIGGER SOUND ANY) */

View File

@ -12,17 +12,17 @@
#include "yin.h"
void yin_free();
void yin_free(snd_susp_type a_susp);
/* for multiple channel results, one susp is shared by all sounds */
/* the susp in turn must point back to all sound list tails */
typedef struct yin_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type s;
long s_cnt;
int s_cnt;
sample_block_values_type s_ptr;
long blocksize;
long stepsize;
@ -31,9 +31,9 @@ typedef struct yin_susp_struct {
sample_type *fillptr;
sample_type *endptr;
snd_list_type chan[2]; /* array of back pointers */
long cnt; /* how many sample frames to read */
long m;
long middle;
int cnt; /* how many sample frames to read */
int m;
int middle;
} yin_susp_node, *yin_susp_type;
/* DEBUG CODE:
@ -392,18 +392,21 @@ void yin_fetch(snd_susp_type a_susp, snd_list_type snd_list)
/* don't run past the s input sample block */
susp_check_term_log_samples(s, s_ptr, s_cnt);
togo = min(togo, susp->s_cnt);
togo = (int) min(togo, susp->s_cnt);
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo/susp->stepsize) {
togo = (susp->terminate_cnt - (susp->susp.current + cnt)) * susp->stepsize;
susp->terminate_cnt <=
susp->susp.current + cnt + togo/susp->stepsize) {
togo = (int) ((susp->terminate_cnt - (susp->susp.current + cnt)) *
susp->stepsize);
if (togo == 0) break;
}
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
int64_t to_stop = susp->susp.log_stop_cnt -
(susp->susp.current + cnt);
/* break if to_stop = 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the output block)
*/
@ -417,7 +420,7 @@ void yin_fetch(snd_susp_type a_susp, snd_list_type snd_list)
*/
susp->logically_stopped = true;
} else /* limit togo so we can start a new block a the LST */
togo = to_stop * susp->stepsize;
togo = (int) (to_stop * susp->stepsize);
}
}
n = togo;
@ -545,10 +548,10 @@ LVAL snd_make_yin(sound_type s, double low_step, double high_step, long stepsize
susp->susp.current = 0;
susp->s = s;
susp->s_cnt = 0;
susp->m = (long) (sr / step_to_hz(high_step));
susp->m = (int) (sr / step_to_hz(high_step));
if (susp->m < 2) susp->m = 2;
/* add 1 to make sure we round up */
susp->middle = (long) (sr / step_to_hz(low_step)) + 1;
susp->middle = (int) (sr / step_to_hz(low_step)) + 1;
susp->blocksize = susp->middle * 2;
susp->stepsize = stepsize;
/* blocksize must be at least step size to implement stepping */

View File

@ -2,5 +2,5 @@
LVAL snd_yin(sound_type s, double low_step, double high_step, long stepsize);
/* LISP: (SND-YIN SOUND ANYNUM ANYNUM FIXNUM) */
/* LISP: (SND-YIN SOUND ANYNUM ANYNUM LONG) */

View File

@ -72,15 +72,12 @@ void Delay :: setMaximumDelay(unsigned long delay)
{
if ( delay < inputs_.size() ) return;
/*
if ( delay < 0 ) {
errorString_ << "Delay::setMaximumDelay: argument (" << delay << ") less than zero!\n";
handleError( StkError::WARNING );
return;
}
else
*/
if (delay < delay_ ) {
else if (delay < delay_ ) {
errorString_ << "Delay::setMaximumDelay: argument (" << delay << ") less than current delay setting (" << delay_ << ")!\n";
handleError( StkError::WARNING );
return;
@ -100,7 +97,6 @@ void Delay :: setDelay(unsigned long delay)
if ( outPoint_ == inputs_.size() ) outPoint_ = 0;
delay_ = inputs_.size() - 1;
}
/*
else if ( delay < 0 ) {
errorString_ << "Delay::setDelay: argument (" << delay << ") less than zero ... setting to zero!\n";
handleError( StkError::WARNING );
@ -108,7 +104,6 @@ void Delay :: setDelay(unsigned long delay)
outPoint_ = inPoint_;
delay_ = 0;
}
*/
else { // read chases write
if ( inPoint_ >= delay ) outPoint_ = inPoint_ - delay;
else outPoint_ = inputs_.size() + inPoint_ - delay;
@ -124,19 +119,19 @@ unsigned long Delay :: getDelay(void) const
StkFloat Delay :: energy(void) const
{
unsigned long i;
StkFloat e = 0;
register StkFloat e = 0;
if (inPoint_ >= outPoint_) {
for (i=outPoint_; i<inPoint_; i++) {
StkFloat t = inputs_[i];
register StkFloat t = inputs_[i];
e += t*t;
}
} else {
for (i=outPoint_; i<inputs_.size(); i++) {
StkFloat t = inputs_[i];
register StkFloat t = inputs_[i];
e += t*t;
}
for (i=0; i<inPoint_; i++) {
StkFloat t = inputs_[i];
register StkFloat t = inputs_[i];
e += t*t;
}
}

View File

@ -48,7 +48,7 @@ void Stk :: setRawwavePath( std::string path )
void Stk :: swap16(unsigned char *ptr)
{
unsigned char val;
register unsigned char val;
// Swap 1st and 2nd bytes
val = *(ptr);
@ -58,7 +58,7 @@ void Stk :: swap16(unsigned char *ptr)
void Stk :: swap32(unsigned char *ptr)
{
unsigned char val;
register unsigned char val;
// Swap 1st and 4th bytes
val = *(ptr);
@ -74,7 +74,7 @@ void Stk :: swap32(unsigned char *ptr)
void Stk :: swap64(unsigned char *ptr)
{
unsigned char val;
register unsigned char val;
// Swap 1st and 8th bytes
val = *(ptr);

View File

@ -16,10 +16,10 @@
#include <sgtty.h>
#include "cext.h"
extern int IOinputfd; /* input file descriptor (usually 0) */
int IOinputfd; /* input file descriptor (usually 0) */
extern int IOnochar; /* Value to be returned by IOgetchar()
where there is no input to be had */
int IOnochar; /* Value to be returned by IOgetchar()
where there is no input to be had */
static struct sgttyb IOoldmodes, IOcurrentmodes;
/* Initial and current tty modes */

View File

@ -36,6 +36,8 @@
* advertised.
* 28-OCT-05 Roger Dannenberg at CMU-SCS
* added directory listing functions
* 9-JUL-2020 Roger Dannenberg
* added get-real-time lisp function
*/
#include "switches.h"
@ -44,6 +46,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <dirent.h>
@ -80,12 +83,19 @@ static char lbuf[LBSIZE];
static int lpos[LBSIZE];
#endif
#if USE_RAND
#if __APPLE__
#else
#include <time.h>
#endif
#endif
static int echo_enabled = 1;
/* forward declarations */
FORWARD LOCAL void xflush();
FORWARD LOCAL int xcheck();
FORWARD LOCAL void hidden_msg();
FORWARD LOCAL void xflush(void);
FORWARD LOCAL int xcheck(void);
FORWARD LOCAL void hidden_msg(void);
/*==========================================================================*/
/* control-c interrupt handling routines and variables. Uses B4.2 signal
@ -96,14 +106,13 @@ FORWARD LOCAL void hidden_msg();
#include <signal.h>
static int ctc = FALSE;
static void control_c(int x) {ctc = TRUE;}
void ctcinit() {signal ( SIGINT, control_c );}
static void ctcreset() {signal ( SIGINT, control_c );}
static void control_c(int x) {ctc = TRUE;}
void ctcinit(void) {signal ( SIGINT, control_c );}
static void ctcreset(void) {signal ( SIGINT, control_c );}
/*==========================================================================*/
const char os_pathchar = '/';
const char os_sepchar = ':';
@ -112,6 +121,10 @@ const char os_sepchar = ':';
void osinit(const char *banner)
{
printf("%s\n",banner);
if (max_sample_block_len < 64) {
printf("Warning: max_sample_block_len %d is small. Maybe you forgot"
" to reset it after debugging.\n", max_sample_block_len);
}
/* start the random number generator. Older version was srand(1)
seed of 1 makes the sequence repeatable. Random gives better
pseudo randomness than does rand().
@ -164,7 +177,8 @@ void oserror(const char *msg) {printf("error: %s\n",msg);}
/* osaopen - open an ascii file */
FILE *osaopen(name,mode) const char *name,*mode; {
FILE *osaopen(const char *name, const char *mode)
{
FILE *fp = NULL;
if (ok_to_open(name, mode))
fp = fopen(name,mode);
@ -237,7 +251,7 @@ int osbputc(ch,fp) int ch; FILE *fp; {return (putc(ch,fp));}
#ifdef OLDEST_OSTGETC
/* ostgetc - get a character from the terminal */
int ostgetc()
int ostgetc(void)
{
int ch;
switch (ch = term_getchar()) {
@ -293,7 +307,7 @@ int ostgetc()
#else
#if OLD_OSTGETC
/* ostgetc - get a character from the terminal */
int ostgetc()
int ostgetc(void)
{ int ch;
for (;;) {
@ -328,7 +342,7 @@ int readline_first = 1;
extern int xldebug;
int ostgetc()
int ostgetc(void)
{
int rval;
@ -364,7 +378,7 @@ int ostgetc()
#else /* no readline */
void end_of_line_edit()
void end_of_line_edit(void)
{
line_edit = FALSE;
if (tfp) {
@ -375,7 +389,7 @@ void end_of_line_edit()
}
/* THIS IS THE "REAL" ostgetc(): */
LOCAL int rawtchar()
LOCAL int rawtchar(void)
{
int ch;
if (typeahead_tail != typeahead_head) {
@ -392,7 +406,7 @@ LOCAL int rawtchar()
return ch;
}
int ostgetc()
int ostgetc(void)
{
/*
* NOTE: lbuf[] accumulates characters as they are typed
@ -561,7 +575,7 @@ void ostputc(int ch)
}
/* ostoutflush - flush output buffer */
void ostoutflush()
void ostoutflush(void)
{
if (tfp) fflush(tfp);
fflush(stdout);
@ -585,7 +599,7 @@ void osflush(void)
*
* This function assumes that '\016' has been received already.
*/
LOCAL void hidden_msg()
LOCAL void hidden_msg(void)
{
#define MSGBUF_MAX 64
char msgbuf[MSGBUF_MAX];
@ -687,14 +701,14 @@ void oscheck(void)
}
/* xflush - flush the input line buffer and start a new line */
LOCAL void xflush()
LOCAL void xflush(void)
{
osflush();
ostputc('\n');
}
/* xsystem - execute a system command */
LVAL xsystem()
LVAL xsystem(void)
{ /*LVAL strval;*/
unsigned char *cmd = NULL;
if (SAFE_NYQUIST) return NULL;
@ -706,7 +720,7 @@ LVAL xsystem()
/* xsetdir -- set current directory of the process */
LVAL xsetdir()
LVAL xsetdir(void)
{
char *dir = (char *)getstring(xlgastring());
int result = -1;
@ -738,13 +752,13 @@ LVAL xsetdir()
}
/* xget_temp_path -- get a path to create temp files */
LVAL xget_temp_path()
LVAL xget_temp_path(void)
{
return cvstring("/tmp/");
}
/* xget_user -- get a string identifying the user, for use in file names */
LVAL xget_user()
LVAL xget_user(void)
{
const char *user = getenv("USER");
if (!user || !*user) {
@ -756,7 +770,7 @@ LVAL xget_user()
/* xechoenabled -- set/clear echo_enabled flag (unix only) */
LVAL xechoenabled()
LVAL xechoenabled(void)
{
int flag = (xlgetarg() != NULL);
xllastarg();
@ -789,7 +803,7 @@ int osdir_list_start(const char *path)
/* osdir_list_next -- read the next entry from a directory */
const char *osdir_list_next()
const char *osdir_list_next(void)
{
if (osdir_list_status != OSDIR_LIST_STARTED) {
return NULL;
@ -805,7 +819,7 @@ const char *osdir_list_next()
/* osdir_list_finish -- close an open directory */
void osdir_list_finish()
void osdir_list_finish(void)
{
if (osdir_list_status != OSDIR_LIST_READY) {
closedir(osdir_dir);
@ -815,18 +829,26 @@ void osdir_list_finish()
/* xcheck -- return a character if one is present */
LOCAL int xcheck()
LOCAL int xcheck(void)
{
int ch = term_testchar();
return ch;
}
/* xgetkey - get a key from the keyboard */
LVAL xgetkey() {xllastarg(); return (cvfixnum((FIXTYPE)term_getchar()));}
LVAL xgetkey(void) {xllastarg(); return (cvfixnum((FIXTYPE)term_getchar()));}
/* ossymbols - enter os specific symbols */
void ossymbols(void) {}
/* xsetupconsole -- used to configure window in Win32 version */
LVAL xsetupconsole() { return NIL; }
LVAL xsetupconsole(void) { return NIL; }
/* xgetrealtime - get current time in seconds */
LVAL xgetrealtime(void)
{
struct timeval te;
gettimeofday(&te, NULL); // get current time
return cvflonum((double) te.tv_sec + (te.tv_usec * 1e-6));
}

View File

@ -191,7 +191,9 @@
/* NYQUIST tells some CMT code that we're really in
* XLISP and NYQUIST
*/
#ifndef NYQUIST
#define NYQUIST 1
#endif
/* If SAFE_NYQUIST is defined, Nyquist will prevent:
* - writes anywhere except in the directory tree

View File

@ -19,7 +19,7 @@
#include <unistd.h>
#include <stdio.h>
void ctcinit();
void ctcinit(void);
/* This will be used for new terminal settings. */
static struct termios current;
@ -34,14 +34,14 @@ void term_restore(void)
}
/* Clean up termianl; called on exit. */
void term_exit()
void term_exit(void)
{
term_restore();
}
/* Will be called when contrl-Z is pressed;
* this correctly handles the terminal. */
void term_ctrlz()
void term_ctrlz(int i)
{
signal(SIGTSTP, term_ctrlz);
term_restore();
@ -50,12 +50,18 @@ void term_ctrlz()
/* Will be called when the application is continued
* after having been stopped. */
void term_cont()
void term_cont(int i)
{
signal(SIGCONT, term_cont);
tcsetattr(0, TCSANOW, &current);
}
/* callback for SIGQUIT is different type from atexit callback */
void term_quit(int i)
{
term_exit();
}
/* Needs to be called to initialize the terminal. */
void term_init(void)
{
@ -67,7 +73,7 @@ void term_init(void)
/* We _must_ clean up when we exit. */
/* signal(SIGINT, term_exit); */
ctcinit(); /* XLisp wants to catch ctrl C */
signal(SIGQUIT, term_exit);
signal(SIGQUIT, term_quit);
/* Control-Z must also be handled. */
signal(SIGTSTP, term_ctrlz);
signal(SIGCONT, term_cont);
@ -103,7 +109,7 @@ void term_line(void)
*
* if ready, return it, otherwise return -2
*/
int term_testchar()
int term_testchar(void)
{
int n;
char c;
@ -124,7 +130,7 @@ int term_testchar()
/* term_getchar -- get a character (block if necessary) */
/**/
int term_getchar()
int term_getchar(void)
{
char c;
int rslt = read(0, &c, 1);

View File

@ -1,6 +1,6 @@
void term_init();
void term_exit();
void ctcinit(); /* not implemented in term.h */
int term_testchar();
int term_getchar();
void term_character();
void term_init(void);
void term_exit(void);
void ctcinit(void); /* not implemented in term.h */
int term_testchar(void);
int term_getchar(void);
void term_character(void);

View File

@ -82,7 +82,7 @@ static char *linebuf = NULL, *lineptr;
static int numChars;
/* input thread */
unsigned long input_thread_handle = -1;
static uintptr_t input_thread_handle = -1;
#define NEED_INPUT if (input_thread_handle == -1) start_input_thread();
#define input_buffer_max 1024
#define input_buffer_mask (input_buffer_max - 1)
@ -425,3 +425,18 @@ LVAL xechoenabled()
}
/* xgetrealtime - get current time in seconds */
LVAL xgetrealtime()
{
static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL);
SYSTEMTIME system_time;
FILETIME file_time;
uint64_t time;
GetSystemTime(&system_time);
SystemTimeToFileTime(&system_time, &file_time);
time = (uint64_t) file_time.dwLowDateTime;
time += ((uint64_t) file_time.dwHighDateTime) << 32;
time -= EPOCH;
time /= 10000000L;
return cvflonum((double) time + system_time.wMilliseconds * 0.001);
}

View File

@ -0,0 +1 @@
Run command-line nyquist in this directory and type (m) to regenerate all .c and .h files. See translate.lsp for other commands to translate individual files or groups of files.

View File

@ -14,10 +14,10 @@ void abs_free(snd_susp_type a_susp);
typedef struct abs_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type input;
long input_cnt;
int input_cnt;
sample_block_values_type input_ptr;
} abs_susp_node, *abs_susp_type;
@ -39,94 +39,94 @@ void abs_n_fetch(snd_susp_type a_susp, snd_list_type snd_list)
snd_list->block = out;
while (cnt < max_sample_block_len) { /* outer loop */
/* first compute how many samples to generate in inner loop: */
/* don't overflow the output sample block: */
togo = max_sample_block_len - cnt;
/* first compute how many samples to generate in inner loop: */
/* don't overflow the output sample block: */
togo = max_sample_block_len - cnt;
/* don't run past the input input sample block: */
susp_check_term_log_samples(input, input_ptr, input_cnt);
togo = min(togo, susp->input_cnt);
/* don't run past the input input sample block: */
susp_check_term_log_samples(input, input_ptr, input_cnt);
togo = min(togo, susp->input_cnt);
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
if (togo < 0) togo = 0; /* avoids rounding errros */
if (togo == 0) break;
}
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo < 0) togo = 0; /* avoids rounding errros */
if (togo == 0) break;
}
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
/* break if to_stop == 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the
* output block).
*/
if (to_stop < 0) to_stop = 0; /* avoids rounding errors */
if (to_stop < togo) {
if (to_stop == 0) {
if (cnt) {
togo = 0;
break;
} else /* keep togo as is: since cnt == 0, we
* can set the logical stop flag on this
* output block
*/
susp->logically_stopped = true;
} else /* limit togo so we can start a new
* block at the LST
*/
togo = to_stop;
}
}
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
/* break if to_stop == 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the
* output block).
*/
if (to_stop < 0) to_stop = 0; /* avoids rounding errors */
if (to_stop < togo) {
if (to_stop == 0) {
if (cnt) {
togo = 0;
break;
} else /* keep togo as is: since cnt == 0, we
* can set the logical stop flag on this
* output block
*/
susp->logically_stopped = true;
} else /* limit togo so we can start a new
* block at the LST
*/
togo = (int) to_stop;
}
}
n = togo;
input_ptr_reg = susp->input_ptr;
out_ptr_reg = out_ptr;
if (n) do { /* the inner sample computation loop */
n = togo;
input_ptr_reg = susp->input_ptr;
out_ptr_reg = out_ptr;
if (n) do { /* the inner sample computation loop */
{ sample_type s = *input_ptr_reg++;
sample_type o = s;
if (o < 0.0) o = -o;
*out_ptr_reg++ = o; };
} while (--n); /* inner loop */
} while (--n); /* inner loop */
/* using input_ptr_reg is a bad idea on RS/6000: */
susp->input_ptr += togo;
out_ptr += togo;
susp_took(input_cnt, togo);
cnt += togo;
/* using input_ptr_reg is a bad idea on RS/6000: */
susp->input_ptr += togo;
out_ptr += togo;
susp_took(input_cnt, togo);
cnt += togo;
} /* outer loop */
/* test for termination */
if (togo == 0 && cnt == 0) {
snd_list_terminate(snd_list);
snd_list_terminate(snd_list);
} else {
snd_list->block_len = cnt;
susp->susp.current += cnt;
snd_list->block_len = cnt;
susp->susp.current += cnt;
}
/* test for logical stop */
if (susp->logically_stopped) {
snd_list->logically_stopped = true;
snd_list->logically_stopped = true;
} else if (susp->susp.log_stop_cnt == susp->susp.current) {
susp->logically_stopped = true;
susp->logically_stopped = true;
}
} /* abs_n_fetch */
void abs_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
{
abs_susp_type susp = (abs_susp_type) a_susp;
time_type final_time = susp->susp.t0;
long n;
int n;
/* fetch samples from input up to final_time for this block of zeros */
while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >=
susp->input->current)
susp_get_samples(input, input_ptr, input_cnt);
susp->input->current)
susp_get_samples(input, input_ptr, input_cnt);
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr -
n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr -
(susp->input->current - susp->input_cnt));
susp->input_ptr += n;
susp_took(input_cnt, n);

View File

@ -14,10 +14,10 @@ void allpoles_free(snd_susp_type a_susp);
typedef struct allpoles_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
boolean logically_stopped;
sound_type x_snd;
long x_snd_cnt;
int x_snd_cnt;
sample_block_values_type x_snd_ptr;
long ak_len;
@ -52,47 +52,47 @@ void allpoles_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
snd_list->block = out;
while (cnt < max_sample_block_len) { /* outer loop */
/* first compute how many samples to generate in inner loop: */
/* don't overflow the output sample block: */
togo = max_sample_block_len - cnt;
/* first compute how many samples to generate in inner loop: */
/* don't overflow the output sample block: */
togo = max_sample_block_len - cnt;
/* don't run past the x_snd input sample block: */
susp_check_term_log_samples(x_snd, x_snd_ptr, x_snd_cnt);
togo = min(togo, susp->x_snd_cnt);
/* don't run past the x_snd input sample block: */
susp_check_term_log_samples(x_snd, x_snd_ptr, x_snd_cnt);
togo = min(togo, susp->x_snd_cnt);
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
if (togo < 0) togo = 0; /* avoids rounding errros */
if (togo == 0) break;
}
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo < 0) togo = 0; /* avoids rounding errros */
if (togo == 0) break;
}
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
/* break if to_stop == 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the
* output block).
*/
if (to_stop < 0) to_stop = 0; /* avoids rounding errors */
if (to_stop < togo) {
if (to_stop == 0) {
if (cnt) {
togo = 0;
break;
} else /* keep togo as is: since cnt == 0, we
* can set the logical stop flag on this
* output block
*/
susp->logically_stopped = true;
} else /* limit togo so we can start a new
* block at the LST
*/
togo = to_stop;
}
}
/* don't run past logical stop time */
if (!susp->logically_stopped && susp->susp.log_stop_cnt != UNKNOWN) {
int64_t to_stop = susp->susp.log_stop_cnt - (susp->susp.current + cnt);
/* break if to_stop == 0 (we're at the logical stop)
* AND cnt > 0 (we're not at the beginning of the
* output block).
*/
if (to_stop < 0) to_stop = 0; /* avoids rounding errors */
if (to_stop < togo) {
if (to_stop == 0) {
if (cnt) {
togo = 0;
break;
} else /* keep togo as is: since cnt == 0, we
* can set the logical stop flag on this
* output block
*/
susp->logically_stopped = true;
} else /* limit togo so we can start a new
* block at the LST
*/
togo = (int) to_stop;
}
}
if (susp->ak_array == NULL) {
@ -120,15 +120,15 @@ void allpoles_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
}
n = togo;
ak_len_reg = susp->ak_len;
gain_reg = susp->gain;
ak_coefs_reg = susp->ak_coefs;
zk_buf_reg = susp->zk_buf;
index_reg = susp->index;
x_snd_ptr_reg = susp->x_snd_ptr;
out_ptr_reg = out_ptr;
if (n) do { /* the inner sample computation loop */
n = togo;
ak_len_reg = susp->ak_len;
gain_reg = susp->gain;
ak_coefs_reg = susp->ak_coefs;
zk_buf_reg = susp->zk_buf;
index_reg = susp->index;
x_snd_ptr_reg = susp->x_snd_ptr;
out_ptr_reg = out_ptr;
if (n) do { /* the inner sample computation loop */
double z0; long xi; long xj; z0 = (x_snd_scale_reg * *x_snd_ptr_reg++)*gain_reg;
for (xi=0; xi < ak_len_reg ; xi++) {
xj = index_reg + xi; if (xj >= ak_len_reg) xj -= ak_len_reg;
@ -137,46 +137,46 @@ void allpoles_s_fetch(snd_susp_type a_susp, snd_list_type snd_list)
zk_buf_reg[index_reg] = z0;
index_reg++; if (index_reg == ak_len_reg) index_reg = 0;
*out_ptr_reg++ = (sample_type) z0;
} while (--n); /* inner loop */
} while (--n); /* inner loop */
susp->zk_buf = zk_buf_reg;
susp->index = index_reg;
/* using x_snd_ptr_reg is a bad idea on RS/6000: */
susp->x_snd_ptr += togo;
out_ptr += togo;
susp_took(x_snd_cnt, togo);
cnt += togo;
susp->zk_buf = zk_buf_reg;
susp->index = index_reg;
/* using x_snd_ptr_reg is a bad idea on RS/6000: */
susp->x_snd_ptr += togo;
out_ptr += togo;
susp_took(x_snd_cnt, togo);
cnt += togo;
} /* outer loop */
/* test for termination */
if (togo == 0 && cnt == 0) {
snd_list_terminate(snd_list);
snd_list_terminate(snd_list);
} else {
snd_list->block_len = cnt;
susp->susp.current += cnt;
snd_list->block_len = cnt;
susp->susp.current += cnt;
}
/* test for logical stop */
if (susp->logically_stopped) {
snd_list->logically_stopped = true;
snd_list->logically_stopped = true;
} else if (susp->susp.log_stop_cnt == susp->susp.current) {
susp->logically_stopped = true;
susp->logically_stopped = true;
}
} /* allpoles_s_fetch */
void allpoles_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
{
allpoles_susp_type susp = (allpoles_susp_type) a_susp;
time_type final_time = susp->susp.t0;
long n;
int n;
/* fetch samples from x_snd up to final_time for this block of zeros */
while ((ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr)) >=
susp->x_snd->current)
susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt);
susp->x_snd->current)
susp_get_samples(x_snd, x_snd_ptr, x_snd_cnt);
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
n = ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr -
n = (int) ROUNDBIG((final_time - susp->x_snd->t0) * susp->x_snd->sr -
(susp->x_snd->current - susp->x_snd_cnt));
susp->x_snd_ptr += n;
susp_took(x_snd_cnt, n);

View File

@ -14,9 +14,9 @@ void alpass_free(snd_susp_type a_susp);
typedef struct alpass_susp_struct {
snd_susp_node susp;
long terminate_cnt;
int64_t terminate_cnt;
sound_type input;
long input_cnt;
int input_cnt;
sample_block_values_type input_ptr;
double feedback;
@ -47,67 +47,67 @@ void alpass_n_fetch(snd_susp_type a_susp, snd_list_type snd_list)
snd_list->block = out;
while (cnt < max_sample_block_len) { /* outer loop */
/* first compute how many samples to generate in inner loop: */
/* don't overflow the output sample block: */
togo = max_sample_block_len - cnt;
/* first compute how many samples to generate in inner loop: */
/* don't overflow the output sample block: */
togo = max_sample_block_len - cnt;
/* don't run past the input input sample block: */
susp_check_term_samples(input, input_ptr, input_cnt);
togo = min(togo, susp->input_cnt);
/* don't run past the input input sample block: */
susp_check_term_samples(input, input_ptr, input_cnt);
togo = min(togo, susp->input_cnt);
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = susp->terminate_cnt - (susp->susp.current + cnt);
if (togo < 0) togo = 0; /* avoids rounding errros */
if (togo == 0) break;
}
/* don't run past terminate time */
if (susp->terminate_cnt != UNKNOWN &&
susp->terminate_cnt <= susp->susp.current + cnt + togo) {
togo = (int) (susp->terminate_cnt - (susp->susp.current + cnt));
if (togo < 0) togo = 0; /* avoids rounding errros */
if (togo == 0) break;
}
n = togo;
feedback_reg = susp->feedback;
delayptr_reg = susp->delayptr;
endptr_reg = susp->endptr;
input_ptr_reg = susp->input_ptr;
out_ptr_reg = out_ptr;
if (n) do { /* the inner sample computation loop */
n = togo;
feedback_reg = susp->feedback;
delayptr_reg = susp->delayptr;
endptr_reg = susp->endptr;
input_ptr_reg = susp->input_ptr;
out_ptr_reg = out_ptr;
if (n) do { /* the inner sample computation loop */
register sample_type y, z;
y = *delayptr_reg;
*delayptr_reg++ = z = (sample_type) (feedback_reg * y + *input_ptr_reg++);
*out_ptr_reg++ = (sample_type) (y - feedback_reg * z);
if (delayptr_reg >= endptr_reg) delayptr_reg = susp->delaybuf;
} while (--n); /* inner loop */
} while (--n); /* inner loop */
susp->delayptr = delayptr_reg;
/* using input_ptr_reg is a bad idea on RS/6000: */
susp->input_ptr += togo;
out_ptr += togo;
susp_took(input_cnt, togo);
cnt += togo;
susp->delayptr = delayptr_reg;
/* using input_ptr_reg is a bad idea on RS/6000: */
susp->input_ptr += togo;
out_ptr += togo;
susp_took(input_cnt, togo);
cnt += togo;
} /* outer loop */
/* test for termination */
if (togo == 0 && cnt == 0) {
snd_list_terminate(snd_list);
snd_list_terminate(snd_list);
} else {
snd_list->block_len = cnt;
susp->susp.current += cnt;
snd_list->block_len = cnt;
susp->susp.current += cnt;
}
} /* alpass_n_fetch */
void alpass_toss_fetch(snd_susp_type a_susp, snd_list_type snd_list)
{
{
alpass_susp_type susp = (alpass_susp_type) a_susp;
time_type final_time = susp->susp.t0;
long n;
int n;
/* fetch samples from input up to final_time for this block of zeros */
while ((ROUNDBIG((final_time - susp->input->t0) * susp->input->sr)) >=
susp->input->current)
susp_get_samples(input, input_ptr, input_cnt);
susp->input->current)
susp_get_samples(input, input_ptr, input_cnt);
/* convert to normal processing when we hit final_count */
/* we want each signal positioned at final_time */
n = ROUNDBIG((final_time - susp->input->t0) * susp->input->sr -
n = (int) ROUNDBIG((final_time - susp->input->t0) * susp->input->sr -
(susp->input->current - susp->input_cnt));
susp->input_ptr += n;
susp_took(input_cnt, n);

View File

@ -14,8 +14,8 @@
(TERMINATE (MIN input))
(INNER-LOOP-LOCALS " register sample_type y, z, fb;\n")
(INNER-LOOP "y = *delayptr;
*delayptr++ = z = (sample_type)
((fb = feedback) * y + input);
*delayptr++ = z =
((fb = (sample_type) feedback) * y + input);
output = (sample_type) (y - fb * z);
if (delayptr >= endptr) delayptr = susp->delaybuf")
(FINALIZATION "free(susp->delaybuf);")

Some files were not shown because too many files have changed in this diff Show More