Update 1.811- Criticul bug fix (Sound engine stop. maybe, finished)
- Recommended usage add to PDF manual
- Change Logo image
- Remove LockMutex from multi thread programming
- Build by PureBasic 5.00
have fun.
If you use multi thread, You should get cores on main thread.
coz sometimes rarely crush thread....
Code:
Procedure.b CheckCores()
Protected ProcessMask.l, SystemMask.l, Count.b, i.b
If GetProcessAffinityMask_(GetCurrentProcess_(), @ProcessMask, @SystemMask)
For i=0 To 31
If ProcessMask & (1<<i)
Count+1
EndIf
Next
EndIf
If Count=0: Count=1: EndIf
ProcedureReturn Count
EndProcedure
Main thread ... call OK
Sub thread ... call rarely crush
BASS ASIO and BASS WASAPI, code snippets.
Code:
Procedure.l AsioProc(input.b, channel.l, *buffer, length.l, *user)
;http://www.un4seen.com/forum/?topic=11261.0
Shared chan4.l, UST.b
Protected infopos.q, infolen.q
Protected *b=*buffer
Protected C.l = 0
Select chan4
Case #chan3
If (out_2s-out_2p)>length ; must > , next songs? crush
CopyMemory(*out_2+out_2p, *b, length)
out_2p + length : C = length
ElseIf out_2s>out_2p
CopyMemory(*out_2+out_2p, *b, out_2s-out_2p)
C = out_2s - out_2p : out_2s=out_2p
If out_1p=0
CopyMemory(*out_1, *b+C, length-C)
out_1p = length - C : C = length
chan4 = #chan2
EndIf
EndIf
Case #chan2
If (out_1s-out_1p)>length
CopyMemory(*out_1+out_1p, *b, length)
out_1p + length : C = length
ElseIf out_1s>out_1p
CopyMemory(*out_1+out_1p, *b, out_1s-out_1p)
C = out_1s - out_1p : out_1s=out_1p
If out_2p=0
CopyMemory(*out_2, *b+C, length-C)
out_2p = length - C : C = length
chan4=#chan3
EndIf
EndIf
EndSelect
If ListSize(Info())>0
FirstElement(Info())
Info()\pos + Int(length/UST)
infopos = Info()\pos
infolen = Info()\length
If infopos>=infolen
DeleteElement(Info())
If ListSize(Info())>0
FirstElement(Info())
Info()\pos = infopos - infolen
EndIf
EndIf
EndIf
ProcedureReturn C
EndProcedure
Procedure.l WasapiProc( *buffer, length.l, *user)
Shared chan4.l, UST.b
Protected infopos.q, infolen.q
Protected *b=*buffer
Protected C.l = 0
Select chan4
Case #chan3
If (out_2s-out_2p)>length
CopyMemory(*out_2+out_2p, *b, length)
out_2p + length : C = length
ElseIf out_2s>out_2p
CopyMemory(*out_2+out_2p, *b, out_2s-out_2p)
C = out_2s - out_2p : out_2s=out_2p
If out_1p=0
CopyMemory(*out_1, *b+C, length-C)
out_1p = length - C : C = length
chan4 = #chan2
EndIf
EndIf
Case #chan2
If (out_1s-out_1p)>length
CopyMemory(*out_1+out_1p, *b, length)
out_1p + length : C = length
ElseIf out_1s>out_1p
CopyMemory(*out_1+out_1p, *b, out_1s-out_1p)
C = out_1s - out_1p : out_1s=out_1p
If out_2p=0
CopyMemory(*out_2, *b+C, length-C)
out_2p = length - C : C = length
chan4=#chan3
EndIf
EndIf
EndSelect
If ListSize(Info())>0
FirstElement(Info())
Info()\pos + Int(length/UST)
infopos = Info()\pos
infolen = Info()\length
If infopos>=infolen
DeleteElement(Info())
If ListSize(Info())>0
FirstElement(Info())
Info()\pos = infopos - infolen
EndIf
EndIf
EndIf
ProcedureReturn C
EndProcedure
BASS Decode process, Code snippets
Code:
pos.q = BASS_ChannelGetLength(chan,#BASS_POS_BYTE)
pos2.q = BASS_ChannelGetPosition(chan,#BASS_POS_BYTE)
If (pos-pos2)<=#BUF1
pdiv = pos-pos2
K = Bass_ChannelGetData(chan, *out2, pdiv)
If K>0
pdiv = K
ElseIf BASS_ErrorGetCode()<>#BASS_ERROR_ENDED
Endpos=2
Break
EndIf
Repeat
NextPlaysongs()
If chan<>0
pos=BASS_ChannelGetLength(chan,#BASS_POS_BYTE)
K = Bass_ChannelGetData(chan, *out2+pdiv, #BUF1-pdiv)
If K>0
pdiv + K
Else
Endpos=2
Break
EndIf
Else
Endpos=2
Break
EndIf
Until pdiv=>#BUF1
Else
pdiv = #BUF1
K = Bass_ChannelGetData(chan, *out2, pdiv)
If K>0
pdiv = K
Else
Endpos=2
Break
EndIf
EndIf
Select ch
Case 1
CopyMemory(*out2, *out_2, pdiv)
NowChan = #chan2 : out_2s = pdiv : out_2p = 0
ready=pdiv :; chan4 = #chan2
Case 2
CopyMemory(*out2, *out_1, pdiv)
NowChan = #chan3 : out_1s = pdiv : out_1p = 0
ready=pdiv:; chan4 = #chan3
EndSelect