home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio Version 4.94
/
audioversion4.94knowledgemediaresourcelibraryoctober1994.iso
/
amiga
/
midi
/
dxvcesrt.lzh
/
DX-VOICESORTER
/
VOICESORTER.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-16
|
16KB
|
578 lines
/***************************************************************************
*DX7 Fileshifter David Bouckley*
*Copyright David Bouckley (1988) *
* *
* This program allows for sorting of individual voices from Yamaha DX7 *
* voice files saved using Jack Deckard's Voicefiler program found on *
* Fish Disks 38 and 82. It may be freely used so long as no commercial *
* gain is made from either the program or it's code. *
***************************************************************************/
#include <exec/types.h> /*Files to include*/
#include <intuition/intuition.h>
#include <libraries/dos.h>
#include <exec/exec.h>
#include <intuition/intuitionbase.h>
struct IntuitionBase *IntuitionBase; /*Structures Used*/
struct GfxBase *GfxBase;
struct Window *Window;
struct Message *GetMsg();
struct Screen *Screen;
struct Menu menu[1];
struct MenuItem menuitem[4];
struct IntuiText menutext[4];
struct IntuiMessage *NewMessage;
struct Gadget gadget[65];
#define INTUITION_REV 1L /*Define Manx Version*/
#define GRAPHICS_REV 1L
UBYTE infile[4096]; /*File Storage For Input*/
UBYTE buffer[4096]; /*File Storage For Buffer*/
UBYTE buff[128]; /*Individual Voice Buffer*/
static char name[26];
char *inname[32];
/* Initialize the NewWindow structure for the call to OpenWindow() */
struct NewWindow NewWindow =
{
150,10,480,185,0,1,
REFRESHWINDOW | MOUSEBUTTONS | MOUSEMOVE | GADGETDOWN | GADGETUP |
CLOSEWINDOW | MENUPICK | VANILLAKEY,
WINDOWSIZING | WINDOWCLOSE | REPORTMOUSE |
SMART_REFRESH | ACTIVATE | WINDOWDRAG | WINDOWDEPTH,
&gadget[0], NULL,
"DX7 VoiceSorter",
NULL, NULL,
0,0,240,100,
WBENCHSCREEN,
};
/* function to get file name*/
VOID filename(across)
int across;
{
ULONG class, code, keepgoing = 1, i = 0;
LONG x = across;
Move(Window->RPort,across,17);
Text(Window->RPort," ",17);
Move(Window->RPort,across,17);
Text(Window->RPort,"Filename:" ,9);
Move(Window->RPort,across,25);
Text(Window->RPort," ",27);
Move(Window->RPort,across,25);
while(keepgoing)
{
Wait( 1L << Window -> UserPort -> mp_SigBit);
while(NewMessage=(struct IntuiMessage *)GetMsg(Window->UserPort))
{
class = NewMessage->Class;
code = NewMessage->Code;
ReplyMsg(NewMessage);
if(class = VANILLAKEY)
{
switch(code)
{
case (13): /* return */
{
name[i]=0;
keepgoing = 0;
break;
}
case (27): /* ESC */
{
name[0]=0;
keepgoing = 0;
break;
}
case (8):
if (i > 0) /* backspace */
{
i--;
name[i] = 0;
x=x-8;
Move(Window->RPort,x,25L);
Text(Window->RPort," ",1L);
Move(Window->RPort,x,25L);
break;
}
default:
if ((code >= 32) && (code < 255))
{
name[i]=code;
Text(Window->RPort,&name[i],1L);
x=x+8L;
i++;
break;
}
} /* end Switch*/
} /* end VANILLAKEY if*/
} /* end of new message loop */
} /* end of while(keepgoing) */
} /* end of function */
/*Final Cleanup Function*/
VOID ClearWindow()
{
ClearMenuStrip(Window);
CloseWindow(Window);
CloseLibrary(GfxBase);
CloseLibrary(IntuitionBase);
}
/*Gets file from disk*/
char load_file(infile,name)
char infile[],name[];
{
VOID filename();
int gile, across=7;
char *file;
filename(across);
if (name[0]==0)
{
Move(Window->RPort,7,25);
Text(Window->RPort," ",25);
}
else
{
file = Open( name, MODE_OLDFILE );
if (file==0)
{
Move(Window->RPort,7,25);
Text(Window->RPort,"File Not Found ",25);
}
else
{
gile = Read(file, infile, 4096);
if (gile==-1)
{
Move(Window->RPort,7,25);
Text(Window->RPort,"Error Reading File ",25);
}
}
Close (file);
}
}
/*function to save buffer created*/
char save_file(buffer,name)
char buffer[],name[];
{
VOID filename();
int gile,across=240;
char *file;
filename(across);
if (name[0]==0)
{
Move(Window->RPort,240,25);
Text(Window->RPort," ",25);
}
else
{
file = Open( name, MODE_NEWFILE );
if (file==0)
{
Move(Window->RPort,240,25);
Text(Window->RPort,"Error Opening File ",25);
}
else
{
gile = Write(file, buffer, 4096);
if (gile==-1)
{
Move(Window->RPort,240,25);
Text(Window->RPort,"Error Writing File ",25);
}
}
Close (file);
}
}
/*shoves spaces into the buffer display*/
char fill_buffer (buffer,buff)
char buffer[],buff[];
{
int i;
for (i=1;i<=4096;++i)
buffer[i]=' ';
for (i=1;i<=128;++i)
buff[i]=' ';
}
/*displays above*/
display_empty_buffer (buffer)
char buffer[];
{
int i=0,j=118,k=1,l=0,m=238,n=35;
int *x;
char *z,*y;
for (k=1;k<=32;k++)
{
x=&k;
z = &buffer[j];
Move(Window->RPort,(m+20),n);
Text(Window->RPort,z,10);
j=j+128;
n=n+9;
if (k==16)
{
m=353;
n=35;
}
}
}
/*displays voice names of the file opened*/
display_file (infile)
char infile[];
{
int i=0,j=118,k=1,l=0,m=5,n=35;
int *x;
char *z,*y;
for (k=1;k<=32;k++)
{
x=&k;
z = &infile[j];
Move(Window->RPort,(m+22),n);
Text(Window->RPort,z,10);
j=j+128;
n=n+9;
if (k==16)
{
m=120;
n=35;
}
}
}
sound_to_buff(mes,win,k,a)
struct IntuiMessage *mes;
struct Window *win;
int k, a[];
{
struct Gadget *gad;
int i,j,l;
char *z;
gad = (struct Gadget *) mes->IAddress;
j = gad->GadgetID;
a[k] = j;
if (k==1)
{
for (i=1;i<=128;i++)
{
if (j<=31)
buff[i]=infile[(j)*128+i];
if (j>=32 && j<=63)
buff[i]=buffer[(j-32)*128+i];
if (j==64)
buff[i]=buff[i];
}
z= &buff[118];
Move(Window->RPort,222,180);
Text(Window->RPort,z,10);
}
if (k==2 && j>=32)
{
for (i=1;i<=128;i++)
{
if (j<=63)
buffer[(j-32)*128+i]=buff[i];
if (j==64)
buff[i]=buff[i];
}
z= &buff[118];
if ((j>=32) && (j<=47))
{
Move(Window->RPort,258,(26+9*(j-31)));
Text(Window->RPort,z,10);
}
if ((j>=48) && (j<=63))
{
Move(Window->RPort,373,(26+9*(j-47)));
Text(Window->RPort,z,10);
}
}
}
/*set up the menus*/
VOID InitMenu()
{
/* Initialize Menu Header Whatcha wanta Do */
menu[0].NextMenu = NULL;
menu[0].LeftEdge = 5;
menu[0].TopEdge = 0;
menu[0].Width = 165;
menu[0].Height = 10;
menu[0].Flags = MENUENABLED | MIDRAWN;
menu[0].MenuName = "Selection";
menu[0].FirstItem = &menuitem[0];
/* Initialize menu item "Dump Voices From Synth" */
menuitem[0].NextItem = &menuitem[1];
menuitem[0].LeftEdge = 0;
menuitem[0].TopEdge = 0;
menuitem[0].Width = 156;
menuitem[0].Height = 11;
menuitem[0].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
menuitem[0].MutualExclude = 0xffff;
menuitem[0].ItemFill = (APTR)&menutext[0];
menuitem[0].SelectFill = NULL;
menuitem[0].Command = NULL;
menuitem[0].SubItem = NULL;
menuitem[0].NextSelect = NULL;
menutext[0].FrontPen = 0;
menutext[0].BackPen = 1;
menutext[0].DrawMode = JAM2;
menutext[0].LeftEdge = 10;
menutext[0].TopEdge = 1;
menutext[0].ITextFont = NULL;
menutext[0].IText = (UBYTE *) "Load from disk";
menutext[0].NextText = NULL;
/* Second Menu Item "Save Voice Buffer To Disk" */
menuitem[1].NextItem = &menuitem[2];
menuitem[1].LeftEdge = 0;
menuitem[1].TopEdge = 11;
menuitem[1].Width = 156;
menuitem[1].Height = 11;
menuitem[1].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
menuitem[1].MutualExclude = 0xffff;
menuitem[1].ItemFill = (APTR) &menutext[1];
menuitem[1].SelectFill = NULL;
menuitem[1].Command = NULL;
menuitem[1].SubItem = NULL;
menuitem[1].NextSelect = NULL;
menutext[1].FrontPen = 0;
menutext[1].BackPen = 1;
menutext[1].DrawMode = JAM2;
menutext[1].LeftEdge = 10;
menutext[1].TopEdge = 1;
menutext[1].ITextFont = NULL;
menutext[1].IText = (UBYTE *) "Save Buffer";
menutext[1].NextText = NULL;
/* Third Menu Item "Clear the Buffer" */
menuitem[2].NextItem = &menuitem[3];
menuitem[2].LeftEdge = 0;
menuitem[2].TopEdge = 22;
menuitem[2].Width = 156;
menuitem[2].Height = 11;
menuitem[2].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
menuitem[2].MutualExclude = 0xffff;
menuitem[2].ItemFill = (APTR) &menutext[2];
menuitem[2].SelectFill = NULL;
menuitem[2].Command = NULL;
menuitem[2].SubItem = NULL;
menuitem[2].NextSelect = NULL;
menutext[2].FrontPen = 0;
menutext[2].BackPen = 1;
menutext[2].DrawMode = JAM2;
menutext[2].LeftEdge = 10;
menutext[2].TopEdge = 1;
menutext[2].ITextFont = NULL;
menutext[2].IText = (UBYTE *) "Clear Buffer";
menutext[2].NextText = NULL;
/* Initialize menu item "Quit" */
menuitem[3].NextItem = NULL;
menuitem[3].LeftEdge = 0;
menuitem[3].TopEdge = 33;
menuitem[3].Width = 156;
menuitem[3].Height = 11;
menuitem[3].Flags = CHECKIT | ITEMTEXT | ITEMENABLED | HIGHCOMP;
menuitem[3].MutualExclude = 0xfffe;
menuitem[3].ItemFill = (APTR)&menutext[3];
menuitem[3].SelectFill = NULL;
menuitem[3].Command = NULL;
menuitem[3].SubItem = NULL;
menuitem[3].NextSelect = NULL;
menutext[3].FrontPen = 0;
menutext[3].BackPen = 1;
menutext[3].DrawMode = JAM2;
menutext[3].LeftEdge = 10;
menutext[3].TopEdge = 1;
menutext[3].ITextFont = NULL;
menutext[3].IText = (UBYTE *) "Quit";
menutext[3].NextText = NULL;
}
main()
{
VOID InitMenu() , ClearWindow();
ULONG class, code, menunum, itemnum, Men = 0, MenuNumber;
int KeepGoing, capture, send, i, j, k=1, a[3];
char load_file();
static char *numbers[] =
{
" 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","11","12","13","14","15","16",
"17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32"
};
for (i=0;i<=64;i++)
{
if (i == 64)
gadget[i].NextGadget = NULL;
else
gadget[i].NextGadget = &gadget[i+1];
if (i <=15)
{
gadget[i].LeftEdge = 25;
gadget[i].TopEdge = (19+9*(i+1));
}
if (i >=16 && i<=31)
{
gadget[i].LeftEdge = 140;
gadget[i].TopEdge = (19+9*(i-15));
}
if (i >=32 && i<=47)
{
gadget[i].LeftEdge = 255;
gadget[i].TopEdge = (19+9*(i-31));
}
if (i >=48 && i <=63)
{
gadget[i].LeftEdge = 370;
gadget[i].TopEdge = (19+9*(i-47));
}
if (i == 64)
{
gadget[i].LeftEdge = 220;
gadget[i].TopEdge = 173;
}
gadget[i].Width = 83;
gadget[i].Height = 9;
gadget[i].Flags = GADGHCOMP;
gadget[i].Activation = GADGIMMEDIATE | RELVERIFY;
gadget[i].GadgetType = BOOLGADGET;
gadget[i].GadgetRender =NULL;
gadget[i].SelectRender = NULL;
gadget[i].GadgetText = NULL;
gadget[i].MutualExclude = NULL;
gadget[i].SpecialInfo = NULL;
gadget[i].GadgetID = i;
gadget[i].UserData = NULL;
}
/* Open the Intuition library */
IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library",INTUITION_REV);
if(IntuitionBase == NULL)
exit(FALSE);
/* Open the Graphics library */
GfxBase = (struct GfxBase *)
OpenLibrary("graphics.library",GRAPHICS_REV);
if(GfxBase == NULL)
exit(FALSE);
/* Open Window */
if ((Window = (struct Window *) OpenWindow(&NewWindow)) == NULL)
exit(FALSE);
/*Opens window according to structure of NewWindow (pointed to)*/
/* Initialize Menu items, then submit them to Intuition */
InitMenu();
SetMenuStrip(Window,&menu);
Move(Window->RPort,240,17);
Text(Window->RPort,"Buffer Store:" ,13);
Move(Window->RPort,140,180);
Text(Window->RPort,"Voicename:" ,10);
for (i=1;i<=4096;++i)
infile[i]=' ';
for (i=0;i<=15;i++)
{
Move(Window->RPort,5,(26+9*(i+1)));
Text(Window->RPort,numbers[i],2);
Move(Window->RPort,235,(26+9*(i+1)));
Text(Window->RPort,numbers[i],2);
}
for (i=16;i<=31;i++)
{
Move(Window->RPort,120,(26+9*(i-15)));
Text(Window->RPort,numbers[i],2);
Move(Window->RPort,350,(26+9*(i-15)));
Text(Window->RPort,numbers[i],2);
}
KeepGoing = 1;
capture = FALSE;
fill_buffer (buffer,buff);
while (KeepGoing !=0)
{
Wait ((1 << Window->UserPort->mp_SigBit));
while ( NewMessage=(struct IntuiMessage *)GetMsg(Window->UserPort))
{
class = NewMessage->Class;
code = NewMessage->Code;
ReplyMsg( NewMessage);
switch (class)
{
case MENUPICK:
{
if (code !=MENUNULL)
{
menunum = MENUNUM(code);
itemnum = ITEMNUM(code);
switch (menunum)
{
case 0:
{
switch (itemnum)
{
case 0:
load_file (infile, name);
display_file (infile);
k=1;
break;
case 1:
save_file(buffer,name);
break;
case 2:
fill_buffer (buffer,buff);
display_empty_buffer (buffer);
break;
case 3:
KeepGoing = 0;
ClearWindow();
Exit(0);
} /*end switch (itemnum)*/
} /*end case 0 switch (menunum)*/
break;
} /*end switch (menunum)*/
} /*end if code != MENUNULL*/
} /*end case MENUPICK*/
break;
case GADGETUP:
sound_to_buff(NewMessage,Window,k,a);
++k;
if (k==3)
k=1;
break;
case GADGETDOWN:
break;
case CLOSEWINDOW:
KeepGoing = 0;
ClearWindow();
Exit(0);
break;
/*end case CLOSEWINDOW*/
} /*end switch (class)*/
} /*end while (newmessage etc)*/
} /*end while (KeepGoing)*/
}