1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-04 09:39:42 +02:00
Leland Lucius 15b9bb96cd 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.
2021-01-27 23:45:25 -06:00

301 lines
11 KiB
C

/* seq.h -- definitions for seq, the MIDI Toolkit sequence data type */
#define minpitch 0
#define maxpitch 127
#define NO_PITCH (maxpitch+1)
#define minprogram 1
#define maxprogram 128
/* keep these two lines in sync */
#define nmacroparms 4
#define parm_expected_error "Parameter number [1-4] expected"
#define seq_dflt_loud 127
#define seq_dflt_voice 1
#define seq_dflt_pitch 60
struct clock_struct {
time_type ticksize;
};
struct ctrlramp_struct {
unsigned char from_value;
unsigned char to_value;
};
struct deframp_struct {
unsigned char *definition;
short parameter[nmacroparms];
unsigned char parm_num;
short to_value;
};
struct macctrl_struct {
unsigned char ctrl_number;
unsigned char value;
};
struct macro_struct {
unsigned char *definition;
short parameter[nmacroparms];
};
struct note_struct {
long ndur; /* duration */
/* char nloud; loudness (MIDI velocity) now stored as low order byte
* of ndur
*/
};
struct ramp_struct {
time_type dur;
short ctrl; /* encode pitch bend and after touch as negative */
short step;
union {
struct ctrlramp_struct ctrl;
struct deframp_struct def;
} u;
};
struct seti_struct {
int *int_to_set;
int value;
};
#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 {
seq_cmd_fn routine;
/* make a structure so we can copy by value */
seq_arg_t args;
};
typedef struct event_struct {
struct event_struct *next;
time_type ntime; /* start time */
short nline; /* line number from source code */
unsigned char nvoice; /* adagio voice (MIDI Channel)
* if this is a control change, high order 4 bits
* contain the control number, otherwise high order
* 4 bits are 0 (see is_note macro below)
*/
unsigned char value;
/* this is a note pitch or a control value. It goes
* here rather than in the union to achieve word
* alignment (!). Also, value is used for extra commands
* such as call, seti, setv.
*/
union {
struct cause_struct call;
struct clock_struct clock;
struct macctrl_struct macctrl;
struct macro_struct macro;
struct note_struct note;
struct ramp_struct ramp;
struct seti_struct seti;
} u;
} event_node, *event_type;
#define PSWITCH_CTRL 1
#define MODWHEEL_CTRL 2
#define TOUCH_CTRL 3
#define VOLUME_CTRL 4
#define BEND_CTRL 5
#define PROGRAM_CTRL 6
#define ESC_CTRL 7
#define CALL_VALUE 0
#define CLOCK_VALUE 1
#define MACCTRL_VALUE 2
#define MACRO_VALUE 3
#define CTRLRAMP_VALUE 4
#define DEFRAMP_VALUE 5
#define SETI_VALUE 6
#define commonsize (sizeof(struct event_struct) - sizeof(struct cause_struct))
#define rampcommon (sizeof(struct ramp_struct) - sizeof(struct deframp_struct))
#define ctrlsize commonsize
#define callsize (commonsize + sizeof(struct cause_struct))
#define clocksize (commonsize + sizeof(struct clock_struct))
#define ctrlrampsize (commonsize + rampcommon + sizeof(struct ctrlramp_struct))
#define deframpsize (commonsize + sizeof(struct ramp_struct))
#define macctrlsize (commonsize + sizeof(struct macctrl_struct))
#define macrosize (commonsize + sizeof(struct macro_struct))
#define notesize (commonsize + sizeof(struct note_struct))
#define setisize (commonsize + sizeof(struct seti_struct))
#define ctrl_voice(c, v) (((c) << 5) + ((v) - 1))
#define vc_ctrl(v) ((v) >> 5)
#define vc_voice(v) (((v) & 0x1F) + 1)
#define is_note(n) (((n)->nvoice & 0xE0) == 0)
#define CHUNK_SIZE 2000
typedef struct def_struct {
struct def_struct *next;
char *symbol;
unsigned char *definition;
} def_node, *def_type;
typedef struct chunk_struct {
struct chunk_struct *next;
short free;
union {
char data[CHUNK_SIZE];
struct info_struct {
short refcount;
struct chunk_struct *last_chunk; /* where to allocate memory */
def_type dictionary; /* macro defns, routine addresses */
event_type eventlist; /* first event in sequence */
ulong used_mask; /* tells what channels are actually present */
long ctrlcount;
long notecount;
time_type duration; /* time of the last event+dur in score */
} info;
} u;
} chunk_node, *chunk_type;
typedef struct seq_struct {
void (*cause_noteoff_fn)(struct seq_struct *, time_type, int, int);
void (*midi_bend_fn)(struct seq_struct * seq, int voice, int value);
void (*midi_ctrl_fn)(struct seq_struct * seq, int voice, int ctrl, int value);
void (*midi_program_fn)(struct seq_struct * seq, int voice, int prog);
void (*midi_touch_fn)(struct seq_struct * seq, int voice, int value);
void (*noteoff_fn)(call_args_type args);
void (*noteon_fn)(struct seq_struct * seq, int chan, int pitch, int vel);
void (*free_fn)(struct seq_struct * seq);
void (*reset_fn)(struct seq_struct * seq);
void (*stopfunc)(struct seq_struct *);
chunk_type chunklist;
/* event_type eventlist;
seq->eventlist is now seq->eventlist->chunklist */
event_type current;
boolean runflag; /* normally true, set to false as a flag for
* processes started by score to terminate */
boolean note_enable; /* normally true, set to false as a flag to
* suppress note output, e.g. when indexing
* to a particular time point */
boolean cycleflag; /* normally false, set to true to make the
* sequence cycle every cycledur */
int transpose;
int loudness;
time_type cycledur;
timebase_type timebase;
time_type rate; /* remembers rate across pauses */
boolean paused; /* remembers if seq has been stopped or not */
short noteoff_count; /* keeps track of pending events, such as
* note off commands. When this count goes
* to zero, the score is finished */
ulong channel_mask;
} seq_node, *seq_type;
extern seq_type sequence;
chunk_type chunk_create(boolean first_flag);
#define seq_cause_noteoff(seq, delay, voice, pitch) \
(*(((seq_type) seq)->cause_noteoff_fn))(seq, delay, voice, pitch)
#define seq_midi_bend(seq, voice, value) \
(*(((seq_type) seq)->midi_bend_fn))(seq, voice, value)
#define seq_midi_ctrl(seq, voice, ctrl, value) \
(*(((seq_type) seq)->midi_ctrl_fn))(seq, voice, ctrl, value)
#define seq_midi_program(seq, voice, prog) \
(*(((seq_type) seq)->midi_program_fn))(seq, voice, prog)
#define seq_midi_touch(seq, voice, value) \
(*(((seq_type) seq)->midi_touch_fn))(seq, voice, value)
#define seq_noteoff(seq, args) \
(*(((seq_type) seq)->noteoff_fn))(args)
#define seq_noteon(seq, voice, pitch, vel) \
(*(((seq_type) seq)->noteon_fn))(seq, voice, pitch, vel)
#define seq_free(seq) (*(((seq_type) seq)->free_fn))(seq)
#define seq_register(seq) \
cu_register((cu_fn_type) (((seq_type) seq)->free_fn), seq)
#define seq_reset(seq) (*(((seq_type) seq)->reset_fn))(seq)
/* LISP: void (SEQ-RESET SEQ) */
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)(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 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 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,
time_type step, time_type dur, def_type def,
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 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 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);
seq_type seq_alloc(void);
void seq_at_end(seq_type seq, void (*fn)(seq_type));
void seq_cause_noteoff_meth(seq_type seq, time_type delay, int voice, int pitch);
#define seq_channel_mask(seq) ((seq)->channel_mask)
seq_type seq_copy(seq_type from_seq); /* LISP: (SEQ-COPY SEQ) */
seq_type seq_create(void); /* LISP: (SEQ-CREATE) */
void seq_cycle(seq_type seq, boolean flag, time_type dur);
#define seq_duration(seq) (((seq_type) seq)->chunklist->u.info.duration)
void seq_end_event(call_args_type args);
#define seq_events(seq) (((seq_type) seq)->chunklist ? \
(((seq_type) seq)->chunklist->u.info.eventlist) : NULL)
#define seq_dictionary(seq) (seq)->chunklist->u.info.dictionary
#define seq_eventlist(seq) (seq)->chunklist->u.info.eventlist
#define seq_ctrlcount(seq) (seq)->chunklist->u.info.ctrlcount
#define seq_notecount(seq) (seq)->chunklist->u.info.notecount
#define seq_used_mask(seq) (seq)->chunklist->u.info.used_mask
void seq_free_chunks(seq_type seq);
seq_type seq_init(seq_type seq, int create_chunk);
#define seq_loudness(seq) (((seq_type) seq)->loudness)
void seq_midi_bend_meth(seq_type seq, int voice, int value);
void seq_midi_ctrl_meth(seq_type seq, int voice, int ctrl, int value);
void seq_midi_program_meth(seq_type seq, int voice, int prog);
void seq_midi_touch_meth(seq_type seq, int voice, int value);
void seq_noteon_meth(seq_type seq, int voice, int pitch, int vel);
void seq_noteoff_meth(call_args_type args);
time_type seq_pause(seq_type seq, boolean flag);
void seq_play(seq_type seq);
#define seq_rate(seq) ((seq_type) seq)->rate
void seq_reset_meth(seq_type seq);
#define seq_runflag(seq) ((seq_type) seq)->runflag
#define seq_set_channel_mask(seq, cm) ((seq)->channel_mask) = (cm)
void seq_set_loudness(seq_type seq, int offset);
void seq_set_rate(seq_type seq, time_type rate);
#define seq_set_timebase(seq, tb) ((seq_type) seq)->timebase = (tb)
void seq_set_transpose(seq_type seq, int trans);
void seq_start_time(seq_type seq, time_type start_time);
void seq_stop(seq_type seq);
#define seq_timebase(seq) ((seq_type) seq)->timebase
#define seq_transpose(seq) ((seq_type) seq)->transpose