TempleOSCDV5.00.ISO
This commit is contained in:
1 parent
122df6338e
commit
f6eacf7744
374 files changed
+11078
-11204
No files matched your search
+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
|
||||
|
||||
Reference in new issue
Block a user