[comp.sys.amiga.programmer] Amiga to Mac sound file conversion

mykes@amiga0.SF-Bay.ORG (Mike Schwartz) (05/28/91)

In article <1991May27.175826.8556@watserv1.waterloo.edu> tcapener@watserv1.waterloo.edu (CAPENER TD - ENGLISH ) writes:
>In article <1991May22.131159.29523@magnus.acs.ohio-state.edu>, dasay@magnus.acs.ohio-state.edu (Devin N Asay) writes:
>> Anybody out there know of any utilities that convert Amiga IFF sampled
>> audio files to any Mac audio file format?
>> 
>> Devin N. Asay
>> Computer-Based Instruction
>> *The* Ohio State University
>
>SoundEdit from Farralon Computing (a Mac program) can read and write
>IFF format files (sort of).  I recently converted a lot of PD Mac sounds
>into Amiga format.  Unfortunately, it wasn't all that straightforward.
>
>What I did was to load the Mac sound resources into SoundEdit, then save
>them as IFF files.  Unfortunately, most 8SVX players don't like SoundEdit's
>idea of IFF (but the PD player 'play' does).  So, I used a byte-by-byte
>file editor (zap) to remove all of the IFF header information and turned
>the file into raw 8SVX sound, which I then loaded into Perfect Sound and
>saved in a more palatteable IFF format which all of my 8SVX players can
>read.
>
>I realise you want to do the opposite of what I did, so if SoundEdit can't
>read Amiga's IFF sound files then you'll have to do what I did in reverse.
>Look in the Addisson Wesely Amiga Autodocs book for info on how to make
>an 8SVX header if you need to.
>
>Sorry this is so vague, but I hope it helps a bit.


The following 'C' program should do the trick.  It compiles under SAS 5.10.
It reads in an IFF file and converts into a Mac sound format compatible with
various Mac utilities (just xmodem to a mac).  It also will convert a Mac sound
to Amiga format, but doesn't write out IFF.

#include <exec/types.h>
#include <stdio.h>
#include <fcntl.h>

ULONG	sampleSize = 0;
BYTE	*samplePtr, *sampleData, *malloc();

ReadSound(fn)
char	*fn;
{
	int 	fd;
	ULONG	*pl;

	if (sampleSize) free(sampleData);
	sampleSize = 0;

	fd = open(fn, O_RDONLY);	
	if (fd == -1) return 0;
	sampleSize = (ULONG)lseek(fd, 0, 2); lseek(fd, 0,0);
	samplePtr = (BYTE *)malloc(sampleSize);
	if (!samplePtr) {
		printf("Insufficient memory for %d bytes\n", sampleSize);
		return 0;
	}
	read(fd, samplePtr, sampleSize);
	close(fd);
	sampleData = samplePtr;
	if (!strncmp(sampleData, "FORM", 4)) {
		samplePtr = &samplePtr[0x60];
		while (strncmp(samplePtr, "BODY", 4)) samplePtr += 2;
		samplePtr += 4;
		pl = (ULONG *)&samplePtr[0];
		sampleSize = *pl;
		samplePtr += 4;
	}
	printf("SampleSize = %d bytes\n", sampleSize);
	return !0;
}

main(ac, av) 
int   ac;
char  *av[];
{
	long	i;
	int	fd;

	if (ac != 3) {
		printf("Usage: maccvt infile outfile\n");
		exit(999);
	}
	if (!ReadSound(av[1])) {
		printf("Can't read %s\n", av[1]);
		exit(999);
	}
	for (i=0; i<sampleSize; i++) samplePtr[i] ^= 0x80;
	fd = open(av[2], O_WRONLY|O_CREAT|O_TRUNC);
	if (fd == -1) {
		printf("Can't open %s\n", av[2]);
		exit(999);
	}
	write(fd, samplePtr, sampleSize);
	close(fd);
	exit(0);
}

--
****************************************************
* I want games that look like Shadow of the Beast  *
* but play like Leisure Suit Larry.                *
****************************************************

crafton@psych.toronto.edu (Brad Crafton) (05/30/91)

In article <mykes.2956@amiga0.SF-Bay.ORG> mykes@amiga0.SF-Bay.ORG (Mike Schwartz) writes:
>
>
>The following 'C' program should do the trick.  It compiles under SAS 5.10.
>It reads in an IFF file and converts into a Mac sound format compatible with
>various Mac utilities (just xmodem to a mac).  It also will convert a Mac sound
>to Amiga format, but doesn't write out IFF.
>

Since I don't have a C compiler, could someone please e-mail me a uuencoded
version of the binary?  Or perhaps post it to alt.binaries.amiga?

Many thanks!

Brad
crafton@psych.toronto.edu
       @psych.utoronto.ca