About Me
// *************************************************
//
// File: franky.cpp
// Author: Burkay Donderici
// Date: 03.06.2002 (start)
//
// *************************************************#include "franky.h"// DDRAW
#define DDON
//#undef DDON// WINDOWS
char szAppName[]="Franky";
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);// Timing Works
#define TIMER_ID 1
#define TIMER_DELAY 1 // in ms
DWORD old_time=timeGetTime();// Polling
bool pollready=true;// Digital Time
int t=0;// Mouse
int mousex=100;
int mousey=100;
double mousek=2.0;#define DKERROR {MessageBox( hwnd, DKT_ErrName(result), szAppName, MB_OK );return 0;}DWORD FR_GetNewID();bool display_changed=false;// FINAL NOTES
DKVECTOR final_notes=DKVECTOR(4); // FRNOTE Vector// INSTRUMENTS
DKVECTOR instruments=DKVECTOR(4);
DKVECTOR instrument_instances=DKVECTOR(4);// *** INSTRUMENT ***
FRINSTRUMENT::FRINSTRUMENT()
{
memset(name, 0, MAX_PATH);
}FRINSTRUMENT::FRINSTRUMENT(LPSTR name_)
{
strcpy(name, name_);
memory_instr=false;
}FRINSTRUMENT::FRINSTRUMENT(LPSTR name_, DKSOUND *dks)
{
strcpy(name, name_);
memory_instr=true;
memory_dks=dks;
}FRINSTRUMENT::~FRINSTRUMENT()
{
if(memory_instr)
DKS_DisposeSoundMemory(memory_dks);
}FRINSTRUMENTINST::FRINSTRUMENTINST(FRINSTRUMENT *fi)
{
strcpy(name, fi-name);
memory_instr=false;loop=0;
memset(instr_elements, 0, sizeof(FRCARDELEMENT)*FRCARDINSTRELEMENT_MAX);dksound=new DKSOUND();if(fi-memory_instr)
{
dksound-Nb=fi-memory_dks-Nb;
dksound-data=new char[dksound-Nb];
memcpy(dksound-data, fi-memory_dks-data, dksound-Nb);
}
else
{
DKS_CreateWavSoundMemory(name, dksound);
}
}FRINSTRUMENTINST::~FRINSTRUMENTINST()
{
DKS_DisposeSoundMemory(dksound);
}FRNOTE::FRNOTE()
{
octave=2;
note=0;time=0;
length=400;
offset=0;volume=0;
pan=0;time_noise=0;
volume_noise=0;
pan_noise=0;
}FRNOTE::FRNOTE(FRNOTE *frn)
{
octave=frn-octave;
note=frn-note;time=frn-time;
length=frn-length;offset=frn-offset;volume=frn-volume;
pan=frn-pan;time_noise=frn-time_noise;
volume_noise=frn-volume_noise;
pan_noise=frn-pan_noise;
}// For experimental purposes
FRNOTE::FRNOTE(DWORD time_, DWORD length_, BYTE octave_, BYTE note_)
{
octave=octave_;
note=note_;time=time_;
length=length_;offset=0;volume=0;
pan=0;time_noise=0;
volume_noise=0;
pan_noise=0;
}FRNOTE::~FRNOTE()
{
}
FRNOTEINST::FRNOTEINST()
{
}FRNOTEINST::FRNOTEINST(FRNOTE *frn, DWORD instrument_)
{
instrument=instrument_;octave=frn-octave;
note=frn-note;time=frn-time;
length=frn-length;offset=frn-offset;volume=frn-volume;
pan=frn-pan;time_noise=frn-time_noise;
volume_noise=frn-volume_noise;
pan_noise=frn-pan_noise;// SAMPLE ALLOC
// check for old allocation
allocated_sample=true;
for(int i=0; i note==note && ni-octave==octave && ni-instrument==instrument)
{
allocated_sample=false;
sample=ni-sample;
}
}// new allocation
if(allocated_sample)
{
FRINSTRUMENTINST *frii=(FRINSTRUMENTINST*)(instrument_instances.GetElement(in
strument));
DWORD freq=NOTEFREQ[note];
switch(octave)
{
case 0:
freq/=4;
break;
case 1:
freq/=2;
break;
case 2:
freq/=1;
break;
case 3:
freq*=2;
break;
case 4:
freq*=4;
break;
}DWORD byte_len=(DWORD)((double)(frii-dksound-Nb)*(double)44100/(do
uble)freq);
byte_len=byte_len-(byte_len%4);
DWORD short_len=byte_len/2;sample=new DKSOUND();
sample-data=new char[byte_len];double j=0;
double jd=(double)freq/(double)44100;
short *src=(short*)(frii-dksound-data);
short *dest=(short*)(sample-data);
for(DWORD i=0; i Nb=byte_len;
}
}FRNOTEINST::~FRNOTEINST()
{
if(allocated_sample)
DKS_DisposeSoundMemory(sample);
}// CLASS ----------------------------------------------------FRSPIRIT
ELEMENT::FRSPIRITELEMENT()
{
}FRSPIRITELEMENT::~FRSPIRITELEMENT()
{
switch(type)
{
case FRELEMENTTYPE_WORDINSTANCE:
delete (FRWORDINST*)element;
break;
case FRELEMENTTYPE_SPIRITINSTANCE:
delete (FRSPIRITINST*)element;
break;
case FRELEMENTTYPE_WORDQUERY:
delete (FRWORDQUERY*)element;
break;
case FRELEMENTTYPE_SPIRITQUERY:
delete (FRSPIRITQUERY*)element;
break;
}
}FRSPIRITELEMENT::FRSPIRITELEMENT(FRSPIRITELEMENT* frse)
{
type=frse-type;switch(type)
{
case FRELEMENTTYPE_WORDINSTANCE:
element=(void*)new FRWORDINST((FRWORDINST*)(frse-element));
break;
case FRELEMENTTYPE_SPIRITINSTANCE:
element=(void*)new FRSPIRITINST((FRSPIRITINST*)(frse-element));
break;
case FRELEMENTTYPE_WORDQUERY:
element=(void*)new FRWORDQUERY((FRWORDQUERY*)(frse-element));
break;
case FRELEMENTTYPE_SPIRITQUERY:
element=(void*)new FRSPIRITQUERY((FRSPIRITQUERY*)(frse-element));
break;
}
}FRSPIRIT::FRSPIRIT()
{
id=FR_GetNewID();
depth=0;spirit_channels=new DKVECTOR(4);memset(card_elements, 0, sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);instr_dominancy=0;
instr_query_noise=0;
memset(instr_elements, 0, sizeof(FRCARDINSTRELEMENT)*FRCARDINSTRELEMENT_MAX);
}FRSPIRIT::~FRSPIRIT()
{
for(int i=0; i GetElementCount(); i++)
{
DKVECTOR *spirit_elements=(DKVECTOR*)(spirit_channels-GetElement(i));
for(int j=0; j GetElementCount(); j++)
delete (FRSPIRITELEMENT*)(spirit_elements-GetElement(j));
delete spirit_elements;
}delete spirit_channels;
}FRSPIRITINST::FRSPIRITINST()
{
}FRSPIRITINST::FRSPIRITINST(FRSPIRITINST *frs)
{
depth=frs-depth;
id=frs-id;
for(int j=0; j spirit_channels-GetElementCount(); j++)
{
DKVECTOR *newchannel=new DKVECTOR(4);
DKVECTOR *channel=(DKVECTOR*)(frs-spirit_channels-GetElement(j));
for(int i=0; i GetElementCount(); i++)
{
FRSPIRITELEMENT* frse=(FRSPIRITELEMENT*)(channel-GetElement(i));
newchannel-AddElement(new FRSPIRITELEMENT(frse));
}
spirit_channels-AddElement(newchannel);
}memcpy(card_elements, (frs-card_elements), sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);time=frs-time;
published=frs-published;instr_dominancy=frs-instance_instr_d
ominancy;
instr_query_noise=frs-instance_instr_query_noise;
memcpy(instr_elements, frs-instance_instr_elements, sizeof(FRCARDINSTRELEMENT)*FRCARDINSTRELEMENT_MAX);
instance_instr_dominancy=frs-instance_instr_dominancy;
instance_instr_query_noise=frs-instance_instr_query_noise;
instance_instr_elements=frs-instance_instr_elements;
}FRSPIRITINST::FRSPIRITINST(FRSPIRIT *frs)
{
depth=frs-depth;
id=frs-id;
for(int j=0; j spirit_channels-GetElementCount(); j++)
{
DKVECTOR *newchannel=new DKVECTOR(4);
DKVECTOR *channel=(DKVECTOR*)(frs-spirit_channels-GetElement(j));
for(int i=0; i GetElementCount(); i++)
{
FRSPIRITELEMENT* frse=(FRSPIRITELEMENT*)(channel-GetElement(i));
newchannel-AddElement(new FRSPIRITELEMENT(frse));
}
spirit_channels-AddElement(newchannel);
}memcpy(card_elements, (frs-card_elements), sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);published=false;ins
tr_dominancy=frs-instr_dominancy;
instr_query_noise=frs-instr_query_noise;
memcpy(instr_elements, frs-instr_elements, sizeof(FRCARDINSTRELEMENT)*FRCARDINSTRELEMENT_MAX);
instance_instr_dominancy=frs-instr_dominancy;
instance_instr_query_noise=frs-instr_query_noise;
instance_instr_elements=frs-instr_elements;
}FRSPIRITINST::~FRSPIRITINST()
{
}FRSPIRITQUERY::FRSPIRITQUERY()
{
query_depth=0;
query_noise=1.0;
memset(card_elements, 0, sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);
}FRSPIRITQUERY::FRSPIRITQUERY(FRSPIRITQUERY* frsq)
{
query_depth=frsq-query_depth;
query_noise=frsq-query_noise;
memcpy(card_elements, frsq-card_elements, sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);
}// CLASS ----------------------------------------------------FRWORD::
FRWORD()
{
depth=0;
id=FR_GetNewID();
length=0;notes=new DKVECTOR(4);memset(card_elements, 0, sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);instr_dominancy=0;
instr_query_noise=0;
memset(instr_elements, 0, sizeof(FRCARDINSTRELEMENT)*FRCARDINSTRELEMENT_MAX);
}FRWORD::FRWORD(FRWORD *frw)
{
id=FR_GetNewID();notes=new DKVECTOR(4);
for(int i=0; i notes-GetElementCount(); i++)
notes-AddElement(new FRNOTE((FRNOTE*)(frw-notes-GetElement(i))));id=frw-id;
length=frw-length;memcpy(card_elements, (frw-card_elements), sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);instr_dominancy=frw
-instr_dominancy;
instr_query_noise=frw-instr_query_noise;
memcpy(instr_elements, (frw-instr_elements), sizeof(FRCARDINSTRELEMENT)*FRCARDINSTRELEMENT_MAX);
}FRWORD::~FRWORD()
{
for(int i=0; i GetElementCount(); i++)
delete (FRNOTE*)(notes-GetElement(i));
delete notes;
}FRWORDINST::FRWORDINST()
{
}FRWORDINST::FRWORDINST(FRWORDINST *frw)
{
for(int i=0; i notes-GetElementCount(); i++)
notes-AddElement(new FRNOTE((FRNOTE*)(frw-notes-GetElement(i))));id=frw-id;
length=frw-length;memcpy(card_elements, (frw-card_elements), sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);time=frw-time;
published=frw-published;instr_dominancy=frw-instance_instr_d
ominancy;
instr_query_noise=frw-instance_instr_query_noise;
memcpy(instr_elements, frw-instance_instr_elements, sizeof(FRCARDINSTRELEMENT)*FRCARDINSTRELEMENT_MAX);
instance_instr_dominancy=frw-instance_instr_dominancy;
instance_instr_query_noise=frw-instance_instr_query_noise;
instance_instr_elements=frw-instance_instr_elements;
}FRWORDINST::FRWORDINST(FRWORD *frw)
{
for(int i=0; i notes-GetElementCount(); i++)
notes-AddElement(new FRNOTE((FRNOTE*)(frw-notes-GetElement(i))));id=frw-id;
length=frw-length;memcpy(card_elements, (frw-card_elements), sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);published=false;ins
tr_dominancy=frw-instr_dominancy;
instr_query_noise=frw-instr_query_noise;
memcpy(instr_elements, frw-instr_elements, sizeof(FRCARDINSTRELEMENT)*FRCARDINSTRELEMENT_MAX);
instance_instr_dominancy=frw-instr_dominancy;
instance_instr_query_noise=frw-instr_query_noise;
instance_instr_elements=frw-instr_elements;
}FRWORDINST::~FRWORDINST()
{
}FRWORDQUERY::FRWORDQUERY()
{
query_depth=0;
query_noise=1.0;
memset(card_elements, 0, sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);
}FRWORDQUERY::FRWORDQUERY(FRWORDQUERY* frwq)
{
query_depth=frwq-query_depth;
query_noise=frwq-query_noise;
memcpy(card_elements, frwq-card_elements, sizeof(FRCARDELEMENT)*FRCARDELEMENT_MAX);
}// EXPERIENCE
DKVECTOR exp_words=DKVECTOR(4);
DKVECTOR exp_spirits=DKVECTOR(4);// FINAL SONG OBJECT
FRSPIRITINST *songspirit;// FINAL BUFFER
#define FR_FINAL_BUFFER_BYTE_LEN (44100*4)
LPDIRECTSOUNDBUFFER final_buffer;
bool final_buffer_playing=false;
bool final_buffer_poll_for_second;
DWORD song_buffered_byte_pos;
DWORD song_final_bytes;bool song_ready=false;// TRIAL BUFFER
bool trial_buffer_loaded=false;
LPDIRECTSOUNDBUFFER trial_buffer;// ANTIGLITCH ADDER
#define FR_AGSMARTSEARCH_RANGE 20 // ms
#define FR_AGSMARTSEARCH_SHORTRANGE (FR_AGSMARTSEARCH_RANGE*44100/500-(FR_AGSMARTSEARCH_RANGE*88
2/5)%4) // bytes// SONG NAME
#define FR_SONG_EXT_SIZE 4
const char *song_ext=".fky";
const char *wav_ext=".wav";
const char *search_ext="*.fky";
const char *untitled="untitled.fky";
char song_name[MAX_PATH];// ID
DWORD current_id=0;// INTERFACE VARS
int frin_column=0;
int frin_max_cards=2;
int frin_max_cardinstrs=2;typedef struct FRIN_INTERFACE_
{
void *host_ptr;
BYTE type;int x;
int y;}FRIN_INTERFACE;DKVECTOR interfaces=DKVECTOR(4);DWORD new_interface_offset_y=0;bool frin_hold=false;
int frin_hold_index=-1;
int frin_hold_xoffset;
int frin_hold_yoffset;#define FRIN_EDITTYPE_DWORD 0
#define FRIN_EDITTYPE_SIMPLEDWORD 1
#define FRIN_EDITTYPE_INT 2
#define FRIN_EDITTYPE_DOUBLE 3
#define FRIN_EDITTYPE_SIMPLEINT 4
#define FRIN_EDITTYPE_BYTE 5
#define FRIN_EDITTYPE_STRING 6
#define FRIN_EDITTYPE_LONG 7typedef struct FRIN_EDIT_
{
BYTE input_type;
void *input_ptr;
char complete[32];
int head_len;int input_x;
int input_y;
int input_width;
int input_height;}FRIN_EDIT;DKVECTOR edits=DKVECTOR(4);
DKVECTOR general_edits=DKVECTOR(4);bool edit_mode=false;
bool edit_capital;
FRIN_EDIT edit_obj;#define FRIN_EDITTEMPMAX 160
char edit_temp[FRIN_EDITTEMPMAX];
int edit_cursor=0;#define FRIN_ACTIONTYPE_ADDCHANNEL 0
#define FRIN_ACTIONTYPE_ADDSPIRITQUERY 1
#define FRIN_ACTIONTYPE_ADDWORDQUERY 2
#define FRIN_ACTIONTYPE_DELETECHANNEL 3
#define FRIN_ACTIONTYPE_DELETESPIRITQUERY 4
#define FRIN_ACTIONTYPE_DELETEWORDQUERY 5
#define FRIN_ACTIONTYPE_ADDNOTE 6
#define FRIN_ACTIONTYPE_DELETENOTE 7
#define FRIN_ACTIONTYPE_ADDSPIRIT 8
#define FRIN_ACTIONTYPE_ADDWORD 9
#define FRIN_ACTIONTYPE_DELETEWORD 10
#define FRIN_ACTIONTYPE_DELETESPIRIT 11
#define FRIN_ACTIONTYPE_ADDINSTR 12
#define FRIN_ACTIONTYPE_DELETEINSTR 13
#define FRIN_ACTIONTYPE_SAVE 14
#define FRIN_ACTIONTYPE_LOAD 15
#define FRIN_ACTIONTYPE_NEW 16
#define FRIN_ACTIONTYPE_ERASE 17
#define FRIN_ACTIONTYPE_REVERT 18
#define FRIN_ACTIONTYPE_SAVEWAV 19typedef struct FRIN_ACTION_
{
BYTE action_type;
void *param0;
void *param1;int action_x;
int action_y;
int action_width;
int action_height;}FRIN_ACTION;DKVECTOR actions=DKVECTOR(4);bool action_double_check=false;
int action_double_index=-1;// FUNCTION PROTOTYPES
void TimingWorksMain();
void FR_InitRandom();
bool FR_LoadInstruments();
void FR_DisposeInstrumentInstances();
void FR_DisposeInstruments();
void FR_AddInstrumentInstr(LPSTR name);
void FR_DeleteInstrumentInstr(LPSTR name);
FRINSTRUMENTINST* FR_GetInstrumentInst(LPSTR name);
void FRIN_RegisterAllExistingInstruments();
void FR_PasteSongPieceDataToFinalBuffer(DWORD song_byte_offset, DWORD song_byte_length, DWORD final_buffer_offset);
void FR_PasteSongPieceDataToMemory(DWORD song_byte_offset, DWORD song_byte_length, DKSOUND *dks);
DWORD FR_FindFinalBytes();void FR_Dispose();
void FR_HandleKeys();
void FR_StartPlay();
void FR_StopPlay();
void FR_PlayPoll();
void FR_InitPlayPoll();
void FR_DisposeFinalBuffer();
void FR_DisposeTrialBuffer();
void FR_DisposeFinalNotes();
void FR_DisposeExperience();
void FR_DisposeTheSong();
void FR_RefreshTheSong();
void FRIN_PlayInterfaceElementSong();// publish
void FR_PublishWord(FRWORDINST *frwi);
void FR_PublishSpirit(FRSPIRITINST *frsi);
void FR_PublishSong();// interface
void FRIN_DisposeInterfaces();
void FRIN_RedrawInterfaces();
void FRIN_DrawSpiritInfo(FRSPIRIT *frs);
void FRIN_DrawWordInfo(FRWORD *frw);
void FRIN_DrawInstrumentInfo(FRINSTRUMENT* fri);
void FRIN_DrawSongInfo();
bool FRIN_InterfaceHoldCheck();
void FRIN_InterfaceReleaseCheck();
void FRIN_RegisterNewInterface(void *ptr, BYTE type);
void FRIN_RegisterAllExistingExperiences();
void FRIN_RedrawAll();
void FRIN_ClearAll();
FRIN_INTERFACE* FRIN_GetElementInterface(void *ptr);
FRIN_INTERFACE* FRIN_GetSongInterface();
FRIN_INTERFACE* FRIN_GetLastInterface();
void FRIN_ZeroNewInterfaceOffset();// edits
void FRIN_RegisterEdit(BYTE type, void *ptr, char* complete, int head_len, int x, int y, int w, int h);
void FRIN_KillAllEdits();
void FRIN_RedrawCurrentEdit();
bool FRIN_EditPressCheck();
void FRIN_ProcessAndCloseEdit();// actions
void FRIN_RegisterAction(BYTE type, void *param0, void *param1, int x, int y, int w, int h);
void FRIN_KillAllActions();
void FRIN_RedrawAllActions();
bool FRIN_ActionPressCheck();// paste ops
void FRIN_PasteDWORDtoSTR(DWORD dword, char* temp_str, int* index);
void FRIN_PasteSTRtoSTR(char* paste_str, char* temp_str, int* index);
void FRIN_PasteINTtoSTR(int i, char* temp_str, int* index);
void FRIN_PasteSimpleDWORDtoSTR(DWORD dword, char* temp_str, int* index);
void FRIN_PasteDOUBLEtoSTR(double d, char* temp_str, int* index);
void FRIN_PasteSimpleINTtoSTR(int i, char* temp_str, int* index);
void FRIN_PasteBYTEtoSTR(BYTE i, char* temp_str, int* index);
void FRIN_PasteLONGtoSTR(LONG l, char* temp_str, int* index);void FRIN_RegisterSong();
void FRIN_SaveTheSong(bool save_interface);
void FRIN_LoadTheSong(char *load_name);
void FRIN_NewSong();
void FR_SaveTheSongAsWav();FRSPIRIT* FR_QuerySpirit(FRSPIRITQUERY *frsq);
FRWORD* FR_QueryWord(FRWORDQUERY *frwq);int FR_QueryInstrument(FRWORDINST *frwi);void FR_FormTheSong();
FRSPIRITINST* FR_FormTheSpirit(FRSPIRITQUERY *frsq);
FRSPIRITINST* FR_FormThisSpirit(FRSPIRIT *frs);
FRWORDINST* FR_FormTheWord(FRWORDQUERY *frwq);void FR_AddExperience();// WinMain (Windows application main function)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
// Register the Main Window Class:
wndclass.cbSize=sizeof (wndclass);
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon (NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor (NULL,IDC_ARROW);
wndclass.hbrBackground=NULL;
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=szAppName;
wndclass.hIconSm=LoadIcon(NULL,IDI_APPLICATION);RegisterClas
sEx (&wndclass);.r{}* create a window
*/
hwnd = CreateWindowEx(
WS_EX_TOPMOST,
szAppName,
szAppName,
WS_POPUP,
0,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL );HRESULT result;ShowWindow (hwnd,iCmdShow);
UpdateWindow (hwnd);// DREAM KING INPUT
result = DKI_Init(hInstance);
if(result!=DI_OK)
DKERROR;result = DKI_InitKeyboard(hwnd);
if(result!=DI_OK)
DKERROR;#ifdef DDON
// DREAM KING DRAWresult = DKD_Init(hwnd, FRIN_SCRX, FRIN_SCRY, FRIN_SCRDEPTH);
if(result!=DD_OK)
DKERROR;result = DKD_ClearBackSurface(0);
if(result!=DD_OK)
DKERROR;result = DKD_Flip();
if(result!=DD_OK)
DKERROR;
result = DKD_ClearBackSurface(0);
if(result!=DD_OK)
DKERROR;
#endif// DREAM KING SOUNDresult = DKS_Init(hwnd);
if(result!=DS_OK)
DKERROR;result= DKS_CreateEmptyBuffer(FR_FINAL_BUFFER_BYTE_LEN, &final_buffer);// New song
FRIN_NewSong();
// Refresh the Display
FRIN_RedrawAll();// Message Loop
while(true)
{
if(timeGetTime()-old_timeTIMER_DELAY && pollready)
{
TimingWorksMain();
t++;
old_time=timeGetTime();
}if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;if (hwnd)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
// End Application
return msg.wParam;
}// WndProc (Main window procedure - Message Processor)
LRESULT CALLBACK WndProc (HWND hwnd,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
switch (iMsg)
{
case WM_CREATE:
break;
case WM_SIZE:
break;
case WM_PAINT:
break;
case WM_DESTROY:
pollready=false;
FRIN_SaveTheSong(true);
FR_Dispose();
DKS_Dispose();
DKI_DisposeKeyboard();
DKI_Dispose();
#ifdef DDON
DKD_Dispose();
#endif
PostQuitMessage(0);
break;
case WM_MOUSEMOVE:
mousex = ((int) LOWORD(lParam) 16;
mousey = ((int) HIWORD(lParam) 16;
break;
case WM_LBUTTONDOWN:
if(!FRIN_ActionPressCheck())
{
if(action_double_check)
{
action_double_check=false;
action_double_index=-1;
FRIN_RedrawAll();
}
if(!FRIN_InterfaceHoldCheck())
{
FRIN_EditPressCheck();
}
else
FRIN_ProcessAndCloseEdit();
}break;
case WM_LBUTTONUP:
FRIN_InterfaceReleaseCheck();
break;
case WM_RBUTTONDOWN:
break;break;
}
return DefWindowProc (hwnd,iMsg,wParam,lParam);
}// -----------------
// TIMING WORKS MAIN
// -----------------
void TimingWorksMain()
{
FR_HandleKeys();if(final_buffer_playing)
FR_PlayPoll();if(frin_hold)
{
FRIN_INTERFACE *in=(FRIN_INTERFACE*)(interfaces.GetElement(frin_hold_index)
);
in-x=mousex-frin_hold_xoffset;
in-y=mousey-frin_hold_yoffset;
FRIN_RedrawAll();
}if(display_changed)
{
display_changed=false;
DKD_Flip();
DKD_CopyFrontToBack();
}
}// ----------------
// LOAD INSTRUMENTS
// ----------------
bool FR_LoadInstruments()
{
// LOAD WAV FILE NAMES
WIN32_FIND_DATAA FileData;
HANDLE handle;
handle = FindFirstFileA("*.wav", &FileData);
if(handle==INVALID_HANDLE_VALUE)
return false;while(true)
{
if(!FR_GetInstrumentInst(FileData.cFileName))
{
FRINSTRUMENT *fri=new FRINSTRUMENT(FileData.cFileName);
instruments.AddElement(fri);
FRIN_RegisterNewInterface(fri, FRIN_INTERFACETYPE_INSTR);
}
if(!FindNextFile(handle, &FileData))
break;
}return true;
}// -------
// DISPOSE
// -------
void FR_Dispose()
{
FR_StopPlay();
FRIN_KillAllEdits();
FRIN_KillAllActions();
FRIN_DisposeInterfaces();FR_DisposeFinalNotes();
FR_DisposeFinalBuffer();
FR_DisposeTrialBuffer();
FR_DisposeTheSong();
FR_DisposeExperience();
FR_DisposeInstrumentInstances();
FR_DisposeInstruments();
}// ----------------
// REFRESH THE SONG
// ----------------
void FR_RefreshTheSong()
{
FR_DisposeFinalNotes();
FR_DisposeTheSong();
FR_FormTheSong();
FR_PublishSong();
}// ---------------------------
// PLAY INTERFACE ELEMENT SONG
// ---------------------------
void FRIN_PlayInterfaceElementSong()
{
if(frin_hold_index==-1)
return;FRIN_INTERFACE *in=(FRIN_INTERFACE*)(interfaces.GetElement(frin_hold_index)
);
if(in-type==FRIN_INTERFACETYPE_SPIRIT)
{
FR_StopPlay();
FR_DisposeFinalNotes();
FR_DisposeTheSong();
songspirit=FR_FormThisSpirit((FRSPIRIT*)(in-host_ptr));
song_ready=true;
FR_PublishSong();
FR_StartPlay();
}
else if(in-type==FRIN_INTERFACETYPE_WORD)
{
FR_StopPlay();
FR_DisposeFinalNotes();
FR_DisposeTheSong();
FRWORDINST *wi=new FRWORDINST((FRWORD*)(in-host_ptr));
wi-time=0;
FR_PublishWord(wi);
delete wi;
FR_StartPlay();
}
else if(in-type==FRIN_INTERFACETYPE_SONG)
{
FR_StopPlay();
FR_RefreshTheSong();
FR_StartPlay();
}
else if(in-type==FRIN_INTERFACETYPE_INSTR)
{
FR_DisposeTrialBuffer();
FRINSTRUMENTINST *fii=new FRINSTRUMENTINST((FRINSTRUMENT*)in-host_ptr);
DKS_CreateBufferFromMemory(fii-dksound, &trial_buffer);
trial_buffer-Play(0,0,0);
delete fii;
trial_buffer_loaded=true;
}
}// ----------------
// FIND FINAL BYTES
// ----------------
DWORD FR_FindFinalBytes()
{
int i;// Find length
DWORD final_bytes=0;
DWORD time_bytes;
for(i=0; i time)*882/5;
if(time_bytes+ni-sample-Nbfinal_bytes)
final_bytes=time_bytes+ni-sample-Nb;
}return final_bytes;
}// -------------------------------------
// PASTE SONG PIECE DATA TO FINAL BUFFER
// -------------------------------------
void FR_PasteSongPieceDataToFinalBuffer(DWORD song_byte_offset, DWORD song_byte_length, DWORD final_buffer_offset)
{
DKSOUND *dks=new DKSOUND();
FR_PasteSongPieceDataToMemory(song_byte_offset, song_byte_length, dks);
DKS_CopyToBufferFromMemory(dks, 0, &final_buffer, final_buffer_offset, song_byte_length);
DKS_DisposeSoundMemory(dks);
}// -------------------------------
// PASTE SONG PIECE DATA TO MEMORY
// -------------------------------
void FR_PasteSongPieceDataToMemory(DWORD song_byte_offset, DWORD song_byte_length, DKSOUND *dks)
{
DWORD j;// Create first temp memory
long *temp=new long[song_byte_length/2];
memset(temp, 0, song_byte_length/2*sizeof(long));// Create second temp memory
dks-data=new char[song_byte_length];
dks-Nb=song_byte_length;// Paste notes into buffer
for(int i=0; i time*882/5;
byte_start=byte_start-byte_start%4;// byte offset
DWORD byte_offset=ni-offset*882/5;
byte_offset=byte_offset-byte_offset%4;
// byte len
DWORD byte_len=ni-length*882/5;
if(byte_len+byte_offsetni-sample-Nb)
byte_len=ni-sample-Nb-byte_offset;
byte_len=byte_len-byte_len%4;// byte end
DWORD byte_end=byte_start+byte_len;
// Intersection
if(byte_endsong_byte_offset && byte_start byte_start)
src_start=song_byte_offset-byte_start;DWORD src_end=byte_len;
if(song_byte_offset+song_byte_length volume))/100);
// Pan
double panleft;
double panright;
if(ni-pan=0)
{
panleft=1.0;
panright=pow(10.0,-((double)(ni-pan))/100.0);
}
else
{
panleft=pow(10.0,((double)(ni-pan))/100.0);
panright=1.0;
}// Expand source bits
short *src_short =((short*)(ni-sample-data))+short_src_start+short_offset;
long *src=new long[short_len];
for(DWORD i=0; i FR_AGSMARTSEARCH_SHORTRANGE)
{
double smallest=(double)src[0]*(double)src[0]+(double)src[1]*(doubl
e)src[1];
DWORD smallest_index=0;
// smart-search
for(j=0; j FR_AGSMARTSEARCH_SHORTRANGE)
{
double smallest=(double)src[short_len-2]*(double)src[short_len-2]+(
double)src[short_len-1]*(double)src[short_len-1];
DWORD smallest_index=short_len-2;
// smart-search
for(j=short_len-FR_AGSMARTSEARCH_SHORTRANGE; j greatest)
greatest=temp[j];
if(-temp[j]greatest)
greatest=-temp[j];
}
double vk=(double)32768/(double)greatest;
if(vk1.0)
vk=1.0;// Apply damped amplitude
short *dest=(short*)(dks-data);
for(j=0; j SetCurrentPosition(0);
final_buffer_playing=true;
final_buffer-Play(0,0,DSBPLAY_LOOPING);
}// --------------
// INIT PLAY POLL
// --------------
void FR_InitPlayPoll()
{
song_buffered_byte_pos=0;
FR_PasteSongPieceDataToFinalBuffer(song_buffered_byte_pos,FR
_FINAL_BUFFER_BYTE_LEN, 0);
song_buffered_byte_pos+=FR_FINAL_BUFFER_BYTE_LEN;
final_buffer_poll_for_second=true;
song_final_bytes=FR_FindFinalBytes();
}// ---------
// PLAY POLL
// ---------
void FR_PlayPoll()
{
if(song_buffered_byte_possong_final_bytes+FR_FINAL_BUFFER_BY
TE_LEN)
{
FR_StopPlay();
return;
}DWORD play_pos;
final_buffer-GetCurrentPosition(&play_pos, NULL);
if(play_pos FR_FINAL_BUFFER_BYTE_LEN/2 && final_buffer_poll_for_second)
{
FR_PasteSongPieceDataToFinalBuffer(song_buffered_byte_pos,FR
_FINAL_BUFFER_BYTE_LEN/2, 0);
final_buffer_poll_for_second=false;
song_buffered_byte_pos+=FR_FINAL_BUFFER_BYTE_LEN/2;
}
}// ---------
// STOP PLAY
// ---------
void FR_StopPlay()
{
final_buffer-Stop();
final_buffer_playing=false;
if(trial_buffer_loaded)
trial_buffer-Stop();
}// ------------
// PUBLISH SONG
// ------------
void FR_PublishSong()
{
if(songspirit)
{
songspirit-time=0;
FR_PublishSpirit(songspirit);
}
}// ------------
// PUBLISH WORD
// ------------
void FR_PublishWord(FRWORDINST *frwi)
{
if(!(frwi-published))
{
for(int i=0; i notes-GetElementCount(); i++)
{
FRNOTE *note=(FRNOTE*)(frwi-notes-GetElement(i));
int instr_index=FR_QueryInstrument(frwi);
if(instr_index-1)
{
FRNOTEINST *pnote=new FRNOTEINST(note,instr_index);
pnote-time+=frwi-time;
if(pnote-pan_noise)
pnote-pan+=(LONG)((double)rand()*(double)pnote-pan_noise/(do
uble)RAND_MAX);
if(pnote-volume_noise)
pnote-volume+=(LONG)((double)rand()*(double)pnote-volume_noi
se/(double)RAND_MAX);
if(pnote-time_noise)
pnote-time+=(DWORD)((double)rand()*(double)pnote-time_noise/
(double)RAND_MAX);
final_notes.AddElement(pnote);
}
}
}
}// ----------------
// PUBLISH SPIRIT
// ----------------
void FR_PublishSpirit(FRSPIRITINST *frsi)
{
for(int i=0; i spirit_channels-GetElementCount(); i++)
{
DWORD channel_time=frsi-time;
DKVECTOR *spirit_elements=(DKVECTOR*)(frsi-spirit_channels-GetElement
(i));DWORD element_time=channel_time;
for(int j=0; j GetElementCount(); j++)
{
FRSPIRITELEMENT* frse=(FRSPIRITELEMENT*)(spirit_elements-GetElement(j));
if(frse-type==FRELEMENTTYPE_SPIRITINSTANCE)
{
FRSPIRITINST* frsi_=(FRSPIRITINST*)(frse-element);
frsi_-time=element_time;
// instrument inheritance
if(frsi-instance_instr_dominancy=frsi_-instance_instr_domina
ncy)
{
frsi_-instance_instr_dominancy=frsi-instance_instr_dominancy
;
frsi_-instance_instr_query_noise=frsi-instance_instr_query_n
oise;
frsi_-instance_instr_elements=frsi-instance_instr_elements;
}
// ----------------------
FR_PublishSpirit(frsi_);
element_time+=frsi_-length;
}
else if(frse-type==FRELEMENTTYPE_WORDINSTANCE)
{
FRWORDINST* frwi=(FRWORDINST*)(frse-element);
frwi-time=element_time;
// instrument inheritance
if(frsi-instance_instr_dominancy=frwi-instance_instr_dominan
cy)
{
frwi-instance_instr_dominancy=frsi-instance_instr_dominancy;
frwi-instance_instr_query_noise=frsi-instance_instr_query_no
ise;
frwi-instance_instr_elements=frsi-instance_instr_elements;
}
// ----------------------
FR_PublishWord(frwi);
element_time+=frwi-length;
}
}
}
}// ----------------
// QUERY INSTRUMENT
// ----------------
int FR_QueryInstrument(FRWORDINST *frwi)
{
int i;FRCARDINSTRELEMENT *elements=frwi-instance_instr_elements;// create point table
double *pts=new double[instrument_instances.GetElementCount()];// manage point table
int greatests_index=-1;
double greatests_point=-1;
for(i=0;i instr_elements[j].value, elements[j].value, frii-instr_elements[j].coeff, elements[j].coeff);
// add noise
pts[i]+=(double)rand()*frwi-instance_instr_query_noise/(doub
le)RAND_MAX;// keep the greatest
if(pts[i]greatests_point)
{
greatests_point=pts[i];
greatests_index=i;
}j++;
}// clean up
delete pts;return greatests_index;
}// ----------
// QUERY SONG
// ----------
FRSPIRIT* FR_QuerySong()
{
if(exp_spirits.GetElementCount()0)
{
FRSPIRIT* spirit=(FRSPIRIT*)(exp_spirits.GetElement(0));
int greatest_index=0;
DWORD greatest_depth=spirit-depth;
for(int i=1;i depthgreatest_depth)
{
greatest_depth=spirit-depth;
greatest_index=i;
}
}return (FRSPIRIT*)(exp_spirits.GetElement(greatest_index));
}return 0;
}// --------------
// QUERY SPIRIT
// --------------
FRSPIRIT* FR_QuerySpirit(FRSPIRITQUERY *frsq)
{
int i;
int j=0;// create point table
double *pts=new double[exp_spirits.GetElementCount()];// manage point table
int greatests_index=-1;
double greatests_point=-1.0;
for(i=0;i depth==frsq-query_depth)
{
pts[j]=0;
// sum up negative distances
for(int k=0; k card_elements[k].value, frsq-card_elements[k].value, spirit-card_elements[k].coeff, frsq-card_elements[k].coeff);
// add noise
pts[j]+=(double)rand()*frsq-query_noise/(double)RAND_MAX;
// keep the greatest
if(pts[j]greatests_point)
{
greatests_point=pts[j];
greatests_index=i;
}j++;
}
}
// clean up
delete pts;if(j0)
return (FRSPIRIT*)(exp_spirits.GetElement(greatests_index));
else
return 0;
}// ----------
// QUERY WORD
// ----------
FRWORD* FR_QueryWord(FRWORDQUERY *frwq)
{
int i;
int j=0;// create point table
double *pts=new double[exp_words.GetElementCount()];// manage point table
int greatests_index=-1;
double greatests_point=-1.0;
for(i=0;i depth==frwq-query_depth)
{
pts[j]=0;
// sum up negative distances
for(int k=0; k card_elements[k].value, frwq-card_elements[k].value, word-card_elements[k].coeff, frwq-card_elements[k].coeff);
// add noise
pts[j]+=(double)rand()*frwq-query_noise/(double)RAND_MAX;
// keep the greatest
if(pts[j]greatests_point)
{
greatests_point=pts[j];
greatests_index=i;
}j++;
}
}
// clean up
delete pts;if(j0)
return (FRWORD*)(exp_words.GetElement(greatests_index));
else
return 0;
}// -------------
// FORM THE SONG
// -------------
void FR_FormTheSong()
{
songspirit=FR_FormTheSpirit((FRSPIRITQUERY*)0);
song_ready=true;
}// -----------------
// FORM THE SPIRIT 1
// -----------------
FRSPIRITINST* FR_FormTheSpirit(FRSPIRITQUERY *frsq)
{
FRSPIRIT* spirit;
if(frsq)
spirit=FR_QuerySpirit(frsq);
else
spirit=FR_QuerySong();if(!spirit) return 0;
return FR_FormThisSpirit(spirit);
}// -----------------
// FORM THE SPIRIT 2
// -----------------
FRSPIRITINST* FR_FormThisSpirit(FRSPIRIT *frs)
{
FRSPIRITINST* spirit=new FRSPIRITINST(frs);// query childrenfor(int j=0; j spirit_channels-GetElementCount(); j++)
{
DWORD time_offset=0;
DKVECTOR *spirit_elements=(DKVECTOR*)(spirit-spirit_channels-GetEleme
nt(j));for(int i=0; i GetElementCount(); i++)
{
FRWORDINST *frwi;
FRSPIRITINST *frsi;
FRSPIRITELEMENT *frse=(FRSPIRITELEMENT*)(spirit_elements-GetElement(i));
if(frse-type==FRELEMENTTYPE_WORDQUERY)
{
void *element=FR_FormTheWord((FRWORDQUERY*)(frse-element));
if(element)
{
frse-element=element;
frse-type=FRELEMENTTYPE_WORDINSTANCE;
frwi=(FRWORDINST*)(frse-element);
frwi-time=time_offset;
time_offset+=frwi-length;
}
}
else if(frse-type==FRELEMENTTYPE_SPIRITQUERY)
{
void *element=FR_FormTheSpirit((FRSPIRITQUERY*)(frse-element));
if(element)
{
frse-element=element;
frse-type=FRELEMENTTYPE_SPIRITINSTANCE;
frsi=(FRSPIRITINST*)(frse-element);
frsi-time=time_offset;
time_offset+=frsi-length;
}
}
}spirit-length=time_offset;
}return spirit;
}// -------------
// FORM THE WORD
// -------------
FRWORDINST* FR_FormTheWord(FRWORDQUERY *frwq)
{
FRWORD* word_=FR_QueryWord(frwq);
if(!word_) return 0;
FRWORDINST* word=new FRWORDINST(word_);return word;
}// --------------------
// ADD INSTRUMENT INSTR
// --------------------
void FR_AddInstrumentInstr(LPSTR name)
{
int i;for(i=0; i name, name))
return;
}FRINSTRUMENT *fri;
for(i=0; i name, name))
break;
}if(i name, name))
break;
}if(i name, name))
break;
}
if(i notes-AddElement(new FRNOTE( 0,400,1,0));
word-length=400;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0xffffffff;
word-card_elements[0].value=0x00000000;
exp_words.AddElement(word);// WORD 1
word=new FRWORD();
word-notes-AddElement(new FRNOTE( 0,400,1,1));
word-length=400;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0xffffffff;
word-card_elements[0].value=0x00000000;
exp_words.AddElement(word);// WORD 2
word=new FRWORD();
word-notes-AddElement(new FRNOTE( 0,400,1,3));
word-length=400;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0xffffffff;
word-card_elements[0].value=0x00000000;
exp_words.AddElement(word);// WORD 3
word=new FRWORD();
word-notes-AddElement(new FRNOTE( 0,400,1,5));
word-length=400;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0xffffffff;
word-card_elements[0].value=0x00000000;
exp_words.AddElement(word);
// WORD 4
word=new FRWORD();
word-length=400;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0xffffffff;
word-card_elements[0].value=0xffffffff;
exp_words.AddElement(word);// WORD 5
word=new FRWORD();
word-notes-AddElement(new FRNOTE( 0,800,0,0));
word-notes-AddElement(new FRNOTE( 0,800,0,0));
word-notes-AddElement(new FRNOTE( 0,800,0,7));
word-notes-AddElement(new FRNOTE( 0,800,0,7));
word-length=800;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0x00000000;
word-card_elements[0].value=0x00000000;
word-card_elements[1].coeff=0xffffffff;
word-card_elements[1].value=0xffffffff;
exp_words.AddElement(word);// WORD 5
word=new FRWORD();
word-notes-AddElement(new FRNOTE( 0,800,0,1));
word-notes-AddElement(new FRNOTE( 0,800,0,8));
word-notes-AddElement(new FRNOTE(200,800,0,1));
word-notes-AddElement(new FRNOTE(200,800,0,10));
word-notes-AddElement(new FRNOTE(400,800,0,1));
word-notes-AddElement(new FRNOTE(400,800,0,8));
word-notes-AddElement(new FRNOTE(600,800,0,1));
word-notes-AddElement(new FRNOTE(600,800,0,10));
word-length=800;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0x00000000;
word-card_elements[0].value=0x00000000;
word-card_elements[1].coeff=0xffffffff;
word-card_elements[1].value=0xffffffff;
exp_words.AddElement(word);// WORD 6
word=new FRWORD();
word-notes-AddElement(new FRNOTE( 0,800,2,7));
word-notes-AddElement(new FRNOTE( 200,800,2,8));
word-notes-AddElement(new FRNOTE( 400,800,2,7));
word-notes-AddElement(new FRNOTE( 600,800,2,8));
word-length=800;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0x00000000;
word-card_elements[0].value=0x00000000;
word-card_elements[1].coeff=0xffffffff;
word-card_elements[1].value=0xffffffff;
exp_words.AddElement(word);// WORD 6
word=new FRWORD();
word-notes-AddElement(new FRNOTE( 0,800,2,10));
word-notes-AddElement(new FRNOTE( 200,800,2,8));
word-notes-AddElement(new FRNOTE( 400,800,2,7));
word-notes-AddElement(new FRNOTE( 600,800,2,8));
word-length=800;
word-instr_dominancy=0x00;
word-instr_elements[0].value=0;
word-card_elements[0].coeff=0xffffffff;
word-card_elements[0].value=0xffffffff;
exp_words.AddElement(word);// SPIRIT 0
spirit=new FRSPIRIT();
spirit-depth=1;
spirit-instr_dominancy=0x00;
spirit-instr_elements[0].value=1;
spirit-card_elements[0].coeff=0xffffffff;
spirit-card_elements[0].value=0x00000000;DKVECTOR *channel=new DKVECTOR(4);
wq=new FRWORDQUERY(); // QUERY0
wq-query_depth=0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0x00000000;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
wq=new FRWORDQUERY(); // QUERY1
wq-query_depth=0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0x00000000;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
wq=new FRWORDQUERY(); // QUERY2
wq-query_depth=0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0x00000000;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
wq=new FRWORDQUERY(); // QUERY3
wq-query_depth=0;
wq-query_noise=0.0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0xffffffff;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);channel=new DKVECTOR(4);
wq=new FRWORDQUERY(); // QUERY0
wq-query_depth=0;
wq-card_elements[0].coeff=0x00000000;
wq-card_elements[0].value=0x00000000;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
wq=new FRWORDQUERY(); // QUERY1
wq-query_depth=0;
wq-query_noise=10000.0;
wq-card_elements[0].coeff=0x00000000;
wq-card_elements[0].value=0x00000000;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);// SPIRIT 00
spirit=new FRSPIRIT();
spirit-depth=1;
spirit-instr_dominancy=0x00;
spirit-instr_elements[0].value=1;
spirit-card_elements[0].coeff=0xffffffff;
spirit-card_elements[0].value=0xffffffff;channel=new DKVECTOR(4);
wq=new FRWORDQUERY(); // QUERY0
wq-query_depth=0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0x00000000;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
wq=new FRWORDQUERY(); // QUERY1
wq-query_depth=0;
wq-query_noise=2000.0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0xffffffff;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
wq=new FRWORDQUERY(); // QUERY2
wq-query_depth=0;
wq-query_noise=2000.0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0xffffffff;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
wq=new FRWORDQUERY(); // QUERY3
wq-query_depth=0;
wq-query_noise=2000.0;
wq-card_elements[0].coeff=0xffffffff;
wq-card_elements[0].value=0xffffffff;
wq-card_elements[1].coeff=0xffffffff;
wq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_WORDQUERY;
se-element=(void*)wq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);// SPIRIT 1
spirit=new FRSPIRIT();
spirit-depth=2;
spirit-instr_dominancy=0x00;
spirit-instr_elements[0].coeff=0xffffffff;
spirit-instr_elements[0].value=0xffffffff;
spirit-instr_query_noise=0000.0;
spirit-card_elements[0].coeff=0xffffffff;
spirit-card_elements[0].value=0x00000000;channel=new DKVECTOR(4);
sq=new FRSPIRITQUERY(); // QUERY0
sq-query_depth=1;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY1
sq-query_depth=1;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY2
sq-query_depth=1;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY3
sq-query_depth=1;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);// SPIRIT 11
spirit=new FRSPIRIT();
spirit-depth=2;
spirit-instr_dominancy=0x00;
spirit-instr_elements[0].coeff=0xffffffff;
spirit-instr_elements[0].value=0xffffffff;
spirit-instr_query_noise=0000.0;
spirit-card_elements[0].coeff=0xffffffff;
spirit-card_elements[0].value=0xffffffff;channel=new DKVECTOR(4);
sq=new FRSPIRITQUERY(); // QUERY0
sq-query_depth=1;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY1
sq-query_depth=1;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY2
sq-query_depth=1;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY3
sq-query_depth=1;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);// SPIRIT 2
spirit=new FRSPIRIT();
spirit-depth=3;
spirit-instr_dominancy=0x90;
spirit-instr_elements[0].coeff=0xffffffff;
spirit-instr_elements[0].value=0xffffffff;
spirit-instr_query_noise=3000.0;
spirit-card_elements[0].coeff=0xffffffff;
spirit-card_elements[0].value=0xffffffff;
spirit-card_elements[1].coeff=0xffffffff;
spirit-card_elements[1].value=0x00000000;channel=new DKVECTOR(4);
sq=new FRSPIRITQUERY(); // QUERY0
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY1
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY2
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY3
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);// SPIRIT 22
spirit=new FRSPIRIT();
spirit-depth=3;
spirit-instr_dominancy=0xa0;
spirit-instr_elements[0].coeff=0xffffffff;
spirit-instr_elements[0].value=0xffffffff;
spirit-instr_query_noise=0.0;
spirit-card_elements[0].coeff=0xffffffff;
spirit-card_elements[0].value=0x00000000;
spirit-card_elements[1].coeff=0xffffffff;
spirit-card_elements[1].value=0x00000000;channel=new DKVECTOR(4);
sq=new FRSPIRITQUERY(); // QUERY0
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY1
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY2
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY3
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);channel=new DKVECTOR(4);
sq=new FRSPIRITQUERY(); // QUERY0
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY1
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY2
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY3
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);// SPIRIT 222
spirit=new FRSPIRIT();
spirit-depth=3;
spirit-instr_dominancy=0x90;
spirit-instr_elements[0].coeff=0xffffffff;
spirit-instr_elements[0].value=0x00000000;
spirit-instr_query_noise=3000.0;
spirit-card_elements[0].coeff=0xffffffff;
spirit-card_elements[0].value=0x00000000;
spirit-card_elements[1].coeff=0xffffffff;
spirit-card_elements[1].value=0xffffffff;channel=new DKVECTOR(4);
sq=new FRSPIRITQUERY(); // QUERY0
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY1
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY2
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY3
sq-query_depth=2;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);// SPIRIT 3
spirit=new FRSPIRIT();
spirit-depth=4;
spirit-instr_dominancy=0xb0;
spirit-instr_elements[0].coeff=0xffffffff;
spirit-instr_elements[0].value=0xffffffff;
spirit-instr_query_noise=2000.0;channel=new DKVECTOR(4);
sq=new FRSPIRITQUERY(); // QUERY0
sq-query_depth=3;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0xffffffff;
sq-card_elements[1].coeff=0xffffffff;
sq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY1
sq-query_depth=3;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
sq-card_elements[1].coeff=0xffffffff;
sq-card_elements[1].value=0x00000000;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
sq=new FRSPIRITQUERY(); // QUERY2
sq-query_depth=3;
sq-card_elements[0].coeff=0xffffffff;
sq-card_elements[0].value=0x00000000;
sq-card_elements[1].coeff=0xffffffff;
sq-card_elements[1].value=0xffffffff;
se=new FRSPIRITELEMENT();
se-type=FRELEMENTTYPE_SPIRITQUERY;
se-element=(void*)sq;
channel-AddElement(se);
spirit-spirit_channels-AddElement(channel);channel=new DKVECTOR(4);
spirit-spirit_channels-AddElement(channel);exp_spirits.AddEl
ement(spirit);FR_AddInstrumentInstr("BASS02.wav");
FR_AddInstrumentInstr("flut2.wav");FRIN_RegisterAllExistingE
xperiences();
}// ----------
// GET NEW ID
// ----------
DWORD FR_GetNewID()
{
current_id++;
return current_id-1;
}// ********
// ADD WORD
// ********
void FRIN_AddWord()
{
}// **********
// REDRAW ALL
// **********
void FRIN_RedrawAll()
{
FRIN_ClearAll();
FRIN_RedrawInterfaces();
FRIN_RedrawCurrentEdit();
}// **********************
// FRIN_DisposeInterfaces
// **********************,
void FRIN_DisposeInterfaces()
{
for(int i=0; i host_ptr==ptr)
return fri;
}return 0;
}// ******************
// GET SONG INTERFACE
// ******************
FRIN_INTERFACE* FRIN_GetSongInterface()
{
for(int i=0; i type==FRIN_INTERFACETYPE_SONG)
return fri;
}return 0;
}// ******************
// GET LAST INTERFACE
// ******************
FRIN_INTERFACE* FRIN_GetLastInterface()
{
if(interfaces.GetElementCount())
return (FRIN_INTERFACE*)interfaces.GetElement(interfaces.GetElement
Count()-1);
else
return 0;
}// **********************
// REGISTER NEW INTERFACE
// **********************
void FRIN_RegisterNewInterface(void *ptr, BYTE type)
{
FRIN_INTERFACE *fri=new FRIN_INTERFACE();
fri-host_ptr=ptr;
fri-type=type;
fri-x=FRIN_PLACEMENTOFFSET_X;
fri-y=FRIN_PLACEMENTOFFSET_Y+new_interface_offset_y;
new_interface_offset_y+=FRIN_LINEHEIGHT;interfaces.AddElemen
t(fri);
}// *************************
// ZERO NEW INTERFACE OFFSET
// *************************
void FRIN_ZeroNewInterfaceOffset()
{
new_interface_offset_y=0;
}// *********
// CLEAR ALL
// *********
void FRIN_ClearAll()
{
#ifdef DDON
DKD_ClearBackSurface(FRIN_BACKCOLOR);
#endif
}