1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-27 07:40:10 +01:00

Update Nyquist to v3.09.

This commit is contained in:
Leland Lucius
2015-04-07 22:10:17 -05:00
parent f88b27e6d8
commit 9fb0ce5b82
358 changed files with 26327 additions and 7043 deletions

View File

@@ -89,6 +89,13 @@
#include "ctype.h"
#include "string.h"
/* this should really be defined in security.h, but it is in xlisp.h.
* I don't want to add an xlisp dependency here, nor do I want to
* create security.h since that's not how xlisp does things.
* The C++ linker will type check so this is at least type safe.
*/
int ok_to_open(const char *filename, const char *mode);
#define syntax_max 10 /* allow for 10 syntax strings */
private char *syntax[syntax_max];
private int n_syntax = 0; /* number of strings so far */
@@ -440,9 +447,11 @@ private void indirect_command(filename, oldarg0)
char *filename;
char *oldarg0;
{
FILE *argfile = fopen(filename, "r");
FILE *argfile = NULL;
if (ok_to_open(filename, "r"))
argfile = fopen(filename, "r");
if (!argfile) {
argv = (char **) malloc(sizeof(char *));
argv = (char **) malloc(sizeof(char *));
argv[0] = oldarg0;
argc = 1;
} else {

View File

@@ -1,27 +1,27 @@
extern void midifile();
extern int (*Mf_getc)();
extern void (*Mf_header)();
extern void (*Mf_starttrack)();
extern void (*Mf_endtrack)();
extern void (*Mf_on)();
extern void (*Mf_off)();
extern void (*Mf_pressure)();
extern void (*Mf_controller)();
extern void (*Mf_pitchbend)();
extern void (*Mf_program)();
extern void (*Mf_chanpressure)();
extern void (*Mf_sysex)();
extern void (*Mf_metamisc)();
extern void (*Mf_sqspecific)();
extern void (*Mf_seqnum)();
extern void (*Mf_text)();
extern void (*Mf_eot)();
extern void (*Mf_timesig)();
extern void (*Mf_smpte)();
extern void (*Mf_tempo)();
extern void (*Mf_keysig)();
extern void (*Mf_arbitrary)();
extern void (*Mf_error)();
extern void midifile(void);
extern int (*Mf_getc)(void);
extern void (*Mf_header)(int,int,int);
extern void (*Mf_starttrack)(void);
extern void (*Mf_endtrack)(void);
extern void (*Mf_on)(int,int,int);
extern void (*Mf_off)(int,int,int);
extern void (*Mf_pressure)(int,int,int);
extern void (*Mf_controller)(int,int,int);
extern void (*Mf_pitchbend)(int,int,int);
extern void (*Mf_program)(int,int);
extern void (*Mf_chanpressure)(int,int);
extern void (*Mf_sysex)(int,char*);
extern void (*Mf_metamisc)(int,int,char*);
extern void (*Mf_sqspecific)(int,char*);
extern void (*Mf_seqnum)(int);
extern void (*Mf_text)(int,int,char*);
extern void (*Mf_eot)(void);
extern void (*Mf_timesig)(int,int,int,int);
extern void (*Mf_smpte)(int,int,int,int,int);
extern void (*Mf_tempo)(int);
extern void (*Mf_keysig)(int,int);
extern void (*Mf_arbitrary)(int,char*);
extern void (*Mf_error)(char *);
extern long Mf_currtime;
extern int Mf_nomerge;
extern int Mf_skipinit;

View File

@@ -600,7 +600,20 @@ boolean rec_init(boolean bender)
/* it would be silly to record with only room enough for 10 notes! */
}
#ifdef NEED_REC_EVENT
/*
This function was part of the CMU MIDI Toolkit. It provided a constant time
fast way to record midi data into a buffer. After recording, the buffered
data could be transferred into an Adagio score structure, which involved
linked list allocation and insertion that might have caused performance
problems. This code uses the high-order bit of longs to distinguish timestamps
from data (MIDI messages), but the code seems to assume little endian, and
I'm not sure how it worked on both Intel and 68000 processors. Rather than
look more closely or fix it, I'm commenting it out because Nyquist does not
have any MIDI I/O capability and does not need the function. It is here for
completeness, since this is probably the only archived version of the CMU
MIDI Toolkit. */
/****************************************************************************
* rec_event
* Inputs:
@@ -636,3 +649,5 @@ overflow:
gprintf(ERROR, "No more memory.\n");
return FALSE;
}
#endif

View File

@@ -35,14 +35,15 @@ boolean clock_running = FALSE; /* TRUE if clock is running */
boolean external_midi_clock = FALSE;
boolean suppress_midi_clock = FALSE;
private void insert_event();
private void process_event();
private void insert_event(seq_type, register event_type);
private void process_event(seq_type);
private char *chunk_alloc();
private void clock_tick();
private char *chunk_alloc(seq_type seq, int size);
private void clock_tick(seq_type seq, time_type fraction);
private void ramp_event(seq_type seq, event_type event, unsigned int value,
unsigned int to_value, int increment, time_type step, int n);
/*private*/ void send_macro();
/*private*/ void send_macro(register unsigned char *ptr, int voice,
short parameter[], int parm_num, int value, int nline);
/* chunk_alloc -- allocate data for a sequence */
/*
@@ -103,9 +104,7 @@ chunk_type chunk_create(boolean first_flag)
/* clock_tick -- advance the clock and send a tick */
/**/
private void clock_tick(seq, fraction)
seq_type seq;
time_type fraction;
private void clock_tick(seq_type seq, time_type fraction)
{
int delay;
fraction += clock_ticksize;
@@ -121,8 +120,7 @@ private void clock_tick(seq, fraction)
}
}
private void cycle(seq)
seq_type seq;
private void cycle(seq_type seq)
{
seq_reset(seq);
seq_play(seq);
@@ -828,11 +826,7 @@ void seq_at_end(seq, fn)
/* seq_cause_noteoff_meth -- turn off a note in the future */
/**/
void seq_cause_noteoff_meth(seq, delay, voice, pitch)
seq_type seq;
time_type delay;
int voice;
int pitch;
void seq_cause_noteoff_meth(seq_type seq, time_type delay, int voice, int pitch)
{
if (seq->note_enable) {
pitch += seq->transpose;
@@ -1021,10 +1015,7 @@ void seq_midi_touch_meth(seq_type seq, int voice, int value)
/* seq_noteoff_meth -- turn a seq note off */
/**/
void seq_noteoff_meth(seq, voice, pitch)
seq_type seq;
int voice;
int pitch;
void seq_noteoff_meth(seq_type seq, int voice, int pitch)
{
midi_note(voice, pitch, 0);
/*gprintf(TRANS, "_e");*/
@@ -1034,9 +1025,7 @@ void seq_noteoff_meth(seq, voice, pitch)
/* seq_noteon_meth -- play a note with transformations */
/**/
void seq_noteon_meth(seq, chan, pitch, vel)
seq_type seq;
int chan, pitch, vel;
void seq_noteon_meth(seq_type seq, int chan, int pitch, int vel)
{
if (seq->note_enable) {
pitch += seq->transpose;
@@ -1100,8 +1089,7 @@ void seq_play(seq)
/* seq_reset_meth -- reset a sequence to start back at the first event */
/**/
void seq_reset_meth(seq)
seq_type seq;
void seq_reset_meth(seq_type seq)
{
timebase_type old_timebase = timebase;

View File

@@ -168,15 +168,15 @@ typedef struct chunk_struct {
typedef struct seq_struct {
void (*cause_noteoff_fn)();
void (*midi_bend_fn)();
void (*midi_ctrl_fn)();
void (*midi_program_fn)();
void (*midi_touch_fn)();
void (*noteoff_fn)();
void (*noteon_fn)();
void (*free_fn)();
void (*reset_fn)();
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)(struct seq_struct * seq, int voice, int pitch);
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;

View File

@@ -167,9 +167,6 @@ private void smfw_dotrack(seq)
unsigned long chunk_size;
if (seq->runflag) {
if ((seq->timebase->virt_base == 0) &&
(seq->timebase->rate == STOPRATE))
/*we just set these last time through... do nothing*/;
seq_stop(seq);
}
timebase_use(seq->timebase);
@@ -541,8 +538,9 @@ void seq_write_smf(seq, outfile)
event = seq_events(smfw_seq.seq);
/*search for clock events up till start of score*/
while(event->ntime <= 0){
/* search for clock events up till start of score */
/* careful: there may be no events at all */
while(event && event->ntime <= 0){
if(debug) gprintf(TRANS, "event (time:%ld)\n", event->ntime);
if(vc_ctrl(event->nvoice) == ESC_CTRL && event->value == CLOCK_VALUE) {
if(debug) gprintf(TRANS, "clock %lu at 0\n", event->u.clock.ticksize);
@@ -570,55 +568,61 @@ void seq_write_smf(seq, outfile)
putc(0x02, smfw_seq.outfile);/*division resolution of 600*/
putc(0x58, smfw_seq.outfile);
for(i = 0; i < 17; i++){/*for each track..*/
if(((seq_used_mask(smfw_seq.seq) >> (i - 1)) & 0x1) || (i == 0)){
if(debug) gprintf(TRANS, "write track %d \n", i);
track_count++;
clock_ticksize = starting_ticksize;
last_tick_size = starting_ticksize;
putc(0x4D, smfw_seq.outfile);/*track header: MTrk*/
putc(0x54, smfw_seq.outfile);
putc(0x72, smfw_seq.outfile);
putc(0x6B, smfw_seq.outfile);
for (i = 0; i < 17; i++) { /* for each track... */
if (((seq_used_mask(smfw_seq.seq) >> (i - 1)) & 0x1) || (i == 0)) {
if (debug) gprintf(TRANS, "write track %d \n", i);
track_count++;
clock_ticksize = starting_ticksize;
last_tick_size = starting_ticksize;
putc(0x4D, smfw_seq.outfile);/*track header: MTrk*/
putc(0x54, smfw_seq.outfile);
putc(0x72, smfw_seq.outfile);
putc(0x6B, smfw_seq.outfile);
chunk_size_marker = ftell(smfw_seq.outfile);/*size of chunk will be written later*/
putc(0x00, smfw_seq.outfile); /*will be filled by chunk_size_marker*/
putc(0x00, smfw_seq.outfile);
putc(0x00, smfw_seq.outfile);
putc(0x00, smfw_seq.outfile);
if(i == 0) { /*tempo and time signature track*/
putc(0x00, smfw_seq.outfile);/* default time sig stuff*/
putc(0xFF, smfw_seq.outfile);
putc(0x58, smfw_seq.outfile);
putc(0x04, smfw_seq.outfile);
putc(0x04, smfw_seq.outfile);
putc(0x02, smfw_seq.outfile);
putc(0x18, smfw_seq.outfile);
putc(0x08, smfw_seq.outfile);
chunk_size_marker = ftell(smfw_seq.outfile);
/* size of chunk will be written later */
/* will be filled by chunk_size_marker */
putc(0x00, smfw_seq.outfile);
putc(0x00, smfw_seq.outfile);
putc(0x00, smfw_seq.outfile);
putc(0x00, smfw_seq.outfile);
if (i == 0) { /* tempo and time signature track */
putc(0x00, smfw_seq.outfile);/* default time sig stuff*/
putc(0xFF, smfw_seq.outfile);
putc(0x58, smfw_seq.outfile);
putc(0x04, smfw_seq.outfile);
putc(0x04, smfw_seq.outfile);
putc(0x02, smfw_seq.outfile);
putc(0x18, smfw_seq.outfile);
putc(0x08, smfw_seq.outfile);
putc(0x00, smfw_seq.outfile);
putc(0xFF, smfw_seq.outfile);/*TEMPO: inserted here in case default is used*/
putc(0x51, smfw_seq.outfile);
putc(0x03, smfw_seq.outfile);
/* ticksize is in ms<<16, so to get milliseconds per tick, it's
ticksize / 65536. To get beat durations, multiply by 24 to get
ticksize * 24 / 65536. To get microseconds, multiply by 1000:
ticksize * 24000 / 65536. Divide both constants by 64 to get
ticksize * 375 / 1024 = microseconds per quarter note.
*/
put_tick_size = scale(clock_ticksize, 375L, 1024L);
putc((int) ((put_tick_size >> 16) & 0xFF), smfw_seq.outfile);
putc((int) ((put_tick_size >> 8) & 0xFF), smfw_seq.outfile);
putc((int) (put_tick_size & 0xFF), smfw_seq.outfile);
/* TEMPO: inserted here in case default is used */
putc(0xFF, smfw_seq.outfile);
putc(0x51, smfw_seq.outfile);
putc(0x03, smfw_seq.outfile);
/* ticksize is in ms<<16, so to get milliseconds per tick, it's
ticksize / 65536. To get beat durations, multiply by 24
to get ticksize * 24 / 65536. To get microseconds,
multiply by 1000: ticksize * 24000 / 65536. Divide both
constants by 64 to get ticksize * 375 / 1024 =
microseconds per quarter note.
*/
put_tick_size = scale(clock_ticksize, 375L, 1024L);
putc((int) ((put_tick_size >> 16) & 0xFF), smfw_seq.outfile);
putc((int) ((put_tick_size >> 8) & 0xFF), smfw_seq.outfile);
putc((int) (put_tick_size & 0xFF), smfw_seq.outfile);
}
smfw_seq.track = i;
smfw_dotrack(smfw_seq.seq);
}
smfw_seq.track = i;
smfw_dotrack(smfw_seq.seq);
}
}
if(seti_counter) gprintf(TRANS, "%d SETI events IGNORED!\n", seti_counter);
if (seti_counter)
gprintf(TRANS, "%d SETI events IGNORED!\n", seti_counter);
seq_stop(smfw_seq.seq);
fseek(smfw_seq.outfile, track_count_marker, 0);/*go back and insert number of tracks*/
/* go back and insert number of tracks */
fseek(smfw_seq.outfile, track_count_marker, 0);
putc(0xFF & track_count, smfw_seq.outfile);
fclose(smfw_seq.outfile);
}

View File

@@ -139,7 +139,7 @@
#ifndef NYQUIST
#define MIDIMGR
#endif
#define USE_VSPRINTF
#define HAVE_VSNPRINTF 1
#endif
#ifdef BORLAND
@@ -161,12 +161,12 @@
#define ITC
#endif
/* USE_VSPRINTF says vsprintf() is defined */
/* HAVE_VSNPRINTF says vsnprintf() is defined */
#ifdef ITC
#define USE_VSPRINTF
#define HAVE_VSNPRINTF 1
#endif
#ifdef AZTEC
#define USE_VSPRINTF
#define HAVE_VSNPRINTF 1
#endif

View File

@@ -537,8 +537,14 @@ FILE *fileopen(deflt, extension, mode, prompt)
strcpy(extname, fileopen_name);
strcat(extname, ".");
strcat(extname, extension);
fp = fopen(fileopen_name, mode);
fpext = fopen(extname, mode);
fp = NULL;
fpext = NULL;
if (ok_to_open(fileopen_name, mode)) {
fp = fopen(fileopen_name, mode);
}
if (ok_to_open(extname, mode)) {
fpext = fopen(extname, mode);
}
if (fp != NULL && fpext != NULL) {
gprintf(TRANS,
"warning: both %s and %s exist. %s will be used.\n",
@@ -566,7 +572,9 @@ FILE *fileopen(deflt, extension, mode, prompt)
&& added_extension
#endif
) {
fp = fopen(fileopen_name, "r");
fp = NULL;
if (ok_to_open(fileopen_name, "r"))
fp = fopen(fileopen_name, "r");
if (fp != NULL) {
char question[100];
fclose(fp);
@@ -579,7 +587,9 @@ FILE *fileopen(deflt, extension, mode, prompt)
}
}
}
fp = fopen(fileopen_name, mode);
fp = NULL;
if (ok_to_open(fileopen_name, mode))
fp = fopen(fileopen_name, mode);
if (fp == NULL) problem = "Couldn't create %s.\n";
}
tryagain:
@@ -592,7 +602,6 @@ FILE *fileopen(deflt, extension, mode, prompt)
return fp;
}
#ifdef MACINTOSH
static int GetReadFileName(name)
@@ -786,7 +795,7 @@ void readln(fp)
* Note that to handle the variable argument list, a number of different
* approaches are implemented. The first part of the implementation selects
* one of 4 ways to build temp1, a formatted string. The 4 ways arise from
* use or non-use of vsprintf, and use or non-use of ... in the arg list.
* use or non-use of vsnprintf, and use or non-use of ... in the arg list.
* After building temp1, non-Amiga systems write to stdout or stderr,
* whereas AMIGA writes to a special console. Why? Because the Amiga
* needs a new console so we can set up a signal upon character typein.
@@ -794,10 +803,10 @@ void readln(fp)
#ifndef gprintf
#define GPRINTF_MESSAGE_LEN 512
#ifdef USE_VSPRINTF
#ifdef HAVE_VSNPRINTF
#ifdef DOTS_FOR_ARGS
/* define with ... in arg list and use vsprintf to get temp1 */
/* define with ... in arg list and use vsnprintf to get temp1 */
public void gprintf(long where, char *format, ...)
{
char temp1[GPRINTF_MESSAGE_LEN];
@@ -807,12 +816,12 @@ public void gprintf(long where, char *format, ...)
va_list ap;
va_start(ap, format);
vsprintf(temp1, format, ap);
vsnprintf(temp1, GPRINTF_MESSAGE_LEN, format, ap);
va_end(ap);
#else /* !DOTS_FOR_ARGS */
/* define with va_alist and use vsprintf to get temp1 */
/* define with va_alist and use vsnprintf to get temp1 */
public void gprintf(where, format, va_alist)
long where;
char *format;
@@ -823,19 +832,19 @@ va_dcl
/* this is a syntax error - if you don't have to remove this, */
/* then this whole section of code is unnecessary. */
va_start(pvar);
vsprintf(temp1, format, pvar);
vsnprintf(temp1, GPRINTF_MESSAGE_LEN, format, pvar);
va_end(pvar);
#endif /* DOTS_FOR_ARGS */
#else /* !USE_VSPRINTF */
#else /* !HAVE_VSNPRINTF */
#define MAX_GPRINTF_ARGS 10
typedef struct gp_args_struct {
long arg[MAX_GPRINTF_ARGS];
} gp_args_node;
#ifdef DOTS_FOR_ARGS
/* use ... but not vsprintf */
/* use ... but not vsnprintf */
public void gprintf(long where, char *format, ...)
{
char temp1[GPRINTF_MESSAGE_LEN];
@@ -848,7 +857,7 @@ public void gprintf(long where, char *format, ...)
args = va_arg(ap, gp_args_node);
va_end(ap);
#else /* !DOTS_FOR_ARGS */
/* don't use ... and don't use vsprintf */
/* don't use ... and don't use vsnprintf */
public void gprintf(where, format, args)
long where;
char *format;
@@ -860,9 +869,9 @@ public void gprintf(where, format, args)
#endif /* AMIGA*/
#endif /* DOTS_FOR_ARGS */
sprintf(temp1, format, args);
snprintf(temp1, GPRINTF_MESSAGE_LEN, format, args);
#endif /* USE_VSPRINTF */
#endif /* HAVE_VSNPRINTF */
/*
* Now we've got formatted output in temp1. Write it out.