Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info.

VOC2SPL.C

From Higher Intellect Vintage Wiki
Jump to navigation Jump to search
/* Converts VOC samples to raw SPL format */

#include <stdio.h>
#include <conio.h>

unsigned char buffer[32768];

main(int argc,char **argv)
{
FILE *vocf, *splf;
char vocfname[80],splfname[80];
unsigned i,numread;
unsigned char in_char;
char *ptr;
char silencebyte = 0x80;

	 if(argc > 1)
	 {
		 strcpy(vocfname,argv[1]);
		 if(strstr(strupr(vocfname),".VOC") == NULL)
			strcat(vocfname,".VOC");

		  if(vocf = fopen(vocfname,"rb"))
		  {
			   if(argc < 3)
			   {
				 ptr = strchr(vocfname,'.');
				 strncpy( splfname, vocfname, ptr - vocfname);
				 splfname[ptr-vocfname] = 0;
				 strcat(splfname,".SPL");
			   }
			   else
					strcpy(splfname,argv[2]);

			   splf = fopen(splfname,"wb");

			   fread(buffer,1,0x1A,vocf);    /* Read past VOC header */
			   fread(buffer,1,6,vocf);       /* Read past 1st block header */

			   do
			   {
					numread = fread(buffer,1,sizeof(buffer),vocf);
					fwrite(buffer,1,numread,splf);
			   } while(numread == sizeof(buffer));

			   fseek(splf,-1,SEEK_CUR);
			   fwrite(&silencebyte,1,1,splf);

			   fclose(vocf);
			   fclose(splf);

			   printf("Ok.\n");
		  }
		  else
			   printf("File %s not found!\n",argv[1]);
	 }
	 else
	 {
		  printf("VOC2SPL converts VOC samples to Raw SPL format\n");
		  printf("usage: voc2spl <VOCInFile> [<SPLOutFile>]\n");
	 }
}