diff -c -r /users/boyce/c-source/csound_orig/makefile /users/boyce/c-source/csound/makefile
*** /users/boyce/c-source/csound_orig/makefile	Thu Mar 17 10:41:35 1994
--- /users/boyce/c-source/csound/makefile	Wed Sep 21 23:21:47 1994
***************
*** 26,32 ****
  #	.c.o:
  #		$(CC) $(CFLAGS) -c $*.c -o $@
  
! DEFINES = -DWINDOWS -DRTAUDIO -DSFIRCAM -DDEC
  # choose any of -
  #	-DSYS5	    invoke System 5 headers (e.g. 'string.h' for 'strings.h')
  #	-DWINDOWS   include window system calls (X11, SGI, or FG graphics)
--- 26,32 ----
  #	.c.o:
  #		$(CC) $(CFLAGS) -c $*.c -o $@
  
! DEFINES = -DNeXT
  # choose any of -
  #	-DSYS5	    invoke System 5 headers (e.g. 'string.h' for 'strings.h')
  #	-DWINDOWS   include window system calls (X11, SGI, or FG graphics)
***************
*** 44,50 ****
  #	-Dsun		send rtaudio calls to sun audio device handler
  #	-DHP		send rtaudio calls to HP  audio device handler
  
! CFLAGS = -O -f $(DEFINES)
  #	-O2		to be more specific about the optimization level
  #	-f		compile single-precision floats (4.3,VAX,DEC-RISC)
  # 	-fsingle	as above, for SUN Unix
--- 44,50 ----
  #	-Dsun		send rtaudio calls to sun audio device handler
  #	-DHP		send rtaudio calls to HP  audio device handler
  
! CFLAGS = -O -pipe $(DEFINES)
  #	-O2		to be more specific about the optimization level
  #	-f		compile single-precision floats (4.3,VAX,DEC-RISC)
  # 	-fsingle	as above, for SUN Unix
***************
*** 61,67 ****
  #	-I/usr/include/X11R4		to find HP X11 includes, v.4
  #	-I/usr/include/sys		to find NeXT malloc.h
  
! LIBS =	-lX11 -lm
  #	-lm		    		required
  #	-lX11				for X window calls
  #	-L/usr/lib/X11R4		for HP X11 library, v.4
--- 61,67 ----
  #	-I/usr/include/X11R4		to find HP X11 includes, v.4
  #	-I/usr/include/sys		to find NeXT malloc.h
  
! LIBS = -lm
  #	-lm		    		required
  #	-lX11				for X window calls
  #	-L/usr/lib/X11R4		for HP X11 library, v.4
***************
*** 74,86 ****
  #	-lAlib				on HP, to include rt devaudio library
  #	-lmidi				on NeXT, to find the midi support
  
! WINOBJ = winX11.o
  # ;if WINDOWS enabled in DEFINES, choose one of -
  #	winX11.o	for X11 window graphics
  #	winSGI.o	for SGI window graphics
  #	winfg.o 	for PC  Flash Graphics
  
! AUDOBJ = rtaudio.o DECaudio.o DECplay.o
  # ;if RTAUDIO enabled in DEFINES, include
  #	rtaudio.o		general interface to audio handlers & libraries
  # and at most one set of -
--- 74,86 ----
  #	-lAlib				on HP, to include rt devaudio library
  #	-lmidi				on NeXT, to find the midi support
  
! WINOBJ =
  # ;if WINDOWS enabled in DEFINES, choose one of -
  #	winX11.o	for X11 window graphics
  #	winSGI.o	for SGI window graphics
  #	winfg.o 	for PC  Flash Graphics
  
! AUDOBJ = 
  # ;if RTAUDIO enabled in DEFINES, include
  #	rtaudio.o		general interface to audio handlers & libraries
  # and at most one set of -
***************
*** 90,96 ****
  #				blank for SUN audio lib  (with -Dsun)
  #	[other things]		device handlers for other hardware
  
! AUDHDR = DECplay.h
  # ;if RTAUDIO enabled include
  #	DECplay.h		for rtaudio and DECplay (with -DDEC)
  # ;else leave blank
--- 90,96 ----
  #				blank for SUN audio lib  (with -Dsun)
  #	[other things]		device handlers for other hardware
  
! AUDHDR = 
  # ;if RTAUDIO enabled include
  #	DECplay.h		for rtaudio and DECplay (with -DDEC)
  # ;else leave blank
diff -c -r /users/boyce/c-source/csound_orig/midirecv.c /users/boyce/c-source/csound/midirecv.c
*** /users/boyce/c-source/csound_orig/midirecv.c	Wed Mar 16 18:37:27 1994
--- /users/boyce/c-source/csound/midirecv.c	Mon Sep 19 00:48:42 1994
***************
*** 44,50 ****
  #include <sys/stropts.h>
  #endif
  
! #ifdef NeXT
  #include <mach.h>
  #include <servers/netname.h>
  #include <midi/midi_server.h>
--- 44,50 ----
  #include <sys/stropts.h>
  #endif
  
! #if defined(NeXT) && defined(__m68k__)
  #include <mach.h>
  #include <servers/netname.h>
  #include <midi/midi_server.h>
***************
*** 190,196 ****
  	    ioctl(rtfd, TCFLSH, 0);
  	    fcntl(rtfd, F_SETFL, O_NDELAY);
  #else
! #ifdef NeXT
          {   kern_return_t r;
  	    char *midiPort = "midi1" ; /* "midi0" is A */
              close(rtfd) ; /* easier to close it than hassle with idndefs */
--- 190,196 ----
  	    ioctl(rtfd, TCFLSH, 0);
  	    fcntl(rtfd, F_SETFL, O_NDELAY);
  #else
! #if defined(NeXT) && defined(__m68k__)
          {   kern_return_t r;
  	    char *midiPort = "midi1" ; /* "midi0" is A */
              close(rtfd) ; /* easier to close it than hassle with idndefs */
***************
*** 691,697 ****
  	int n;
  
  nxtchr:	if (bufp >= endatp) {
! #ifdef NeXT
              in_msg->msg_size = MSG_SIZE_MAX;
  	    in_msg->msg_local_port = port_set;	
  	    msg_receive(in_msg, RCV_TIMEOUT, 0);
--- 691,697 ----
  	int n;
  
  nxtchr:	if (bufp >= endatp) {
! #if defined(NeXT) && defined(__m68k__)
              in_msg->msg_size = MSG_SIZE_MAX;
  	    in_msg->msg_local_port = port_set;	
  	    msg_receive(in_msg, RCV_TIMEOUT, 0);
***************
*** 976,982 ****
  	return(0);
  }
  
! #ifdef NeXT
  kern_return_t getMidiData(void *arg,midi_raw_t midi_raw_data,u_int midi_raw_dataCnt)
  {           /* copy midi data into mbuf for comsumption by sensMidi().  */
  	    /* Also, set variable midiCnt to number of incoming bytes.  */
--- 976,982 ----
  	return(0);
  }
  
! #if defined(NeXT) && defined(__m68k__)
  kern_return_t getMidiData(void *arg,midi_raw_t midi_raw_data,u_int midi_raw_dataCnt)
  {           /* copy midi data into mbuf for comsumption by sensMidi().  */
  	    /* Also, set variable midiCnt to number of incoming bytes.  */
diff -c -r /users/boyce/c-source/csound_orig/sfheader.c /users/boyce/c-source/csound/sfheader.c
*** /users/boyce/c-source/csound_orig/sfheader.c	Sun Apr 17 11:54:58 1994
--- /users/boyce/c-source/csound/sfheader.c	Wed Sep 21 11:46:39 1994
***************
*** 1,6 ****
--- 1,10 ----
  #include "cs.h"				/*	       SFHEADER.C	*/
  #include "soundio.h"
  #include <stdio.h>
+ #ifdef NeXT
+ #include <architecture/byte_order.h>
+ #include <sound/soundstruct.h>
+ #endif /* NeXT */
  
  extern OPARMS O;
  
***************
*** 82,90 ****
  
  #endif
  
- #ifdef NeXT
- #include <sound/soundstruct.h>
- #endif /* NeXT */
  
  #ifdef SFSUN41
  #define INFOMAX   100    /* blksiz for SUN info data */
--- 86,91 ----
***************
*** 167,173 ****
  	return(hdp);                /* SFIRCAM always returns hdp, and data */
  #endif
  #ifdef NeXT
! 	if (headfirstlong == SND_MAGIC) {      /* if IRCAM header, read rem */
  	    register SNDSoundStruct *sfh;
  	    int  n;
  
--- 168,175 ----
  	return(hdp);                /* SFIRCAM always returns hdp, and data */
  #endif
  #ifdef NeXT
! 	/* if NeXT header, read rem */
! 	if (headfirstlong == NXSwapBigLongToHost(SND_MAGIC)) { 
  	    register SNDSoundStruct *sfh;
  	    int  n;
  
***************
*** 176,184 ****
  	    sfh = (SNDSoundStruct *) inhdrblk;
  	    sreadin(ifd, inhdrblk+sizeof(long), 
  		    sizeof(SNDSoundStruct)-sizeof(long), p);
! 	    hdp->sr = sfh->samplingRate;
! 	    hdp->nchnls = sfh->channelCount;
! 	    switch(sfh->dataFormat) {	/* map NeXT formats to ours */
  	    case SND_FORMAT_MULAW_8:   hdp->format = AE_ULAW;
  		hdp->sampsize = 1;	break;
  	    case SND_FORMAT_LINEAR_8:  hdp->format = AE_CHAR;
--- 178,187 ----
  	    sfh = (SNDSoundStruct *) inhdrblk;
  	    sreadin(ifd, inhdrblk+sizeof(long), 
  		    sizeof(SNDSoundStruct)-sizeof(long), p);
! 	    hdp->sr = NXSwapBigLongToHost(sfh->samplingRate);
! 	    hdp->nchnls = NXSwapBigLongToHost(sfh->channelCount);
! 	    switch(NXSwapBigLongToHost(sfh->dataFormat)) {
! 	    	/* map NeXT formats to ours */
  	    case SND_FORMAT_MULAW_8:   hdp->format = AE_ULAW;
  		hdp->sampsize = 1;	break;
  	    case SND_FORMAT_LINEAR_8:  hdp->format = AE_CHAR;
***************
*** 191,200 ****
  		hdp->sampsize = 4;	break;
  		default:        hdp->format = O.informat;
  		}
! 	    hdp->hdrsize = sfh->dataLocation;
! 	    hdp->audsize -= sfh->dataLocation;
! 	    if (sfh->dataLocation > sizeof(SNDSoundStruct))  /* skip rem hdr */
! 	       lseek(ifd, sfh->dataLocation-sizeof(SNDSoundStruct), SEEK_CUR);
  	    hdp->readlong = 0;                 /* now aligned on audio_start */
  	}
  	else if (BYTREVL(headfirstlong) == SND_MAGIC) { /* else byte-rev: bad */
--- 194,205 ----
  		hdp->sampsize = 4;	break;
  		default:        hdp->format = O.informat;
  		}
! 	    hdp->hdrsize = NXSwapBigLongToHost(sfh->dataLocation);
! 	    hdp->audsize -= NXSwapBigLongToHost(sfh->dataLocation);
! 	    if (NXSwapBigLongToHost(sfh->dataLocation) > 
! 	    		sizeof(SNDSoundStruct))  /* skip rem hdr */
! 	       lseek(ifd, NXSwapBigLongToHost(sfh->dataLocation) - 
! 			sizeof(SNDSoundStruct), SEEK_CUR);
  	    hdp->readlong = 0;                 /* now aligned on audio_start */
  	}
  	else if (BYTREVL(headfirstlong) == SND_MAGIC) { /* else byte-rev: bad */
***************
*** 300,307 ****
  #ifdef SFIRCAM
          register SFHEADER *sfh;
  	int n;
  	SFAUDIOENCOD *aep;
- 	void sndwrterr();
  	outhdrblk = mcalloc((long)sizeof(SFHEADER));	/* allocate hdr blk */
  	sfh = (SFHEADER *)outhdrblk;
  	sfmagic(sfh) = SF_MAGIC;
--- 305,312 ----
  #ifdef SFIRCAM
          register SFHEADER *sfh;
  	int n;
+ 	extern void sndwrterr();
  	SFAUDIOENCOD *aep;
  	outhdrblk = mcalloc((long)sizeof(SFHEADER));	/* allocate hdr blk */
  	sfh = (SFHEADER *)outhdrblk;
  	sfmagic(sfh) = SF_MAGIC;
***************
*** 321,334 ****
  #ifdef NeXT
          register SNDSoundStruct *sfh;
  	int n;
! 	void sndwrterr();
  	outhdrblk = mcalloc((long)sizeof(SNDSoundStruct)); /* alloc hdr blk */
  	sfh = (SNDSoundStruct *)outhdrblk;
! 	sfh->magic = SND_MAGIC;
! 	sfh->samplingRate = esr;     			/*  assgn headrvals */
! 	sfh->channelCount = nchnls;
! 	sfh->dataLocation = sizeof(SNDSoundStruct);
! 	sfh->dataSize = -1;
  	/* set formats .. */
  	switch(O.outformat)
  	    {
--- 326,339 ----
  #ifdef NeXT
          register SNDSoundStruct *sfh;
  	int n;
! 	extern void sndwrterr();
  	outhdrblk = mcalloc((long)sizeof(SNDSoundStruct)); /* alloc hdr blk */
  	sfh = (SNDSoundStruct *)outhdrblk;
! 	sfh->magic = NXSwapHostLongToBig(SND_MAGIC);
! 	sfh->samplingRate = NXSwapHostLongToBig(esr); 	/*  assgn headrvals */
! 	sfh->channelCount = NXSwapHostLongToBig(nchnls);
! 	sfh->dataLocation = NXSwapHostLongToBig(sizeof(SNDSoundStruct));
! 	sfh->dataSize = NXSwapHostLongToBig(-1L);
  	/* set formats .. */
  	switch(O.outformat)
  	    {
***************
*** 339,344 ****
--- 344,350 ----
  	case AE_FLOAT:	sfh->dataFormat = SND_FORMAT_FLOAT;	break;
  	default:	sfh->dataFormat = SND_FORMAT_LINEAR_16;	/* lose.. */
  	    }
+ 	sfh->dataFormat = NXSwapHostLongToBig(sfh->dataFormat);
  	if ((n = write(ofd,sfh,sizeof(SNDSoundStruct)))<sizeof(SNDSoundStruct))
  	        sndwrterr(n, sizeof(SNDSoundStruct));
  #endif /* NeXT */
diff -c -r /users/boyce/c-source/csound_orig/soundio.c /users/boyce/c-source/csound/soundio.c
*** /users/boyce/c-source/csound_orig/soundio.c	Sun Apr 17 12:09:24 1994
--- /users/boyce/c-source/csound/soundio.c	Wed Sep 21 04:47:24 1994
***************
*** 1,5 ****
--- 1,8 ----
  #include "cs.h"			/*	       		SOUNDIO.C	*/
  #include "soundio.h"
+ #ifdef NeXT
+ #include <architecture/byte_order.h>
+ #endif
  
  static  char	*sfoutname;     		    /* soundout filename    */
  static	char	*inbuf,    *outbuf;   		    /* contin sndio buffers */
***************
*** 269,276 ****
  	        audtran = audwrtrev4;
  	    else audtran = audwrite;
  	}
  	else audtran = audwrite; 		/* else use standard audio puts */
! 
  outset: outbufsiz = (unsigned)O.outbufsamps * O.outsampsiz;/* calc outbuf size  */
          outbuf = mmalloc((long)outbufsiz);                 /*  & alloc bufspace */
          printf("writing %d-byte blks of %s to %s %s\n",
--- 272,286 ----
  	        audtran = audwrtrev4;
  	    else audtran = audwrite;
  	}
+ #if !defined(NeXT) && !defined(__LITTLE_ENDIAN__)
  	else audtran = audwrite; 		/* else use standard audio puts */
! #else
! 	    if (O.outformat == AE_SHORT)        /* if audio out needs byte rev  */
! 	        audtran = audwrtrev2;           /*   redirect the audio puts    */
! 	    else if (O.outformat == AE_LONG)
! 	        audtran = audwrtrev4;
! 	    else audtran = audwrite;
! #endif
  outset: outbufsiz = (unsigned)O.outbufsamps * O.outsampsiz;/* calc outbuf size  */
          outbuf = mmalloc((long)outbufsiz);                 /*  & alloc bufspace */
          printf("writing %d-byte blks of %s to %s %s\n",
