TempleOSCDV4.12.ISO

This commit is contained in:
Terry A. Davis authored and minexew committed 2018-09-08 21:47:56 +02:00
1 parent 93ca216483
commit b84bbff6db
381 files changed
+18356 -18798

No files matched your search

+24 -24
View File
@@ -18,20 +18,20 @@ CTask *SingleSong(U8 *msg,U8 *name)
Bool JBPutKey(CDoc *doc,U8 *,I64 ch,I64 sc)
{//ch=ASCII; sc=scan_code
CDocEntry *doc_ce=doc->cur_entry,*doc_e;
CDirEntry *tempde;
CDirEntry *tmpde;
CDoc *s;
if (!(sc&(SCF_ALT|SCF_CTRL|SCF_SHIFT))
&& doc_ce->type_u8==DOCT_MENU_VAL && doc_ce->left_exp>=0) {
tempde=doc_ce->left_exp;
tmpde=doc_ce->left_exp;
if (sc.u8[0]==SC_DELETE ) {
Beep;
Silent;
Del(tempde->full_name);
Del(tmpde->full_name);
Silent(OFF);
} else if ('0'<=ch<='9') {
if (StrLen(doc_ce->tag)>1)
doc_ce->tag[0]=ch;
s=DocRead(tempde->full_name);
s=DocRead(tmpde->full_name);
doc_e=s->head.next;
while (doc_e!=s && doc_e->type_u8!=DOCT_TEXT)
doc_e=doc_e->next;
@@ -42,7 +42,7 @@ Bool JBPutKey(CDoc *doc,U8 *,I64 ch,I64 sc)
DocDel(s);
return TRUE;
} else if (ch==CH_SPACE||ch==CH_ESC)
tempde->user_data++; //JB_RUN_LEVEL++
tmpde->user_data++; //JB_RUN_LEVEL++
//<SPACE> is followed by <ESC> --> JB_RUN_LEVEL_TWO
//Actual <ESC> just exits --> JB_RUN_LEVEL_ONE
}
@@ -53,7 +53,7 @@ public U0 JukeBox(U8 *dirname="~/Psalmody",U8 **_filename=NULL)
{//_filename is for using this as a song-chooser program.
I64 i=0,rating;
U8 *st,*st2;
CDirEntry *tempde,*tempde1;
CDirEntry *tmpde,*tmpde1;
CDoc *doc=DocNew,*s;
CDocEntry *doc_e;
CTask *task=NULL;
@@ -61,7 +61,7 @@ public U0 JukeBox(U8 *dirname="~/Psalmody",U8 **_filename=NULL)
*_filename=NULL;
dirname=StrNew(dirname);
st=MStrPrint("%s/*.HC.Z",dirname);
tempde=tempde1=FilesFind(st);
tmpde=tmpde1=FilesFind(st);
Free(st);
Free(dirname);
doc->user_put_key=&JBPutKey;
@@ -70,13 +70,13 @@ public U0 JukeBox(U8 *dirname="~/Psalmody",U8 **_filename=NULL)
"$$BLACK$$Incomplete $$CYAN$$Special$$FG$$\n\n"
"$$GREEN$$<DELETE>$$FG$$ to delete a song.\n"
"Press a number to rate a song.\n");
while (tempde) {
while (tmpde) {
if (!(i++%5))
DocPrint(doc,"\n");
if (FileOcc("Play(",tempde->full_name,"")) {
st=StrNew(tempde->name);
if (FileOcc("Play(",tmpde->full_name,"")) {
st=StrNew(tmpde->name);
FileExtRem(st);
s=DocRead(tempde->full_name);
s=DocRead(tmpde->full_name);
doc_e=s->head.next;
while (doc_e!=s && doc_e->type_u8!=DOCT_TEXT)
doc_e=doc_e->next;
@@ -94,7 +94,7 @@ public U0 JukeBox(U8 *dirname="~/Psalmody",U8 **_filename=NULL)
DocPrint(doc,"$$CYAN$$");
else if (StrMatch("no nothing",doc_e->tag)) {
DocPrint(doc,"$$RED$$");
if (FileOcc("\\0",tempde->full_name,"")) {
if (FileOcc("\\0",tmpde->full_name,"")) {
s->cur_entry=doc_e->next;
s->cur_col=0;
DocEntryDel(s,doc_e);
@@ -102,37 +102,37 @@ public U0 JukeBox(U8 *dirname="~/Psalmody",U8 **_filename=NULL)
DocWrite(s);
}
}
DocPrint(doc,"$$MU-UL,\"%c%-8ts\",LE=%d$$ ",rating,st,tempde);
tempde->user_data=JB_RUN_LEVEL_NULL;
DocPrint(doc,"$$MU-UL,\"%c%-8ts\",LE=%d$$ ",rating,st,tmpde);
tmpde->user_data=JB_RUN_LEVEL_NULL;
}
DocDel(s);
Free(st);
}
tempde=tempde->next;
tmpde=tmpde->next;
}
DocPrint(doc,"\n$$CYAN$$$$MU-UL,\"DONE\",LE=%d$$\n",DOCM_CANCEL);
while (TRUE) {
if (_filename)
tempde=PopUpMenu(doc,DOF_INTERCEPT_TASK_END);
tmpde=PopUpMenu(doc,DOF_INTERCEPT_TASK_END);
else
tempde=PopUpMenu(doc);
tmpde=PopUpMenu(doc);
if (task)
Kill(task);
if (tempde<=0) break;
st2=StrNew(tempde->name);
if (tmpde<=0) break;
st2=StrNew(tmpde->name);
if (_filename) {
Free(*_filename);
*_filename=StrNew(tempde->full_name);
*_filename=StrNew(tmpde->full_name);
}
if (tempde->user_data==JB_RUN_LEVEL_ONE) break; //<ESC>
tempde->user_data=JB_RUN_LEVEL_NULL; //Rst from <SPACE>
if (tmpde->user_data==JB_RUN_LEVEL_ONE) break; //<ESC>
tmpde->user_data=JB_RUN_LEVEL_NULL; //Rst from <SPACE>
FileExtRem(st2);
st=MStrPrint("ExeFile(\"%s\");",tempde->full_name);
st=MStrPrint("ExeFile(\"%s\");",tmpde->full_name);
MusicSettingsRst;
task=SingleSong(st,st2);
Free(st2);
Free(st);
}
DocDel(doc);
DirTreeDel(tempde1);
DirTreeDel(tmpde1);
}
+11 -11
View File
@@ -2,13 +2,13 @@ U0 SongPuppet(CTask *task,I64 passes)
{
CDbgInfo *dbg_info;
I64 i,start,end,rip,last_rip;
CHashFun *tempf=NULL;
CHashFun *tmpf=NULL;
for (i=0;i<250 && TaskValidate(task);i++) {
if (tempf=HashFind("Song",task->hash_table,HTT_FUN))
if (tmpf=HashFind("Song",task->hash_table,HTT_FUN))
break;
Sleep(1);
}
if (tempf && (dbg_info=tempf->dbg_info)) {
if (tmpf && (dbg_info=tmpf->dbg_info)) {
start=dbg_info->body[0];
end =dbg_info->body[dbg_info->max_line+1-dbg_info->min_line];
last_rip=0;
@@ -74,16 +74,16 @@ public U0 JukeSongsPuppet(U8 *dirname="~/Psalmody",I64 passes=2,
I64 start_song=0,I64 end_song=MAX_I64)
{//Help make music video by puppeting JukeBox task.
I64 i;
CDirEntry *tempde,*tempde1;
CDirEntry *tmpde,*tmpde1;
CTask *juke_task=User("JukeBox(0x%X);\n",dirname);
Cd(dirname);
tempde1=FilesFind("*",FUF_RECURSE|FUF_JUST_TXT|FUF_JUST_FILES);
for (tempde=tempde1,i=0;tempde && i<start_song;i++)
tempde=tempde->next;
for (i=start_song;tempde && i<end_song;i++) {
JukeSongPuppet(juke_task,passes,i,tempde->name);
tempde=tempde->next;
tmpde1=FilesFind("*",FUF_RECURSE|FUF_JUST_TXT|FUF_JUST_FILES);
for (tmpde=tmpde1,i=0;tmpde && i<start_song;i++)
tmpde=tmpde->next;
for (i=start_song;tmpde && i<end_song;i++) {
JukeSongPuppet(juke_task,passes,i,tmpde->name);
tmpde=tmpde->next;
}
DirTreeDel(tempde1);
DirTreeDel(tmpde1);
Kill(juke_task);
}
+3 -10
View File
@@ -19,7 +19,7 @@ This uses four types of output
4) The Fs->next_ctrl for the tempo/stacatto sliders.
See $LK,"GrUpdateTaskWin",A="MN:GrUpdateTaskWin"$(), $LK,"GrUpdateTasks",A="MN:GrUpdateTasks"$() and $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
See $LK,"GrUpdateTaskWin",A="MN:GrUpdateTaskWin"$(), $LK,"GrUpdateTasks",A="MN:GrUpdateTasks"$() and $LK,"GrUpdateScrn",A="MN:GrUpdateScrn"$().
$WW,1$$WW,0$*/
#define NOTE_REST MIN_I64
@@ -62,20 +62,13 @@ class PsmCtrl
PsmNote head;
PsmNote clipboard;
CMenuEntry *incomplete_entry,*record_entry;
I64 screen_x,
I64 scrn_x,
tool;
PsmNote *cur_note;
CDC *dc2;
Bool playing;
} oc;
} psm;
U8 *psm_note_lst="A\0A#\0B\0C\0C#\0D\0D#\0E\0F\0F#\0G\0G#\0";
U8 psm_note_map[12]={6,6,5,4,4,3,3,2,1,1,0,0};
U8 psm_note_inverse_map[7]={10,8,7,5,3,2,0};
#define PSMPM_NORMAL 0
#define PSMPM_REVERB1 1
#define PSMPM_NUM_PLAY_MODES 2
I64 psm_play_mode=0;
F64 psm_play_f=0;
+84 -86
View File
@@ -63,7 +63,7 @@ Bool psm_triplet_durations[PSM_NUM_DURATIONS]={TRUE,FALSE,TRUE,
Bool PsmBlink()
{
if (Blink || oc.playing)
if (Blink || psm.playing)
return TRUE;
else
return FALSE;
@@ -88,27 +88,27 @@ Bool PsmIsDotted(I64 duration)
U0 PsmMarkSel(I64 x1,I64 x2,Bool sel)
{
PsmNote *tempo=oc.head.next;
while (tempo!=&oc.head) {
PsmNote *tmpn=psm.head.next;
while (tmpn!=&psm.head) {
if (sel) {
if (x1<=tempo->x<=x2)
tempo->flags|=PSMF_SEL;
if (x1<=tmpn->x<=x2)
tmpn->flags|=PSMF_SEL;
} else
tempo->flags&=~PSMF_SEL;
tempo=tempo->next;
tmpn->flags&=~PSMF_SEL;
tmpn=tmpn->next;
}
}
U0 PsmSetWidth(PsmNote *tempo)
U0 PsmSetWidth(PsmNote *tmpn)
{
if (tempo->type==PSMT_METER)
tempo->width=12;
if (tmpn->type==PSMT_METER)
tmpn->width=12;
else {
tempo->width=PSM_NOTE_SPACING;
if (PsmIsDotted(tempo->duration))
tempo->width+=PSM_NOTE_SPACING/2;
if (Bt(&tempo->flags,PSMf_SHARP) || Bt(&tempo->flags,PSMf_FLAT))
tempo->width+=PSM_NOTE_SPACING;
tmpn->width=PSM_NOTE_SPACING;
if (PsmIsDotted(tmpn->duration))
tmpn->width+=PSM_NOTE_SPACING/2;
if (Bt(&tmpn->flags,PSMf_SHARP) || Bt(&tmpn->flags,PSMf_FLAT))
tmpn->width+=PSM_NOTE_SPACING;
}
}
@@ -116,18 +116,16 @@ U0 PsmSetOctave(I64 octave)
{
I64 i;
U8 buf[STR_LEN];
CMenuEntry *tempse;
CMenuEntry *tmpse;
for (i=0;i<=6;i++) {
StrPrint(buf,"Snd/Octave%d",i);
if (tempse=MenuEntryFind(Fs->cur_menu,buf)) {
if (tmpse=MenuEntryFind(Fs->cur_menu,buf)) {
if (i==octave)
tempse->checked=TRUE;
tmpse->checked=TRUE;
else
tempse->checked=FALSE;
tmpse->checked=FALSE;
}
}
if (tempse=MenuEntryFind(Fs->cur_menu,"Snd/Reverb"))
tempse->checked=psm_play_mode==1;
}
U0 DrawNote(CDC *dc,I64 x,I64 y,I64 duration)
@@ -150,21 +148,21 @@ U0 DrawTimeSignature(CDC *dc,I64 x,I64 y,I64 top,I64 bottom)
U0 PsmRecalcNoteXY()
{
F64 measure_len=4,measure_left=measure_len;
PsmNote *tempo=oc.head.next;
I64 x=8-oc.screen_x,note,octave;
PsmNote *tmpn=psm.head.next;
I64 x=8-psm.scrn_x,note,octave;
while (TRUE) {
tempo->x=x;
tempo->y=50;
if (tempo==&oc.head)
tmpn->x=x;
tmpn->y=50;
if (tmpn==&psm.head)
break;
else {
if (tempo->type!=PSMT_METER) {
octave=tempo->octave;
if (tmpn->type!=PSMT_METER) {
octave=tmpn->octave;
if (octave!=OCTAVE_REST) {
note=tempo->note;
if (Bt(&tempo->flags,PSMf_SHARP))
note=tmpn->note;
if (Bt(&tmpn->flags,PSMf_SHARP))
note--;
if (Bt(&tempo->flags,PSMf_FLAT))
if (Bt(&tmpn->flags,PSMf_FLAT))
note++;
if (note<0) {
note=11;
@@ -174,27 +172,27 @@ U0 PsmRecalcNoteXY()
octave++;
}
note=music.note_map[*LstSub(note,psm_note_lst)-'A'];
tempo->y=(15+(psm_note_map[note]-7*(octave-2)))*4;
tmpn->y=(15+(psm_note_map[note]-7*(octave-2)))*4;
}
}
x+=tempo->width;
if (tempo->type==PSMT_METER) {
measure_len=tempo->meter_top*4.0/tempo->meter_bottom;
x+=tmpn->width;
if (tmpn->type==PSMT_METER) {
measure_len=tmpn->meter_top*4.0/tmpn->meter_bottom;
measure_left=0;
} else
measure_left-=psm_durations[tempo->duration];
measure_left-=psm_durations[tmpn->duration];
if (measure_left<0.001) {
x+=PSM_NOTE_SPACING;
measure_left=measure_len;
}
}
tempo=tempo->next;
tmpn=tmpn->next;
}
}
U0 DrawIt(CTask *task,CDC *dc)
{
PsmNote *tempo;
PsmNote *tmpn;
I64 i,x,y,
w=task->pix_width;
F64 measure_len=4,measure_left=measure_len;
@@ -206,63 +204,63 @@ U0 DrawIt(CTask *task,CDC *dc)
GrLine(dc,0,i*8,w,i*8);
PsmRecalcNoteXY;
if (oc.cur_note->x<64) {
oc.screen_x-=128;
if (psm.cur_note->x<64) {
psm.scrn_x-=128;
PsmRecalcNoteXY;
}
if (oc.cur_note->x>=GR_WIDTH-64) {
oc.screen_x+=128;
if (psm.cur_note->x>=GR_WIDTH-64) {
psm.scrn_x+=128;
PsmRecalcNoteXY;
}
tempo=oc.head.next;
while (tempo!=&oc.head) {
x=tempo->x;
y=tempo->y;
tmpn=psm.head.next;
while (tmpn!=&psm.head) {
x=tmpn->x;
y=tmpn->y;
if (measure_left<0.001) {
dc->color=BLACK;
GrLine(dc,x-PSM_NOTE_SPACING,8,x-PSM_NOTE_SPACING,11*8);
measure_left=measure_len;
}
if (tempo->type==PSMT_METER) {
if (tempo==oc.cur_note && PsmBlink)
if (tmpn->type==PSMT_METER) {
if (tmpn==psm.cur_note && PsmBlink)
dc->color=BROWN;
else
dc->color=BLACK;
DrawTimeSignature(dc,x,5*8,tempo->meter_top,tempo->meter_bottom);
measure_len=tempo->meter_top*4.0/tempo->meter_bottom;
DrawTimeSignature(dc,x,5*8,tmpn->meter_top,tmpn->meter_bottom);
measure_len=tmpn->meter_top*4.0/tmpn->meter_bottom;
measure_left=0;
} else {
if (tempo==oc.cur_note && PsmBlink) {
if (tmpn==psm.cur_note && PsmBlink) {
dc->color=BROWN;
GrPrint(dc,x+8,y,"%s",tempo->word);
} else if (tempo->flags&PSMF_SEL)
GrPrint(dc,x+8,y,"%s",tmpn->word);
} else if (tmpn->flags&PSMF_SEL)
dc->color=RED;
else {
if (tempo->note!=NOTE_REST)
if (tmpn->note!=NOTE_REST)
dc->color=BLACK;
else
dc->color=LTGRAY;
if (PsmHasWords(tempo->word))
if (PsmHasWords(tmpn->word))
dc->color=GREEN;
}
DrawNote(dc,x,y,tempo->duration);
if (PsmIsDotted(tempo->duration))
DrawNote(dc,x,y,tmpn->duration);
if (PsmIsDotted(tmpn->duration))
x+=PSM_NOTE_SPACING/2;
if (Bt(&tempo->flags,PSMf_SHARP))
if (Bt(&tmpn->flags,PSMf_SHARP))
Sprite3(dc,x,y,0,$IB,"<13>",BI=13$);
else if (Bt(&tempo->flags,PSMf_FLAT))
else if (Bt(&tmpn->flags,PSMf_FLAT))
Sprite3(dc,x,y,0,$IB,"<14>",BI=14$);
measure_left-=psm_durations[tempo->duration];
measure_left-=psm_durations[tmpn->duration];
}
tempo=tempo->next;
tmpn=tmpn->next;
}
if (oc.cur_note==&oc.head && PsmBlink)
if (psm.cur_note==&psm.head && PsmBlink)
dc->color=BROWN;
else
dc->color=BLACK;
Sprite3(dc,oc.head.x,50,0,$IB,"<12>",BI=12$);
Sprite3(dc,psm.head.x,50,0,$IB,"<12>",BI=12$);
}
#define PSM_NOTE_BOX_X 220
@@ -298,12 +296,12 @@ U0 DrawPickNoteBox()
for (i=0;i<PSM_NUM_DURATIONS;i++) {
PsmSetPickNoteBoxX(i,&x);
if (PsmIsDotted(i))
oc.dc2->color=RED;
psm.dc2->color=RED;
else if (psm_triplet_durations[i])
oc.dc2->color=LTRED;
psm.dc2->color=LTRED;
else
oc.dc2->color=BLACK;
DrawNote(oc.dc2,x,PSM_NOTE_BOX_Y,i);
psm.dc2->color=BLACK;
DrawNote(psm.dc2,x,PSM_NOTE_BOX_Y,i);
}
}
@@ -312,19 +310,19 @@ U0 DrawPickNoteBox()
U0 DrawPickTools()
{
if (oc.tool==PSMTT_BOX_TOOL)
oc.dc2->color=ROPF_DITHER+WHITE<<16+RED;
if (psm.tool==PSMTT_BOX_TOOL)
psm.dc2->color=ROPF_DITHER+WHITE<<16+RED;
else
oc.dc2->color=ROPF_DITHER+WHITE<<16+BLACK;
GrBorder(oc.dc2,PSM_TOOLS_X,PSM_TOOLS_Y,
psm.dc2->color=ROPF_DITHER+WHITE<<16+BLACK;
GrBorder(psm.dc2,PSM_TOOLS_X,PSM_TOOLS_Y,
PSM_TOOLS_X+10,PSM_TOOLS_Y+10);
if (oc.tool==PSMTT_PTR_TOOL)
oc.dc2->color=RED;
if (psm.tool==PSMTT_PTR_TOOL)
psm.dc2->color=RED;
else
oc.dc2->color=BLACK;
(*gr.fp_draw_input_ptr)(oc.dc2,PSM_TOOLS_X+15,PSM_TOOLS_Y);
oc.dc2->color=BLACK;
psm.dc2->color=BLACK;
(*gr.fp_draw_input_ptr)(psm.dc2,PSM_TOOLS_X+15,PSM_TOOLS_Y);
psm.dc2->color=BLACK;
}
Bool PsmGetPickToolBox(I64 xx,I64 yy)
@@ -333,9 +331,9 @@ Bool PsmGetPickToolBox(I64 xx,I64 yy)
PSM_TOOLS_Y<=yy<PSM_TOOLS_Y+15) {
PsmMarkSel(0,0,FALSE);
if (xx<PSM_TOOLS_X+13)
oc.tool=PSMTT_BOX_TOOL;
psm.tool=PSMTT_BOX_TOOL;
else
oc.tool=PSMTT_PTR_TOOL;
psm.tool=PSMTT_PTR_TOOL;
return TRUE;
} else
return FALSE;
@@ -364,9 +362,9 @@ Bool PsmGetPickMeterBox(I64 xx,I64 yy,I64 *top,I64 *bottom)
U0 DrawPickMeterBox()
{
I64 i;
oc.dc2->color=BLACK;
psm.dc2->color=BLACK;
for (i=0;i<PSM_NUM_METERS;i++)
DrawTimeSignature(oc.dc2,PSM_METER_X+i*PSM_METER_W,PSM_METER_Y,
DrawTimeSignature(psm.dc2,PSM_METER_X+i*PSM_METER_W,PSM_METER_Y,
meter_tops[i],meter_bottoms[i]);
}
@@ -398,25 +396,25 @@ U0 PsmMenu(I64 psm_octave)
"$$LTGREEN$$<BACKSPACE>$$FG$$\tDeletes Last Note\n"
"$$LTGREEN$$Left Mouse$$FG$$\tDrag note or shift word\n"
"$$LTGREEN$$Right Mouse$$FG$$\tChange duration or set word\n";
Sprite($IB,"<6>",BI=6$,"$$SP+LA,\"\","
Sprite($IB,"<6>",BI=6$,"$$SP+LIS,\"\","
"LM=\"Msg(MSG_KEY_DOWN,0,SCF_CTRL|SC_CURSOR_LEFT);\",BI=%d$$");
" ";
if (oc.playing)
if (psm.playing)
Sprite($IB,"<9>",BI=9$,"$$SP,\"\",LM=\"x\",BI=%d$$");
else
Sprite($IB,"<8>",BI=8$,"$$SP,\"\",LM=\"x\",BI=%d$$");
" ";
if (oc.record_entry->checked) {
oc.record_entry->checked=TRUE;
if (psm.record_entry->checked) {
psm.record_entry->checked=TRUE;
Sprite($IB,"<10>",BI=10$,"$$SP,\"\",LM=\"z\",BI=%d$$");
} else
Sprite($IB,"<11>",BI=11$,"$$SP,\"\",LM=\"z\",BI=%d$$");
" ";
Sprite($IB,"<7>",BI=7$,"$$SP+LA,\"\","
Sprite($IB,"<7>",BI=7$,"$$SP+LIS,\"\","
"LM=\"Msg(MSG_KEY_DOWN,0,SCF_CTRL|SC_CURSOR_RIGHT);\",BI=%d$$");
"$$CM+LX,0,6$$";
PsmSetOctave(psm_octave);
WinMgrSync(2);
Refresh(2);
}
"
òÿÿÿñÿÿÿ
+129 -129
View File
@@ -1,83 +1,83 @@
U0 PsmNoteDel(PsmNote *tempo)
U0 PsmNoteDel(PsmNote *tmpn)
{
Free(tempo->word);
Free(tempo);
Free(tmpn->word);
Free(tmpn);
}
PsmNote *PsmNoteCopy(PsmNote *tempo)
PsmNote *PsmNoteCopy(PsmNote *tmpn)
{
PsmNote *tempo1=MAllocIdent(tempo);
if (tempo->word)
tempo1->word=StrNew(tempo->word);
PsmNote *tmpn1=MAllocIdent(tmpn);
if (tmpn->word)
tmpn1->word=StrNew(tmpn->word);
else
tempo1->word=NULL;
return tempo1;
tmpn1->word=NULL;
return tmpn1;
}
U0 PsmSongDel(PsmNote *head)
{
PsmNote *tempo,*tempo1;
tempo=head->next;
while (tempo!=head) {
tempo1=tempo->next;
PsmNoteDel(tempo);
tempo=tempo1;
PsmNote *tmpn,*tmpn1;
tmpn=head->next;
while (tmpn!=head) {
tmpn1=tmpn->next;
PsmNoteDel(tmpn);
tmpn=tmpn1;
}
QueInit(head);
}
U0 PsmCutToClipboard()
{
PsmNote *tempo,*tempo1;
PsmSongDel(&oc.clipboard);
tempo=oc.head.next;
while (tempo!=&oc.head) {
tempo1=tempo->next;
if (tempo->flags&PSMF_SEL) {
if (oc.cur_note==tempo)
oc.cur_note=tempo->next;
QueRem(tempo);
tempo->flags&=~PSMF_SEL;
QueIns(tempo,oc.clipboard.last);
PsmNote *tmpn,*tmpn1;
PsmSongDel(&psm.clipboard);
tmpn=psm.head.next;
while (tmpn!=&psm.head) {
tmpn1=tmpn->next;
if (tmpn->flags&PSMF_SEL) {
if (psm.cur_note==tmpn)
psm.cur_note=tmpn->next;
QueRem(tmpn);
tmpn->flags&=~PSMF_SEL;
QueIns(tmpn,psm.clipboard.last);
}
tempo=tempo1;
tmpn=tmpn1;
}
}
U0 PsmPasteClipboard()
{
PsmNote *tempo,*tempo1;
tempo=oc.clipboard.next;
while (tempo!=&oc.clipboard) {
tempo1=PsmNoteCopy(tempo);
QueIns(tempo1,oc.cur_note->last);
tempo=tempo->next;
PsmNote *tmpn,*tmpn1;
tmpn=psm.clipboard.next;
while (tmpn!=&psm.clipboard) {
tmpn1=PsmNoteCopy(tmpn);
QueIns(tmpn1,psm.cur_note->last);
tmpn=tmpn->next;
}
}
U0 PsmCopyToClipboard()
{
PsmNote *tempo,*tempo1;
PsmSongDel(&oc.clipboard);
tempo=oc.head.next;
while (tempo!=&oc.head) {
if (tempo->flags&PSMF_SEL) {
tempo->flags&=~PSMF_SEL;
tempo1=PsmNoteCopy(tempo);
QueIns(tempo1,oc.clipboard.last);
PsmNote *tmpn,*tmpn1;
PsmSongDel(&psm.clipboard);
tmpn=psm.head.next;
while (tmpn!=&psm.head) {
if (tmpn->flags&PSMF_SEL) {
tmpn->flags&=~PSMF_SEL;
tmpn1=PsmNoteCopy(tmpn);
QueIns(tmpn1,psm.clipboard.last);
}
tempo=tempo->next;
tmpn=tmpn->next;
}
}
PsmNote *PsmFindNote(I64 x,I64)
{
PsmNote *tempo=oc.head.next;
PsmNote *tmpn=psm.head.next;
PsmRecalcNoteXY;
x+=PSM_NOTE_SPACING/2;
while (x>tempo->next->x && tempo!=&oc.head)
tempo=tempo->next;
return tempo;
while (x>tmpn->next->x && tmpn!=&psm.head)
tmpn=tmpn->next;
return tmpn;
}
U8 *PsmMusicSetOctave(U8 *st,I64 *psm_octave)
@@ -109,48 +109,48 @@ U8 *PsmMusicSetNoteLen(U8 *st,F64 *psm_duration)
U0 PsmLoadSongStr(U8 *st,I64 *psm_octave,F64 *psm_duration)
{
PsmNote *tempo,*tempo1;
PsmNote *tmpn,*tmpn1;
I64 note,i=0;
while (*st) {
tempo=CAlloc(sizeof(PsmNote));
tmpn=CAlloc(sizeof(PsmNote));
while (*st && !('A'<=*st<='G') && *st!='R') {
if (*st=='M') {
tempo1=CAlloc(sizeof(PsmNote));
tempo1->type=PSMT_METER;
tmpn1=CAlloc(sizeof(PsmNote));
tmpn1->type=PSMT_METER;
st++;
if ('1'<=*st<='9')
tempo1->meter_top=*st++-'0';
tmpn1->meter_top=*st++-'0';
else
tempo1->meter_top=4;
tmpn1->meter_top=4;
if (*st=='/')
st++;
if ('1'<=*st<='9')
tempo1->meter_bottom=*st++-'0';
tmpn1->meter_bottom=*st++-'0';
else
tempo1->meter_bottom=4;
PsmSetWidth(tempo1);
QueIns(tempo1,oc.head.last);
tmpn1->meter_bottom=4;
PsmSetWidth(tmpn1);
QueIns(tmpn1,psm.head.last);
}
while (*st=='(') {
Bts(&tempo->flags,PSMf_TIE);
Bts(&tmpn->flags,PSMf_TIE);
st++;
}
st=PsmMusicSetOctave(st,psm_octave);
st=PsmMusicSetNoteLen(st,psm_duration);
}
if (!*st) {
PsmNoteDel(tempo);
PsmNoteDel(tmpn);
break;
}
note=*st++-'A';
if (note<7) {
note=music.note_map[note];
if (*st=='b') {
Bts(&tempo->flags,PSMf_FLAT);
Bts(&tmpn->flags,PSMf_FLAT);
note--;
st++;
} else if (*st=='#') {
Bts(&tempo->flags,PSMf_SHARP);
Bts(&tmpn->flags,PSMf_SHARP);
note++;
st++;
}
@@ -161,11 +161,11 @@ U0 PsmLoadSongStr(U8 *st,I64 *psm_octave,F64 *psm_duration)
note=0;
*psm_octave+=1;
}
tempo->note=note;
tempo->octave=*psm_octave;
tmpn->note=note;
tmpn->octave=*psm_octave;
} else {
tempo->note=NOTE_REST;
tempo->octave=OCTAVE_REST;
tmpn->note=NOTE_REST;
tmpn->octave=OCTAVE_REST;
}
if (*psm_duration<=2*.25/3)
i=0;
@@ -191,38 +191,38 @@ U0 PsmLoadSongStr(U8 *st,I64 *psm_octave,F64 *psm_duration)
i=10;
else
i=11;
tempo->duration=i;
tempo->type=PSMT_NOTE;
PsmSetWidth(tempo);
QueIns(tempo,oc.cur_note->last);
tmpn->duration=i;
tmpn->type=PSMT_NOTE;
PsmSetWidth(tmpn);
QueIns(tmpn,psm.cur_note->last);
}
}
U0 PsmLoadSong(U8 *filename,I64 *psm_octave,F64 *psm_duration)
{
U8 *st;
PsmNote *tempo;
PsmNote *tmpn;
CCmpCtrl *cc=CmpCtrlNew(MStrPrint("#include \"%s\"",filename));
if (FileOcc("incomplete",filename,""))
oc.incomplete_entry->checked=TRUE;
psm.incomplete_entry->checked=TRUE;
else
oc.incomplete_entry->checked=FALSE;
psm.incomplete_entry->checked=FALSE;
while (Lex(cc)) {
if (cc->token==TK_IDENT)
if (!StrCmp(cc->cur_str,"Play")) {
if (Lex(cc)=='(')
if (Lex(cc)==TK_STR) {
tempo=oc.head.last;
tmpn=psm.head.last;
st=LexExtStr(cc);
PsmLoadSongStr(st,psm_octave,psm_duration);
if (cc->token==',') {
if (Lex(cc)==TK_STR) {
st=LexExtStr(cc);
do {
do tempo=tempo->next;
while (tempo!=&oc.head && tempo->type==PSMT_METER);
if (tempo!=&oc.head)
tempo->word=StrNew(st);
do tmpn=tmpn->next;
while (tmpn!=&psm.head && tmpn->type==PSMT_METER);
if (tmpn!=&psm.head)
tmpn->word=StrNew(st);
st+=StrLen(st)+1;
} while (*st);
}
@@ -249,28 +249,28 @@ U0 PsmLoadSong(U8 *filename,I64 *psm_octave,F64 *psm_duration)
U8 *PsmCvtSong()
{
PsmNote *tempo;
PsmNote *tmpn;
U8 *st,*src,*dst;
I64 i,note,octave,last_octave,last_duration;
i=0;
tempo=oc.head.next;
tmpn=psm.head.next;
last_octave=OCTAVE_REST;
last_duration=-1;
while (tempo!=&oc.head) {
dst=&tempo->ascii;
if (tempo->type==PSMT_METER) {
while (tmpn!=&psm.head) {
dst=&tmpn->ascii;
if (tmpn->type==PSMT_METER) {
*dst++='M';
*dst++=tempo->meter_top+'0';
*dst++=tmpn->meter_top+'0';
*dst++='/';
*dst++=tempo->meter_bottom+'0';
*dst++=tmpn->meter_bottom+'0';
} else {
octave=tempo->octave;
note=tempo->note;
octave=tmpn->octave;
note=tmpn->note;
if (note!=NOTE_REST) {
if (Bt(&tempo->flags,PSMf_SHARP))
if (Bt(&tmpn->flags,PSMf_SHARP))
note--;
if (Bt(&tempo->flags,PSMf_FLAT))
if (Bt(&tmpn->flags,PSMf_FLAT))
note++;
if (note<0) {
note=11;
@@ -281,43 +281,43 @@ U8 *PsmCvtSong()
}
note=music.note_map[*LstSub(note,psm_note_lst)-'A'];
}
if (Bt(&tempo->flags,PSMf_TIE))
if (Bt(&tmpn->flags,PSMf_TIE))
*dst++='(';
if (octave!=last_octave && note!=NOTE_REST) {
*dst++=octave+'0';
last_octave=octave;
}
if (tempo->duration!=last_duration) {
src=LstSub(tempo->duration,psm_duration_lst);
if (tmpn->duration!=last_duration) {
src=LstSub(tmpn->duration,psm_duration_lst);
*dst++=src[0];
if (src[1])
*dst++=src[1];
last_duration=tempo->duration;
last_duration=tmpn->duration;
}
if (note!=NOTE_REST) {
src=LstSub(note,psm_note_lst);
*dst++=src[0];
if (src[1])
*dst++=src[1];
else if (Bt(&tempo->flags,PSMf_FLAT))
else if (Bt(&tmpn->flags,PSMf_FLAT))
*dst++='b';
else if (Bt(&tempo->flags,PSMf_SHARP))
else if (Bt(&tmpn->flags,PSMf_SHARP))
*dst++='#';
} else
*dst++='R';
}
*dst++=0;
i+=StrLen(tempo->ascii);
tempo=tempo->next;
i+=StrLen(tmpn->ascii);
tmpn=tmpn->next;
}
st=MAlloc(i+1);
dst=st;
tempo=oc.head.next;
while (tempo!=&oc.head) {
StrCpy(dst,tempo->ascii);
dst+=StrLen(tempo->ascii);
tempo=tempo->next;
tmpn=psm.head.next;
while (tmpn!=&psm.head) {
StrCpy(dst,tmpn->ascii);
dst+=StrLen(tmpn->ascii);
tmpn=tmpn->next;
}
*dst++=0;
return st;
@@ -327,23 +327,23 @@ U8 *PsmSaveSong(U8 *dirname,U8 *full_filename)
{
CDoc *doc=DocNew(full_filename);
Bool has_words;
PsmNote *tempo,*tempo1;
PsmNote *tmpn,*tmpn1;
F64 measure_len=4,two_measure_left=2*measure_len;
I64 ch;
U8 *ptr;
Free(PsmCvtSong); //set tempo->ascii;
Free(PsmCvtSong); //set tmpn->ascii;
music.tempo=4.4*tempo_state.tempo/TEMPO_RANGE+0.5;
music.stacatto_factor=0.88*tempo_state.stacatto/TEMPO_RANGE+0.12;
has_words=FALSE;
tempo=oc.head.next;
while (tempo!=&oc.head) {
if (PsmHasWords(tempo->word)) has_words=TRUE;
tempo=tempo->next;
tmpn=psm.head.next;
while (tmpn!=&psm.head) {
if (PsmHasWords(tmpn->word)) has_words=TRUE;
tmpn=tmpn->next;
}
if (oc.incomplete_entry->checked)
if (psm.incomplete_entry->checked)
DocPrint(doc,"//0 incomplete\n");
else if (has_words)
DocPrint(doc,"//0 has words\n");
@@ -361,58 +361,58 @@ U8 *PsmSaveSong(U8 *dirname,U8 *full_filename)
" while (!ScanKey) {\n"
"\tPlay(\"",music.tempo+0.0005,music.stacatto_factor+0.0005);
tempo=oc.head.next;
tempo1=tempo;
tmpn=psm.head.next;
tmpn1=tmpn;
has_words=FALSE;
while (tempo!=&oc.head) {
DocPrint(doc,"%s",tempo->ascii);
if (PsmHasWords(tempo->word)) has_words=TRUE;
if (tempo->type==PSMT_METER) {
measure_len=tempo->meter_top*4.0/tempo->meter_bottom;
while (tmpn!=&psm.head) {
DocPrint(doc,"%s",tmpn->ascii);
if (PsmHasWords(tmpn->word)) has_words=TRUE;
if (tmpn->type==PSMT_METER) {
measure_len=tmpn->meter_top*4.0/tmpn->meter_bottom;
two_measure_left=0;
} else
two_measure_left-=psm_durations[tempo->duration];
tempo=tempo->next;
if (two_measure_left<0.001 && tempo!=&oc.head) {
two_measure_left-=psm_durations[tmpn->duration];
tmpn=tmpn->next;
if (two_measure_left<0.001 && tmpn!=&psm.head) {
if (has_words) {
DocPrint(doc,"\",\n\t\t\"");
while (tempo1!=tempo) {
if (tempo1->type!=PSMT_METER) {
if (ptr=tempo1->word) {
while (tmpn1!=tmpn) {
if (tmpn1->type!=PSMT_METER) {
if (ptr=tmpn1->word) {
while (ch=*ptr) {
if (ch==CH_SPACE)
*ptr=CH_SHIFT_SPACE;
ptr++;
}
DocPrint(doc,"%Q\\0",tempo1->word);
DocPrint(doc,"%Q\\0",tmpn1->word);
} else
DocPrint(doc,"%c\\0",CH_SHIFT_SPACE);
}
tempo1=tempo1->next;
tmpn1=tmpn1->next;
}
}
DocPrint(doc,"\");\n"
"\tPlay(\"");
two_measure_left=2*measure_len;
tempo1=tempo;
tmpn1=tmpn;
has_words=FALSE;
}
}
if (has_words) {
DocPrint(doc,"\",\n\t\t\"");
while (tempo1!=tempo) {
if (tempo1->type!=PSMT_METER) {
if (ptr=tempo1->word) {
while (tmpn1!=tmpn) {
if (tmpn1->type!=PSMT_METER) {
if (ptr=tmpn1->word) {
while (ch=*ptr) {
if (ch==CH_SPACE)
*ptr=CH_SHIFT_SPACE;
ptr++;
}
DocPrint(doc,"%Q\\0",tempo1->word);
DocPrint(doc,"%Q\\0",tmpn1->word);
} else
DocPrint(doc,"%c\\0",CH_SHIFT_SPACE);
}
tempo1=tempo1->next;
tmpn1=tmpn1->next;
}
}
DocPrint(doc,"\");\n"
@@ -427,7 +427,7 @@ U8 *PsmSaveSong(U8 *dirname,U8 *full_filename)
if (full_filename)
Free(full_filename);
else
StrPrint(doc->filename.name,"%s/Temp.HC.Z",dirname);
StrPrint(doc->filename.name,"%s/Tmp.HC.Z",dirname);
DocWrite(doc,TRUE);
full_filename=StrNew(doc->filename.name);
DocDel(doc);
+179 -220
View File
@@ -28,94 +28,94 @@ F64 PopUpDuration()
U0 PsmRightClick(I64 x,I64 y)
{
U8 *st,*st2;
PsmNote *tempo,*tempo1;
PsmNote *tmpn,*tmpn1;
I64 i,old_doc_flags;
if (DocPut) old_doc_flags=DocPut->flags;
oc.cur_note=tempo=PsmFindNote(x,y);
if (tempo!=&oc.head) {
psm.cur_note=tmpn=PsmFindNote(x,y);
if (tmpn!=&psm.head) {
Fs->win_inhibit=WIG_USER_TASK_DFT;
i=PopUpDuration;
if (0<=i<PSM_NUM_DURATIONS) {
if (tempo->type==PSMT_NOTE)
tempo->duration=i;
if (tmpn->type==PSMT_NOTE)
tmpn->duration=i;
} else {
switch (i) {
case PSMR_REST:
if (tempo->type==PSMT_NOTE) {
tempo->octave=OCTAVE_REST;
tempo->note=NOTE_REST;
if (tmpn->type==PSMT_NOTE) {
tmpn->octave=OCTAVE_REST;
tmpn->note=NOTE_REST;
}
break;
case PSMR_SHARP:
if (tempo->type==PSMT_NOTE && tempo->octave!=OCTAVE_REST) {
if (Btr(&tempo->flags,PSMf_FLAT))
tempo->note++;
if (Btc(&tempo->flags,PSMf_SHARP))
tempo->note--;
if (tmpn->type==PSMT_NOTE && tmpn->octave!=OCTAVE_REST) {
if (Btr(&tmpn->flags,PSMf_FLAT))
tmpn->note++;
if (Btc(&tmpn->flags,PSMf_SHARP))
tmpn->note--;
else
tempo->note++;
if (tempo->note<0) {
tempo->note=11;
tempo->octave--;
} else if (tempo->note>11) {
tempo->note=0;
tempo->octave++;
tmpn->note++;
if (tmpn->note<0) {
tmpn->note=11;
tmpn->octave--;
} else if (tmpn->note>11) {
tmpn->note=0;
tmpn->octave++;
}
}
break;
case PSMR_FLAT:
if (tempo->type==PSMT_NOTE && tempo->octave!=OCTAVE_REST) {
if (Btr(&tempo->flags,PSMf_SHARP))
tempo->note--;
if (Btc(&tempo->flags,PSMf_FLAT))
tempo->note++;
if (tmpn->type==PSMT_NOTE && tmpn->octave!=OCTAVE_REST) {
if (Btr(&tmpn->flags,PSMf_SHARP))
tmpn->note--;
if (Btc(&tmpn->flags,PSMf_FLAT))
tmpn->note++;
else
tempo->note--;
if (tempo->note<0) {
tempo->note=11;
tempo->octave--;
} else if (tempo->note>11) {
tempo->note=0;
tempo->octave++;
tmpn->note--;
if (tmpn->note<0) {
tmpn->note=11;
tmpn->octave--;
} else if (tmpn->note>11) {
tmpn->note=0;
tmpn->octave++;
}
}
break;
case PSMR_TIE:
if (tempo->type==PSMT_NOTE)
Btc(&tempo->flags,PSMf_TIE);
if (tmpn->type==PSMT_NOTE)
Btc(&tmpn->flags,PSMf_TIE);
break;
case PSMR_SET_WORD:
if (tempo->type==PSMT_NOTE) {
if (tmpn->type==PSMT_NOTE) {
if (DocPut) DocPut->flags&=~DOCF_FORM;
if (PsmHasWords(tempo->word))
st2=MStrPrint("\nWord(\"%Q\"):",tempo->word);
if (PsmHasWords(tmpn->word))
st2=MStrPrint("\nWord(\"%Q\"):",tmpn->word);
else
st2=MStrPrint("\nWord(\"\"):");
DocBottom;
st=GetStr(st2);
Free(st2);
Free(tempo->word);
Free(tmpn->word);
if (*st) {
tempo->word=MStrPrint("%q",st);
tmpn->word=MStrPrint("%q",st);
Free(st);
} else
tempo->word=StrNew(" ");
tmpn->word=StrNew(" ");
if (DocPut) DocPut->flags=DocPut->flags&
~DOCF_FORM|old_doc_flags&DOCF_FORM;
}
break;
case PSMR_INS_NOTE:
tempo1=PsmNoteCopy(tempo);
QueIns(tempo1,tempo);
tmpn1=PsmNoteCopy(tmpn);
QueIns(tmpn1,tmpn);
break;
case PSMR_DELETE_NOTE:
oc.cur_note=tempo->next;
QueRem(tempo);
PsmNoteDel(tempo);
psm.cur_note=tmpn->next;
QueRem(tmpn);
PsmNoteDel(tmpn);
break;
}
}
PsmSetWidth(oc.cur_note);
PsmSetWidth(psm.cur_note);
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
-WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU-WIF_SELF_CTRLS;
}
@@ -124,23 +124,23 @@ U0 PsmRightClick(I64 x,I64 y)
U0 PsmLeftClickPickNoteBox(I64 duration)
{
I64 o,n,msg_code,a1,a2;
PsmNote *tempo,*tempo1;
PsmNote *tmpn,*tmpn1;
do {
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP|1<<MSG_IP_MOVE);
if (msg_code==MSG_IP_MOVE) {
DrawDC2;
DrawNote(oc.dc2,a1,a2,duration);
DrawNote(psm.dc2,a1,a2,duration);
}
} while (msg_code!=MSG_IP_L_UP);
if (a2<13*FONT_HEIGHT) {
if (a1>oc.head.last->x)
tempo1=oc.head.last;
else if (a1<oc.head.next->x)
tempo1=&oc.head;
if (a1>psm.head.last->x)
tmpn1=psm.head.last;
else if (a1<psm.head.next->x)
tmpn1=&psm.head;
else
tempo1=PsmFindNote(a1-PSM_NOTE_SPACING/2,a2);
tempo=CAlloc(sizeof(PsmNote));
tempo->type=PSMT_NOTE;
tmpn1=PsmFindNote(a1-PSM_NOTE_SPACING/2,a2);
tmpn=CAlloc(sizeof(PsmNote));
tmpn->type=PSMT_NOTE;
a2=a2/4-15;
n=-a2%7;
o=2+a2/-7;
@@ -150,12 +150,12 @@ U0 PsmLeftClickPickNoteBox(I64 duration)
o++;
}
n=psm_note_inverse_map[n];
tempo->note=n;
tempo->octave=o;
tempo->duration=duration;
PsmSetWidth(tempo);
QueIns(tempo,tempo1);
oc.cur_note=tempo->next;
tmpn->note=n;
tmpn->octave=o;
tmpn->duration=duration;
PsmSetWidth(tmpn);
QueIns(tmpn,tmpn1);
psm.cur_note=tmpn->next;
}
DrawDC2;
}
@@ -163,53 +163,53 @@ U0 PsmLeftClickPickNoteBox(I64 duration)
U0 PsmLeftClickPickMeterBox(I64 top,I64 bottom)
{
I64 msg_code,a1,a2;
PsmNote *tempo,*tempo1;
PsmNote *tmpn,*tmpn1;
do {
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP|1<<MSG_IP_MOVE);
if (msg_code==MSG_IP_MOVE) {
DrawDC2;
DrawTimeSignature(oc.dc2,a1,a2,top,bottom);
DrawTimeSignature(psm.dc2,a1,a2,top,bottom);
}
} while (msg_code!=MSG_IP_L_UP);
if (a2<13*FONT_HEIGHT) {
if (a1>=oc.head.x)
tempo1=oc.head.last;
else if (a1<oc.head.next->x)
tempo1=&oc.head;
if (a1>=psm.head.x)
tmpn1=psm.head.last;
else if (a1<psm.head.next->x)
tmpn1=&psm.head;
else
tempo1=PsmFindNote(a1-PSM_NOTE_SPACING/2,a2);
tempo=CAlloc(sizeof(PsmNote));
tempo->type=PSMT_METER;
tempo->meter_top=top;
tempo->meter_bottom=bottom;
PsmSetWidth(tempo);
QueIns(tempo,tempo1);
oc.cur_note=tempo->next;
tmpn1=PsmFindNote(a1-PSM_NOTE_SPACING/2,a2);
tmpn=CAlloc(sizeof(PsmNote));
tmpn->type=PSMT_METER;
tmpn->meter_top=top;
tmpn->meter_bottom=bottom;
PsmSetWidth(tmpn);
QueIns(tmpn,tmpn1);
psm.cur_note=tmpn->next;
}
DrawDC2;
}
U0 PsmLeftClickStaffPtr(I64 x,I64 y)
{
PsmNote *tempo,*tempo1;
PsmNote *tmpn,*tmpn1;
I64 o,n,msg_code,a1,a2,n_original,o_original;
oc.cur_note=tempo=PsmFindNote(x,y);
if (tempo!=&oc.head) {
if (tempo->type==PSMT_NOTE) {
n_original=tempo->note;
o_original=tempo->octave;
psm.cur_note=tmpn=PsmFindNote(x,y);
if (tmpn!=&psm.head) {
if (tmpn->type==PSMT_NOTE) {
n_original=tmpn->note;
o_original=tmpn->octave;
do {
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP|1<<MSG_IP_MOVE);
if (msg_code==MSG_IP_L_UP) {
tempo1=PsmFindNote(a1,a2);
if (tempo1==&oc.head || tempo1==tempo)
tmpn1=PsmFindNote(a1,a2);
if (tmpn1==&psm.head || tmpn1==tmpn)
goto move_note;
else {
Free(tempo1->word);
tempo1->word=tempo->word;
tempo->word=NULL;
tempo->note=n_original;
tempo->octave=o_original;
Free(tmpn1->word);
tmpn1->word=tmpn->word;
tmpn->word=NULL;
tmpn->note=n_original;
tmpn->octave=o_original;
}
} else {
move_note:
@@ -222,11 +222,11 @@ move_note:
o++;
}
n=psm_note_inverse_map[n];
tempo->note=n;
tempo->octave=o;
tmpn->note=n;
tmpn->octave=o;
}
} while (msg_code!=MSG_IP_L_UP);
PsmSetWidth(tempo);
PsmSetWidth(tmpn);
}
}
}
@@ -237,8 +237,8 @@ U0 PsmLeftClickStaffBox(I64 x,I64 y)
do {
msg_code=GetMsg(&a1,&a2,1<<MSG_IP_L_UP|1<<MSG_IP_MOVE);
DrawDC2;
oc.dc2->color=ROPF_DITHER+WHITE<<16+BLACK;
GrBorder(oc.dc2,x,y,a1,a2);
psm.dc2->color=ROPF_DITHER+WHITE<<16+BLACK;
GrBorder(psm.dc2,x,y,a1,a2);
if (msg_code==MSG_IP_L_UP) {
if (x>a1) SwapI64(&x,&a1);
PsmMarkSel(x,a1,TRUE);
@@ -251,7 +251,7 @@ U0 PsmLeftClick(I64 x,I64 y)
{
I64 duration,top,bottom;
if (y<13*FONT_HEIGHT) {
if (oc.tool==PSMTT_PTR_TOOL)
if (psm.tool==PSMTT_PTR_TOOL)
PsmLeftClickStaffPtr(x,y);
else
PsmLeftClickStaffBox(x,y);
@@ -266,38 +266,6 @@ U0 PsmLeftClick(I64 x,I64 y)
}
}
U0 PsmPlayTask(I64)
{
I64 i=0;
F64 f=0,f2=0;
Fs->task_end_cb=&SndTaskEndCB;
while (TRUE) {
i++;
switch (psm_play_mode) {
case PSMPM_NORMAL:
if (psm_play_f!=f) {
f=psm_play_f;
Snd(f);
}
break;
case PSMPM_REVERB1:
if (psm_play_f!=f) {
if (f>0)
f2=f;
f=psm_play_f;
}
if (!(i&15)) {
if (i&16)
Snd(f);
else
Snd(f2);
}
break;
}
Sleep(1);
}
}
U8 PsmCvtDuration(F64 d)
{
F64 d1,d2;
@@ -403,8 +371,7 @@ U0 Psalmody(U8 *dirname="~/Psalmody")
note=NOTE_REST,octave=OCTAVE_REST,psm_octave=3,timeout_val,timeout_val2,
old_doc_flags;
U8 *filename=NULL,*st,*st2;
CTask *play_task=Spawn(&PsmPlayTask,NULL,"Psalmody Play",,Fs);
PsmNote *tempo;
PsmNote *tmpn;
F64 f=0,last_f=0,psm_duration=1.0,
d,evt_time=tS,note_down_time=tS;
CCtrl *c=TempoNew;
@@ -418,12 +385,12 @@ U0 Psalmody(U8 *dirname="~/Psalmody")
if (DocPut) DocPut->flags|=DOCF_FORM;
MemSet(&oc,0,sizeof(PsmCtrl));
oc.screen_x=0;
oc.head.next=oc.head.last=&oc.head;
oc.clipboard.next=oc.clipboard.last=&oc.clipboard;
oc.cur_note=&oc.head;
oc.dc2=DCAlias;
MemSet(&psm,0,sizeof(PsmCtrl));
psm.scrn_x=0;
psm.head.next=psm.head.last=&psm.head;
psm.clipboard.next=psm.clipboard.last=&psm.clipboard;
psm.cur_note=&psm.head;
psm.dc2=DCAlias;
MenuPush(
"File {"
@@ -454,7 +421,6 @@ U0 Psalmody(U8 *dirname="~/Psalmody")
" MarkIncomplete(MSG_CMD,PSMF_INCOMPLETE);"
"}"
"Snd {"
" Reverb(,'c');"
" Octave0(,'0');"
" Octave1(,'1');"
" Octave2(,'2');"
@@ -467,8 +433,8 @@ U0 Psalmody(U8 *dirname="~/Psalmody")
" Help(,,SC_F1);"
"}"
);
oc.incomplete_entry=MenuEntryFind(Fs->cur_menu,"Song/MarkIncomplete");
oc.record_entry=MenuEntryFind(Fs->cur_menu,"Song/Record");
psm.incomplete_entry=MenuEntryFind(Fs->cur_menu,"Song/MarkIncomplete");
psm.record_entry=MenuEntryFind(Fs->cur_menu,"Song/Record");
AutoComplete;
WinBorder;
@@ -522,7 +488,7 @@ mo_got_msg:
dirname=st2;
break;
case PSMF_INCOMPLETE:
oc.incomplete_entry->checked=!oc.incomplete_entry->checked;
psm.incomplete_entry->checked=!psm.incomplete_entry->checked;
break;
}
PsmPushMode(psm_octave);
@@ -569,31 +535,31 @@ mo_got_msg:
switch (a2.u8[0]) {
case SC_CURSOR_LEFT:
if (a2&SCF_CTRL) {
while (oc.cur_note->last!=&oc.head) {
oc.cur_note=oc.cur_note->last;
if (oc.cur_note!=&oc.head)
LBEqu(&oc.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
while (psm.cur_note->last!=&psm.head) {
psm.cur_note=psm.cur_note->last;
if (psm.cur_note!=&psm.head)
LBEqu(&psm.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
}
} else {
if (oc.cur_note->last!=&oc.head) {
oc.cur_note=oc.cur_note->last;
if (oc.cur_note!=&oc.head)
LBEqu(&oc.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
if (psm.cur_note->last!=&psm.head) {
psm.cur_note=psm.cur_note->last;
if (psm.cur_note!=&psm.head)
LBEqu(&psm.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
}
}
break;
case SC_CURSOR_RIGHT:
if (a2&SCF_CTRL) {
while (oc.cur_note!=&oc.head) {
if (oc.cur_note!=&oc.head)
LBEqu(&oc.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
oc.cur_note=oc.cur_note->next;
while (psm.cur_note!=&psm.head) {
if (psm.cur_note!=&psm.head)
LBEqu(&psm.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
psm.cur_note=psm.cur_note->next;
}
} else {
if (oc.cur_note!=&oc.head) {
if (oc.cur_note!=&oc.head)
LBEqu(&oc.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
oc.cur_note=oc.cur_note->next;
if (psm.cur_note!=&psm.head) {
if (psm.cur_note!=&psm.head)
LBEqu(&psm.cur_note->flags,PSMf_SEL,a2&SCF_SHIFT);
psm.cur_note=psm.cur_note->next;
}
}
break;
@@ -601,11 +567,11 @@ mo_got_msg:
if (a2&SCF_SHIFT)
PsmCutToClipboard;
else {
tempo=oc.cur_note;
oc.cur_note=tempo->next;
if (tempo!=&oc.head) {
QueRem(tempo);
PsmNoteDel(tempo);
tmpn=psm.cur_note;
psm.cur_note=tmpn->next;
if (tmpn!=&psm.head) {
QueRem(tmpn);
PsmNoteDel(tmpn);
}
}
break;
@@ -647,14 +613,14 @@ mo_got_msg:
filename=NULL;
JukeBox(dirname,&filename);
if (filename) {
oc.screen_x=0;
psm.scrn_x=0;
psm_duration=1.0;
psm_octave=3;
PsmSongDel(&oc.head);
oc.cur_note=&oc.head;
PsmSongDel(&psm.head);
psm.cur_note=&psm.head;
PsmLoadSong(filename,&psm_octave,&psm_duration);
oc.record_entry->checked=FALSE;
oc.cur_note=oc.head.next;
psm.record_entry->checked=FALSE;
psm.cur_note=psm.head.next;
}
PsmPushMode(psm_octave);
col=0;
@@ -680,23 +646,23 @@ mo_got_msg:
filename=NULL;
psm_duration=1.0;
psm_octave=3;
PsmSongDel(&oc.head);
oc.cur_note=&oc.head;
oc.screen_x=0;
PsmSongDel(&psm.head);
psm.cur_note=&psm.head;
psm.scrn_x=0;
break;
case '\n':
if (oc.cur_note!=&oc.head)
PsmRightClick(oc.cur_note->x,oc.cur_note->y);
if (psm.cur_note!=&psm.head)
PsmRightClick(psm.cur_note->x,psm.cur_note->y);
break;
case 'x':
if (was_playing)
break;
col=0;
oc.playing=TRUE;
psm.playing=TRUE;
PsmMenu(psm_octave);
tempo=oc.cur_note;
while (tempo!=&oc.head) {
if (tempo->type!=PSMT_METER) {
tmpn=psm.cur_note;
while (tmpn!=&psm.head) {
if (tmpn->type!=PSMT_METER) {
timeout_val=cnts.jiffies;
if (ip.pos_text.y-Fs->win_top<18)
msg_code=ScanMsg(&a1,&a2,1<<MSG_KEY_DOWN|
@@ -706,8 +672,8 @@ mo_got_msg:
1<<MSG_IP_L_DOWN|1<<MSG_CMD);
if (msg_code) {
f=0;
psm_play_f=0;
oc.playing=FALSE;
Snd(0);
psm.playing=FALSE;
was_playing=TRUE;
if (ip.pos_text.y-Fs->win_top>=18 &&
msg_code==MSG_IP_L_DOWN)
@@ -715,26 +681,26 @@ mo_got_msg:
else
goto mo_got_msg;
}
oc.cur_note=tempo;
oc.screen_x+=tempo->x-0.33*GR_WIDTH;
if (PsmHasWords(tempo->word))
"%s",tempo->word;
note=tempo->note;
octave=tempo->octave;
psm.cur_note=tmpn;
psm.scrn_x+=tmpn->x-0.33*GR_WIDTH;
if (PsmHasWords(tmpn->word))
"%s",tmpn->word;
note=tmpn->note;
octave=tmpn->octave;
if (note!=NOTE_REST)
f=Note2Freq(note,octave);
else
f=-1; //rest
if (f>0)
psm_play_f=f;
Snd(f);
else
psm_play_f=0;
Snd(0);
music.tempo=4.4*tempo_state.tempo/TEMPO_RANGE+0.5;
music.stacatto_factor=
0.88*tempo_state.stacatto/TEMPO_RANGE+0.12;
d=JIFFY_FREQ*psm_durations[tempo->duration]/music.tempo;
if (Bt(&tempo->flags,PSMf_TIE)) {
d=JIFFY_FREQ*psm_durations[tmpn->duration]/music.tempo;
if (Bt(&tmpn->flags,PSMf_TIE)) {
timeout_val+=d;
timeout_val2=timeout_val;
} else {
@@ -743,44 +709,38 @@ mo_got_msg:
d*(1.0-music.stacatto_factor);
}
SleepUntil(timeout_val);
psm_play_f=0;
Snd(0);
SleepUntil(timeout_val2);
}
tempo=tempo->next;
tmpn=tmpn->next;
}
oc.cur_note=&oc.head;
oc.screen_x+=oc.cur_note->x-GR_WIDTH/2;
oc.playing=FALSE;
psm.cur_note=&psm.head;
psm.scrn_x+=psm.cur_note->x-GR_WIDTH/2;
psm.playing=FALSE;
PsmMenu(psm_octave);
col=0;
f=0;
psm_play_f=0;
Snd(0);
break;
case CH_BACKSPACE:
tempo=oc.cur_note->last;
if (tempo!=&oc.head) {
QueRem(tempo);
PsmNoteDel(tempo);
tmpn=psm.cur_note->last;
if (tmpn!=&psm.head) {
QueRem(tmpn);
PsmNoteDel(tmpn);
}
if (col) {
'' CH_BACKSPACE;
col--;
}
break;
case 'c':
psm_play_mode++;
if (psm_play_mode>=PSMPM_NUM_PLAY_MODES) psm_play_mode=0;
PsmMenu(psm_octave);
col=0;
break;
case 'z':
if (oc.record_entry->checked)
oc.record_entry->checked=FALSE;
if (psm.record_entry->checked)
psm.record_entry->checked=FALSE;
else {
oc.record_entry->checked=TRUE;
psm.record_entry->checked=TRUE;
psm_duration=1.0;
psm_octave=3;
oc.screen_x=0;
psm.scrn_x=0;
}
PsmMenu(psm_octave);
col=0;
@@ -818,32 +778,32 @@ mo_got_msg:
if (f!=last_f) {
if (f>0) {
st=LstSub(note,psm_note_lst);
psm_play_f=f;
Snd(f);
} else {
if (f<0)
st="R";
else
st="";
psm_play_f=0;
Snd(0);
}
if (oc.record_entry->checked) {
if (psm.record_entry->checked) {
if (last_f) {
music.tempo=4.4*tempo_state.tempo/TEMPO_RANGE+0.5;
music.stacatto_factor=0.88*tempo_state.stacatto/TEMPO_RANGE+0.12;
tempo->duration=PsmCvtDuration(
tmpn->duration=PsmCvtDuration(
music.tempo*(evt_time-note_down_time));
PsmSetWidth(tempo);
QueIns(tempo,oc.cur_note->last);
PsmSetWidth(tmpn);
QueIns(tmpn,psm.cur_note->last);
}
if (f) {
note_down_time=tS;
tempo=CAlloc(sizeof(PsmNote));
tempo->type=PSMT_NOTE;
tempo->note=note;
tempo->octave=octave;
tmpn=CAlloc(sizeof(PsmNote));
tmpn->type=PSMT_NOTE;
tmpn->note=note;
tmpn->octave=octave;
if (st[1]=='#')
Bts(&tempo->flags,PSMf_SHARP);
Bts(&tmpn->flags,PSMf_SHARP);
}
}
last_f=f;
@@ -860,12 +820,11 @@ mo_done:
} catch
PutExcept;
PsmPopMode;
PsmSongDel(&oc.head);
PsmSongDel(&oc.clipboard);
PsmSongDel(&psm.head);
PsmSongDel(&psm.clipboard);
TempoDel(c);
Kill(play_task);
DCFill;
DCDel(oc.dc2);
DCDel(psm.dc2);
DocClear;
SettingsPop;
if (DocPut) DocPut->flags=DocPut->flags&~DOCF_FORM|old_doc_flags&DOCF_FORM;