TempleOSCDV5.00.ISO
This commit is contained in:
1 parent
122df6338e
commit
f6eacf7744
374 files changed
+11078
-11204
No files matched your search
+1
-1
@@ -10,7 +10,7 @@ class CSndWaveCtrl
|
||||
|
||||
public U0 SndTaskEndCB()
|
||||
{//Will turn-off snd when a task gets killed.
|
||||
Snd(0);
|
||||
Snd;
|
||||
Exit;
|
||||
}
|
||||
|
||||
|
||||
+32
-28
@@ -5,8 +5,9 @@
|
||||
|
||||
class CSoundEffectFrame
|
||||
{
|
||||
I32 type;
|
||||
F64 duration,freq1,freq2;
|
||||
I32 type;
|
||||
I8 ona1,ona2;
|
||||
F64 duration;
|
||||
};
|
||||
|
||||
U0 SoundEffectEndTaskCB()
|
||||
@@ -18,57 +19,60 @@ U0 SoundEffectEndTaskCB()
|
||||
|
||||
U0 SoundEffectTask(CSoundEffectFrame *ns)
|
||||
{
|
||||
I64 i;
|
||||
F64 f,t0=tS,t,timeout=t0+ns->duration;
|
||||
I64 i,ona;
|
||||
F64 t0=tS,t,timeout=t0+ns->duration;
|
||||
FramePtrAdd("CSoundEffectFrame",ns);
|
||||
Fs->task_end_cb=&SoundEffectEndTaskCB;
|
||||
switch (ns->type) {
|
||||
case SE_NOISE:
|
||||
i=MaxI64(ns->freq2-ns->freq1,1);
|
||||
while (tS<timeout)
|
||||
if (f=RandU16%i+ns->freq1) {
|
||||
Snd(f);
|
||||
Sleep(ClampI64(3000/f,1,50));
|
||||
} else
|
||||
break;
|
||||
i=MaxI64(ns->ona2-ns->ona1,1);
|
||||
while (tS<timeout) {
|
||||
ona=RandU16%i+ns->ona1;
|
||||
Snd(ona);
|
||||
t=Clamp(3000.0/Ona2Freq(ona),1.0,50.0);
|
||||
if (t+tS>timeout)
|
||||
t=timeout-tS;
|
||||
Sleep(t);
|
||||
}
|
||||
break;
|
||||
case SE_SWEEP:
|
||||
while (tS<timeout) {
|
||||
t=(tS-t0)/ns->duration;
|
||||
if (f=(1.0-t)*ns->freq1+t*ns->freq2) {
|
||||
Snd(f);
|
||||
Sleep(ClampI64(3000/f,1,50));
|
||||
} else
|
||||
break;
|
||||
ona=(1.0-t)*ns->ona1+t*ns->ona2;
|
||||
Snd(ona);
|
||||
t=Clamp(3000.0/Ona2Freq(ona),1.0,50.0);
|
||||
if (t+tS>timeout)
|
||||
t=timeout-tS;
|
||||
Sleep(t);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public CTask *Noise(I64 ms,F64 min_freq,F64 max_freq)
|
||||
{//Make white noise for given number of ms.
|
||||
public CTask *Noise(I64 mS,F64 min_ona,F64 max_ona)
|
||||
{//Make white noise for given number of mS.
|
||||
CSoundEffectFrame *ns;
|
||||
if (ms>0) {
|
||||
if (mS>0) {
|
||||
ns=MAlloc(sizeof(CSoundEffectFrame));
|
||||
ns->type=SE_NOISE;
|
||||
ns->duration=ms/1000.0;
|
||||
ns->freq1=min_freq;
|
||||
ns->freq2=max_freq;
|
||||
ns->duration=mS/1000.0;
|
||||
ns->ona1=min_ona;
|
||||
ns->ona2=max_ona;
|
||||
music.mute++;
|
||||
return Spawn(&SoundEffectTask,ns,"Noise",,Fs);
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public CTask *Sweep(I64 ms,F64 freq1,F64 freq2)
|
||||
{//Sweep through freq range in given number of ms.
|
||||
public CTask *Sweep(I64 mS,F64 ona1,F64 ona2)
|
||||
{//Sweep through freq range in given number of mS.
|
||||
CSoundEffectFrame *ns;
|
||||
if (ms>0) {
|
||||
if (mS>0) {
|
||||
ns=MAlloc(sizeof(CSoundEffectFrame));
|
||||
ns->type=SE_SWEEP;
|
||||
ns->duration=ms/1000.0;
|
||||
ns->freq1=freq1;
|
||||
ns->freq2=freq2;
|
||||
ns->duration=mS/1000.0;
|
||||
ns->ona1=ona1;
|
||||
ns->ona2=ona2;
|
||||
music.mute++;
|
||||
return Spawn(&SoundEffectTask,ns,"Noise",,Fs);
|
||||
} else
|
||||
|
||||
+2
-1
@@ -67,7 +67,8 @@ public I64 SndFileCreate(U8 *base_filename,F64 normalized_vol=1.0,
|
||||
d1=d->next;
|
||||
dt=d1->time-d->time;
|
||||
cnt2=dt*SNDFILE_SAMPLE_RATE;
|
||||
SndWaveAddBuf(swc,&s->body[k],cnt2,d->freq,waveform,normalized_vol);
|
||||
SndWaveAddBuf(swc,&s->body[k],cnt2,
|
||||
Ona2Freq(d->ona),waveform,normalized_vol);
|
||||
k+=cnt2;
|
||||
QueRem(d);
|
||||
Free(d);
|
||||
|
||||
+21
-3
@@ -77,9 +77,27 @@ public F64 FullTri(F64 t,F64 period)
|
||||
}
|
||||
|
||||
#help_index "Snd/Math"
|
||||
public F64 Note2Freq(I64 note,I64 octave=3)
|
||||
{//Note number in octave to freq.
|
||||
return 440.0*2.0`(octave-3+note/12.0);
|
||||
|
||||
public I8 Note2Ona(I64 note,I64 octave=4)
|
||||
{//Note to ona. Mid C is ona=51, note=3 and octave=4.
|
||||
if (note<3)
|
||||
return (octave+1)*12+note;
|
||||
else
|
||||
return octave*12+note;
|
||||
}
|
||||
|
||||
public I8 Ona2Note(I8 ona)
|
||||
{//Ona to note in octave. Mid C is ona=51, note=3 and octave=4.
|
||||
return ona%12;
|
||||
}
|
||||
|
||||
public I8 Ona2Octave(I8 ona)
|
||||
{//Ona to octave. Mid C is ona=51, note=3 and octave=4.
|
||||
I64 note=ona%12,octave=ona/12;
|
||||
if (note<3)
|
||||
return octave-1;
|
||||
else
|
||||
return octave;
|
||||
}
|
||||
|
||||
F64 SinPhaseCont(F64 last_y,F64 last_dydt,
|
||||
|
||||
+13
-13
@@ -16,7 +16,7 @@ public class CMusicGlbls
|
||||
I64 play_note_num;
|
||||
|
||||
F64 tM_correction,last_Beat,last_tM;
|
||||
} music={NULL,NULL,3,1.0,{0,2,3,5,7,8,10},FALSE,4,4,2.5,0.9,0,0,0,0};
|
||||
} music={NULL,NULL,4,1.0,{0,2,3,5,7,8,10},FALSE,4,4,2.5,0.9,0,0,0,0};
|
||||
|
||||
#help_index "Snd/Music;Time/Seconds"
|
||||
public F64 tM()
|
||||
@@ -30,7 +30,7 @@ public F64 Beat()
|
||||
PUSHFD
|
||||
CLI
|
||||
if (mp_cnt>1)
|
||||
while (LBts(&sys_semas[SYS_SEMA_TMBEAT],0))
|
||||
while (LBts(&sys_semas[SEMA_TMBEAT],0))
|
||||
PAUSE
|
||||
cur_tM=tM;
|
||||
res=music.last_Beat;
|
||||
@@ -38,7 +38,7 @@ public F64 Beat()
|
||||
res+=(cur_tM-music.last_tM)*music.tempo;
|
||||
music.last_tM=cur_tM;
|
||||
music.last_Beat=res;
|
||||
LBtr(&sys_semas[SYS_SEMA_TMBEAT],0);
|
||||
LBtr(&sys_semas[SEMA_TMBEAT],0);
|
||||
POPFD
|
||||
return res;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public U0 Play(U8 *st,U8 *words=NULL)
|
||||
{/* Notes are entered with a capital letter.
|
||||
|
||||
Octaves are entered with a digit and
|
||||
stay set until changed.
|
||||
stay set until changed. Mid C is octave 4.
|
||||
|
||||
Durations are entered with
|
||||
'w' whole note
|
||||
@@ -127,9 +127,9 @@ per second. It defaults to
|
||||
2.5 and gets faster when bigger.
|
||||
*/
|
||||
U8 *word,*last_st;
|
||||
I64 note,i=0,timeout_val,timeout_val2;
|
||||
I64 note,i=0,ona,timeout_val,timeout_val2;
|
||||
Bool tie;
|
||||
F64 f,d,on_jiffies,off_jiffies;
|
||||
F64 d,on_jiffies,off_jiffies;
|
||||
music.play_note_num=0;
|
||||
while (*st) {
|
||||
timeout_val=cnts.jiffies;
|
||||
@@ -158,9 +158,9 @@ per second. It defaults to
|
||||
note++;
|
||||
st++;
|
||||
}
|
||||
f=Note2Freq(note,music.octave);
|
||||
ona=Note2Ona(note,music.octave);
|
||||
} else
|
||||
f=0;
|
||||
ona=ONA_REST;
|
||||
if (words && (word=LstSub(i++,words)) && StrCmp(word," "))
|
||||
"%s",word;
|
||||
d=JIFFY_FREQ*music.note_len/music.tempo;
|
||||
@@ -175,12 +175,12 @@ per second. It defaults to
|
||||
timeout_val2=timeout_val+off_jiffies;
|
||||
|
||||
if (!music.mute)
|
||||
Snd(f);
|
||||
Snd(ona);
|
||||
SleepUntil(timeout_val);
|
||||
music.tM_correction+=on_jiffies-ToI64(on_jiffies);
|
||||
|
||||
if (!music.mute)
|
||||
Snd(0);
|
||||
Snd;
|
||||
SleepUntil(timeout_val2);
|
||||
music.tM_correction+=off_jiffies-ToI64(off_jiffies);
|
||||
|
||||
@@ -193,7 +193,7 @@ U0 MusicSettingsRst()
|
||||
music.play_note_num=0;
|
||||
music.stacatto_factor=0.9;
|
||||
music.tempo=2.5;
|
||||
music.octave=3;
|
||||
music.octave=4;
|
||||
music.note_len=1.0;
|
||||
music.meter_top=4;
|
||||
music.meter_bottom=4;
|
||||
@@ -201,11 +201,11 @@ U0 MusicSettingsRst()
|
||||
PUSHFD
|
||||
CLI
|
||||
if (mp_cnt>1)
|
||||
while (LBts(&sys_semas[SYS_SEMA_TMBEAT],0))
|
||||
while (LBts(&sys_semas[SEMA_TMBEAT],0))
|
||||
PAUSE
|
||||
music.last_tM=tM;
|
||||
music.last_Beat=0.0;
|
||||
LBtr(&sys_semas[SYS_SEMA_TMBEAT],0);
|
||||
LBtr(&sys_semas[SEMA_TMBEAT],0);
|
||||
POPFD
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user