Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!uakari.primate.wisc.edu!brutus.cs.uiuc.edu!usc!rutgers!mcnc!xanth!cs.odu.edu!Amiga-Request From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) Newsgroups: comp.sources.amiga Subject: v90i093: n2a - convert NeXT sounds files to IFF 8SVX, Part01/01 Message-ID: <11618@xanth.cs.odu.edu> Date: 4 Mar 90 01:11:21 GMT Sender: tadguy@cs.odu.edu Reply-To: kyrimis@Princeton.EDU (Kriton Kyrimis) Lines: 448 Approved: tadguy@cs.odu.edu (Tad Guy) X-Mail-Submissions-To: Amiga@cs.odu.edu X-Post-Discussions-To: comp.sys.amiga Submitted-by: kyrimis@Princeton.EDU (Kriton Kyrimis) Posting-number: Volume 90, Issue 093 Archive-name: audio/n2a [ uuencoded executable enclosed. ...tad ] Here's a little hack I wrote to enable me to play NeXT sounds on my amiga. #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Makefile' <<'END_OF_FILE' Xn2a: n2a.o X blink FROM LIB:c.o n2a.o TO n2a NODEBUG LIB LIB:lc.lib X Xn2a.o: n2a.c X lc n2a.c END_OF_FILE if test 91 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1006 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' Xn2a converts NeXT sound files into 8SVX IFF files. NeXT sound Xfiles come in many different flavors; n2a groks only the XLINEAR_16 format, which is the one that most PD sound files seem Xto be using. NeXT recording applications use the MULAW_8 format. XYou can convert from this format to LINEAR_16 with the sndconvert Xapplication on the NeXT. You can tell whether a sound file can Xbe processed by n2a using the command: X od -b file | head -1 XIf the last number is 003, then the file is in LINEAR_16 format. X XThe program compiles both on the NeXT and the Amiga. I have pro- Xvided an Amiga executable, but I would recommend running the pro- Xgram on the NeXT, because the resulting 8SVX file is half the Xsize of the NeXT file. X XThis program is released to the public domain. X X Kriton (UUCP: rutgers!princeton!kyrimis) X (ARPA: kyrimis@princeton.edu) X----- X"Everybody keep calm. It's all under control, there's nothing to X see. It is merely a major scientific breakthrough." X----- END_OF_FILE if test 1006 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'n2a.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'n2a.c'\" else echo shar: Extracting \"'n2a.c'\" \(3080 characters\) sed "s/^X//" >'n2a.c' <<'END_OF_FILE' X#include X#include X#ifdef AMIGA X#include X#else Xtypedef long LONG; Xtypedef unsigned long ULONG; Xtypedef unsigned char UBYTE; Xtypedef unsigned short UWORD; X#endif X X#define MAGIC 0x2e736e64 X#define LINEAR_16 3 X X#define Unity 0x10000L X Xtypedef LONG Fixed; Xtypedef struct { X ULONG oneShotHiSamples, X repeatHiSamples, X samplesPerHiCycle; X UWORD samplesPerSec; X UBYTE ctOctave, X sCompression; X Fixed volume; X} Voice8Header; X Xmain(int argc, char *argv[]) X{ X Voice8Header v; X long i, nsamples, voffset, lengthoffset, nsamplesoffset; X int magic, offset, size, format, rate, nchannels; X unsigned short s16; X FILE *in, *out; X unsigned char s8; X X if (argc != 3) { X fprintf(stderr, "Usage: %s sndfile 8svxfile\n", argv[0]); X exit(1); X } X in = fopen(argv[1], "r"); X if (!in) { X fprintf(stderr, "Can't open %s!\n", argv[1]); X exit(1); X } X fread((void *)&magic, sizeof(magic), 1, in); X fread((void *)&offset, sizeof(offset), 1, in); X fread((void *)&size, sizeof(size), 1, in); X fread((void *)&format, sizeof(format), 1, in); X fread((void *)&rate, sizeof(rate), 1, in); X fread((void *)&nchannels, sizeof(nchannels), 1, in); X X if (magic != MAGIC) { X fprintf(stderr, "%s Is not a NeXT sound file!\n", argv[1]); X fclose(in); X exit(1); X } X if (format != LINEAR_16 || nchannels != 1) { X fprintf(stderr, "I can only handle linear 16 format with 1 channel!\n"); X if (format != LINEAR_16 && nchannels == 1) { X fprintf(stderr, "Use sndconvert on the NeXT to convert to this format\n"); X } X fclose(in); X exit(1); X } X out = fopen(argv[2], "w"); X if (!out) { X fprintf(stderr, "Can't open %s!\n", argv[2]); X fclose(in); X exit(1); X } X fwrite((void *)"FORM", sizeof(char), 4, out); X lengthoffset = ftell(out); X i = 0; /* update this later */ X fwrite((void *)&i, sizeof(i), 1, out); X fwrite((void *)"8SVX", sizeof(char), 4, out); X fwrite((void *)"VHDR", sizeof(char), 4, out); X i = 20; X fwrite((void *)&i, sizeof(i), 1, out); X voffset = ftell(out); X v.oneShotHiSamples = 0; /* Update this later */ X v.repeatHiSamples = 0; X v.samplesPerHiCycle = 0; X v.samplesPerSec = rate; X v.ctOctave = 1; X v.sCompression = 0; X v.volume = Unity; X fwrite((void *)&v, sizeof(v), 1, out); X fwrite((void *)"BODY", sizeof(char), 4, out); X nsamplesoffset = ftell(out); X i = 0; /* update this later */ X fwrite((void *)&i, sizeof(i), 1, out); X X fseek(in, (long)offset, 0); X nsamples = 0; X while (fread((void *)&s16, sizeof(s16), 1, in)) { X s8 = s16 >> 8; X fwrite((void *)&s8, sizeof(s8), 1, out); X nsamples++; X } X fclose(in); X if (nsamples % 2) { X s8 = 0; X fwrite((void *)&s8, sizeof(s8), 1, out); /* pad to even length */ X } X fseek(out, voffset, 0); X v.oneShotHiSamples = nsamples; X fwrite((void *)&v, sizeof(v), 1, out); X fseek(out, lengthoffset, 0); X i = 40 + nsamples; X fwrite((void *)&i, sizeof(i), 1, out); X fseek(out, nsamplesoffset, 0); X fwrite((void *)&nsamples, sizeof(nsamples), 1, out); X fclose(out); X exit(0); X} END_OF_FILE if test 3080 -ne `wc -c <'n2a.c'`; then echo shar: \"'n2a.c'\" unpacked with wrong size! fi # end of 'n2a.c' fi if test -f 'n2a.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'n2a.uu'\" else echo shar: Extracting \"'n2a.uu'\" \(13686 characters\) sed "s/^X//" >'n2a.uu' <<'END_OF_FILE' Xbegin 644 n2a XM```#\P`````````#``````````(```>6````^0```5L```/I```'EDCG?OXD% XM2"0`2?D`````+'@`!$?Y```#`'(`(#P```";8`(FP5'(__PI3P-`*4X#.$*LZ XM`SQP`"(\```P`$ZN_LY#^@%:<`!.KOW8*4`$F&8&<&1@``#\)FX!%"EK`)@#7 XM-$JK`*QG:"`/D*\`!`:`````@"E``P0@:P"LT``$(FP$F$ZN_F).= XMN@`\2JP#/&<:(BP#1&<$3J[_W"QX``1.KO]\(FP#/$ZN_H8@'RYL`T!,WW]^S XM3G5D;W,N;&EB0!.=4YU3E7_[$CG+Q`N+P`T)F\`."@'<#'`JP`89P9P\ XM_V```G`(*P`'`!I6P$0`2(!(P"P`2JL`%&8``(0(*P`"`!MF>G``)T``#'+_R XMOH%G``)"+PM.NA<.6$]*@&<,".L`!0`;0```!1.N@@0``````````!P84CG(#`F;P`0)$M*" XM$F6!TH+2@=*`8.8,$0`M9@)$- XM@20?(`A3@"!O``@@@9")3G5.5?_F2.`/M+PM.N@<$4$\H, XM`$J$:@0(QP`)"`<`"6<:&WP``?__*6W_\@24+RW_[B\+3KH'B%!/*`!*+?__X XM9S8@!W)XTH'`@4J`9RI*A&LF+P1.N@?02'@#[2\+3KH&LD_O``PH`&`.2'@#; XM[2\+3KH&H%!/*`!*K`,89P1P_V`()(8E1``$(`5,WPSP3EU.=0``````````` XM`````````````````````````````'!A2.P`Q XM\"92(`MG0"`K``2PAVTRL(=F#"!3)(B?K`#T(`M@;B`K``20AW((L(%E%B!+6 XMT<``8&U.J``QM%B!J``1#Z``!)4D`!"`$$(!R`!(`G XM8!(@!'(`$@`O"B\!3KKW.E!/(@!2@68$(`9@"E.%8+Y2AF"R(`9,WPSP3EU.P XM=0``2.``!- XM0J/__3KKU-B`L!)!,[0P`/ XM__A.74YU``!.5?_P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2&W_Z$ZZ`;@NK?^V3KH!PBP`<``K0/_L*T#_\"M`__0@+?_$.T#_Q XM^!M\``'_^D(M__LK?``!``#__"ZM_[9(>``!2'@`%$AM_^Q.N@%R3^\`3"\M[ XM_[9(>``$2'@``4AL`-I.N@%:+JW_MDZZ`61"K?_H+JW_MDAX``%(>``$2&W_' XMZ"M`_]A.N@$V0I``!2'@``DAMN XM_[Y.N@$D3^\`$$J`9RAP`#`M_[[@@!M`_[4O+?^V<`$O`"\`2&W_M4ZZ`.9/0 XM[P`04JW_Y&"\+RW_NDZZ`-I83R`M_^1R`DZZ`+!*@6<:0BW_M2\M_[9P`2\`7 XM+P!(;?^U3KH`KD_O`!!"IR\&+RW_MDZZ`)@K;?_D_^PNK?^V2'@``4AX`!1(^ XM;?_L3KH`A$*7+P4O+?^V3KH```$2&W_Y$ZZ`#@NK?^V3KH`2 XM-D*73KH`-DSM".#_I$Y=3G5.^0``!=A.^0``$,A.^0``&QQ.^0``#$A.^0``B XM"Q!.^0``"B1.^0``&WA.^0``#?A.^0``"I1.^0``"Y0```/L````"@``````Z XM``.P```#P@```]H```/(```#S@```^````.V```#U````[P```.J````````0 XM`_(```/J````P%5S86=E.B`E XM`@("$!`0$"`@("`@("`@("`H*"@H*"`@("`@("`@("`@("`@("`@($@0$!`06 XM$!`0$!`0$!`0$!"$A(2$A(2$A(2$$!`0$!`0$(&!@8&!@0$!`0$!`0$!`0$!9 XM`0$!`0$!`0$!$!`0$!`0@H*"@H*"`@("`@("`@("`@("`@("`@("`@(0$!`0= XM(````````@#__P````X`#@```````````````/__````!``$````````'%@`V XM``)T__\````$``0````````<;@````#__P````X`#@```````!U^`````/__Y XM````!``$``````````````*P__\````$``0````````=F@````#__P````0`Y XM!````````!VD`````````^P````%`````````O@```+D```"O````J@```*47 X@````!`````(```+4```"F````1X```#\`````````_+DJ X`` Xend Xsize 9752 END_OF_FILE if test 13686 -ne `wc -c <'n2a.uu'`; then echo shar: \"'n2a.uu'\" unpacked with wrong size! fi # end of 'n2a.uu' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to . Mail comments to the moderator at . Post requests for sources, and general discussion to comp.sys.amiga.