home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
300-399
/
ff332.lzh
/
K1_Editor
/
K1_Editor_D.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-20
|
56KB
|
1,859 lines
#define INTUITIONPRIVATE 1
#include <exec/exec.h>
#include <intuition/intuitionbase.h>
#include <functions.h>
#include <libraries/dosextens.h>
#include <graphics/gfxbase.h>
#include <intuition/preferences.h>
#include <libraries/reqbase.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>
#include <workbench/icon.h>
#include <midi/kawai_k1.h>
#include "K1_Window_D.c"
#define WAVETEST (MenuItem2.Flags & CHECKED) == CHECKED
#define AUTOWRITE (MenuItem1.Flags & CHECKED) == CHECKED
#define COMMON (Gadget29.Flags & SELECTED) == SELECTED
#define FREQUENCY (Gadget30.Flags & SELECTED) == SELECTED
#define WAVEFORM (Gadget31.Flags & SELECTED) == SELECTED
#define ENVELOPE (Gadget32.Flags & SELECTED) == SELECTED
#define VOICE1 ((Gadget33.Flags & SELECTED) == SELECTED)
#define VOICE2 ((Gadget36.Flags & SELECTED) == SELECTED)
#define VOICE3 ((Gadget34.Flags & SELECTED) == SELECTED)
#define VOICE4 ((Gadget35.Flags & SELECTED) == SELECTED)
#define SCARD ((Gadget38.Flags & SELECTED) == SELECTED)
#define DCARD ((Gadget37.Flags & SELECTED) == SELECTED)
/* für die Form: if(WAVETEST) {...} */
#define SWCOM (1L << wcom->UserPort->mp_SigBit)
#define SWWAV (1L << wwav->UserPort->mp_SigBit)
#define SWFRQ (1L << wfrq->UserPort->mp_SigBit)
#define SWENV (1L << wenv->UserPort->mp_SigBit)
#define SWSPC ((wspc) ? (1L << wspc->UserPort->mp_SigBit) : 0)
#define SMIDI (1L << dest->DestPort->mp_SigBit)
/* für die Hauptschleife */
#define ACTSOUND SoundData[iebase*64+actual]
#define SOURCE (SCARD*64+(int)(Gadget26SInfo.HorizPot / Gadget26SInfo.HorizBody))
#define DESTIN (DCARD*64+(int)(Gadget27SInfo.HorizPot / Gadget27SInfo.HorizBody))
#define PERCENT (Gadget28SInfo.HorizPot / 65535.0)
#define MIX(A,B) (int)(fas*(A) + fad*(B))
#define MIN(A,B) (((A)<(B)) ? (A) : (B))
#define MAX(A,B) (((A)>(B)) ? (A) : (B))
#define DS11 ACTSOUND[11]
#define DS17 ACTSOUND[17]
#define DS22 ACTSOUND[22]
#define DS35 ACTSOUND[35+envVoice]
/* für die Bitfeldzugriffe */
#define SSWAP(N) z=a[N]; a[N]=b[N]; b[N]=z
/* für die SpecialExchange */
int
BoZa[6],
FrqProps[3] = /* Frequenz-TextProps (Param.) */
{ 27,23,83 },
PropOffset[29] = /* Anzeige-Offsets */
{ 0,1,1,-50,0, 1,1,1,1, -24,-50,-50,-24,-50,-50,-24,-50,-50,-24,-50,-50,
-50,-50,-50,-50,-50, 1,1,0
},
EnvProp[11][2] = /* ENV-Gadgets --> Param. */
{ 57,43, 58,59, 59,55, 60,51, 61,47, 62,39,
21,67, 22,71, 23,63, 24,75, 25,79
},
GrafProp[13] = /* Gadgets 50..62 --> Param. */
{ 21,20,19,18, 14,16,13, 43,59,55,51,47,39
},
TextProp[29] = /* Gadgets 1..28 --> Param. */
{ 0, 0,10,12,15, 0,0,0,0, 27,23,83, 28,24,84, 29,25,85, 30,26,86,
67,71,63,75,79, 0,0,0
},
RangeMax[22] = /* max. Werte der s0..s21 Parameter */
{ 0,0,0,0,0,0,0,0,0,0,99,0,100,100,100,12,100,0,100,100,100,100
};
char
*BoTe[6][5] = /* BOOLtexte zum durchschalten */
{ "POLY 1","POLY 2"," SOLO ",0,0,
"2","4",0,0,0,
"-|-","-->","<--",0,0,
"-|-","-->","<--",0,0,
"Single","Multi ",0,0,0,
"INT","int","EXT","ext",0
},
*PrTe[29] = /* PROPtexte zum formatieren */
{ 0,0,"Volume=%3d","Prs } Freq:%3d","Pitch Wheel:%2d",
0,0,0,0,
0,"Freq Fine = %3d","KS } Freq = %3d",
0,"Freq Fine = %3d","KS } Freq = %3d",
0,"Freq Fine = %3d","KS } Freq = %3d",
0,"Freq Fine = %3d","KS } Freq = %3d",
"Prs } EnvLevel %3d","KS } EnvLevel %3d","VC } EnvLevl %3d",
"VC } EnvTime %3d","KS } EnvTime %3d",
0,0,0
},
*ToneName[12] =
{ "C ","C#","D ","D#","E ","F ","F#","G ","G#","A ","B ","H "
},
*WaveName[256] =
{ "Sine 1st","Sine 2nd","Sine 3rd","Sine 4th","Sine 5th","Sine 6th","Sine 7th",
"Sine 8th","Sine 9th","Sine 10th","Sine 11th","Sine 12th","Sine 16th","Saw 1",
"Saw 2","Saw 3","Saw 4","Saw 5","Saw 6","Saw 7","Saw 8","Saw 9","Saw 10",
"Saw 11","Saw 12","Saw 13","Saw 14","Saw 15","Saw 16","Saw 17","Saw 18","Saw 19",
"Square 1","Square 2","Square 3","Square 4","Square 5","Inverse-Saw","Triangle",
"Random",
"French Horn","String 1","String 2","String Pad","Piano 1","El.Grand",
"E.Piano 1","E.Piano 2","E.Piano 3","Clavi","Vibe","A.Guitar","F.Guitar 1",
"F.Guitar 2","Ac Bass 1","Ac Bass 2","Digi Bass 1","Pick Bass","Digi Bass 2",
"Round Bass","Fretless 1","Fretless 2","Flute","Panflute","Harmonica","Glocken",
"Tine","Harp","Marimba","E.Tom","Log Drum","Jazz Organ 1","Mello Pad",
"Synth Solo","Synth 2",
"French Horn 1","French Horn 2","Brass 1","Brass 2","Brass 3","Brass 4",
"Trumpet 1","Trumpet 2","Violin","String","Piano 1","Piano 2","Piano 3",
"Piano 2b","Piano 3b","Piano 4","Piano 4b","El.Grand","E.Piano 1","E.Piano 2",
"E.Piano 3","Clavi","Harpsichord","Vibe","A.Guitar","F.Guitar","Strat 1",
"Strat 2","Ac Bass","Pull Bass 1","Pull Bass 2","Round Bass","Slap Bass 1",
"Slap Bass 2","Slap Bass 3","Fretless 1","Fretless 2","Synth Bass 1",
"Synth Bass 2","Harmonica","Clarinet 1","Clarinet 2","Oboe 1","Oboe 2",
"Shakuhachi","Oriental Bell 1","Oriental Bell 2","Bell","Koto","Sitar",
"E.Tom","Log Drum 1","Log Drum 2","Steel Drum 1","Steel Drum 2","Voice 1",
"Voice 2","Accordion 1","Accordion 2","Jazz Organ 2","Rock Organ 1","Draw Bar 1",
"Draw Bar 2","Pipe Organ 1","Pipe Organ 2","Rock Organ 2","Synth Solo 1",
"Synth Solo 2","Synth 2","Synth 2b","Synth 3",
"Brass 1","Brass 2","Orchestra","Piano 1","Piano 4","E.Piano 1","E.Piano 1b",
"E.Piano 2","E.Piano 3","Clavi","Harpsichord 1","Harpsichord 2","Vibe",
"Digi Bass 1","Digi Bass 2","Digi Bass 2b","Pick Bass","Glocken 1","Glocken 2",
"Tine 1","Tine 2","Tine 3","Tube Bell 1","Tube Bell 2","Tube Bell 3",
"Xylophone 1","Xylophone 2","Harp","Koto","Sitar 1","Sitar 2","Kalimba 1",
"Kalimba 2","Kalimba 3","Log Drum","Steel Drum","Pipe Organ 3","Pipe Organ 3b",
"Synth 1","Synth 2","Synth 3","Synth 3b","Synth 4","Synth 4b",
"Clavi","Digi Bass 1","Digi Bass 2","Pick Bass 1","Pick Bass 2","Round Bass 1",
"Round Bass 2","Harmonica 1","Harmonica 2","Harp","Koto","Sitar","Marimba",
"Synth 1",
/* nun noch die PCM-Samples */
"Bass Drum","Ac Snare","Tight Snare","E.Snare","Rim","Ac Tom","HiHat","Crash",
"Ride","Strat Guitar","Fuzz Mute","A.Guitar","F.Guitar","Guitar Harmo","Pull Bass",
"Bass Harmo","Bowed String","String Attack","String Sus","Pizzicato","Piano",
"El.Grand","Piano Noise","Trumpet","Shakuhachi Att","Shakuhachi Sus","Panflute Att",
"Panflute Sus","Voice","White Noise",
"String Loop","Shakuhachi Loop","Panflute Loop","Voice Loop","White Noise Loop",
"Ac Snare Loop","F.Guitar Loop","Pull Bass Loop",
"Omni Loop 1","Omni Loop 2","Omni Loop 3","Omni Loop 4","Omni Loop 5","Omni Loop 6",
"Omni Loop 7","Omni Loop 8",
"Ac Snare Rev","Ac Tom Rev","F.Guitar Rev",
"HiHat Alt","Crash Alt","Piano Noise Alt"
},
*WriteError[4] =
{ "Einfacher Schreibfehler","Der Synthspeicher ist schreibgeschützt!",
"Keine Cartridge vorhanden!","K1 antwortet nicht!"
};
SHORT NormAB[22] = { 0,20,8,15,16,12,24,9,32,7,40,6,48,4,56,3,64,2,72,1,80,0 },
ABvec0[22], ABvec1[8] =
{ 41,64,41,-1,123,-1,123,64
}, ABvec2[8] =
{ -2,1,129,1,129,21,-2,21
}, VBvec0[14], VBvec1[8] =
{ 0,0,123,0,123,0,0,0
}, VBbas[4][14] =
{ 0,0,0,0,0,0,30,30,61,0,92,-30,123,0, /* die 4 Vibratokurven */
0,0,0,0,0,0,0,0,61,30,61,-30,123,0,
0,0,0,0,0,30,61,30,61,-30,123,-30,123,0,
0,20,20,25,41,-16,61,30,82,28,102,-30,123,-5
}, KSCvec[5][8] =
{ 1,32,1,32,130,1,130,1, /* die 5 KS-Kurven */
1,32,43,27,86,18,130,1,
1,32,43,18,86,6,130,1,
1,32,50,32,80,1,130,1,
1,32,65,32,65,1,130,1
}, ENVvec[10] =
{ 1,62,64,62,128,1,192,16,256,62
}, VCvec[8][8] =
{ 1,32,1,32,130,1,130,1, /* die Velocity-Kurven */
1,32,43,18,86,6,130,1,
1,32,43,27,86,18,130,1,
1,32,78,26,104,17,130,1,
1,32,60,32,112,3,130,1,
1,32,31,28,100,5,130,1,
1,32,30,16,100,9,130,1,
1,1,65,1,100,32,130,32
};
struct Border
ABlines2 = { 29,48,3,0,JAM1,4,ABvec2,NULL },
ABlines1 = { 29,48,3,0,JAM1,4,ABvec1,&ABlines2 },
ABlines = { 29,48,2,0,JAM1,11,ABvec0,&ABlines1 },
VBlines1 = { 347,79,3,0,JAM1,4,VBvec1,NULL },
VBlines = { 347,79,2,0,JAM1,7,VBvec0,&VBlines1 },
KSCline = { -2,-1,2,0,JAM1,4,KSCvec[0],NULL },
ENVline = { 30,23,2,0,JAM1,5,ENVvec,NULL },
VCline = { -2,-1,2,0,JAM1,4,VCvec[0],NULL };
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Screen *ms;
struct Window *wcom, *wwav, *wfrq, *wenv, *wacp, *wspc = NULL;
struct Preferences prefs;
struct MidiBase *MidiBase;
struct ReqBase *ReqBase;
struct MDest *dest;
struct MSource *src;
struct MRoute *inroute, *outroute;
UBYTE SoundData[128][88],
request[9] = { MS_SYSEX,MID_KAWAI,0,K1_OBDR,K1_GROUP,KAWAI_K1,K1_INT,0,MS_EOX },
*idata = NULL, *WarteZeiger = NULL;
int cardda = 0, iebase = 0, actual = 0, channel, envVoice = 0,
kscurve = 0, wavetestnote = 60, specialfunktion, voicemask;
struct Process *myprocess;
APTR olderrorwindow;
struct FileRequester MyFileReqStruct;
char filename[FCHARS],
directoryname[DSIZE],
answerarray[DSIZE+FCHARS],
*extension[4] = { ".single",".block",".all",".dump" };
struct TRStructure meintrs = { 0,0,0,0,0,0,"Sag mir:",0xFFFF,0,0,0,0,0,0 };
extern char *get_fname();
extern struct Library *IconBase = NULL;
static struct MRouteInfo riin =
{ MMF_SYSEX+MMF_PROG, -1, 0, 0, { 0,0,0,0 }, { 0,0,0,0 } };
/* d.h. nur SysExs und ProgChanges passieren die Route */
static struct MRouteInfo riout =
{ MMF_SYSEX+MMF_CHAN, -1, 0, 0, { 0,0,0,0 }, { 0,0,0,0 } };
/* d.h. SysExs und alle ChannelMsgs passieren die Route */
USHORT oWarteZeiger[2][19] =
{ 0,0,
0x0180,0,0x0660,0,0x1818,0,0x6006,0,
0xffff,0x0000,0xf33f,0x0cc0,0xf57f,0x0a80,0xf331,0x0cce,
0xf57f,0x0a80,0xf33f,0x0cc0,0xffff,0x0000,0xd249,0x2db6,
0xb76b,0x4894,0xb36b,0x4c94,0xd75b,0x28a4,0xb34b,0x4cb4,
0xffff,0x0000,
0,0
};
/*******************************************************************/
int WoIsK1() /* -1 bei nirgends Ack, sonst 0..15 */
{ static UBYTE req[5] = { MS_SYSEX,MID_KAWAI,0,K1_MIR,MS_EOX };
UBYTE *ack;
int chn;
for(chn=0; chn<16; chn++)
{ req[OFFS_CHAN] = chn;
PutMidiMsg(src, req);
Delay(25L);
while(ack = GetMidiMsg(dest))
if(ack[OFFS_FUNC] == K1_MIA) return chn;
}
return -1;
}
GetBlock(channel,ie,nr,data) /* Einmal leersaugen, bitte */
int channel,ie,nr;
UBYTE *data;
{ UBYTE *msg;
request[OFFS_CHAN] = channel;
request[OFFS_FUNC] = K1_ABDR;
request[OFFS_SUB1] = ie;
request[OFFS_SUB2] = nr;
PutMidiMsg(src, request);
WaitPort(dest->DestPort);
if(msg = GetMidiMsg(dest))
{ if(msg[OFFS_FUNC]==K1_ABDD) movmem(msg+OFFS_DATA, data, (nr < 64) ? 32*88 : 32*76);
FreeMidiMsg(msg);
}
}
PutBlock(channel,ie,nr,data) /* Einmal vollpumpen, bitte */
int channel,ie,nr;
UBYTE *data;
{ UBYTE *msg,*reply;
int err = 4, bs = (nr < 64) ? 32*88 : 32*76; /* BlockSize abh. von Single/Multi */
register int i;
if(msg = AllocMem(9+bs, MEMF_PUBLIC+MEMF_CLEAR))
{ movmem(request, msg, 9); /* den Header vom Request übernehmen */
msg[OFFS_CHAN] = channel;
msg[OFFS_FUNC] = K1_ABDD;
msg[OFFS_SUB1] = ie;
msg[OFFS_SUB2] = nr;
if(nr < 64) for(i=0; i<32; i++) CalcCheckSum(ie*64+nr+i); /* Prüfsummen neu berechnen */
movmem(data, msg+OFFS_DATA, bs);
msg[OFFS_DATA+bs] = MS_EOX;
PutMidiMsg(src, msg); /* Hinfort! Weiche von mir, elender Dump! */
}
WaitPort(dest->DestPort);
if(reply = GetMidiMsg(dest))
{ err = reply[OFFS_FUNC];
FreeMidiMsg(reply);
}
if(msg) FreeMem(msg, 9+bs);
return(err & 7);
}
CalcCheckSum(n) /* Prüfsumme für Sound n berechnen */
int n; /* n = 0..127 */
{ register int i,cs;
register UBYTE *a;
a = SoundData[n];
for(i=0, cs=0xA5; i<87; ++i) cs = (cs + a[i]) & 127;
a[87] = cs;
}
GetSound(channel,ie,nr,data) /* Einmal Single, bitte */
int channel,ie,nr;
UBYTE *data;
{ UBYTE *msg;
request[OFFS_CHAN] = channel;
request[OFFS_FUNC] = K1_OBDR;
request[OFFS_SUB1] = ie;
request[OFFS_SUB2] = nr;
PutMidiMsg(src, request);
WaitPort(dest->DestPort);
if(msg = GetMidiMsg(dest))
{ movmem(msg+OFFS_DATA, data, (nr < 64) ? 88 : 76);
FreeMidiMsg(msg);
}
}
PutSound(channel, ie, nr, data) /* Einen SingleSound senden */
int channel, ie, nr;
UBYTE *data;
{ UBYTE msg[9+88], *reply;
int err = 4;
movmem(request, msg, 9); /* den Header vom Request übernehmen */
msg[OFFS_CHAN] = channel;
msg[OFFS_FUNC] = K1_OBDD;
msg[OFFS_SUB1] = ie;
msg[OFFS_SUB2] = nr;
CalcCheckSum(ie*64+nr); /* Prüfsumme für den Sound */
movmem(data, msg+OFFS_DATA, 88);
msg[OFFS_DATA+88] = MS_EOX;
PutMidiMsg(src, msg); /* und ab damit */
WaitPort(dest->DestPort); /* auf den Reply warten */
if(reply = GetMidiMsg(dest))
{ err = reply[OFFS_FUNC];
FreeMidiMsg(reply);
}
WaitTOF();
WaitTOF();
WaitTOF();
WaitTOF();
WaitTOF();
ProgChange(nr); /* Änderungen aktivieren */
return(err & 7);
}
NoteOn(note, vel) /* Ton einschalten */
int note, vel;
{ UBYTE msg[3];
msg[0] = MS_NOTEON | channel;
msg[1] = note;
msg[2] = vel;
PutMidiMsg(src, msg);
}
NoteOff(note) /* Ton ausschalten */
int note;
{ UBYTE msg[3];
msg[0] = MS_NOTEOFF | channel;
msg[1] = note;
msg[2] = 64;
PutMidiMsg(src, msg);
}
AllNotesOff() /* Alle Töne ausschalten */
{ UBYTE msg[3];
msg[0] = MS_MODE | channel;
msg[1] = MM_ALLOFF; /* All Notes Off */
msg[2] = 0;
PutMidiMsg(src, msg); /* Alles aus */
}
ProgChange(nr) /* Sound wechseln */
int nr;
{ UBYTE msg[3];
msg[0] = MS_PROG | channel;
msg[1] = nr;
msg[2] = 0;
PutMidiMsg(src, msg);
}
int UserRequest(text,a,b,c)
char *text,*a,*b,*c;
{
meintrs.Text = text;
meintrs.NegativeText = a; /* 0 (rechts) */
meintrs.PositiveText = b; /* 1 (links) */
meintrs.MiddleText = c; /* 2 (mitte) */
return TextRequest(&meintrs);
}
ImWorking()
{ if(wspc) SetPointer(wspc,WarteZeiger,17,16,-8,-7);
SetPointer(wcom,WarteZeiger,17,16,-8,-7);
SetPointer(wwav,WarteZeiger,17,16,-8,-7);
SetPointer(wfrq,WarteZeiger,17,16,-8,-7);
SetPointer(wenv,WarteZeiger,17,16,-8,-7);
SetPointer(wacp,WarteZeiger,17,16,-8,-7);
}
ImWaiting()
{ if(wspc) ClearPointer(wspc);
ClearPointer(wcom);
ClearPointer(wwav);
ClearPointer(wfrq);
ClearPointer(wenv);
ClearPointer(wacp);
}
float fabs(z)
float z;
{
return((z < 0.0) ? -z : z);
}
int iabs(z)
int z;
{
return((z < 0) ? -z : z);
}
struct Gadget *FindGadget(fe, id)
struct Window *fe;
int id;
{ struct Gadget *ga;
ga = fe->FirstGadget;
do
if(ga->GadgetID == id) return(ga);
while((ga = ga->NextGadget) != NULL);
return(NULL);
}
EinGadget(w,g)
struct Window *w;
struct Gadget *g;
{ SHORT l,t;
if(g->UserData == 1) return;
g->UserData = 1;
SetDrMd(w->RPort,JAM1+COMPLEMENT);
SetAPen(w->RPort,1);
l = g->LeftEdge; t = g->TopEdge;
RectFill(w->RPort,l,t,l+g->Width-1,t+g->Height-1);
}
AusGadget(w,g)
struct Window *w;
struct Gadget *g;
{ SHORT l,t;
if(g->UserData == 0) return;
g->UserData = 0;
SetDrMd(w->RPort,JAM1+COMPLEMENT);
SetAPen(w->RPort,1);
l = g->LeftEdge; t = g->TopEdge;
RectFill(w->RPort,l,t,l+g->Width-1,t+g->Height-1);
}
TogGadget(w,g)
struct Window *w;
struct Gadget *g;
{
if(g->UserData == 0) EinGadget(w,g); else AusGadget(w,g);
}
ClearGadget(g,w)
struct Gadget *g;
struct Window *w;
{
SetAPen(w->RPort, 0); SetDrMd(w->RPort, JAM1);
RectFill(w->RPort, g->LeftEdge-1, g->TopEdge,
g->LeftEdge+g->Width, g->TopEdge+g->Height-1);
}
CleanUp()
{
if(inroute) DeleteMRoute(inroute);
if(outroute) DeleteMRoute(outroute);
if(dest) DeleteMDest(dest);
if(src) DeleteMSource(src);
if(ReqBase) { PurgeFiles(&MyFileReqStruct); CloseLibrary(ReqBase); }
if(MidiBase) CloseLibrary(MidiBase);
if(wenv) { ClearMenuStrip(wenv); CloseWindow(wenv); }
if(wfrq) { ClearMenuStrip(wfrq); CloseWindow(wfrq); }
if(wwav) { ClearMenuStrip(wwav); CloseWindow(wwav); }
if(wcom) { ClearMenuStrip(wcom); CloseWindow(wcom); }
if(wacp) CloseWindow(wacp);
if(wspc) { ClearMenuStrip(wspc); CloseWindow(wspc); }
myprocess->pr_WindowPtr = olderrorwindow;
if(ms) CloseScreen(ms);
if(IntuitionBase) CloseLibrary(IntuitionBase);
if(idata) FreeMem(idata, 80+76);
}
shit(text)
char *text;
{
if(text) UserRequest(text,0,0," Tschüß! ");
CleanUp();
exit(0);
}
DrawNewEnvelope()
{ register long delay,level;
register float fact;
fact = 63.0 / 65535.0;
delay = 1+(long)(Gadget78SInfo.HorizPot * fact);
ENVvec[2] = delay;
ENVvec[4] = delay + (long)(Gadget81SInfo.HorizPot * fact);
ENVvec[6] = ENVvec[4] + (long)(Gadget83SInfo.HorizPot * fact);
ENVvec[8] = ENVvec[6] + (long)(Gadget80SInfo.HorizPot * fact);
fact = 61.0 / 65535.0;
level = 61-(long)(Gadget79SInfo.VertPot * fact);
ENVvec[5] = 62-level;
ENVvec[7] = 62-(long)(level * (1.0 - Gadget82SInfo.VertPot / 65535.0));
SetAPen(wenv->RPort,0); SetDrMd(wenv->RPort,JAM1);
RectFill(wenv->RPort,30,24,285,85);
DrawBorder(wenv->RPort,&ENVline,0,0);
}
DrawABend()
{ register int i,r;
for(i=0; i<22; i+=2)
{ ABvec0[i] = 2 + (long)(NormAB[i] * Gadget16SInfo.HorizPot / 65535.0);
ABvec0[i+1] = 31 - (long)(NormAB[i+1] * (1.0 - Gadget9SInfo.VertPot / 32767.5));
}
r = (int)(ABvec0[20] * fabs(0.5 - Gadget4SInfo.HorizPot / 65535.0));
ABvec1[0] = ABvec1[2] = ABvec0[20]-r;
ABvec1[4] = ABvec1[6] = ABvec0[20]+r;
r = (int)((31-ABvec0[1]) * fabs(0.5 - Gadget17SInfo.VertPot / 65535.0));
ABvec2[1] = ABvec2[3] = ABvec0[1]-r;
ABvec2[5] = ABvec2[7] = ABvec0[1]+r;
SetAPen(wcom->RPort,0); SetDrMd(wcom->RPort,JAM1);
RectFill(wcom->RPort,27,47,158,112);
DrawBorder(wcom->RPort,&Border6,0,0);
}
DrawVibrato()
{ register int i,r;
for(i=0; i<14; i+=2)
{ VBvec0[i] = (int)(VBbas[DS17 & 3][i] * Gadget18SInfo.HorizPot / 65535.0);
VBvec0[i+1] = (int)(VBbas[DS17 & 3][i+1] * (Gadget11SInfo.VertPot / 32767.5 - 1.0));
}
i = iabs((int)(30 * (Gadget11SInfo.VertPot / 32767.5 - 1.0))); /* Amplitude */
r = i - (int)(30 * (Gadget15SInfo.VertPot / 32767.5 - 1.0)); /* Aftertouchrange */
if(r < 0) r = 0; else if(r > 30) r = 30;
VBvec1[1] = VBvec1[3] = -r;
VBvec1[5] = VBvec1[7] = r;
SetAPen(wcom->RPort,0); SetDrMd(wcom->RPort,JAM1);
RectFill(wcom->RPort,347,49,471,111);
DrawBorder(wcom->RPort,&Border1,347,49);
DrawBorder(wcom->RPort,&VBlines,0,0);
}
EnvDisplay() /* das ENV-Fenster refreshen */
{ register int i,id;
register ULONG w;
register struct PropInfo *si;
struct Gadget *FindGadget(), *g;
for(i=0; i<11; i++)
{ id = EnvProp[i][0]; /* Gadget-ID */
g = FindGadget(wenv,id); /* Gadget finden */
si = g->SpecialInfo; /* davon die SpecialInfo */
w = ACTSOUND[EnvProp[i][1] + envVoice]; /* welchen Wert dafür? */
if(si->Flags & FREEVERT) si->VertPot = 65535-655*w; else si->HorizPot = 655*w;
if(id < 50) /* ein TextProp... */
sprintf( ((struct IntuiText *)(g->GadgetText))->IText, PrTe[id], w-50);
/* -50 (Offset) bei allen TextProps im ENV-Fenster */
}
SetAPen(wenv->RPort,0); SetDrMd(wenv->RPort,JAM1);
RectFill(wenv->RPort,313,25,442,55);
VCline.XY = VCvec[(DS35 & 0x70) >> 4];
*(wenv->Title + 7) = '1' + envVoice; /* FensterTitel */
RefreshWindowFrame(wenv);
RefreshGadgets(wenv->FirstGadget,wenv,0);
DrawNewEnvelope();
}
AktDisplay() /* kompletter Gadgetrefresh */
{ register int i,j,id;
register ULONG w;
register struct PropInfo *si;
struct Gadget *FindGadget(), *g;
ImWorking();
BoZa[0] = DS11 & 3; /* zuerst die Bool2TextGadgets */
strcpy(IText3.IText,BoTe[0][BoZa[0]]);
BoZa[1] = ((DS11 & 4) >> 2);
strcpy(IText7.IText,BoTe[1][BoZa[1]]);
BoZa[2] = ((DS11 & 24) >> 3);
strcpy(IText87.IText,BoTe[2][BoZa[2]]);
BoZa[3] = ((DS11 & 96) >> 5);
strcpy(IText84.IText,BoTe[3][BoZa[3]]);
RefreshGList(&Gadget68, wwav, 0, 2); /* extra: AmpMod */
for(i=0; i<13; i++)
{ g = FindGadget(wcom,50+i); /* Prop2Graf Gadget finden */
si = g->SpecialInfo; /* davon die SpecialInfo */
w = ACTSOUND[GrafProp[i]]; /* welchen Wert dafür? */
if(si->Flags & FREEVERT)
si->VertPot = 65535 - w * si->VertBody;
else if(i==5) /* LFOspeed extra */
si->HorizPot = 65535 - w * si->HorizBody;
else
si->HorizPot = w * si->HorizBody;
}
Gadget3SInfo.HorizPot = actual * Gadget3SInfo.HorizBody; /* Single */
sprintf(IText10.IText, "Single %2d", actual+1);
movmem(ACTSOUND, Gadget2SIBuff, 10); /* Name */
Gadget2SIBuff[10] = 0;
Gadget10.Flags = Gadget10.Flags & ~SELECTED | (((DS17 & 0x20) >> 5) * SELECTED); /* WheelAssign */
for(i=2; i<5; i++)
{ g = FindGadget(wcom,i); /* Prop2Text Gadget finden */
si = g->SpecialInfo; /* davon die SpecialInfo */
w = ACTSOUND[TextProp[i]]; /* welchen Wert dafür? */
si->HorizPot = w * si->HorizBody;
Prop2Text(wcom,g);
}
if(w = Gadget5.UserData) AusGadget(wcom, &Gadget5);
RefreshGadgets(wcom->FirstGadget, wcom, 0);
if(w) EinGadget(wcom, &Gadget5);
w = MenuItem2.Flags & CHECKED;
MenuItem2.Flags &= ~CHECKED;
for(i=5; i<9; i++)
{ g = FindGadget(wwav,i); /* Prop2Text Gadget finden */
si = g->SpecialInfo; /* davon die SpecialInfo */
si->HorizPot = (ACTSOUND[26+i] + 128 * (ACTSOUND[30+i] & 1)) * 257;
Prop2Text(wwav,g);
RefreshGList(g, wwav, 0, 1);
}
if(w) MenuItem2.Flags |= CHECKED;
if(DS22 & 1) AusGadget(wwav,&Gadget70); else EinGadget(wwav,&Gadget70);
if(DS22 & 2) AusGadget(wwav,&Gadget71); else EinGadget(wwav,&Gadget71);
if(DS22 & 4) AusGadget(wwav,&Gadget72); else EinGadget(wwav,&Gadget72);
if(DS22 & 8) AusGadget(wwav,&Gadget73); else EinGadget(wwav,&Gadget73);
/* Flag gesetzt bedeutet Stimme stummgeschaltet!!! */
for(i=0; i<4; i++) /* 4 Stimmen */
{ w = ACTSOUND[35 + i]; /* die Schalter... */
if(w & 2) EinGadget(wfrq,FindGadget(wfrq,207+i*3)); else AusGadget(wfrq,FindGadget(wfrq,207+i*3));
if(w & 8) EinGadget(wfrq,FindGadget(wfrq,208+i*3)); else AusGadget(wfrq,FindGadget(wfrq,208+i*3));
if(w & 4) EinGadget(wfrq,FindGadget(wfrq,209+i*3)); else AusGadget(wfrq,FindGadget(wfrq,209+i*3));
for(j=0; j<3; j++) /* mit jew. 3 PropGadgets */
{ g = FindGadget(wfrq, 9+i*3+j); /* das sind die TextProps */
si = g->SpecialInfo;
if(j==0)
{ si->HorizBody = (ACTSOUND[35+i] & 2) ? 1365 : 636;
PropOffset[9+i*3] = (ACTSOUND[35+i] & 2) ? -24 : 0;
si->HorizPot = (ACTSOUND[35+i] & 2) ? (ACTSOUND[FrqProps[j]+i]-60) * si->HorizBody
: (ACTSOUND[FrqProps[j]+i]) * si->HorizBody;
}
else
si->HorizPot = ACTSOUND[FrqProps[j]+i] * si->HorizBody;
Prop2Text(wfrq,g);
RefreshGList(g, wfrq, 0, 1);
}
}
DrawABend();
DrawVibrato();
EnvDisplay();
ImWaiting();
}
Init(lace)
BOOL lace;
{ long a,b,c,d;
FILE *fp;
struct ViewPort *vp;
int w,h;
if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 33L)))
shit(0);
GfxBase=IntuitionBase->GfxBase;
GetPrefs(&prefs, sizeof(prefs));
if(!(ReqBase = (struct ReqBase *)OpenLibrary("req.library", 0L)))
{ DisplayBeep(0L);
shit(0);
}
if(!(MidiBase = OpenLibrary(MIDINAME, MIDIVERSION)))
shit("Wou issie Miedieleibräri?");
dest = CreateMDest(NULL, NULL);
src = CreateMSource(NULL, NULL);
inroute = MRouteDest("MidiIn", dest, &riin);
outroute = MRouteSource(src, "MidiOut", &riout);
if((channel = WoIsK1()) == -1)
{ if(UserRequest("Kein K1 gefunden. Was tun?"," Abbruch "," Trotzdem starten ",0))
{ MenuItem2.Flags &= ~(ITEMENABLED+CHECKED); /* Wavetest */
MenuItem1.Flags &= ~(ITEMENABLED+CHECKED); /* Autowrite */
MenuItem7.Flags &= ~ITEMENABLED; /* Test Sound */
MenuItem9.Flags &= ~ITEMENABLED; /* Put dump */
MenuItem8.Flags &= ~ITEMENABLED; /* Get dump */
MenuItem13.Flags &= ~ITEMENABLED; /* Write */
MenuItem12.Flags &= ~ITEMENABLED; /* Read */
cardda = 1;
}
else
shit(NULL);
}
else
{ riin.ChanFlags = 1L << channel; /* Kanal bekannt: Kanalfilter EIN */
riout.ChanFlags = 1L << channel;
ModifyMRoute(inroute, &riin); /* ...Routen erneuern */
ModifyMRoute(outroute, &riout);
GetBlock(channel,0, 0,SoundData); /* Einmal leersaugen, bitte */
GetBlock(channel,0,32,SoundData[32]);
if(cardda = UserRequest("Ist eine Cartridge vorhanden?"," Im Moment nich "," Aber sicher ",0))
{ GetBlock(channel,1, 0,SoundData[64]); /* wenn geht, auch die externen */
GetBlock(channel,1,32,SoundData[96]);
}
else
Gadget5.Flags |= GADGDISABLED;
}
idata = AllocMem(80+76, MEMF_CHIP);
movmem(ImageData6, idata, 40);
movmem(ImageData7, idata+40, 40);
Image6.ImageData = idata;
Image7.ImageData = idata+40;
movmem(oWarteZeiger,idata+80,76); /* Maus-Zeigerdaten */
WarteZeiger = idata+80;
srand(time(NULL));
vp = &IntuitionBase->ActiveScreen->ViewPort; /* das wird wohl der WBenchScreen sein */
w = NewScreenStructure.Width = vp->DWidth;
h = NewScreenStructure.Height = vp->DHeight;
NewScreenStructure.ViewModes = vp->Modes;
if(lace && !(vp->Modes & LACE)) /* LACE als Option? */
{ NewScreenStructure.ViewModes |= LACE;
NewScreenStructure.Height = (h *= 2);
}
NewWindowStructure3.LeftEdge = (w - 348) / 2;
NewWindowStructure3.TopEdge = (h - 78) / 2;
NewWindowStructure5.LeftEdge = w - 419;
NewWindowStructure5.TopEdge = h - 172;
NewWindowStructure6.LeftEdge = w - 322;
NewWindowStructure7.TopEdge = h - 123;
NewWindowStructure8.LeftEdge = w - 89;
if((ms = OpenScreen(&NewScreenStructure))==NULL) shit("Screen kommt nich!");
if(fp = fopen("DEVS:K1EDcolors","r"))
{ fscanf(fp, "%ld%ld%ld%ld", &a, &b, &c, &d);
fclose(fp);
SetRGB4(&ms->ViewPort, 0, (a & 0xf00) >> 8, (a & 0x0f0) >> 4, a & 0x00f );
SetRGB4(&ms->ViewPort, 1, (b & 0xf00) >> 8, (b & 0x0f0) >> 4, b & 0x00f );
SetRGB4(&ms->ViewPort, 2, (c & 0xf00) >> 8, (c & 0x0f0) >> 4, c & 0x00f );
SetRGB4(&ms->ViewPort, 3, (d & 0xf00) >> 8, (d & 0x0f0) >> 4, d & 0x00f );
}
NewWindowStructure1.Screen = ms;
NewWindowStructure5.Screen = ms;
NewWindowStructure6.Screen = ms;
NewWindowStructure7.Screen = ms;
NewWindowStructure8.Screen = ms;
NewWindowStructure3.Screen = ms;
wacp = OpenWindow(&NewWindowStructure8);
wfrq = OpenWindow(&NewWindowStructure5);
wenv = OpenWindow(&NewWindowStructure7);
wwav = OpenWindow(&NewWindowStructure6);
wcom = OpenWindow(&NewWindowStructure1);
if(wfrq==0 || wenv==0 || wwav==0 || wcom==0) shit("Ein Fenster klemmt.");
ImWorking();
myprocess = (struct Process *)FindTask((char *)0);
olderrorwindow = myprocess->pr_WindowPtr;
myprocess->pr_WindowPtr = (APTR)wcom;
MyFileReqStruct.PathName = answerarray;
MyFileReqStruct.Dir = directoryname;
MyFileReqStruct.File = filename;
MyFileReqStruct.Flags = FRQCACHINGM+FRQINFOGADGETM;
MyFileReqStruct.dirnamescolor = 2;
MyFileReqStruct.devicenamescolor = 2;
Border6.NextBorder = &ABlines; /* AutoBend */
Border1.NextBorder = &VBlines; /* Vibrato */
Border2.NextBorder = &KSCline; /* KS-Kurve */
Border51.NextBorder = &ENVline; /* Envelope */
Border50.NextBorder = &VCline; /* Velocity-Kurve */
DrawBorder(wcom->RPort,&BorderList1,0,0);
DrawBorder(wfrq->RPort,&BorderList5,0,0);
DrawBorder(wenv->RPort,&BorderList7,0,0);
SetMenuStrip(wfrq,&MenuList1);
SetMenuStrip(wenv,&MenuList1);
SetMenuStrip(wwav,&MenuList1);
SetMenuStrip(wcom,&MenuList1);
AktDisplay();
SimpleRequest("\
····································\n\
···· Kawai K1 Single Sound Editor ····\n\
···· Version 1.00 9.Februar 1990 ····\n\
····································\n\n\
Dieses Programm ist SHAREWARE. Wer's benutzt sollte mir einen\n\
ihm/ihr angemessen erscheinenden Betrag zukommen lassen (aber\n\
bitte nicht unter 10 DM, das lohnt den Aufwand nicht) (eine\n\
rechtliche Belehrung zu ShareWare spare ich mir hier).\n\
Bug reports, großzügige Spenden und positive Kritik gehen an:\n\n\
Michael Balzer\n\
Wildermuthstraße 18\n\
5828 Ennepetal 14\n\
W-GERMANY");
}
ReverseVoices(o)
int o;
{ register int a,z;
register UBYTE *act;
ImWorking();
act = ACTSOUND;
for(a=23+o; a<86; a+=4)
{ z = act[a];
act[a] = act[a+1];
act[a+1] = z;
}
AktDisplay(); /* Alle Gadgets */
}
WaveTest(v,w,on) /* eine Wellenform testen */
int v,w;
BOOL on;
{ UBYTE msg[10];
NoteOff(wavetestnote, 64);
AllNotesOff();
if(on)
{ movmem(request,msg,9);
msg[OFFS_FUNC] = K1_PS; /* Parameter Send */
msg[OFFS_CHAN] = channel;
msg[OFFS_SUB1] = 35;
msg[OFFS_SUB2] = (v << 1) | ((w & 128) >> 7);
msg[OFFS_DATA] = w & 127;
msg[OFFS_DATA+1] = MS_EOX;
PutMidiMsg(src, msg); /* neue Wellenform setzen */
WaitTOF();
WaitTOF();
WaitTOF();
NoteOn(wavetestnote, 80);
}
}
Bool2Text(w,g)
struct Window *w;
struct Gadget *g;
{ int id;
char *s;
id = g->GadgetID - 100;
s = ((struct IntuiText *)(g->GadgetText))->IText;
if(BoTe[id][++BoZa[id]] == 0) BoZa[id]=0; /* Text weiterschalten */
if((id==5) && (BoZa[4]==1)) /* kein "int/ext" bei MULTI */
{ if(BoZa[5]==1) BoZa[5]++;
else if(BoZa[5]==3) BoZa[5]=0;
}
strcpy(s,BoTe[id][BoZa[id]]);
RefreshGList(g,w,0,1);
if(id < 4) ACTSOUND[11] = BoZa[0] + (BoZa[1]<<2) + (BoZa[2]<<3) + (BoZa[3]<<5);
if((id==2) && (BoZa[2]!=1)) ReverseVoices(0); /* VoiceParameter tauschen, wenn */
if((id==3) && (BoZa[3]!=1)) ReverseVoices(2); /* AM von oder auf REV kommt */
}
Prop2Text(w,g)
struct Window *w;
struct Gadget *g;
{ int id,x,y,c;
register char *s;
register struct IntuiMessage *m;
register long pw,opw=-1000;
struct Gadget *FindGadget();
char namebuf[11];
id = g->GadgetID;
s = ((struct IntuiText *)(g->GadgetText))->IText;
x = g->LeftEdge;
y = g->TopEdge;
do
{ pw = PropOffset[id] + (long)(g->SpecialInfo->HorizPot / g->SpecialInfo->HorizBody);
if(pw != opw)
{ switch(id)
{ case 1:
actual = pw-1;
sprintf(s, "Single %2d", pw);
movmem(ACTSOUND, Gadget2SIBuff, 10);
Gadget2SIBuff[10] = 0;
RefreshGList(&Gadget2,wcom,0,1);
break;
case 5: case 6: case 7: case 8:
ACTSOUND[26+id] = pw-1 & 127;
if(pw > 128) ACTSOUND[30+id] |= 1; else ACTSOUND[30+id] &= ~1;
if(pw > 204)
{ if(pw>252) c='a';
else if(pw>249) c='r';
else if(pw>241) c='L';
else if(pw>233) c='l';
else c='o';
sprintf(s, "Src %d: %3d. P%c %-18s", id-4, pw, c, WaveName[pw-1]);
if(WAVETEST) WaveTest(id-5,pw-1,TRUE);
break;
}
else if(pw<40) c='b';
else if(pw<75) c='l';
else if(pw<146) c='m';
else if(pw<190) c='t'; /* Treble anstelle Mid-Hi */
else c='h';
sprintf(s, "Src %d: %3d. V%c %-18s", id-4, pw, c, WaveName[pw-1]);
if(WAVETEST) WaveTest(id-5,pw-1,TRUE);
break;
case 9: case 12: case 15: case 18:
if((long)FindGadget(wfrq,198+id)->UserData == 1)
{ sprintf(s, "Freq Coarse = %c%2d%c", (pw < 0) ? '-' : '+', iabs(pw) >> 1, (pw & 1) ? '½' : ' ');
ACTSOUND[27+(id-9)/3] = pw + 84;
}
else
{ sprintf(s, "Fixed Key = %2s%2d", ToneName[pw % 12], (int)(pw / 12) - 2);
ACTSOUND[27+(id-9)/3] = pw;
}
break;
case 26:
movmem(SoundData[SCARD*64+pw-1], namebuf, 10);
namebuf[10] = 0;
sprintf(s, PrTe[26], pw, namebuf);
break;
case 27:
movmem(SoundData[DCARD*64+pw-1], namebuf, 10);
namebuf[10] = 0;
sprintf(s, PrTe[27], pw, namebuf);
break;
default:
sprintf(s, PrTe[id], pw);
if(id < 21) ACTSOUND[TextProp[id]] = pw - PropOffset[id];
else if(id < 26) ACTSOUND[TextProp[id]+envVoice] = pw - PropOffset[id];
}
PrintIText(w->RPort,g->GadgetText,x,y);
opw = pw;
}
WaitTOF();
} while((long)g->Flags & SELECTED);
if(id > 4 && id < 9 && WAVETEST) WaveTest(id-5,pw-1,FALSE);
if(id==1)
{ ProgChange(actual); /* anderen Sound bearbeiten */
AktDisplay();
}
if(m = GetMsg(w->UserPort))
ReplyMsg(m); /* GADGRELEASE replyen */
}
Bool2Graf(w,g)
struct Window *w;
struct Gadget *g;
{ register int we;
switch(g->GadgetID)
{
case 150: /* Vibrato Wellenform */
we = ((DS17 & 3) + 1) % 4;
DS17 = DS17 & ~3 | we;
DrawVibrato();
break;
case 151: /* KS Curve */
we = (((DS17 & 28) >> 2) + 1) % 5;
DS17 = DS17 & ~28 | we << 2;
KSCline.XY = KSCvec[we];
ClearGadget(g,w);
DrawBorder(w->RPort,&KSCline,g->LeftEdge,g->TopEdge);
break;
case 152: /* Velocity Curve */
we = (((DS35 & 0x70) >> 4) + 1) % 8;
DS35 = DS35 & ~0x70 | we << 4;
VCline.XY = VCvec[we];
ClearGadget(g,w);
DrawBorder(w->RPort,&VCline,g->LeftEdge,g->TopEdge);
}
}
Prop2Graf(w,g)
struct Window *w;
struct Gadget *g;
{ register long pw,opw=-1000;
struct PropInfo *si;
int id;
static GrafOffset[13] = { -50,-50,0,-50, -50,0,-50, 0,0,0,0,0,0 };
si = g->SpecialInfo;
id = g->GadgetID;
if(wacp) WindowToFront(wacp);
do
{ if(si->Flags & FREEHORIZ)
pw = (long)(g->SpecialInfo->HorizPot / g->SpecialInfo->HorizBody);
else
pw = (long)((65535-g->SpecialInfo->VertPot) / g->SpecialInfo->VertBody);
if(id == 55) pw = 100 - pw; /* VibSpeed umdrehen */
if(pw != opw)
{ if(id > 56)
{ ACTSOUND[GrafProp[id-50] + envVoice] = pw;
DrawNewEnvelope();
}
else
{ ACTSOUND[GrafProp[id-50]] = pw;
if(id < 54) DrawABend();
else DrawVibrato();
}
opw = pw;
}
sprintf(IText97.IText, "%4d", GrafOffset[id-50]+pw);
PrintIText(wacp->RPort, &IText97, 0,0);
} while((long)g->Flags & SELECTED);
WaitPort(w->UserPort);
ReplyMsg(GetMsg(w->UserPort));
}
MakeInfo(s)
char *s;
{ UBYTE info[2048];
FILE *ifp, *fi;
int l;
char t[64];
strcpy(t,s); strcat(t,".info");
if(ifp=fopen("T:MIDIicon","r"))
{ l = fread(info, 1, 2048, ifp);
if(fi=fopen(t,"w"))
{ fwrite(info, l, 1, fi);
fclose(fi);
}
fclose(ifp);
}
}
GetDump(ie, data) /* einen KOMPLETT-Dump einer Bank holen */
int ie; UBYTE *data;
{
ImWorking();
GetBlock(channel, ie, 0, data);
GetBlock(channel, ie, 32, data+2816);
GetBlock(channel, ie, 64, data+5650);
ImWaiting();
}
int PutDump(ie, data) /* einen KOMPLETT-Dump einer Bank senden */
int ie; UBYTE *data;
{ int err=4;
ImWorking();
err = PutBlock(channel, ie, 0, data);
err |= PutBlock(channel, ie, 32, data+2816);
err |= PutBlock(channel, ie, 64, data+5650);
ImWaiting();
return err;
}
char *extend(name,ext)
char *name, *ext;
{ static char buffer[64];
char *s;
if(s = rindex(name, '.'))
if(strncmp(s, ext) == 0) return name;
strcpy(buffer,name);
strcat(buffer,ext);
return buffer;
}
OpenSpecial() /* Specialsetup-Fenster öffnen */
{ static char *tit[4] = { "Zwei Sounds tauschen","Sounds mischen",
"Soundreihe berechnen (m.Zuf.)","Sound kopieren (m.Zuf.)" };
if(wspc) { ClearMenuStrip(wspc); CloseWindow(wspc); }
NewWindowStructure3.Title = tit[specialfunktion];
switch(specialfunktion)
{ case 0:
PrTe[26] = "SoundA: %2d = %-10s";
PrTe[27] = "SoundB: %2d = %-10s";
PrTe[28] = "-----------";
Gadget28.Flags |= GADGDISABLED;
break;
case 1:
PrTe[26] = "Sound : %2d = %-10s";
PrTe[27] = "Zu Snd: %2d = %-10s";
PrTe[28] = "%3d%% Gew.tg";
Gadget28.Flags &= ~GADGDISABLED;
break;
case 2:
PrTe[26] = "Beginn: %2d = %-10s";
PrTe[27] = "Ende : %2d = %-10s";
PrTe[28] = "%3d%% Zufall";
Gadget28.Flags &= ~GADGDISABLED;
break;
case 3:
PrTe[26] = "Quelle: %2d = %-10s";
PrTe[27] = "Ziel : %2d = %-10s";
PrTe[28] = "%3d%% Zufall";
Gadget28.Flags &= ~GADGDISABLED;
}
if((wspc = OpenWindow(&NewWindowStructure3)) == NULL)
SimpleRequest("Das Fenster klemmt...");
else
{ SetMenuStrip(wspc, &MenuList1);
Prop2Text(wspc, &Gadget26);
Prop2Text(wspc, &Gadget27);
Prop2Text(wspc, &Gadget28);
}
}
HandleMenu(code) /* Na was wohl */
USHORT code;
{ int ie, err;
long ColorRequester();
FILE *fp;
UBYTE *data;
char *s, com[2];
static struct GetLongStruct gl = { "Welche Note für Wavetest? (0..127)",
60,0,127,0,NULL,0,0,0 };
switch(MENUNUM(code))
{ case 0: /*** PROJECT ***/
switch(ITEMNUM(code))
{ case 0: /* ...Load */
ie = UserRequest("Was soll geladen werden?"," Akt.Sound "," Akt.Block "," Alles ");
MyFileReqStruct.Flags = FRQCACHINGM+FRQINFOGADGETM+FRQLOADINGM;
MyFileReqStruct.Title = "Sounddaten einlesen:";
MyFileReqStruct.Show[0] = '*';
strcpy(MyFileReqStruct.Show + 1, extension[ie]);
if(FileRequester(&MyFileReqStruct))
{ if(fp = fopen(answerarray, "r+"))
{ ImWorking();
switch(ie)
{ case 0: fread(ACTSOUND, 88, 1, fp); break;
case 1: fread(SoundData[iebase*64 + (actual & 32)], 32*88, 1, fp); break;
case 2: fread(SoundData, 128*88, 1, fp);
}
fclose(fp);
AktDisplay();
}
else SimpleRequest("Ich kann %s nicht öffnen.", answerarray);
}
break;
case 1: /* ...Save */
ie = UserRequest("Was soll gespeichert werden?"," Akt.Sound "," Akt.Block "," Alles ");
MyFileReqStruct.Flags = FRQCACHINGM+FRQINFOGADGETM+FRQSAVINGM;
MyFileReqStruct.Title = "Sounddaten abspeichern:";
MyFileReqStruct.Show[0] = '*';
strcpy(MyFileReqStruct.Show + 1, extension[ie]);
if(FileRequester(&MyFileReqStruct))
{ if(fp = fopen(s = extend(answerarray, extension[ie]), "w+"))
{ ImWorking();
switch(ie)
{ case 0: fwrite(ACTSOUND, 88, 1, fp); break;
case 1: fwrite(SoundData[iebase*64 + (actual & 32)], 32*88, 1, fp); break;
case 2: fwrite(SoundData, 128*88, 1, fp);
}
fclose(fp);
ImWaiting();
}
else SimpleRequest("Ich kann %s nicht öffnen.", s);
}
break;
case 2: /* ...Read */
ie = UserRequest("Was soll gelesen werden?"," Akt.Sound "," Akt.Block "," Alles ");
ImWorking();
switch(ie)
{ case 0: GetSound(channel, iebase, actual, ACTSOUND); break;
case 1: GetBlock(channel, iebase, actual & 32, SoundData[iebase*64 + (actual&32)]); break;
case 2:
GetBlock(channel,0, 0,SoundData); /* Einmal leersaugen, bitte */
GetBlock(channel,0,32,SoundData[32]);
if(cardda)
{ GetBlock(channel,1, 0,SoundData[64]); /* wenn geht, auch die externen */
GetBlock(channel,1,32,SoundData[96]);
}
}
AktDisplay();
break;
case 3: /* ...Write */
ie = UserRequest("Was soll geschrieben werden?"," Akt.Sound "," Akt.Block "," Alles ");
ImWorking();
switch(ie)
{ case 0: PutSound(channel, iebase, actual, ACTSOUND); break;
case 1: PutBlock(channel, iebase, actual & 32, SoundData[iebase*64 + (actual&32)]); break;
case 2:
PutBlock(channel,0, 0,SoundData); /* Einmal vollpumpen, bitte */
PutBlock(channel,0,32,SoundData[32]);
if(cardda)
{ PutBlock(channel,1, 0,SoundData[64]); /* wenn geht, auch die externen */
PutBlock(channel,1,32,SoundData[96]);
}
}
ImWaiting();
break;
case 4: /* ...Quit */
if(UserRequest("Wirklich Programm beenden?"," Oh NO!!! "," Das ist in der Tat mein Wille. ",0))
shit(0);
break;
}
break;
case 1: /*** DUMP ***/
if((data = AllocMem(8082, MEMF_PUBLIC+MEMF_CLEAR)) == NULL)
{ SimpleRequest("Zuwenig freier/zusammenhängender Speicher!");
break;
}
switch(ITEMNUM(code))
{ case 0: /* ...Get */
ie = UserRequest("Von welcher Soundbank?"," Intern "," Extern ",0);
GetDump(ie, data);
MyFileReqStruct.Flags = FRQCACHINGM+FRQINFOGADGETM+FRQSAVINGM;
MyFileReqStruct.Title = "Dumpdatei abspeichern:";
MyFileReqStruct.Show[0] = '*';
strcpy(MyFileReqStruct.Show + 1, extension[3]);
if(FileRequester(&MyFileReqStruct))
{ if(fp = fopen(s = extend(answerarray, extension[3]), "w+"))
{ ImWorking();
fwrite(data, 8082, 1, fp);
fclose(fp);
MakeInfo(s); /* Icon erstellen für PutDump-Programm */
ImWaiting();
}
else SimpleRequest("Ich kann %s nicht öffnen.", s);
}
break;
case 1: /* ...Put */
MyFileReqStruct.Flags = FRQCACHINGM+FRQINFOGADGETM+FRQLOADINGM;
MyFileReqStruct.Title = "Dumpdatei einlesen:";
MyFileReqStruct.Show[0] = '*';
strcpy(MyFileReqStruct.Show + 1, extension[3]);
if(FileRequester(&MyFileReqStruct))
{ if(fp = fopen(answerarray, "r+"))
{ ImWorking();
err = fread(data, 8082, 1, fp);
fclose(fp);
if(err == 1)
{ ie = UserRequest("In welche Soundbank?"," Intern "," Extern ",0);
if(err = PutDump(ie, data))
SimpleRequest(WriteError[err-1]);
else if(UserRequest("Soll der Editorspeicher erneuert werden?"," Nö "," Jau ",0) == 1)
{ GetBlock(channel,ie, 0,SoundData); /* Einmal leersaugen, bitte */
GetBlock(channel,ie,32,SoundData[32]); /* aber nur was gerade geputtet wurde */
AktDisplay();
}
}
else SimpleRequest("%s ist fehlerhaft oder keine Dumpdatei.", answerarray);
ImWaiting();
}
else SimpleRequest("Ich kann %s nicht öffnen.", answerarray);
}
break;
}
FreeMem(data, 8082);
break;
case 2: /*** SPECIAL ***/
if(ITEMNUM(code) < 4)
{ specialfunktion = ITEMNUM(code);
OpenSpecial();
}
else
{ if(fp = fopen("T:TestSequenz","r"))
{ ImWorking();
while(!feof(fp))
{ fscanf(fp,"%1s%d%d",com,&ie,&err); /* command + 2 parameter */
switch(com[0])
{ case 'D': Delay(ie); break;
case '1': NoteOn(ie, err); break;
case '0': NoteOff(ie); break;
case 'A': AllNotesOff();
}
}
fclose(fp);
AllNotesOff();
ImWaiting();
}
else
SimpleRequest("Ich finde »T:TestSequenz« nicht.");
}
break;
case 3: /*** DUMP ***/
switch(ITEMNUM(code))
{ case 0: /* ...Autowrite */
if(AUTOWRITE) /* beim einschalten: akt.Sound senden */
if(err = PutSound(channel, iebase, actual, ACTSOUND))
SimpleRequest(WriteError[err-1]);
break;
case 1: /* ...Wavetest */
if(WAVETEST && GetLong(&gl)) /* beim einschalten: Note festlegen */
wavetestnote = gl.result;
break;
case 2: /* ...Farben */
if(ColorRequester(-1L) != -1L) /* Gott segne den Schöpfer der RequesterLib */
if(UserRequest("Farbeinstellung abspeichern?"," Lieber nicht "," Wär' gut ",0))
{ if(fp = fopen("DEVS:K1EDcolors","w"))
{ fprintf(fp, "%ld %ld %ld %ld\n",
GetRGB4(ms->ViewPort.ColorMap, 0),
GetRGB4(ms->ViewPort.ColorMap, 1),
GetRGB4(ms->ViewPort.ColorMap, 2),
GetRGB4(ms->ViewPort.ColorMap, 3) );
fclose(fp);
}
}
}
}
}
int rangeran(alt, rng, proz)
int alt, rng;
float proz;
{ int neu;
neu = alt + proz * rng * ( rand() / 16384.0 - 1 );
if(neu > rng) neu -= rng;
else if(neu < 0) neu += rng;
return neu;
}
SpecialExchange(a, b)
UBYTE *a, *b;
{ register int i, z;
if(COMMON)
swapmem(a, b, 23);
if(FREQUENCY) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ SSWAP(23+i);
SSWAP(27+i);
SSWAP(83+i);
z=a[35+i];
a[35+i] &= ~14; a[35+i] |= b[35+i] & 14;
b[35+i] &= ~14; b[35+i] |= z & 14;
}
if(WAVEFORM) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ SSWAP(31+i);
z=a[35+i];
a[35+i] &= ~1; a[35+i] |= b[35+i] & 1;
b[35+i] &= ~1; b[35+i] |= z & 1;
}
if(ENVELOPE) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ SSWAP(39+i);
SSWAP(43+i);
SSWAP(47+i);
SSWAP(51+i);
SSWAP(55+i);
SSWAP(59+i);
SSWAP(63+i);
SSWAP(67+i);
SSWAP(71+i);
SSWAP(75+i);
SSWAP(79+i);
z=a[35+i];
a[35+i] &= ~112; a[35+i] |= b[35+i] & 112;
b[35+i] &= ~112; b[35+i] |= z & 112;
}
}
SpecialMix(a, b, p)
UBYTE *a, *b;
float p;
{ register int i, z;
register float q;
q = 1.0 - p;
if(COMMON) for(i=10; i<23; i++) switch(i)
{ case 11:
z = (int)(q*(b[11]&3) + p*(a[11]&3)) & 3;
b[11] &= ~3; b[11] |= z;
z = (int)(q*((b[11]&4)>>2) + p*((a[11]&4)>>2)) & 1;
b[11] &= ~4; b[11] |= z << 2;
z = (int)(q*((b[11]&24)>>3) + p*((a[11]&24)>>3)) & 3;
b[11] &= ~24; b[11] |= z << 3;
z = (int)(q*((b[11]&96)>>5) + p*((a[11]&96)>>5)) & 3;
b[11] &= ~96; b[11] |= z << 5;
break;
case 17:
z = (int)(q*(b[17]&3) + p*(a[17]&3)) & 3;
b[17] &= ~3; b[17] |= z;
z = (int)(q*((b[17]&28)>>2) + p*((a[17]&28)>>2)) & 7;
b[17] &= ~28; b[17] |= z << 2;
z = (int)(q*((b[17]&96)>>5) + p*((a[17]&96)>>5)) & 3;
b[17] &= ~96; b[17] |= z << 5;
break;
case 22:
b[22] &= a[22]; /* Src Mute nicht sinnvoll für Mix */
break;
default:
b[i] = (int)(q * b[i] + p * a[i]);
}
if(FREQUENCY) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ b[23+i] = (int)(q * b[23+i] + p * a[23+i]);
b[27+i] = (int)(q * b[27+i] + p * a[27+i]);
b[83+i] = (int)(q * b[83+i] + p * a[83+i]);
z = (int)(q*((b[35+i]&2)>>1) + p*((a[35+i]&2)>>1)) & 1;
b[35+i] &= ~2; b[35+i] |= z << 1;
z = (int)(q*((b[35+i]&4)>>2) + p*((a[35+i]&4)>>2)) & 1;
b[35+i] &= ~4; b[35+i] |= z << 2;
z = (int)(q*((b[35+i]&8)>>3) + p*((a[35+i]&8)>>3)) & 1;
b[35+i] &= ~8; b[35+i] |= z << 3;
}
if(WAVEFORM) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ b[31+i] = (int)(q * b[31+i] + p * a[31+i]);
z = (int)(q*(b[35+i]&1) + p*(a[35+i]&2)) & 1;
b[35+i] &= ~1; b[35+i] |= z;
}
if(ENVELOPE) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ b[39+i] = (int)(q * b[39+i] + p * a[39+i]);
b[43+i] = (int)(q * b[43+i] + p * a[43+i]);
b[47+i] = (int)(q * b[47+i] + p * a[47+i]);
b[51+i] = (int)(q * b[51+i] + p * a[51+i]);
b[55+i] = (int)(q * b[55+i] + p * a[55+i]);
b[59+i] = (int)(q * b[59+i] + p * a[59+i]);
b[63+i] = (int)(q * b[63+i] + p * a[63+i]);
b[67+i] = (int)(q * b[67+i] + p * a[67+i]);
b[71+i] = (int)(q * b[71+i] + p * a[71+i]);
b[75+i] = (int)(q * b[75+i] + p * a[75+i]);
b[79+i] = (int)(q * b[79+i] + p * a[79+i]);
z = (int)(q*((b[35+i]&112)>>4) + p*((a[35+i]&112)>>4)) & 7;
b[35+i] &= ~112; b[35+i] |= z << 4;
}
}
SpecialRange(a, b, p)
int a, b;
float p;
{ register int i, z;
int h, zz;
register UBYTE *s = SoundData[a], *d = SoundData[b], *l;
float fas, fad, fb = 1.0 / (b - a);
for(h=a+1; h<b; h++)
{ fad = (h - a) * fb; /* geht so von 0.0 - 1.0 */
fas = 1.0 - fad; /* umgekehrt */
l = SoundData[h]; /* zu bearbeitender Sound */
if(COMMON) for(i=10; i<23; i++) switch(i)
{ case 11:
z = rangeran( MIX(s[11]&3,d[11]&3) , 3, p);
l[11] &= ~3; l[11] |= z;
z = rangeran( MIX((s[11]&4)>>2,(d[11]&4)>>2) , 1, p);
l[11] &= ~4; l[11] |= z << 2;
z = rangeran( MIX((s[11]&24)>>3,(d[11]&24)>>3) , 3, p);
l[11] &= ~24; l[11] |= z << 3;
z = rangeran( MIX((s[11]&96)>>5,(d[11]&96)>>5) , 3, p);
l[11] &= ~96; l[11] |= z << 5;
break;
case 17:
z = rangeran( MIX(s[17]&3,d[17]&3) , 3, p);
l[17] &= ~3; l[17] |= z;
z = rangeran( MIX((s[17]&28)>>2,(d[17]&28)>>2) , 7, p);
l[17] &= ~28; l[17] |= z << 2;
z = rangeran( MIX((s[17]&96)>>5,(d[17]&96)>>5) , 3, p);
l[17] &= ~96; l[17] |= z << 5;
break;
case 22:
l[22] = s[22] & d[22]; /* Src Mute nicht sinnvoll für Ran */
break;
default:
l[i] = rangeran( MIX(s[i],d[i]) , RangeMax[i], p);
}
if(FREQUENCY) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ l[23+i] = rangeran( MIX(s[23+i],d[23+i]) , 100, p);
l[83+i] = rangeran( MIX(s[83+i],d[83+i]) , 100, p);
z = rangeran( MIX((s[35+i]&2)>>1,(d[35+i]&2)>>1) , 1, p);
l[35+i] &= ~2; l[35+i] |= z << 1;
if(z)
{ zz = rangeran( MIX(s[27+i],d[27+i]) , 48, p);
while(zz > 48) zz -= 48;
while(zz < 0) zz += 48;
}
else
{ zz = rangeran( MIX(s[27+i],d[27+i]) , 103, p);
while(zz > 103) zz -= 103;
while(zz < 0) zz += 103;
}
l[27+i] = zz;
z = rangeran( MIX((s[35+i]&4)>>2,(d[35+i]&4)>>2) , 1, p);
l[35+i] &= ~4; l[35+i] |= z << 2;
z = rangeran( MIX((s[35+i]&8)>>3,(d[35+i]&8)>>3) , 1, p);
l[35+i] &= ~8; l[35+i] |= z << 3;
}
if(WAVEFORM) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ l[31+i] = rangeran( MIX(s[31+i],d[31+i]) , 127, p);
z = rangeran( MIX(s[35+i]&1,d[35+i]&1) , 1, p);
l[35+i] &= ~1; l[35+i] |= z;
}
if(ENVELOPE) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ l[39+i] = rangeran( MIX(s[39+i],d[39+i]) , 100, p);
l[43+i] = rangeran( MIX(s[43+i],d[43+i]) , 100, p);
l[47+i] = rangeran( MIX(s[47+i],d[47+i]) , 100, p);
l[51+i] = rangeran( MIX(s[51+i],d[51+i]) , 100, p);
l[55+i] = rangeran( MIX(s[55+i],d[55+i]) , 100, p);
l[59+i] = rangeran( MIX(s[59+i],d[59+i]) , 100, p);
l[63+i] = rangeran( MIX(s[63+i],d[63+i]) , 100, p);
l[67+i] = rangeran( MIX(s[67+i],d[67+i]) , 100, p);
l[71+i] = rangeran( MIX(s[71+i],d[71+i]) , 100, p);
l[75+i] = rangeran( MIX(s[75+i],d[75+i]) , 100, p);
l[79+i] = rangeran( MIX(s[79+i],d[79+i]) , 100, p);
z = rangeran( MIX((s[35+i]&112)>>4,(d[35+i]&112)>>4) , 7, p);
l[35+i] &= ~112; l[35+i] |= z << 4;
}
}
}
SpecialCopy(a, b, p)
UBYTE *a, *b;
float p;
{ register int i, z;
if(COMMON) for(i=10; i<23; i++) switch(i)
{ case 11:
z = rangeran(a[11]&3, 3, p);
b[11] &= ~3; b[11] |= z;
z = rangeran((a[11]&4)>>2, 1, p);
b[11] &= ~4; b[11] |= z << 2;
z = rangeran((a[11]&24)>>3, 3, p);
b[11] &= ~24; b[11] |= z << 3;
z = rangeran((a[11]&96)>>5, 3, p);
b[11] &= ~96; b[11] |= z << 5;
break;
case 17:
z = rangeran(a[17]&3, 3, p);
b[17] &= ~3; b[17] |= z;
z = rangeran((a[17]&28)>>2, 7, p);
b[17] &= ~28; b[17] |= z << 2;
z = rangeran((a[17]&96)>>5, 3, p);
b[17] &= ~96; b[17] |= z << 5;
break;
case 22:
b[22] &= a[22]; /* Src Mute nicht sinnvoll für Ran */
break;
default:
b[i] = rangeran(a[i], RangeMax[i], p);
}
if(FREQUENCY) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ b[23+i] = rangeran(a[23+i], 100, p);
b[83+i] = rangeran(a[83+i], 100, p);
z = rangeran((a[35+i]&2)>>1, 1, p);
b[35+i] &= ~2; b[35+i] |= z << 1;
if(z) b[27+i] = rangeran(a[27+i]-60, 48, p) + 60;
else b[27+i] = rangeran(a[27+i], 103, p);
z = rangeran((a[35+i]&4)>>2, 1, p);
b[35+i] &= ~4; b[35+i] |= z << 2;
z = rangeran((a[35+i]&8)>>3, 1, p);
b[35+i] &= ~8; b[35+i] |= z << 3;
}
if(WAVEFORM) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ b[31+i] = rangeran(a[31+i], 127, p);
z = rangeran(a[35+i]&1, 1, p);
b[35+i] &= ~1; b[35+i] |= z;
}
if(ENVELOPE) for(i=0; i<4; i++) if(voicemask & (1 << i))
{ b[39+i] = rangeran(a[39+i], 100, p);
b[43+i] = rangeran(a[43+i], 100, p);
b[47+i] = rangeran(a[47+i], 100, p);
b[51+i] = rangeran(a[51+i], 100, p);
b[55+i] = rangeran(a[55+i], 100, p);
b[59+i] = rangeran(a[59+i], 100, p);
b[63+i] = rangeran(a[63+i], 100, p);
b[67+i] = rangeran(a[67+i], 100, p);
b[71+i] = rangeran(a[71+i], 100, p);
b[75+i] = rangeran(a[75+i], 100, p);
b[79+i] = rangeran(a[79+i], 100, p);
z = rangeran((a[35+i]&112)>>4, 7, p);
b[35+i] &= ~112; b[35+i] |= z << 4;
}
}
HandleWindow(wind)
struct Window *wind;
{ struct IntuiMessage *im;
struct Gadget *gadgt,*g2;
ULONG class, gadid;
USHORT code,err;
if((im = (struct IntuiMessage *)GetMsg(wind->UserPort)) == 0) return;
class = im->Class; code = im->Code;
if(class == GADGETUP || class == GADGETDOWN)
{ gadgt = (struct Gadget *)im->IAddress;
gadid = gadgt->GadgetID;
}
ReplyMsg(im);
if(class == CLOSEWINDOW)
{ if(wind == wspc)
{ CloseWindow(wspc);
wspc = NULL;
}
else
{ if(UserRequest("Wirklich Programm beenden?"," Oh NO!!! "," Das ist in der Tat mein Wille. ",0))
shit(0);
}
}
else if(class == MENUPICK && code != MENUNULL) HandleMenu(code);
else if(class == VANILLAKEY)
{ if((code > '0') && (code < '5'))
{ if(envVoice != code-49)
{ envVoice = code-49; /* 1-4 = Envelope umschalten */
EnvDisplay();
}
}
else switch(code)
{ case 'c': /* Fenster hervor! */
case 'C':WindowToFront(wcom); break;
case 'w':
case 'W':WindowToFront(wwav); break;
case 'e':
case 'E':WindowToFront(wenv); break;
case 'f':
case 'F':WindowToFront(wfrq);
}
}
else if(class == GADGETDOWN || class == GADGETUP)
{ if(gadid < 50) Prop2Text(wind,gadgt);
else if(gadid < 100) Prop2Graf(wind,gadgt);
else if(gadid < 150) Bool2Text(wind,gadgt);
else if(gadid < 200) Bool2Graf(wind,gadgt);
else switch(gadid)
{ case 200:
if(iebase)
{ AusGadget(wind,gadgt); /* erst ausschalten */
iebase = 0;
AktDisplay();
}
else
{ iebase = 1;
AktDisplay(); /* erst wcom refreshen */
EinGadget(wind,gadgt);
}
break;
case 201:
setmem(ACTSOUND, 10, 32); /* mit Spaces füllen */
for(err = 0; Gadget2SIBuff[err] != 0; err++)
ACTSOUND[err] = Gadget2SIBuff[err]; /* ohne 0 kopieren */
break;
case 202:
DS17 &= 31; if(Gadget10.Flags & SELECTED) DS17 |= 32;
break;
case 203: case 204: case 205: case 206:
TogGadget(wind,gadgt);
code = 1 << (gadid-203);
if(gadgt->UserData==1) DS22 &= ~code; else DS22 |= code;
break;
case 207: case 210: case 213: case 216:
TogGadget(wind,gadgt);
code = gadid-207+9; /* PropOffset[...] */
g2 = FindGadget(wind,code);
if(gadgt->UserData == 1)
{ PropOffset[code] = -24;
ACTSOUND[27+(code-9)/3] = 84; /* == +-0 */
ACTSOUND[35+(code-9)/3] |= 2;
((struct PropInfo *)g2->SpecialInfo)->HorizPot = 32760;
((struct PropInfo *)g2->SpecialInfo)->HorizBody = 1365;
}
else
{ PropOffset[code] = 0;
ACTSOUND[27+(code-9)/3] = 60; /* == C3 */
ACTSOUND[35+(code-9)/3] &= ~2;
((struct PropInfo *)g2->SpecialInfo)->HorizPot = 38160;
((struct PropInfo *)g2->SpecialInfo)->HorizBody = 636;
}
RefreshGList(g2,wind,0,1);
Prop2Text(wind,g2);
break;
case 234:
ClearMenuStrip(wspc);
CloseWindow(wspc);
wspc = NULL;
break;
case 235:
ImWorking();
voicemask = (VOICE4 << 3) | (VOICE3 << 2) | (VOICE2 << 1) | VOICE1;
switch(specialfunktion)
{ case 0:
if(SOURCE != DESTIN) SpecialExchange(SoundData[SOURCE], SoundData[DESTIN]);
if(AUTOWRITE)
{ if(err = PutSound(channel, SCARD, SOURCE & 63, SoundData[SOURCE]))
SimpleRequest(WriteError[err-1]);
if(err = PutSound(channel, DCARD, DESTIN & 63, SoundData[DESTIN]))
SimpleRequest(WriteError[err-1]);
}
break;
case 1:
if(SOURCE != DESTIN) SpecialMix(SoundData[SOURCE], SoundData[DESTIN], PERCENT);
if(AUTOWRITE)
{ if(err = PutSound(channel, DCARD, DESTIN & 63, SoundData[DESTIN]))
SimpleRequest(WriteError[err-1]);
}
break;
case 2:
if(SOURCE != DESTIN) SpecialRange(MIN(SOURCE,DESTIN), MAX(SOURCE,DESTIN), PERCENT);
if(AUTOWRITE)
{ PutBlock(channel,0, 0,SoundData); /* Einmal vollpumpen, bitte */
PutBlock(channel,0,32,SoundData[32]);
if(SCARD | DCARD)
{ PutBlock(channel,1, 0,SoundData[64]); /* wenn angewählt auch die externen */
PutBlock(channel,1,32,SoundData[96]);
}
}
break;
case 3:
SpecialCopy(SoundData[SOURCE], SoundData[DESTIN], PERCENT);
if(AUTOWRITE)
{ if(err = PutSound(channel, DCARD, DESTIN & 63, SoundData[DESTIN]))
SimpleRequest(WriteError[err-1]);
}
}
ClearMenuStrip(wspc);
CloseWindow(wspc);
wspc = NULL;
AktDisplay();
break;
case 236: case 237: /* CARD Toggler im SpecialSetup */
Prop2Text(wspc, FindGadget(wspc, gadid-210));
break;
default:
TogGadget(wind,gadgt);
code = gadid-208; gadid = code/3; code = 4 + 4*(1 - code % 3);
if(gadgt->UserData) ACTSOUND[35+gadid] |= code; else ACTSOUND[35+gadid] &= ~code;
}
if(AUTOWRITE && wind != wspc)
if(err = PutSound(channel, iebase, actual, ACTSOUND))
SimpleRequest(WriteError[err-1]);
}
}
/*******************************************************************/
BOOL OptionLace(argc, argv)
int argc;
char **argv;
{ register struct DiskObject *pdo = NULL;
register BOOL lace = FALSE;
register char *cp = NULL;
if(argc == 0)
{ if(IconBase = OpenLibrary("icon.library", 0L))
if(pdo = GetDiskObject( ((struct WBStartup *)argv)->sm_ArgList->wa_Name) )
if(cp = FindToolType(pdo->do_ToolTypes, "LACE"))
if(MatchToolValue(cp, "ON")) lace = TRUE;
}
else if(argc==2 && *argv[1]=='L') lace = TRUE;
if(IconBase) CloseLibrary(IconBase);
if(pdo) FreeDiskObject(pdo);
return lace;
}
main(argc,argv) /* das Hauptprogramm - schön einfach, nech? */
int argc;
char *argv[];
{ UBYTE *msg = NULL;
long signals;
Init(OptionLace(argc, argv));
while(1)
{ signals = Wait(SWCOM | SWWAV | SWFRQ | SWENV | SWSPC | SMIDI);
if(signals & SWCOM) HandleWindow(wcom);
if(signals & SWWAV) HandleWindow(wwav);
if(signals & SWFRQ) HandleWindow(wfrq);
if(signals & SWENV) HandleWindow(wenv);
if(signals & SWSPC) HandleWindow(wspc);
if(signals & SMIDI) while(msg = GetMidiMsg(dest))
{ if((msg[0]&~15) == MS_PROG) /* User-Soundwechsel am Synth */
{ actual = msg[1];
AktDisplay(); /* --> mitwechseln */
}
FreeMidiMsg(msg);
}
}
} /* klar - der Rest is ja schon konfus genug... */