Skip to content
Snippets Groups Projects
Commit 577f3695 authored by rswindell's avatar rswindell
Browse files

Several fixes. Now plays stock .ton files just fine. :-)

parent 05aad3aa
Branches
Tags
No related merge requests found
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
const REVISION = "$Revision$".split(' ')[1]; const REVISION = "$Revision$".split(' ')[1];
const NOT_ABORTABLE =(1<<0)
const SHOW_DOT =(1<<1)
const SHOW_FREQ =(1<<2)
const NO_VISUAL =(1<<3) const NO_VISUAL =(1<<3)
var mode=0; /* Optional modes */ var mode=0; /* Optional modes */
...@@ -30,19 +27,19 @@ function play(freq, dur) ...@@ -30,19 +27,19 @@ function play(freq, dur)
dur="0"; dur="0";
d=parseInt(dur); d=parseInt(dur);
if((f=parseInt(freq))!=0) if(isNaN(f=parseInt(freq.charAt(0))))
switch(freq.charAt(0).toUpperCase()) { switch(freq.charAt(0).toUpperCase()) {
case 'O': /* default octave */ case 'O': /* default octave */
if(parseInt(dur)) if(Number(dur.charAt(0)))
octave=d; octave=d;
else else
octave+=d; octave+=d;
return; return;
case 'P': /* pitch variation */ case 'P': /* pitch variation */
if(parseInt(dur)) if(Number(dur.charAt(0)))
pitch=atof(dur)/32.0; pitch=parseFloat(dur)/32.0;
else else
pitch+=atof(dur); pitch+=parseFloat(dur);
return; return;
case 'Q': /* quit */ case 'Q': /* quit */
exit(0); exit(0);
...@@ -50,7 +47,7 @@ function play(freq, dur) ...@@ -50,7 +47,7 @@ function play(freq, dur)
f=0; f=0;
break; break;
case 'S': /* stacato */ case 'S': /* stacato */
if(parseInt(dur)) if(Number(dur.charAt(0)))
s=d; s=d;
else else
s+=d; s+=d;
...@@ -63,7 +60,7 @@ function play(freq, dur) ...@@ -63,7 +60,7 @@ function play(freq, dur)
return; return;
truncsp(dur); truncsp(dur);
if(dur.charAt(dur.length-1)=='\\') if(dur.charAt(dur.length-1)=='\\')
write(dur); write(truncstr(dur,'\\'));
else else
writeln(dur); writeln(dur);
return; return;
...@@ -81,14 +78,6 @@ function play(freq, dur) ...@@ -81,14 +78,6 @@ function play(freq, dur)
break; break;
} }
if(f && mode&SHOW_FREQ) {
for(i=0;freq[i]>' ';i++)
;
freq[i]=0;
printf("%-4.4s",freq);
}
if(mode&SHOW_DOT)
printf(".");
if(t>10) if(t>10)
len=(d*t)-(d*s); len=(d*t)-(d*s);
else else
...@@ -108,10 +97,10 @@ function play(freq, dur) ...@@ -108,10 +97,10 @@ function play(freq, dur)
} }
printf("\nTone Generation Module %s Copyright 2003 Rob Swindell\n\n", REVISION); printf("\nSynchronet Tone Generation Module %s\n\n", REVISION);
if(argc<1) { if(argc<1) {
alert("!No filename specified"); alert("No filename specified");
exit(); exit();
} }
...@@ -120,7 +109,7 @@ if(!file.exists) ...@@ -120,7 +109,7 @@ if(!file.exists)
file.name=system.exec_dir + file.name; file.name=system.exec_dir + file.name;
writeln("Opening " + file.name); writeln("Opening " + file.name);
if(!file.open("r")) { if(!file.open("r")) {
alert("!Error " + file.error + " opening " + file.name); alert("Error " + file.error + " opening " + file.name);
exit(); exit();
} }
...@@ -131,9 +120,9 @@ for(i in text) { ...@@ -131,9 +120,9 @@ for(i in text) {
if(js.terminated) if(js.terminated)
break; break;
// writeln(text[i]); // writeln(text[i]);
token=text[i].split(/\s+/); if(text[i].charAt(0)==':') /* comment */
cmd=token[0]; continue;
token.shift(); token=truncsp(text[i]).split(/\s+/);
play(cmd, token.join(' ')); play(token.shift(), token.join(' '));
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment