It is currently Fri Dec 06, 2019 12:29 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: BASS.DLL Sound Player for Full Digital Amplifier for Hi-End
PostPosted: Fri Feb 22, 2019 10:23 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2004 11:40 pm
Posts: 760
Location: Okazaki, JAPAN
BASS.DLL Sound Player for Full Digital Amplifier for Hi-End

This sound player's code is for Full Digital Amplifier for Hi-End.
Japan Product: USB-DAC Denon DA-310USB
DDFA Full Digital Headphone Amplifier, Best seller in Japan.
Recommend Headphone: Sennheiser HD 800 S

This code optimizing is Bug head 10.93 (PINK HQ 1.81) based.
This way is full memory sound player. need Ram space 600MB over.
Tested: Windows 10 Home x64, Intel Core i5-8400, RAM 16GB

Output format : WASAPI EXCLUSIVE default output
Commented tips : ASIO output, DSD-RAW output


Bug head Nontallion - oryaaaaa official homepage
Free software for a specified period ( Shareware software )
Copyright (c) 2009-2019, Hiroyuki Yokota ( oryaaaaa )
http://www.mics.ne.jp/~coolverse/

Prohibition clause
Skipping buffer initialization will absolutely damage the audio equipment.
If you removed the very long FNOP code, it will not be the OS like operation code.

Purpose of this post
This is a source code for verification for audio equipment manufacturers to confirm
that the full digital amplifier is caused by WHO smartphone hearing loss.
I will retain only this copyright, but I will not dispute it no matter what
purpose it is used. The volume increases, because it was digital output
with very low noise sound output.

Set Volume Level by EVE audio SC204
+12dB ... General sound player with noise.
+2dB ... This sound player with very low noise.
+0.5dB ... Bug head 10.93 (PINK HQ 1.81) with super low noise.

  • Required: PureBasic single license, BASS win32 shareware license
  • Required: PureBasic 5.70 LTS x64 Windows
  • Required: bass.dll bass.lib x64 2.4.13.8
  • Required: basswasapi.dll basswasapi.lib x64 2.4.2.0
  • Required: bassflac.dll bassflac.lib x64 2.4.4.0
    and
  • Required: run "PureBasicForumTips_Stabilizer_MMX.pb"
    Output "WASAPI_Stabilizer_2_MMX.txt"
    Output "WASAPI_Stabilizer_2_MMX.pbi"
    Output "WASAPI_Stabilizer_3_MMX.txt"
    Output "WASAPI_Stabilizer_3_MMX.pbi"
  • Required: run "PureBasicForumTips_OnlyMyRailgunProcess.pb"
    Output "WASAPI_OnlyMyRailgunProcess_Before.txt"
    Output "WASAPI_OnlyMyRailgunProcess_Before.pbi"
    Output "WASAPI_OnlyMyRailgunProcess_After.pbi"

Test run "PureBasicForumTips_WASAPI_player.pb" with compile option CPU with MMX

Create complete executable
  • run "PureBasicForumTips_BuildExecutable.pb"
    PureBasic.asm "6,370,444 lines" "Binary size 9.1 MB"

Download source code from oryaaaaa homepage
http://www.mics.ne.jp/~coolverse/WASAPI_player/
Size 25,210 ( 25KB )
MD5 87524FF8B629D5FE7AD09179890D109B

run "WASAPI_player.exe"
select MP3 or FLAC file
play ... end

"PureBasicForumTips_Stabilizer_MMX.pb"
Code:
; Generate Stabilizer MMX
; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)
Global NewList SourceList.s()

Macro Out
  AddElement(SourceList()) : SourceList() =
EndMacro

Macro FNOPx32
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
  Out "FNOP"
EndMacro

Macro INIT_MMX
  For I = 0 To 7
    Out "PXOR mm"+Str(I)+", mm"+Str(I)
    Out "PXOR mm"+Str(I)+", mm"+Str(I)
    Out "PAND mm"+Str(I)+", mm"+Str(I)
    Out "PAND mm"+Str(I)+", mm"+Str(I)
    Out "PXOR mm"+Str(I)+", mm"+Str(I)
    Out "PXOR mm"+Str(I)+", mm"+Str(I)
    Out "PAND mm"+Str(I)+", mm"+Str(I)
    Out "PAND mm"+Str(I)+", mm"+Str(I)
  Next
  For I = 0 To 7
    If Not I=5
      Out "MOVQ mm"+Str(I)+", mm5"
    EndIf
  Next
EndMacro

Macro Isolate_MMX
  ; MOVQ mm3, Rax
  Out "MOVQ mm1, mm3"
  Out "MOVQ mm7, mm1"
  Out "MOVQ mm2, mm7"
  Out "MOVQ mm6, mm2"
  Out "MOVQ mm4, mm6"
  Out "MOVQ mm5, mm4"
  ; MOVQ Rax, mm5
EndMacro

INIT_MMX
Out "MOVQ mm3, Rdi"
Out "XOR Rdi, Rdi"
Out "XOR Rdi, Rdi"
Out "AND Rdi, Rdi"
Out "AND Rdi, Rdi"
Out "MOVQ Rdi, mm5"
Isolate_MMX
Out "MOVQ Rdi, mm5"
 
INIT_MMX
Out "MOVQ mm3, Rbp"
Out "XOR Rbp, Rbp"
Out "XOR Rbp, Rbp"
Out "AND Rbp, Rbp"
Out "AND Rbp, Rbp"
Out "MOVQ Rbp, mm5"
Isolate_MMX
Out "MOVQ Rbp, mm5"
 
INIT_MMX
Out "MOVQ mm3, Rbx"
Out "XOR Rbx, Rbx"
Out "XOR Rbx, Rbx"
Out "AND Rbx, Rbx"
Out "AND Rbx, Rbx"
Out "MOVQ Rbx, mm5"
Isolate_MMX
Out "MOVQ Rbx, mm5"
 
INIT_MMX
Out "MOVQ mm3, Rcx"
Out "XOR Rcx, Rcx"
Out "XOR Rcx, Rcx"
Out "AND Rcx, Rcx"
Out "AND Rcx, Rcx"
Out "MOVQ Rcx, mm5"
Isolate_MMX
Out "MOVQ Rcx, mm5"
 
INIT_MMX
Out "MOVQ mm3, R8"
Out "XOR R8, R8"
Out "XOR R8, R8"
Out "AND R8, R8"
Out "AND R8, R8"
Out "MOVQ R8, mm5"
Isolate_MMX
Out "MOVQ R8, mm5"
 
INIT_MMX
Out "MOVQ mm3, R10"
Out "XOR R10, R10"
Out "XOR R10, R10"
Out "AND R10, R10"
Out "AND R10, R10"
Out "MOVQ R10, mm5"
Isolate_MMX
Out "MOVQ R10, mm5"

INIT_MMX
Out "MOVQ mm3, R12"
Out "XOR R12, R12"
Out "XOR R12, R12"
Out "AND R12, R12"
Out "AND R12, R12"
Out "MOVQ R12, mm5"
Isolate_MMX
Out "MOVQ R12, mm5"
 
INIT_MMX
Out "MOVQ mm3, R14"
Out "XOR R14, R14"
Out "XOR R14, R14"
Out "AND R14, R14"
Out "AND R14, R14"
Out "MOVQ R14, mm5"
Isolate_MMX
Out "MOVQ R14, mm5"
 
INIT_MMX
Out "MOVQ mm3, Rsi"
Out "XOR Rsi, Rsi"
Out "XOR Rsi, Rsi"
Out "AND Rsi, Rsi"
Out "AND Rsi, Rsi"
Out "MOVQ Rsi, mm5"
Isolate_MMX
Out "MOVQ Rsi, mm5"

INIT_MMX
Out "MOVQ mm3, Rsp"
Out "XOR Rsp, Rsp"
Out "XOR Rsp, Rsp"
Out "AND Rsp, Rsp"
Out "AND Rsp, Rsp"
Out "MOVQ Rsp, mm5"
Isolate_MMX
Out "MOVQ Rsp, mm5"

INIT_MMX
Out "MOVQ mm3, Rax"
Out "XOR Rax, Rax"
Out "XOR Rax, Rax"
Out "AND Rax, Rax"
Out "AND Rax, Rax"
Out "MOVQ Rax, mm5"
Isolate_MMX
Out "MOVQ Rax, mm5"

INIT_MMX
Out "MOVQ mm3, Rdx"
Out "XOR Rdx, Rdx"
Out "XOR Rdx, Rdx"
Out "AND Rdx, Rdx"
Out "AND Rdx, Rdx"
Out "MOVQ Rdx, mm5"
Isolate_MMX
Out "MOVQ Rdx, mm5"

INIT_MMX
Out "MOVQ mm3, R9"
Out "XOR R9, R9"
Out "XOR R9, R9"
Out "AND R9, R9"
Out "AND R9, R9"
Out "MOVQ R9, mm5"
Isolate_MMX
Out "MOVQ R9, mm5"

INIT_MMX
Out "MOVQ mm3, R11"
Out "XOR R11, R11"
Out "XOR R11, R11"
Out "AND R11, R11"
Out "AND R11, R11"
Out "MOVQ R11, mm5"
Isolate_MMX
Out "MOVQ R11, mm5"

INIT_MMX
Out "MOVQ mm3, R13"
Out "XOR R13, R13"
Out "XOR R13, R13"
Out "AND R13, R13"
Out "AND R13, R13"
Out "MOVQ R13, mm5"
Isolate_MMX
Out "MOVQ R13, mm5"

INIT_MMX
Out "MOVQ mm3, R15"
Out "XOR R15, R15"
Out "XOR R15, R15"
Out "AND R15, R15"
Out "AND R15, R15"
Out "MOVQ R15, mm5"
Isolate_MMX
Out "MOVQ R15, mm5"

INIT_MMX
Out "MOVQ mm1, mm3"
Out "MOVQ mm7, mm1"
Out "MOVQ mm2, mm7"
Out "MOVQ mm6, mm2"
Out "MOVQ mm4, mm6"
Out "MOVQ mm5, mm4"
For I=0 To 15
  Out "MOVQ2DQ xmm"+Str(I)+", mm3"
  Out "PUNPCKLQDQ xmm"+Str(I)+", xmm"+Str(I)
Next
For I=0 To 15
  Out "MOVQ2DQ xmm"+Str(I)+", mm1"
  Out "PUNPCKLQDQ xmm"+Str(I)+", xmm"+Str(I)
Next
For I=0 To 15
  Out "MOVQ2DQ xmm"+Str(I)+", mm7"
  Out "PUNPCKLQDQ xmm"+Str(I)+", xmm"+Str(I)
Next
For I=0 To 15
  Out "MOVQ2DQ xmm"+Str(I)+", mm2"
  Out "PUNPCKLQDQ xmm"+Str(I)+", xmm"+Str(I)
Next
For I=0 To 15
  Out "MOVQ2DQ xmm"+Str(I)+", mm6"
  Out "PUNPCKLQDQ xmm"+Str(I)+", xmm"+Str(I)
Next
For I=0 To 15
  Out "MOVQ2DQ xmm"+Str(I)+", mm4"
  Out "PUNPCKLQDQ xmm"+Str(I)+", xmm"+Str(I)
Next
For I=0 To 15
  Out "MOVQ2DQ xmm"+Str(I)+", mm5"
  Out "PUNPCKLQDQ xmm"+Str(I)+", xmm"+Str(I)
Next

Out "EMMS"

Global fileno.i

fileno = CreateFile(#PB_Any, "WASAPI_Stabilizer_2_MMX.pbi")
If fileno
  WriteStringFormat(fileno, #PB_UTF8)
  WriteStringN(fileno, "; WASAPI_Stabilizer_2_MMX.pbi", #PB_UTF8)
  WriteStringN(fileno, "; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)", #PB_UTF8)
  For I=1 To 32
    WriteStringN(fileno, "!FNOP", #PB_UTF8)
  Next
  ForEach SourceList()
    If Not Left(SourceList(), 1)=";"
      WriteStringN(fileno, "!"+SourceList(), #PB_UTF8)
    EndIf
  Next
  CloseFile(fileno)
EndIf

fileno = CreateFile(#PB_Any, "WASAPI_Stabilizer_2_MMX.txt")
If fileno
  WriteStringFormat(fileno, #PB_UTF8)
  WriteStringN(fileno, "; WASAPI_Stabilizer_2_MMX.txt", #PB_UTF8)
  WriteStringN(fileno, "; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)", #PB_UTF8)
  For I=1 To 32
    WriteStringN(fileno, "FNOP", #PB_UTF8)
  Next
  ForEach SourceList()
    If Not Left(SourceList(), 1)=";"
      WriteStringN(fileno, SourceList(), #PB_UTF8)
    EndIf
  Next
  CloseFile(fileno)
EndIf

ForEach SourceList()
  FNOPx32
Next

fileno = CreateFile(#PB_Any, "WASAPI_Stabilizer_3_MMX.pbi")
If fileno
  WriteStringFormat(fileno, #PB_UTF8)
  WriteStringN(fileno, "; WASAPI_Stabilizer_3_MMX.pbi", #PB_UTF8)
  WriteStringN(fileno, "; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)", #PB_UTF8)
  For I=1 To 512
    WriteStringN(fileno, "!FNOP", #PB_UTF8)
  Next
  ForEach SourceList()
    If Not Left(SourceList(), 1)=";"
      WriteStringN(fileno, "!"+SourceList(), #PB_UTF8)
    EndIf
  Next
  CloseFile(fileno)
EndIf

fileno = CreateFile(#PB_Any, "WASAPI_Stabilizer_3_MMX.txt")
If fileno
  WriteStringFormat(fileno, #PB_UTF8)
  WriteStringN(fileno, "; WASAPI_Stabilizer_3_MMX.txt", #PB_UTF8)
  WriteStringN(fileno, "; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)", #PB_UTF8)
  For I=1 To 512
    WriteStringN(fileno, "FNOP", #PB_UTF8)
  Next
  ForEach SourceList()
    If Not Left(SourceList(), 1)=";"
      WriteStringN(fileno, SourceList(), #PB_UTF8)
    EndIf
  Next
  CloseFile(fileno)
EndIf

End


"PureBasicForumTips_OnlyMyRailgunProcess.pb"
Code:
; Generator Only My Railgun Process
; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)

Global MacroLoop.i, CodeLoop.i
Global NewList OutputCode.s()

Macro Buffer
  AddElement(Buffers()) : Buffers() =
EndMacro

Macro Out
  AddElement(OutputCode()) : OutputCode() =
EndMacro
 
Macro FNOPx32
  For MacroLoop=1 To 32
    Buffer "FNOP"
  Next
EndMacro

Macro OutputFNOPx32
  For MacroLoop=1 To 32
    Out "FNOP"
  Next
EndMacro

Global NewList Buffers.s()
Buffer "; Global OnlyMyRailGun.i"
For CodeLoop=1 To 32
  Buffer "PXOR mm5, mm5"
  Buffer "PXOR mm5, mm5"
  Buffer "PAND mm5, mm5"
  Buffer "PAND mm5, mm5"
Next
Buffer "; !MOVNTQ [v_OnlyMyRailGun], mm5"
Buffer "; !MOVQ mm5, [v_OnlyMyRailGun]"
OutputFNOPx32
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "XOR Rax, Rax"
Buffer "XOR Rax, Rax"
Buffer "AND Rax, Rax"
Buffer "AND Rax, Rax"
Buffer "INC Rax"
Buffer "INC Rax"
Buffer "INC Rax"
Buffer "DEC Rax"
Buffer "DEC Rax"
Buffer "DEC Rax"
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "INC cl"
Buffer "MOVQ Rax, mm5"
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
For CodeLoop=1 To 8
  Buffer "INC al"
  Buffer "SHL al, cl"
  Buffer "INC ah"
  Buffer "SHL ah, cl"
  Buffer "XCHG ah, al"
  Buffer "XCHG al, ah"
Next
Buffer "INC al"
Buffer "INC ah"
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
Buffer "SHL Eax, cl" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Eax"
  Buffer "SHL Eax, cl"
Next
Buffer "INC Rax"
Buffer "SHL Rax, cl" ; FFFF FFFF
For CodeLoop=32 To 63
  Buffer "INC Rax"
  Buffer "SHL Rax, cl"
Next
Buffer "INC Rax" ; FFFF FFFF FFFF FFFF
Buffer "INC Rax" ; 0000
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
For CodeLoop=1 To 8
  Buffer "INC al"
  Buffer "SHL al, cl"
  Buffer "INC ah"
  Buffer "SHL ah, cl"
  Buffer "XCHG ah, al"
  Buffer "XCHG al, ah"
Next
Buffer "INC al"
Buffer "INC ah"
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
Buffer "SHL Eax, cl" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Eax"
  Buffer "SHL Eax, cl"
Next
Buffer "INC Rax"
Buffer "SHL Rax, cl" ; FFFF FFFF
For CodeLoop=32 To 63
  Buffer "INC Rax"
  Buffer "SHL Rax, cl"
Next
Buffer "INC Rax" ; FFFF FFFF FFFF FFFF
Buffer "XOR Rcx, Rcx"
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "a", "b")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "a", "d")
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "XOR R8, R8"
Buffer "XOR R8, R8"
Buffer "AND R8, R8"
Buffer "AND R8, R8"
Buffer "INC R8"
Buffer "INC R8"
Buffer "INC R8"
Buffer "DEC R8"
Buffer "DEC R8"
Buffer "DEC R8"
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "INC cl"
Buffer "MOVQ R8, mm5"
Buffer "XCHG R8b, R8b"
For CodeLoop=1 To 8
  Buffer "INC R8b"
  Buffer "SHL R8b, cl"
Next
Buffer "INC R8b"
Buffer "SHL R8w, cl" ; FF
For CodeLoop=1 To 8
  Buffer "INC R8w"
  Buffer "SHL R8w, cl"
Next
Buffer "INC R8w"
Buffer "SHL R8d, cl" ; FFFF
For CodeLoop=1 To 16
  Buffer "INC R8d"
  Buffer "SHL R8d, cl"
Next
Buffer "INC R8d"
Buffer "SHL R8, cl" ; FFFF FFFF
For CodeLoop=1 To 32
  Buffer "INC R8"
  Buffer "SHL R8, cl"
Next
Buffer "INC R8"  ; FFFF FFFF FFFF FFFF
Buffer "INC R8" ; 0000
Buffer "XCHG R8b, R8b"
For CodeLoop=1 To 8
  Buffer "INC R8b"
  Buffer "SHL R8b, cl"
Next
Buffer "INC R8b"
Buffer "SHL R8w, cl" ; FF
For CodeLoop=1 To 8
  Buffer "INC R8w"
  Buffer "SHL R8w, cl"
Next
Buffer "INC R8w"
Buffer "SHL R8d, cl" ; FFFF
For CodeLoop=1 To 16
  Buffer "INC R8d"
  Buffer "SHL R8d, cl"
Next
Buffer "INC R8d"
Buffer "SHL R8, cl" ; FFFF FFFF
For CodeLoop=1 To 32
  Buffer "INC R8"
  Buffer "SHL R8, cl"
Next
Buffer "INC R8"  ; FFFF FFFF FFFF FFFF
Buffer "XOR Rcx, Rcx"
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "9")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "10")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "11")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "12")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "13")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "14")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "15")
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "MOVQ Rcx, mm5"
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
For CodeLoop=1 To 8
  Buffer "INC cl"
  Buffer "SHL cl, 1"
  Buffer "INC ch"
  Buffer "SHL ch, 1"
  Buffer "XCHG ch, cl"
  Buffer "XCHG cl, ch"
Next
Buffer "INC cl"
Buffer "INC ch"
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
Buffer "SHL Ecx, 1" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Ecx"
  Buffer "SHL Ecx, 1"
Next
Buffer "INC Rcx"
Buffer "SHL Rcx, 1" ; FFFF FFFF
For loop=32 To 63
  Buffer "INC Rcx"
  Buffer "SHL Rcx, 1"
Next
Buffer "INC Rcx"  ; FFFF FFFF FFFF FFFF
Buffer "INC Rcx"  ; 0000
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
For CodeLoop=1 To 8
  Buffer "INC cl"
  Buffer "SHL cl, 1"
  Buffer "INC ch"
  Buffer "SHL ch, 1"
  Buffer "XCHG ch, cl"
  Buffer "XCHG cl, ch"
Next
Buffer "INC cl"
Buffer "INC ch"
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
Buffer "SHL Ecx, 1" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Ecx"
  Buffer "SHL Ecx, 1"
Next
Buffer "INC Rcx"
Buffer "SHL Rcx, 1" ; FFFF FFFF
For loop=32 To 63
  Buffer "INC Rcx"
  Buffer "SHL Rcx, 1"
Next
Buffer "INC Rcx"  ; FFFF FFFF FFFF FFFF
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "XOR Rbx, Rbx"
Buffer "XOR Rbx, Rbx"
Buffer "AND Rbx, Rbx"
Buffer "OR Rbx, Rbx"
Buffer "OR Rbx, Rbx"
Buffer "XOR Rbx, Rbx"
Buffer "XOR Rbx, Rbx"
Buffer "INC Rbx"
Buffer "INC Rbx"
Buffer "INC Rbx"
Buffer "DEC Rbx"
Buffer "DEC Rbx"
Buffer "DEC Rbx"
Buffer "XCHG spl, spl"
Buffer "MOVQ Rbx, mm5"
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "b", "c")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "8")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "10")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "12")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "14")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "b", "a")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "b", "d")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "9")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "11")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "13")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "bx", "15")
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "MOV R8, Rsp"
Buffer "XOR Rsp, Rsp"
Buffer "XOR Rsp, Rsp"
Buffer "AND Rsp, Rsp"
Buffer "AND Rsp, Rsp"
Buffer "INC Rsp"
Buffer "INC Rsp"
Buffer "INC Rsp"
Buffer "DEC Rsp"
Buffer "DEC Rsp"
Buffer "DEC Rsp"
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "INC cl"
Buffer "MOVQ Rsp, mm5"
Buffer "XCHG spl, spl"
For CodeLoop=1 To 8
  Buffer "INC spl"
  Buffer "SHL spl, cl"
Next
Buffer "INC spl"
Buffer "SHL sp, cl" ; FF
For CodeLoop=1 To 8
  Buffer "INC sp"
  Buffer "SHL sp, cl"
Next
Buffer "INC sp"
Buffer "SHL Esp, cl" ; FFFF
For CodeLoop=1 To 16
  Buffer "INC Esp"
  Buffer "SHL Esp, cl"
Next
Buffer "INC Esp"
Buffer "SHL Rsp, cl" ; FFFF FFFF
For CodeLoop=1 To 32
  Buffer "INC Rsp"
  Buffer "SHL Rsp, cl"
Next
Buffer "INC Rsp" ; FFFF FFFF FFFF FFFF
Buffer "INC Rsp" ; 0000
Buffer "XCHG spl, spl"
For CodeLoop=1 To 8
  Buffer "INC spl"
  Buffer "SHL spl, cl"
Next
Buffer "INC spl"
Buffer "SHL sp, cl" ; FF
For CodeLoop=1 To 8
  Buffer "INC sp"
  Buffer "SHL sp, cl"
Next
Buffer "INC sp"
Buffer "SHL Esp, cl" ; FFFF
For CodeLoop=1 To 16
  Buffer "INC Esp"
  Buffer "SHL Esp, cl"
Next
Buffer "INC Esp"
Buffer "SHL Rsp, cl" ; FFFF FFFF
For CodeLoop=1 To 32
  Buffer "INC Rsp"
  Buffer "SHL Rsp, cl"
Next
Buffer "INC Rsp" ; FFFF FFFF FFFF FFFF
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rsp, Rsp"
Buffer "XOR Rsp, Rsp"
Buffer "AND Rsp, Rsp"
Buffer "OR Rsp, Rsp"
Buffer "OR Rsp, Rsp"
Buffer "XOR Rsp, Rsp"
Buffer "XOR Rsp, Rsp"
Buffer "INC Rsp"
Buffer "INC Rsp"
Buffer "INC Rsp"
Buffer "DEC Rsp"
Buffer "DEC Rsp"
Buffer "DEC Rsp"
Buffer "XCHG bpl, bpl"
Buffer "MOVQ Rsp, mm5"
Buffer "MOV Rsp, R8"
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next

Global bufn.s
ForEach Buffers()
  bufn = Buffers()
  bufn = ReplaceString(bufn, "sp", "bp")
  bufn = ReplaceString(bufn, "Rbp, R8", "Rbp, R9")
  bufn = ReplaceString(bufn, "R8, Rbp", "R9, Rbp")
  bufn = ReplaceString(bufn, "XCHG bpl, bpl", "XCHG spl, spl")
  Out bufn
  OutputFNOPx32
Next
ForEach Buffers()
  bufn = Buffers()
  bufn = ReplaceString(bufn, "sp", "si")
  bufn = ReplaceString(bufn, "Rsi, R8", "Rsi, Rax")
  bufn = ReplaceString(bufn, "R8, Rsi", "Rax, Rsi")
  bufn = ReplaceString(bufn, "XCHG bpl, bpl", "XCHG spl, spl")
  Out bufn
  OutputFNOPx32
Next
ForEach Buffers()
  bufn = Buffers()
  bufn = ReplaceString(bufn, "sp", "di")
  bufn = ReplaceString(bufn, "Rdi, R8", "Rdi, Rbx")
  bufn = ReplaceString(bufn, "R8, Rdi", "Rbx, Rdi")
  bufn = ReplaceString(bufn, "XCHG bpl, bpl", "XCHG spl, spl")
  Out bufn
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "XOR Rax, Rax"
Buffer "XOR Rax, Rax"
Buffer "AND Rax, Rax"
Buffer "AND Rax, Rax"
Buffer "INC Rax"
Buffer "INC Rax"
Buffer "INC Rax"
Buffer "DEC Rax"
Buffer "DEC Rax"
Buffer "DEC Rax"
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "INC cl"
Buffer "MOVQ Rax, mm5"
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
For CodeLoop=1 To 8
  Buffer "INC al"
  Buffer "SHL al, cl"
  Buffer "INC ah"
  Buffer "SHL ah, cl"
  Buffer "XCHG ah, al"
  Buffer "XCHG al, ah"
Next
Buffer "INC al"
Buffer "INC ah"
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
Buffer "SHL Eax, cl" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Eax"
  Buffer "SHL Eax, cl"
Next
Buffer "INC Rax"
Buffer "SHL Rax, cl" ; FFFF FFFF
For loop=32 To 63
  Buffer "INC Rax"
  Buffer "SHL Rax, cl"
Next
Buffer "INC Rax" ; FFFF FFFF FFFF FFFF
Buffer "INC Rax" ; 0000
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
For CodeLoop=1 To 8
  Buffer "INC al"
  Buffer "SHL al, cl"
  Buffer "INC ah"
  Buffer "SHL ah, cl"
  Buffer "XCHG ah, al"
  Buffer "XCHG al, ah"
Next
Buffer "INC al"
Buffer "INC ah"
Buffer "XCHG ah, al"
Buffer "XCHG al, ah"
Buffer "SHL Eax, cl" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Eax"
  Buffer "SHL Eax, cl"
Next
Buffer "INC Rax"
Buffer "SHL Rax, cl" ; FFFF FFFF
For loop=32 To 63
  Buffer "INC Rax"
  Buffer "SHL Rax, cl"
Next
Buffer "INC Rax" ; FFFF FFFF FFFF FFFF
Buffer "XOR Rcx, Rcx"
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "a", "b")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "a", "d")
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "XOR R8, R8"
Buffer "XOR R8, R8"
Buffer "AND R8, R8"
Buffer "AND R8, R8"
Buffer "INC R8"
Buffer "INC R8"
Buffer "INC R8"
Buffer "DEC R8"
Buffer "DEC R8"
Buffer "DEC R8"
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "INC cl"
Buffer "MOVQ R8, mm5"
Buffer "XCHG R8b, R8b"
For CodeLoop=1 To 8
  Buffer "INC R8b"
  Buffer "SHL R8b, cl"
Next
Buffer "INC R8b"
Buffer "SHL R8w, cl" ; FF
For CodeLoop=1 To 8
  Buffer "INC R8w"
  Buffer "SHL R8w, cl"
Next
Buffer "INC R8w"
Buffer "SHL R8d, cl" ; FFFF
For CodeLoop=1 To 16
  Buffer "INC R8d"
  Buffer "SHL R8d, cl"
Next
Buffer "INC R8d"
Buffer "SHL R8, cl" ; FFFF FFFF
For CodeLoop=1 To 32
  Buffer "INC R8"
  Buffer "SHL R8, cl"
Next
Buffer "INC R8" ; FFFF FFFF FFFF FFFF
Buffer "INC R8" ; 0000
Buffer "XCHG R8b, R8b"
For CodeLoop=1 To 8
  Buffer "INC R8b"
  Buffer "SHL R8b, cl"
Next
Buffer "INC R8b"
Buffer "SHL R8w, cl" ; FF
For CodeLoop=1 To 8
  Buffer "INC R8w"
  Buffer "SHL R8w, cl"
Next
Buffer "INC R8w"
Buffer "SHL R8d, cl" ; FFFF
For CodeLoop=1 To 16
  Buffer "INC R8d"
  Buffer "SHL R8d, cl"
Next
Buffer "INC R8d"
Buffer "SHL R8, cl" ; FFFF FFFF
For CodeLoop=1 To 32
  Buffer "INC R8"
  Buffer "SHL R8, cl"
Next
Buffer "INC R8" ; FFFF FFFF FFFF FFFF
Buffer "XOR Rcx, Rcx"
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "9")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "10")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "11")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "12")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "13")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "14")
  OutputFNOPx32
Next
ForEach Buffers()
  Out ReplaceString(Buffers(), "8", "15")
  OutputFNOPx32
Next

ClearList(Buffers())
Buffer "XOR Rcx, Rcx"
Buffer "XOR Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "AND Rcx, Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "INC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "DEC Rcx"
Buffer "MOVQ Rcx, mm5"
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
For CodeLoop=1 To 8
  Buffer "INC cl"
  Buffer "SHL cl, 1"
  Buffer "INC ch"
  Buffer "SHL ch, 1"
  Buffer "XCHG ch, cl"
  Buffer "XCHG cl, ch"
Next
Buffer "INC cl"
Buffer "INC ch"
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
Buffer "SHL Ecx, 1" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Ecx"
  Buffer "SHL Ecx, 1"
Next
Buffer "INC Rcx"
Buffer "SHL Rcx, 1" ; FFFF FFFF
For loop=32 To 63
  Buffer "INC Rcx"
  Buffer "SHL Rcx, 1"
Next
Buffer "INC Rcx"  ; FFFF FFFF FFFF FFFF
Buffer "INC Rcx"  ; 0000
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
For CodeLoop=1 To 8
  Buffer "INC cl"
  Buffer "SHL cl, 1"
  Buffer "INC ch"
  Buffer "SHL ch, 1"
  Buffer "XCHG ch, cl"
  Buffer "XCHG cl, ch"
Next
Buffer "INC cl"
Buffer "INC ch"
Buffer "XCHG ch, cl"
Buffer "XCHG cl, ch"
Buffer "SHL Ecx, 1" ; FFFF
For CodeLoop=16 To 31
  Buffer "INC Ecx"
  Buffer "SHL Ecx, 1"
Next
Buffer "INC Rcx"
Buffer "SHL Rcx, 1" ; FFFF FFFF
For loop=32 To 63
  Buffer "INC Rcx"
  Buffer "SHL Rcx, 1"
Next
Buffer "INC Rcx"  ; FFFF FFFF FFFF FFFF
ForEach Buffers()
  Out Buffers()
  OutputFNOPx32
Next

ClearList(Buffers())
Out "EMMS"
OutputFNOPx32

Global fileno.i

fileno = CreateFile(#PB_Any, "WASAPI_OnlyMyRailgunProcess_Before.pbi")
If fileno
  WriteStringFormat(fileno, #PB_UTF8)
  WriteStringN(fileno, "; WASAPI_OnlyMyRailgunProcess_Before.pbi", #PB_UTF8)
  WriteStringN(fileno, "; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)", #PB_UTF8)
  For I=1 To 512
    WriteStringN(fileno, "!FNOP", #PB_UTF8)
  Next
  ForEach OutputCode()
    If Not Left(OutputCode(), 1)=";"
      WriteStringN(fileno, "!"+OutputCode(), #PB_UTF8)
    EndIf
  Next
  CloseFile(fileno)
EndIf

fileno = CreateFile(#PB_Any, "WASAPI_OnlyMyRailgunProcess_Before.txt")
If fileno
  WriteStringFormat(fileno, #PB_UTF8)
  WriteStringN(fileno, "; WASAPI_OnlyMyRailgunProcess_Before.txt", #PB_UTF8)
  WriteStringN(fileno, "; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)", #PB_UTF8)
  For I=1 To 512
    WriteStringN(fileno, "FNOP", #PB_UTF8)
  Next
  ForEach OutputCode()
    If Not Left(OutputCode(), 1)=";"
      WriteStringN(fileno, OutputCode(), #PB_UTF8)
    EndIf
  Next
  CloseFile(fileno)
EndIf

fileno = CreateFile(#PB_Any, "WASAPI_OnlyMyRailgunProcess_After.pbi")
If fileno
  WriteStringFormat(fileno, #PB_UTF8)
  WriteStringN(fileno, "; WASAPI_OnlyMyRailgunProcess_After.pbi", #PB_UTF8)
  WriteStringN(fileno, "; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)", #PB_UTF8)
  For I=1 To 512
    WriteStringN(fileno, "!FNOP", #PB_UTF8)
  Next
  ForEach OutputCode()
    If FindString(OutputCode(), "OnlyMyRailGun")
      WriteStringN(fileno, Mid(OutputCode(), 3), #PB_UTF8)
    Else
      If Not Left(OutputCode(), 1)=";"
        WriteStringN(fileno, "!"+OutputCode(), #PB_UTF8)
      EndIf
    EndIf
  Next
  CloseFile(fileno)
EndIf

End

_________________
My general site & Bug head technology - Ultimate high quality sound player by BASS
My facebook page.


Last edited by oryaaaaa on Fri Feb 22, 2019 12:09 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: BASS.DLL Sound Player for Full Digital Amplifier for Hi-
PostPosted: Fri Feb 22, 2019 10:24 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2004 11:40 pm
Posts: 760
Location: Okazaki, JAPAN
"PureBasicForumTips_WASAPI_player.pb"
Code:
; PureBasicForumTips_WASAPI_player.pb
; Copyright (c) 2018-2019, Hiroyuki Yokota (oryaaaaa)
!PureBasicStartEND:

Macro FNOPx16
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
EndMacro

Macro NOP_bx_cx_ax_dx
  !NOP bx
  !NOP Ebx
  !NOP cx
  !NOP Ecx
  !NOP bp
  !NOP Ebp
  !NOP di
  !NOP Edi
  !NOP R8w
  !NOP R8d
  !NOP R10w
  !NOP R10d
  !NOP R12w
  !NOP R12d
  !NOP R14w
  !NOP R14d
  !NOP ax
  !NOP Eax
  !NOP dx
  !NOP Edx
  !NOP sp
  !NOP Esp
  !NOP si
  !NOP Esi
  !NOP R9w
  !NOP R9d
  !NOP R11w
  !NOP R11d
  !NOP R13w
  !NOP R13d
  !NOP R15w
  !NOP R15d
EndMacro

Macro NOP_Rbx_Rcx_Rax_Rdx
  !NOP Rbx
  !NOP Rcx
  !NOP Rbp
  !NOP Rdi
  !NOP R8
  !NOP R10
  !NOP R12
  !NOP R14
  !NOP Rax
  !NOP Rdx
  !NOP Rsp
  !NOP Rsi
  !NOP R9
  !NOP R11
  !NOP R13
  !NOP R15
EndMacro

Macro XCHG_Rbx_Rcx_Rax_Rdx
  !XCHG Rbx, Rbx
  !XCHG Rcx, Rcx
  !XCHG Rbp, Rbp
  !XCHG Rdi, Rdi
  !XCHG R8, R8
  !XCHG R10, R10
  !XCHG R12, R12
  !XCHG R14, R14
  !XCHG Rax, Rax
  !XCHG Rdx, Rdx
  !XCHG Rsp, Rsp
  !XCHG Rsi, Rsi
  !XCHG R9, R9
  !XCHG R11, R11
  !XCHG R13, R13
  !XCHG R15, R15
EndMacro

Macro XCHG_bx_cx_ax_dx
  !XCHG bh, bl
  !XCHG bl, bh
  !XCHG Ebx, Ebx
  !XCHG ch, cl
  !XCHG cl, ch
  !XCHG Ecx, Ecx
  !XCHG bp, bp
  !XCHG Ebp, Ebp
  !XCHG di, di
  !XCHG Edi, Edi
  !XCHG R8w, R8w
  !XCHG R8d, R8d
  !XCHG R10w, R10w
  !XCHG R10d, R10d
  !XCHG R12w, R12w
  !XCHG R12d, R12d
  !XCHG R14w, R14w
  !XCHG R14d, R14d
  !XCHG ah, al
  !XCHG al, ah
  !XCHG Eax, Eax
  !XCHG dh, dl
  !XCHG dl, dh
  !XCHG Edx, Edx
  !XCHG sp, sp
  !XCHG Esp, Esp
  !XCHG si, si
  !XCHG Esi, Esi
  !XCHG R9w, R9w
  !XCHG R9d, R9d
  !XCHG R11w, R11w
  !XCHG R11d, R11d
  !XCHG R13w, R13w
  !XCHG R13d, R13d
  !XCHG R15w, R15w
  !XCHG R15d, R15d
EndMacro

IncludeFile "WASAPI_OnlyMyRailgunProcess_Before.pbi"
IncludeFile "WASAPI_Stabilizer_3_MMX.pbi"
IncludeFile "WASAPI_OnlyMyRailgunProcess_Before.pbi"
IncludeFile "WASAPI_Stabilizer_3_MMX.pbi"
IncludeFile "WASAPI_OnlyMyRailgunProcess_Before.pbi"
IncludeFile "WASAPI_Stabilizer_3_MMX.pbi"
IncludeFile "WASAPI_OnlyMyRailgunProcess_Before.pbi"
IncludeFile "WASAPI_Stabilizer_3_MMX.pbi"
IncludeFile "WASAPI_OnlyMyRailgunProcess_After.pbi"
IncludeFile "WASAPI_Stabilizer_3_MMX.pbi"
!XOR Rcx, Rcx
FNOPx16
!XOR Rcx, Rcx
FNOPx16
!INC Rcx
FNOPx16
!INC Rcx
FNOPx16
!INC Rcx
FNOPx16
!INC Rcx
FNOPx16
!INC Rcx
FNOPx16
!INC Rcx
FNOPx16
!INC Rcx
FNOPx16
!INC Rcx
FNOPx16
!SHL Rcx, cl
FNOPx16
!CALL PB_Delay
FNOPx16

; Import BASS libraly
; ;BASS 2.4 C/C++ header file, copyright (c) 1999-2008 Ian Luck.
; ;Please report bugs/suggestions/etc... To bass@un4seen.com
; ;
; ;See the BASS.CHM file for implementation documentation
; ;
; ;BASS v2.4 include for PureBasic v4.20
; ;C to PB adaption by Roger "Rescator" Hagensen, 27th March 2008, http://EmSai.net/
;
; ;Needed by some code in this include and various other BASS sourcecodes.
#BASS_ERROR_ENDED     = 45
#BASS_ERROR_HANDLE      = 5
#BASS_ERROR_NOTAVAIL    =37
#BASS_ERROR_BUFLOST     =4
#BASS_DEVICE_ENABLED = 1
#BASS_DEVICE_DEFAULT = 2
#BASS_DEVICE_NOSPEAKER  =4096
#BASS_SAMPLE_SOFTWARE = 16
#BASS_SAMPLE_FLOAT     = 256
#BASS_STREAM_PRESCAN  = $20000
#BASS_STREAM_DECODE   = $200000
#BASS_FILEPOS_CURRENT = 0
#BASS_ATTRIB_FREQ            = 1
#BASS_POS_BYTE              =0
#BASS_INPUT_ON      =$20000
#BASS_DATA_FLOAT = $40000000
#BASS_UNICODE = $80000000
#BASS_CONFIG_UNICODE = 42

Import "bass.lib"
  BASS_Init.l(device.l,Freq.l,flags.l,win.l,*dsguid)
  BASS_Free.l()
  BASS_StreamCreateFile.l(mem.l,*file,offset.q,length.q,flags.l)
  BASS_StreamFree.l(handle.l)
  BASS_ChannelGetAttribute.l(handle.l,attrib.l,*value)
  BASS_ChannelGetLength.q(handle.l,mode.l)
  BASS_ChannelGetPosition.q(handle.l,mode.l)
  BASS_ChannelGetData.l(handle.l,*buffer,length.l)
  BASS_ChannelStop.l(handle.l)
  BASS_ErrorGetCode.i()
EndImport
; End Import BASS libraly


; Import BASS WASAPI Plugins
Structure BASS_WASAPI_DEVICEINFO
  *name
  *Id
  Type.l
  flags.l
  minperiod.f
  defperiod.f
  mixfreq.l
  mixchans.l
EndStructure

Structure BASS_WASAPI_INFO
  initflags.l
  Freq.l
  chans.l
  format.l
  buflen.l
  volmax.l
  volmin.l
  volstep.l
EndStructure

#BASS_WASAPI_FORMAT_FLOAT = 0
#BASS_WASAPI_FORMAT_8BIT = 1
#BASS_WASAPI_FORMAT_16BIT = 2
#BASS_WASAPI_FORMAT_24BIT = 3
#BASS_WASAPI_FORMAT_32BIT = 4

#BASS_WASAPI_EXCLUSIVE = 1
#BASS_WASAPI_AUTOFORMAT = 2
#BASS_ERROR_UNKNOWN = -1

Import "basswasapi.lib"
  BASS_WASAPI_Init.b(device.i, Freq.l, chans.l, flags.l, Buffer.f, period.f, *proc, *User)
  BASS_WASAPI_Free.b()
  BASS_WASAPI_IsStarted.b()
  BASS_WASAPI_Start.b()
  BASS_WASAPI_Stop.b(reset.b)
  BASS_WASAPI_GetInfo.b(*info)
  BASS_WASAPI_CheckFormat.l(device.i, Freq.l, chans.l, flags.l)
  BASS_WASAPI_PutData.l(*buffer, length.l)
EndImport

Import "bassflac.lib"
  BASS_FLAC_StreamCreateFile.l(mem.l,*file,offset.q,length.q,flags.l)
EndImport

; End Import BASS WASAPI Plugins

Global WASAPI_device_format.i
!XOR Rax, Rax
!MOVNTI [v_WASAPI_device_format], Rax
WASAPI_device_format = BASS_WASAPI_Checkformat(-1, 44100, 2, #BASS_WASAPI_EXCLUSIVE)
If WASAPI_device_format = #BASS_ERROR_UNKNOWN
  Delay(128)
  MessageRequester("ERROR 1", "I can't setup Wasapi 44.1kHz device.", #PB_MessageRequester_Error)
  End
EndIf

Procedure FillMemoryNatural(*memory, Size.i)
  ; Bug head 10.93, Nontallion 10.93, PINK HQ 1.81 based
  ; Copyright (c) 2018-2019, Hiroyuki Yokota (oryaaaaa)
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  NOP_bx_cx_ax_dx
  NOP_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  !XOR R8, R8
  !XOR R9, R9
  !PXOR mm3, mm3
  !PXOR mm3, mm3
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !MOVQ mm5, [p.p_memory]
  !MOVQ mm3, mm5
  !MOVQ R9, mm3
  !PXOR mm3, mm3
  !PXOR mm3, mm3
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !MOVQ mm5, [p.v_Size]
  !MOVQ mm3, mm5
  !MOVQ R8, mm3
  !XCHG spl, bpl
  !XCHG Rsp, Rsp
  !XCHG Rbp, Rbp
  !XCHG bpl, spl
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FillMemoryNatural_Start:
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !MOVNTQ [R9], mm5
  !INC R9
  !INC R9
  !INC R9
  !INC R9
  !INC R9
  !INC R9
  !INC R9
  !INC R9
  !DEC R8
  !DEC R8
  !DEC R8
  !DEC R8
  !DEC R8
  !DEC R8
  !DEC R8
  !DEC R8
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !JNZ FillMemoryNatural_Start
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !EMMS
  !XOR R8, R8
  !XOR R9, R9
EndProcedure

; Procedure.l AsioProc(input.b, channel.l, *buffer, length.l, *user)
Procedure.l WasapiProc(*buffer, length.l, *user)
  ; Bug head 10.93, Nontallion 10.93, PINK HQ 1.81 based
  ; Copyright (c) 2018-2019, Hiroyuki Yokota (oryaaaaa)
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !WasapiProc_NOP_XCHG_A:
  NOP_bx_cx_ax_dx
  NOP_bx_cx_ax_dx
  !JMP WasapiProc_NOP_XCHG_B
  !HLT
  !HLT
  !WasapiProc_NOP_XCHG_B:
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  !WasapiProc_NOP_XCHG_C:
  NOP_Rbx_Rcx_Rax_Rdx
  !WasapiProc_NOP_XCHG_D:
  XCHG_Rbx_Rcx_Rax_Rdx
  IncludeFile "WASAPI_Stabilizer_2_MMX.pbi"
  !FNOP
  !FNOP
  Shared *bufferDecode
  Shared WasapiPos.q, Musiclength.q, WasapiStop.i, INT16_Adjust.i
  !AddFNOP_S_WasapiProc:
  !PXOR mm5, mm5
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVQ mm4, mm5
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !XOR Rax, Rax
  !MOVQ mm4, Rax
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !MOVQ2DQ xmm14, mm5
  !GateOfBabylon_WasapiProc_1:
  !MOVQ2DQ xmm14, mm0
  !XOR Rax, Rax
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !GateOfBabylon_WasapiProc_2:
  !LEA Rax, [p.p_buffer]
  !MOVQ mm4, Rax
  !XOR Rax, Rax
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !MOVQ Rax, mm0
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !GateOfBabylon_WasapiProc_3:
  !MOVQ mm4, [Rax]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_4:
  !MOVNTQ [Rax], mm0
  !XOR Rax, Rax
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !GateOfBabylon_WasapiProc_5:
  !LEA Rax, [p.v_length]
  !MOVQ mm4, Rax
  !XOR Rax, Rax
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !MOVQ Rax, mm0
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !GateOfBabylon_WasapiProc_6:
  !MOVQ mm4, [Rax]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_7:
  !MOVNTQ [Rax], mm0
  !XOR Rax, Rax
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !GateOfBabylon_WasapiProc_8:
  !LEA Rax, [v_WasapiPos]
  !MOVQ mm4, Rax
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_9:
  !MOVQ2DQ xmm11, mm0
  !XOR Rax, Rax
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !GateOfBabylon_WasapiProc_10:
  !LEA Rax, [v_WasapiStop]
  !MOVQ mm4, Rax
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_11:
  !MOVQ R8, mm0
  !XOR Rax, Rax
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVQ2DQ xmm10, mm5
  !GateOfBabylon_WasapiProc_12:
  !MOVQ mm4, [p.p_buffer]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_13:
  !MOVQ2DQ xmm10, mm0
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVQ2DQ xmm12, mm5
  !GateOfBabylon_WasapiProc_14:
  !MOVQ mm4, [p.v_length]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_15:
  !MOVQ2DQ xmm12, mm0
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVQ2DQ xmm8, mm5
  !GateOfBabylon_WasapiProc_16:
  !MOVQ mm4, [v_WasapiPos]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_17:
  !MOVQ2DQ xmm8, mm0
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVQ2DQ xmm6, mm5
  !GateOfBabylon_WasapiProc_18:
  !MOVQ mm4, [v_Musiclength]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_19:
  !MOVQ2DQ xmm6, mm0
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVQ2DQ xmm4, mm5
  !GateOfBabylon_WasapiProc_20:
  !MOVQ mm4, [v_INT16_Adjust]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_21:
  !MOVQ2DQ xmm4, mm0
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVQ2DQ xmm2, mm5
  !GateOfBabylon_WasapiProc_22:
  !MOVQ mm4, [p_bufferDecode]
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !GateOfBabylon_WasapiProc_23:
  !MOVQ2DQ xmm2, mm0
  !XOR Rax, Rax
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !MOVDQ2Q mm4, xmm10
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !MOVQ Rax, mm0
  !GateOfBabylon_WasapiProc_24:
  !MOVNTDQA xmm15, [Rax]
  !PXOR mm4, mm4
  !MOVQ mm4, mm5
  !PXOR mm0, mm0
  !MOVQ mm0, mm5
  !XOR Rax, Rax
  !XOR Rdx, Rdx
  !PXOR mm2, mm2
  !GateOfBabylon_WasapiProc_25:
  !MOVQ mm2, [R8]
  !MOVQ Rax, mm2
  !CMP Rax, Rdx
  !JE WasapiProc_EndIf47
  !JMP WasapiProc_END_Finish
  !WasapiProc_EndIf47:
  !XOR Rax, Rax
  !XOR Rdx, Rdx
  !PXOR mm2, mm2
  !MOVDQ2Q mm2, xmm6
  !MOVQ Rax, mm2
  !PXOR mm2, mm2
  !MOVDQ2Q mm2, xmm8
  !MOVQ Rdx, mm2
  !CMP Rax, Rdx
  !JNE WasapiProc_EndIf48
  !XOR Rax, Rax
  !INC Rax
  !PXOR mm2, mm2
  !MOVQ mm2, Rax
  !GateOfBabylon_WasapiProc_26:
  !MOVNTQ [R8], mm2
  !JMP WasapiProc_END_Finish
  !WasapiProc_EndIf48:
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !XOR Rdx, Rdx
  !PXOR mm2, mm2
  !MOVDQ2Q mm2, xmm6
  !MOVQ Rax, mm2
  !PXOR mm2, mm2
  !MOVDQ2Q mm2, xmm8
  !MOVQ Rdx, mm2
  !PXOR mm2, mm2
  !MOVDQ2Q mm2, xmm12
  !MOVQ Rcx, mm2
  !ADD Rdx,Rcx
  !CMP Rax,Rdx
  !JG WasapiProc_EndIf49
  !XOR Rax, Rax
  !INC Rax
  !PXOR mm2, mm2
  !MOVQ mm2, Rax
  !GateOfBabylon_WasapiProc_27:
  !MOVNTQ [R8], mm2
  !PXOR mm2, mm2
  !MOVQ mm2, mm5
  !JMP WasapiPorc_Process_A
  !WasapiProc_EndIf49:
  !XOR Rax, Rax
  !XOR Rdx, Rdx
  !PXOR mm2, mm2
  !MOVDQ2Q mm2, xmm6
  !MOVQ Rax, mm2
  !PXOR mm2, mm2
  !MOVDQ2Q mm2, xmm8
  !MOVQ Rdx, mm2
  !CMP Rax,Rdx
  !JLE WasapiProc_END_Finish
  !PXOR mm2, mm2
  !MOVQ mm2, mm5
  !JMP WasapiPorc_Process_B
  !WasapiPorc_Process_A:
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !PAND mm5, mm5
  !PAND mm5, mm5
  !PXOR mm1, mm1
  !PXOR mm1, mm1
  !PAND mm1, mm1
  !PAND mm1, mm1
  !PXOR mm3, mm3
  !PXOR mm3, mm3
  !PAND mm3, mm3
  !PAND mm3, mm3
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !XOR Rdx, Rdx
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !GateOfBabylon_WasapiProc_28:
  !MOVDQ2Q mm6, xmm2
  !MOVQ mm7, mm6
  !MOVQ Rax, mm7
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVDQ2Q mm6, xmm8
  !MOVQ mm7, mm6
  !MOVQ Rdx, mm7
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVDQ2Q mm6, xmm6
  !MOVQ mm7, mm6
  !MOVQ Rcx, mm7
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVQ mm6, Rcx
  !MOVQ mm7, mm6
  !PXOR mm6, mm6
  !MOVDQ2Q mm6, xmm11
  !XOR R8, R8
  !MOVQ R8, mm6
  !GateOfBabylon_WasapiProc_29:
  !MOVNTQ [R8], mm7
  !XOR R8, R8
  !Add R8, Rcx
  !Sub R8, Rdx
  !XOR R9, R9
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVQ mm6, R8
  !MOVQ mm7, mm6
  !MOVQ R9, mm7
  !XOR Rcx, Rcx
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVDQ2Q mm6, xmm4
  !MOVQ mm7, mm6
  !MOVQ Rcx, mm7
  !Sub R9, Rcx
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVQ mm6, R9
  !MOVQ mm7, mm6
  !GateOfBabylon_WasapiProc_30:
  !MOVQ2DQ xmm14, mm7
  !XOR R9, R9
  !XOR Rcx, Rcx
  !MOV Rcx, R8
  !ADD Rax, Rdx
  !XOR Rdx, Rdx
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !GateOfBabylon_WasapiProc_31:
  !MOVDQ2Q mm6, xmm10
  !MOVQ mm7, mm6
  !MOVQ Rdx, mm7
  !JMP WASAPI_Proc_LOOP_Start
  !WasapiPorc_Process_B:
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !PAND mm5, mm5
  !PAND mm5, mm5
  !PXOR mm1, mm1
  !PXOR mm1, mm1
  !PAND mm1, mm1
  !PAND mm1, mm1
  !PXOR mm3, mm3
  !PXOR mm3, mm3
  !PAND mm3, mm3
  !PAND mm3, mm3
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !XOR Rdx, Rdx
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !GateOfBabylon_WasapiProc_32:
  !MOVDQ2Q mm6, xmm2
  !MOVQ mm7, mm6
  !MOVQ Rax, mm7
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVDQ2Q mm6, xmm8
  !MOVQ mm7, mm6
  !MOVQ Rdx, mm7
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVDQ2Q mm6, xmm12
  !MOVQ mm7, mm6
  !MOVQ Rcx, mm7
  !XOR R8, R8
  !Add R8, Rdx
  !Add R8, Rcx
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVQ mm6, R8
  !MOVQ mm7, mm6
  !PXOR mm6, mm6
  !MOVDQ2Q mm6, xmm11
  !XOR R8, R8
  !MOVQ R8, mm6
  !GateOfBabylon_WasapiProc_33:
  !MOVNTQ [R8], mm7
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !MOVQ mm6, Rcx
  !MOVQ mm7, mm6
  !GateOfBabylon_WasapiProc_34:
  !MOVQ2DQ xmm14, mm7
  !ADD Rax, Rdx
  !XOR Rdx, Rdx
  !PXOR mm6, mm6
  !PXOR mm7, mm7
  !GateOfBabylon_WasapiProc_35:
  !MOVDQ2Q mm6, xmm10
  !MOVQ mm7, mm6
  !MOVQ Rdx, mm7
  !WASAPI_Proc_LOOP_Start:
  !NOP Rsp
  !GateOfBabylon_WasapiProc_36:
  !NOP Rbp
  !GateOfBabylon_WasapiProc_37:
  !XCHG spl, bpl
  !GateOfBabylon_WasapiProc_38:
  !XCHG Rsp, Rsp
  !GateOfBabylon_WasapiProc_39:
  !XCHG Rbp, Rbp
  !GateOfBabylon_WasapiProc_40:
  !XCHG bpl, spl
  !WASAPI_Proc_LOOP:
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !XOR R9, R9
  !XOR R9, R9
  !NOP R9
  !NOP R9
  !GateOfBabylon_WasapiProc_41:
  !NOT R9
  !NOP R9
  !NOP R9
  !GateOfBabylon_WasapiProc_42:
  !NOT R9
  !NOP R9
  !NOP R9
  !GateOfBabylon_WasapiProc_43:
  !NOT R9
  !XCHG R9, R9
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !PAND mm5, mm5
  !PAND mm5, mm5
  !GateOfBabylon_WasapiProc_44:
  !MOVQ mm5, R9
  !PXOR mm0, mm0
  !PXOR mm0, mm0
  !PAND mm0, mm0
  !PAND mm0, mm0
  !PXOR mm0, mm0
  !PXOR mm0, mm0
  !PAND mm0, mm0
  !PAND mm0, mm0
  !MOVQ mm0, mm5
  !PAND mm0, mm0
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !PAND mm5, mm5
  !PAND mm5, mm5
  !PXOR mm5, mm5
  !PXOR mm5, mm5
  !PAND mm5, mm5
  !PAND mm5, mm5
  !GateOfBabylon_WasapiProc_45:
  !MOVNTQ [Rdx], mm0
  !GateOfBabylon_WasapiProc_46:
  !MOVNTQ [Rdx], mm5
  !GateOfBabylon_WasapiProc_47:
  !MOVQ mm5, [Rdx]
  !GateOfBabylon_WasapiProc_48:
  !MOVNTQ [Rdx], mm0
  !PXOR mm1, mm1
  !PXOR mm1, mm1
  !PAND mm1, mm1
  !PAND mm1, mm1
  !PXOR mm1, mm1
  !PXOR mm1, mm1
  !PAND mm1, mm1
  !PAND mm1, mm1
  !PXOR mm2, mm2
  !PXOR mm2, mm2
  !PAND mm2, mm2
  !PAND mm2, mm2
  !PXOR mm2, mm2
  !PXOR mm2, mm2
  !PAND mm2, mm2
  !PAND mm2, mm2
  !PXOR mm3, mm3
  !PXOR mm3, mm3
  !PAND mm3, mm3
  !PAND mm3, mm3
  !PXOR mm3, mm3
  !PXOR mm3, mm3
  !PAND mm3, mm3
  !PAND mm3, mm3
  !PXOR mm4, mm4
  !PXOR mm4, mm4
  !PAND mm4, mm4
  !PAND mm4, mm4
  !PXOR mm4, mm4
  !PXOR mm4, mm4
  !PAND mm4, mm4
  !PAND mm4, mm4
  !PXOR mm6, mm6
  !PXOR mm6, mm6
  !PAND mm6, mm6
  !PAND mm6, mm6
  !PXOR mm6, mm6
  !PXOR mm6, mm6
  !PAND mm6, mm6
  !PAND mm6, mm6
  !PXOR mm7, mm7
  !PXOR mm7, mm7
  !PAND mm7, mm7
  !PAND mm7, mm7
  !PXOR mm7, mm7
  !PXOR mm7, mm7
  !PAND mm7, mm7
  !PAND mm7, mm7
  !MOVQ mm1, mm5
  !MOVQ mm2, mm5
  !MOVQ mm3, mm5
  !MOVQ mm4, mm5
  !MOVQ mm6, mm5
  !GateOfBabylon_WasapiProc_49:
  !MOVQ mm7, mm5
  !GateOfBabylon_WasapiProc_50:
  !MOVQ mm7, [Rax]
  !GateOfBabylon_WasapiProc_51:
  !MOVQ mm7, [Rax]
  !MOVQ mm2, mm7
  !MOVQ mm6, mm2
  !MOVQ mm4, mm6
  !MOVQ mm1, mm4
  !GateOfBabylon_WasapiProc_52:
  !MOVQ mm3, mm1
  !GateOfBabylon_WasapiProc_53:
  !MOVQ mm5, mm3
  !GateOfBabylon_WasapiProc_54:
  !PXOR mm2, mm0
  !MOVQ mm6, mm2
  !PAND mm6, mm6
  !MOVQ mm4, mm6
  !PAND mm4, mm4
  !GateOfBabylon_WasapiProc_55:
  !MOVQ mm1, mm4
  !PAND mm1, mm1
  !GateOfBabylon_WasapiProc_56:
  !MOVQ mm3, mm1
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !GateOfBabylon_WasapiProc_57:
  !MOVNTQ [Rdx], mm3
  !GateOfBabylon_WasapiProc_58:
  !MOVNTQ [Rdx], mm5
  !GateOfBabylon_WasapiProc_59:
  !MOVQ mm2, [Rdx]
  !MOVQ mm4, mm2
  !MOVQ mm6, mm4
  !GateOfBabylon_WasapiProc_60:
  !MOVQ mm7, mm6
  !GateOfBabylon_WasapiProc_61:
  !MOVQ mm5, mm7
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !GateOfBabylon_WasapiProc_62:
  !MOVNTQ [Rdx], mm3
  !GateOfBabylon_WasapiProc_63:
  !MOVNTQ [Rdx], mm5
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !INC Rax
  !INC Rax
  !INC Rax
  !INC Rax
  !INC Rax
  !INC Rax
  !INC Rax
  !INC Rax
  !INC Rdx
  !INC Rdx
  !INC Rdx
  !INC Rdx
  !INC Rdx
  !INC Rdx
  !INC Rdx
  !INC Rdx
  !DEC Rcx
  !DEC Rcx
  !DEC Rcx
  !DEC Rcx
  !DEC Rcx
  !DEC Rcx
  !DEC Rcx
  !DEC Rcx
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !JNZ WASAPI_Proc_LOOP
  !WasapiProc_END_Finish:
  !XOR R8, R8
  !PXOR mm4, mm4
  !PXOR mm2, mm2
  !PXOR mm0, mm0
  !GateOfBabylon_WasapiProc_64:
  !MOVDQ2Q mm4, xmm10
  !MOVQ mm2, mm4
  !MOVQ mm0, mm2
  !MOVQ R8, mm0
  !GateOfBabylon_WasapiProc_65:
  !MOVNTDQA xmm15, [R8]
  !PXOR mm3, mm3
  !PXOR mm1, mm1
  !PXOR mm5, mm5
  !XOR Rax, Rax
  !GateOfBabylon_WasapiProc_66:
  !MOVDQ2Q mm3, xmm14
  !MOVQ mm1, mm3
  !MOVQ mm5, mm1
  !MOVQ Rax, mm5
  !EMMS
  !XOR Rdx, Rdx
  !XOR R9, R9
  !XOR Rcx, Rcx
  !XOR R8, R8
  !XOR R10, R10
  !XOR Rdx, Rdx
  !XOR R9, R9
  !XOR Rcx, Rcx
  !XOR R8, R8
  !XOR R10, R10
  !NOP Rax
  !NOP Rdx
  !NOP R9
  !NOP Rcx
  !NOP R8
  !NOP R10
  !NOP Rax
  !NOP Rdx
  !NOP R9
  !NOP Rcx
  !NOP R8
  !NOP R10
  !NOT Rdx
  !NOT R9
  !NOT Rcx
  !NOT R8
  !NOT R10
  !NOP Rax
  !NOP Rdx
  !NOP R9
  !NOP Rcx
  !NOP R8
  !NOP R10
  !NOP Rax
  !NOP Rdx
  !NOP R9
  !NOP Rcx
  !NOP R8
  !NOP R10
  !NOT Rax
  !NOT Rdx
  !NOT R9
  !NOT Rcx
  !NOT R8
  !NOT R10
  !NOP Rax
  !NOP Rdx
  !NOP R9
  !NOP Rcx
  !NOP R8
  !NOP R10
  !NOP Rax
  !NOP Rdx
  !NOP R9
  !NOP Rcx
  !NOP R8
  !NOP R10
  !NOT Rax
  !NOT Rdx
  !NOT R9
  !NOT Rcx
  !NOT R8
  !NOT R10
  !XCHG Rax, Rax
  !XCHG Rdx, Rdx
  !XCHG R9, R9
  !XCHG Rcx, Rcx
  !XCHG R8, R8
  !XCHG R10, R10 
  NOP_bx_cx_ax_dx
  NOP_bx_cx_ax_dx
  !JMP WasapiProc_NOP_XCHG_HLT1
  !HLT
  !HLT
  !WasapiProc_NOP_XCHG_HLT1:
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  !JMP WasapiProc_NOP_XCHG_HLT2
  !HLT
  !HLT
  !WasapiProc_NOP_XCHG_HLT2:
  NOP_bx_cx_ax_dx
  NOP_bx_cx_ax_dx
  !JMP WasapiProc_NOP_XCHG_HLT3
  !HLT
  !HLT
  !WasapiProc_NOP_XCHG_HLT3:
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  !AddFNOP_E_WasapiProc:
  ProcedureReturn
  !HLT
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx 
EndProcedure

Procedure MainThread()
  ; Bug head 10.93, Nontallion 10.93, PINK HQ 1.81 based
  ; Copyright (c) 2018-2019, Hiroyuki Yokota (oryaaaaa)
  NOP_bx_cx_ax_dx
  NOP_bx_cx_ax_dx
  !JMP NaturalBladeProcess_MainThread_Startup_Shareware
  !HLT
  !HLT
  !NaturalBladeProcess_MainThread_Startup_Shareware:
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  IncludeFile "WASAPI_Stabilizer_2_MMX.pbi"
  !FNOP
  !FNOP
  !AddFNOP_S_Main_1:
  Shared *bufferDecode
  Shared WasapiPos.q, Musiclength.q, WasapiStop.i, INT16_Adjust.i
  Protected MusicFileName.s, chan.l, PlayingStatus.i, Freq_float.f, Musiclength_2.q
  Protected Double_1_0000.d, Float_1_000.f, D0.i, D1.i, D2.i, D4.i, D5.i, D6.i, D8.i
  Protected bassoption_WAV_FLAC.l, BASS_ATTRIB_FREQ.l, BASS_POS_BYTE.l, False.i, DM1.i
  Protected Bass_flags_FFFFFFF.i, BASS_DATA_FLOAT.i, Bass_ErrorCode.i, eventTimer.f
  Protected in_4096_size.q, D4096.i, D2048.i 
  !XOR R8, R8
  !NOT R8
  !PXOR mm1, mm1
  !PXOR mm3, mm3
  !PXOR mm5, mm5
  !MOVQ mm1, R8
  !XOR R8, R8
  !MOVQ mm3, mm1
  !MOVQ mm5, mm3
  !MOVQ R8, mm5
  !EMMS
  !XOR Rax, Rax
  !MOVNTI [p.v_Double_1_0000], R8
  !MOVNTI [p.v_Double_1_0000], Rax
  !XOR R8, R8
  !PXOR xmm14, xmm14
  !XOR Rax, Rax
  !MOVQ xmm14, Rax
  !MOVSD [p.v_Double_1_0000], xmm14
  !PXOR xmm14, xmm14
  !XOR Rax, Rax
  !MOVQ xmm14, Rax
  !XOR Rcx, Rcx
  !INC cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !MOVQ xmm14, Rax
  !MOVSD [p.v_Double_1_0000], xmm14
  !XOR R8, R8
  !NOT R8
  !PXOR mm1, mm1
  !PXOR mm3, mm3
  !PXOR mm5, mm5
  !MOVQ mm1, R8
  !XOR R8, R8
  !MOVQ mm3, mm1
  !MOVQ mm5, mm3
  !MOVQ R8, mm5
  !EMMS
  !XOR Rax, Rax
  !MOVNTI dword [p.v_Float_1_000], R8d
  !MOVNTI dword [p.v_Float_1_000], Eax
  !XOR R8, R8
  !XOR Rcx, Rcx
  !INC cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !MOVNTI dword [p.v_Float_1_000], Eax
  !XOR R8, R8
  !NOT R8
  !PXOR mm1, mm1
  !PXOR mm3, mm3
  !PXOR mm5, mm5
  !MOVQ mm1, R8
  !XOR R8, R8
  !MOVQ mm3, mm1
  !MOVQ mm5, mm3
  !MOVQ R8, mm5
  !EMMS
  !MOVNTI [p_bufferDecode], R8
  !MOVNTI [v_WasapiPos], R8
  !MOVNTI [v_WasapiStop], R8
  !MOVNTI [v_INT16_Adjust], R8
  !MOVNTI [p.v_Bass_flags_FFFFFFF], R8
  !MOVNTI [p.v_Bass_ErrorCode], R8
  !MOVNTI dword [p.v_eventTimer], R8d
  !MOVNTI dword [p.v_Freq_float], R8d
  !MOVNTI [p.v_chan], R8d
  !MOVNTI [p.v_BASS_ATTRIB_FREQ], R8d
  !MOVNTI [p.v_BASS_POS_BYTE], R8d
  !MOVNTI [p.v_bassoption_WAV_FLAC], R8d
  !MOVNTI [p.v_PlayingStatus], R8
  !MOVNTI [p.v_BASS_DATA_FLOAT], R8
  !MOVNTI [p.v_False], R8
  !MOVNTI [p.v_DM1], Rax 
  !MOVNTI [p.v_D0], R8
  !MOVNTI [p.v_D1], R8
  !MOVNTI [p.v_D2], R8
  !MOVNTI [p.v_D4], R8
  !MOVNTI [p.v_D5], R8
  !MOVNTI [p.v_D6], R8
  !MOVNTI [p.v_D8], R8
  !MOVNTI [p.v_D2048], R8
  !MOVNTI [p.v_D4096], R8
  !MOVNTI [v_Musiclength], R8
  !MOVNTI [p.v_Musiclength_2], R8
  !XOR R8, R8
  !XOR Rax, Rax
  !MOVNTI [p_bufferDecode], Rax
  !MOVNTI [v_WasapiPos], Rax
  !MOVNTI [v_WasapiStop], Rax
  !MOVNTI [v_INT16_Adjust], Rax
  !MOVNTI [p.v_Bass_flags_FFFFFFF], Rax
  !MOVNTI [p.v_Bass_ErrorCode], Rax
  !MOVNTI dword [p.v_eventTimer], Eax
  !MOVNTI dword [p.v_Freq_float], Eax
  !MOVNTI [p.v_chan], Eax
  !MOVNTI [p.v_BASS_ATTRIB_FREQ], Eax
  !MOVNTI [p.v_BASS_POS_BYTE], Eax
  !MOVNTI [p.v_bassoption_WAV_FLAC], Eax
  !MOVNTI [p.v_PlayingStatus], Rax
  !MOVNTI [p.v_BASS_DATA_FLOAT], Rax
  !MOVNTI [p.v_False], Rax
  !MOVNTI [p.v_DM1], Rax
  !MOVNTI [p.v_D0], Rax
  !MOVNTI [p.v_D1], Rax
  !MOVNTI [p.v_D2], Rax
  !MOVNTI [p.v_D4], Rax
  !MOVNTI [p.v_D5], Rax
  !MOVNTI [p.v_D6], Rax
  !MOVNTI [p.v_D8], Rax
  !MOVNTI [p.v_D2048], Rax
  !MOVNTI [p.v_D4096], Rax
  !MOVNTI [v_Musiclength], Rax
  !MOVNTI [p.v_Musiclength_2], Rax
  !NOT Rax
  !MOVNTI [p.v_DM1], Rax
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !INC Rax
  !INC Rcx
  !SHL Rax, cl
  !SHL Rax, cl
  !INC Rax
  !MOVNTI [p.v_D5], Rax
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !INC Rax
  !INC Rcx
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !MOVNTI [p.v_D6], Rax
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !INC Rax
  !MOVNTI [p.v_D1], Rax
  !MOVNTI [p.v_BASS_ATTRIB_FREQ], Eax
  !INC Rcx
  !SHL Rax, cl
  !MOVNTI [p.v_D2], Rax
  !SHL Rax, cl
  !MOVNTI [p.v_D4], Rax
  !SHL Rax, cl
  !MOVNTI [p.v_D8], Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !MOVNTI [p.v_D2048], Rax
  !SHL Rax, cl
  !MOVNTI [p.v_D4096], Rax
  ; BASS_DATA_FLOAT =1073741824= $40000000
  !XOR R8, R8
  !NOT R8
  !PXOR mm1, mm1
  !PXOR mm3, mm3
  !PXOR mm5, mm5
  !MOVQ mm1, R8
  !XOR R8, R8
  !MOVQ mm3, mm1
  !MOVQ mm5, mm3
  !MOVQ R8, mm5
  !EMMS
  !XOR Rax, Rax
  !MOVNTI [p.v_BASS_DATA_FLOAT], R8
  !MOVNTI [p.v_BASS_DATA_FLOAT], Rax
  !XOR R8, R8
  !XOR Rcx, Rcx
  !INC cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !MOVNTI [p.v_BASS_DATA_FLOAT], Rax 
  ; Bass option =2149712144 #BASS_UNICODE | #BASS_STREAM_DECODE | #BASS_SAMPLE_FLOAT | #BASS_STREAM_PRESCAN | #BASS_SAMPLE_SOFTWARE
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !INC cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !MOVNTI [p.v_bassoption_WAV_FLAC], Eax
  ; Bass_ChannelGetData $FFFFFFF = 268435455
  !XOR Rax, Rax
  !XOR Rcx, Rcx
  !INC Rcx
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !MOVNTI [p.v_Bass_flags_FFFFFFF], Rax
  ;   ; Bass option =2149581328 #BASS_UNICODE | #BASS_STREAM_DECODE  | #BASS_DSD_RAW | #BASS_SAMPLE_SOFTWARE
  ;   !XOR Rax, Rax
  ;   !XOR Rcx, Rcx
  ;   !INC cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !MOVNTI [p.v_bassoption_DSD], Eax
  ;   ; BASS_ASIO_FORMAT_FLOAT = 19
  ;   !XOR Rax, Rax
  ;   !XOR Rcx, Rcx
  ;   !INC cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !MOVNTI [p.v_BASS_ASIO_FORMAT_FLOAT], Rax
  ;   ;
  ;   ; Bass option =33 #BASS_ASIO_FORMAT_DSD_MSB
  ;   !XOR Rax, Rax
  ;   !XOR Rcx, Rcx
  ;   !INC cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !MOVNTI [p.v_BASS_ASIO_FORMAT_DSD_MSB], Eax
  ;   ;
  ;   ; Bass option =81921 #BASS_ATTRIB_DSD_RATE
  ;   !XOR Rax, Rax
  ;   !XOR Rcx, Rcx
  ;   !INC cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !SHL Rax, cl
  ;   !INC Rax
  ;   !MOVNTI [p.v_BASS_ATTRIB_DSD_RATE], Eax
  ;
  MusicFileName = OpenFileRequester("Music File", "*.MP3;*.FLAC", "MP3 or FLAC|*.MP3;*.FLAC", 0)
  If FileSize(MusicFileName)<=0
    End
  EndIf
  BASS_Init( D0, 44100, D0, D0, D0)
  !XOR Rax, Rax
  !MOVNTI [p.v_chan], Eax
  If Right(UCase(MusicFileName), D4)=".MP3"
    chan.l = BASS_StreamCreateFile(False, @MusicFileName, D0, D0, bassoption_WAV_FLAC)
  ElseIf Right(UCase(MusicFileName), D5)=".FLAC"
    chan.l = BASS_FLAC_StreamCreateFile(False, @MusicFileName, D0, D0, bassoption_WAV_FLAC)
    ;     CompilerIf #Natural_output = #Natural_ASIO
    ;     ElseIf Right(UCase(MusicFileName), D4)=".DFF" Or Right(UCase(MusicFileName), D4)=".DSF"
    ;       chan.l = BASS_DSD_StreamCreateFile(False, @MusicFileName, 0, 0, bassoption_DSD,D0) )
    ;       !XOR Rax, Rax
    ;       !MOVNTI [p.v_SetDSD], Rax
    ;       !INC Rax
    ;       !MOVNTI [p.v_SetDSD], Rax
    ;     CompilerEndIf
  Else
    BASS_Free()
    MessageRequester("ERROR 1", "I can't load music file.", #PB_MessageRequester_Error)
    End
  EndIf
  If chan
    !XOR Rax, Rax
    !MOVNTI dword [p.v_Freq_float], Eax
    ;     If SetDSD=D1
    ;       BASS_ChannelGetAttribute(chan, BASS_ATTRIB_DSD_RATE, @Freq_float.f)
    ;     Else
    BASS_ChannelGetAttribute(chan, BASS_ATTRIB_FREQ, @Freq_float.f)
    ;     EndIf
    Musiclength.q = BASS_ChannelGetLength(chan, BASS_POS_BYTE)
  Else
    BASS_Free()
    MessageRequester("ERROR 2", "I can't load music file.", #PB_MessageRequester_Error)
    End
  EndIf
  ;   If SetDSD=D1
  ;     !XOR Rax, Rax
  ;     !MOVNTI [p.v_BASS_DATA_FLOAT], Rax
  ;   EndIf
  !XOR Rax, Rax
  !MOVNTI [p.v_in_4096_size], Rax
  in_4096_size = Musiclength + D4096 - Musiclength%D4096
  *bufferDecode = AllocateMemory(in_4096_size, #PB_Memory_NoClear)
  FillMemoryNatural(*bufferDecode, in_4096_size)
  If Pos>=Bass_flags_FFFFFFF
    Bass_ChannelGetData(chan, *bufferDecode, Bass_flags_FFFFFFF|BASS_DATA_FLOAT)
  Else
    Bass_ChannelGetData(chan, *bufferDecode, Pos|BASS_DATA_FLOAT)
  EndIf
  !JMP MainThread_Bass_ChannelGetData_Single
  !JMP MainThread_Bass_ChannelGetData_Single
  !NOP Rsp
  !NOP Rbp
  !XCHG spl, bpl
  !XCHG Rsp, Rsp
  !XCHG Rbp, Rbp
  !XCHG bpl, spl
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !MainThread_Bass_ChannelGetData_Single:
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  Bass_ErrorCode = BASS_ErrorGetCode()
  Musiclength_2.q = BASS_ChannelGetPosition(chan,BASS_POS_BYTE)
  If Bass_ErrorCode=D0 And Musiclength<>Musiclength_2
    If (Musiclength-Musiclength_2)>=Bass_flags_FFFFFFF
      Bass_ChannelGetData(chan, *bufferDecode+Musiclength_2, Bass_flags_FFFFFFF|BASS_DATA_FLOAT)
    Else
      Bass_ChannelGetData(chan, *bufferDecode+Musiclength_2, (Musiclength-Musiclength_2)|BASS_DATA_FLOAT)
    EndIf
    !XOR Rax, Rax
    !MOVNTI [p.v_Musiclength_2], Rax
    !MOVNTI [p.v_Bass_ErrorCode], Rax
    !JMP MainThread_Bass_ChannelGetData_Single
  EndIf
  !XOR Rax, Rax
  !MOVNTI [p.v_Bass_ErrorCode], Rax
  BASS_ChannelStop(chan)
  BASS_StreamFree(chan)
  If Not Musiclength=Musiclength_2
    FreeMemory(*bufferDecode)
    BASS_Free()
    MessageRequester("ERROR 3", "I can't decode music file.", #PB_MessageRequester_Error)
    End
  EndIf
  BASS_Free()
  ; Adjust Aliement 8 bytes
  !XOR Rax, Rax
  !MOVNTI [v_INT16_Adjust], Rax
  INT16_Adjust = D8 - Musiclength%D8
  Musiclength = Musiclength + D8 - Musiclength%D8
  !XOR R8, R8
  !NOT R8
  !PXOR mm1, mm1
  !PXOR mm3, mm3
  !PXOR mm5, mm5
  !MOVQ mm1, R8
  !XOR R8, R8
  !MOVQ mm3, mm1
  !MOVQ mm5, mm3
  !MOVQ R8, mm5
  !EMMS
  !XOR Rcx, Rcx
  !XOR Rax, Rax
  !XOR Rax, Rax
  !MOVNTI dword [p.v_eventTimer], R8d
  !MOVNTI dword [p.v_eventTimer], Eax
  !XOR R8, R8
  !INC cl
  !SHL Rax, cl
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !INC Rax
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !SHL Rax, cl
  !MOVNTI dword [p.v_eventTimer], Eax
  ;   CompilerIf #Natural_output = #Natural_ASIO
  ;     WasapiResult = BASS_ASIO_Init(Asio_Device, BASS_ASIO_THREAD)
  ;     If SetDSD=D1
  ;       If Not BASS_ASIO_SetDSD(D1)
  ;       EndIf
  ;       If BASS_ASIO_ChannelSetFormat(D0, D0, BASS_ASIO_FORMAT_DSD_MSB)
  ;       EndIf
  ;     Else
  ;       BASS_ASIO_ChannelSetFormat(D0,D0,BASS_ASIO_FORMAT_FLOAT)
  ;     EndIf
  ;     BASS_ASIO_SetRate(Double_1_0000*Freq_float)
  ;     BASS_ASIO_ChannelEnable(D0,D0, @AsioProc(), DM1)
  ;     BASS_ASIO_ChannelJoin(D0,D1,D0)
  ;     BASS_ASIO_ChannelSetVolume(False, DM1, D0)
  ;     BASS_ASIO_ChannelSetVolume(False, DM1, Float_1_000)
  ;   CompilerElseIf #Natural_output = #Natural_WASAPI
  WasapiResult = BASS_WASAPI_Init(DM1, Int(Freq_float), D2, #BASS_WASAPI_EXCLUSIVE, EventTimer, D0, @WasapiProc(), DM1)
  If Not WasapiResult
    FreeMemory(*bufferDecode)
    MessageRequester("ERROR 4", "I can't initialize wasapi device."+" Frequency "+StrF(Freq_float/1000,1)+" kHz", #PB_MessageRequester_Error)
    End
  EndIf
  ;   CompilerEndIf
  !XOR Rax, Rax
  !INC Rax
  !MOVNTI [p.v_PlayingStatus], Rax
  BASS_WASAPI_Start()
  !AddFNOP_E_Main_1:
  NOP_bx_cx_ax_dx
  NOP_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  IncludeFile "WASAPI_Stabilizer_2_MMX.pbi"
  !FNOP
  !FNOP
  !JMP MainThread_Repeat_Start_before
  !FNOP
  !FNOP
  !JMP MainThread_Repeat_Start
  !FNOP
  !FNOP
  !JMP MainThread_WASAPI_Proc_Stop
  !FNOP
  !FNOP
  !MainThread_Repeat_Start_before:
  !NOP Rsp
  !NOP Rbp
  !XCHG spl, bpl
  !XCHG Rsp, Rsp
  !XCHG Rbp, Rbp
  !XCHG bpl, spl
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !MainThread_Repeat_Start:
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  NOP_bx_cx_ax_dx
  NOP_bx_cx_ax_dx
  !JMP NaturalBladeProcess_MainThread
  !HLT
  !HLT
  !NaturalBladeProcess_MainThread:
  XCHG_bx_cx_ax_dx
  XCHG_bx_cx_ax_dx
  IncludeFile "WASAPI_Stabilizer_2_MMX.pbi"
  !FNOP
  !FNOP
  ;   Delay(D4) ;WASAPI Transfer is delay timing
  !XOR Rcx, Rcx
  !INC Rcx
  !INC Rcx
  !INC Rcx
  !INC Rcx
  !CALL   PB_Delay
  !MainThread_WASAPI_Proc:
  If PlayingStatus
    If Musiclength=WasapiPos
      !JMP MainThread_WASAPI_Proc_Stop
    EndIf
  EndIf
  !FNOP
  !FNOP
  !FNOP
  !FNOP
  !JMP MainThread_Repeat_Start
 
  !MainThread_WASAPI_Proc_Stop:
  !XOR Rax, Rax
  !INC Rax
  !MOVNTI [v_WasapiStop], Rax
  !XOR Rax, Rax
  !MOVNTI [p.v_PlayingStatus], Rax
  !AddFNOP_S_WASAPI_Proc_C1:
  ;   CompilerIf #Natural_output = #Natural_ASIO
  ;     If SetDSD=D1
  ;       BASS_ASIO_SetDSD(D0)
  ;     EndIf
  ;     BASS_ASIO_Stop()
  ;     BASS_ASIO_Free()
  ;   CompilerElseIf #Natural_output = #Natural_WASAPI
  BASS_WASAPI_Stop(D1)
  BASS_WASAPI_Free()
  ;   CompilerEndIf
  FreeMemory(*bufferDecode)
  !AddFNOP_E_WASAPI_Proc_C1:
  !XOR Rax, Rax
  !MOVNTI [p.v_chan], Eax
  !MOVNTI [v_WasapiPos], Rax
  !MOVNTI [v_WasapiStop], Rax
  !MOVNTI [v_Musiclength], Rax
  !MOVNTI [v_INT16_Adjust], Rax
  !MOVNTI [p_bufferDecode], Rax
  !MOVNTI dword [p.v_Freq_float], Eax
EndProcedure

!XOR Rax, Rax
!XOR Rcx, Rcx
!XOR Rdx, Rdx
SetPriorityClass_(GetCurrentProcess_(),#ABOVE_NORMAL_PRIORITY_CLASS)
NOP_bx_cx_ax_dx
NOP_bx_cx_ax_dx
NOP_bx_cx_ax_dx
NOP_bx_cx_ax_dx
!JMP NaturalBladeProcess_Startup
!HLT
!HLT
!NaturalBladeProcess_Startup:
XCHG_bx_cx_ax_dx
XCHG_bx_cx_ax_dx
XCHG_bx_cx_ax_dx
XCHG_bx_cx_ax_dx
MainThread()
End

_________________
My general site & Bug head technology - Ultimate high quality sound player by BASS
My facebook page.


Top
 Profile  
Reply with quote  
 Post subject: Re: BASS.DLL Sound Player for Full Digital Amplifier for Hi-
PostPosted: Fri Feb 22, 2019 10:25 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2004 11:40 pm
Posts: 760
Location: Okazaki, JAPAN
"PureBasicForumTips_BuildExecutable.pb"
Code:
; PureBasicForumTips_BuildExecutable.pb
; Copyright (c) 2017-2019, Hiroyuki Yokota (oryaaaaa)
SetPriorityClass_(GetCurrentProcess_(),#IDLE_PRIORITY_CLASS)

#NBFILE = "PureBasicForumTips_WASAPI_player.pb"
#RCFILE = "PureBasicForumTips_WASAPI_player.rc"
#NBVER = "0.0.0.1"
#NBVER4 = "0,0,0,1"
#NBNAME = "PureBasicForumTips_WASAPI_player"
#NBEXE = "WASAPI_player.exe"
#NBCopyright = "Hiroyuki Yokota (oryaaaaa)"
#NBMAIL = "oryaaaaa@gmail.com"
file$=OpenFileRequester("PureBasic", "*.pb", "*.pb|"+#NBFILE, 0)
dir$ = GetPathPart(file$)
DeleteFile(dir$+"PureBasic.asm")

Select MessageRequester("CHECK", GetFilePart(file$), #PB_MessageRequester_YesNo)
  Case #PB_MessageRequester_No
    End
EndSelect

Global rc_fileno.i
rc_fileno = CreateFile(#PB_Any, dir$+#RCFILE, #PB_Unicode)
If rc_fileno
  WriteStringFormat(rc_fileno, #PB_Unicode)
  WriteStringN(rc_fileno, "", #PB_Unicode)
  WriteStringN(rc_fileno, "1 VERSIONINFO", #PB_Unicode)
  WriteStringN(rc_fileno, "FILEVERSION "+#NBVER4, #PB_Unicode)
  WriteStringN(rc_fileno, "PRODUCTVERSION "+#NBVER4, #PB_Unicode)
  WriteStringN(rc_fileno, "FILEOS 0x40004", #PB_Unicode)
  WriteStringN(rc_fileno, "FILETYPE 0x1", #PB_Unicode)
  WriteStringN(rc_fileno, "{", #PB_Unicode)
  WriteStringN(rc_fileno, "BLOCK "+Chr(34)+"StringFileInfo"+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, "{", #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+"BLOCK "+Chr(34)+"000004B0"+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+"{", #PB_Unicode)
 
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"CompanyName"+Chr(34)+", "+Chr(34)+#NBCopyright+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"ProductName"+Chr(34)+", "+Chr(34)+#NBNAME+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"ProductVersion"+Chr(34)+", "+Chr(34)+#NBVER+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"FileVersion"+Chr(34)+", "+Chr(34)+#NBVER+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"FileDescription"+Chr(34)+", "+Chr(34)+"Music Player for USB-DAC"+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"InternalName"+Chr(34)+", "+Chr(34)+#NBNAME+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"OriginalFilename"+Chr(34)+", "+Chr(34)+#NBEXE+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"LegalCopyright"+Chr(34)+", "+Chr(34)+#NBCopyright+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"LegalTrademarks"+Chr(34)+", "+Chr(34)+#NBCopyright+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"PrivateBuild"+Chr(34)+", "+Chr(34)+#NBFILE+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"SpecialBuild"+Chr(34)+", "+Chr(34)+"%date-% Windows 10"+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"Email"+Chr(34)+", "+Chr(34)+#NBMAIL+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+Chr(9)+"VALUE "+Chr(34)+"Comment"+Chr(34)+", "+Chr(34)+"free software."+Chr(34), #PB_Unicode)
 
  WriteStringN(rc_fileno, Chr(9)+"}", #PB_Unicode)
  WriteStringN(rc_fileno, "}", #PB_Unicode)
  WriteStringN(rc_fileno, "", #PB_Unicode)
  WriteStringN(rc_fileno, "BLOCK "+Chr(34)+"VarFileInfo"+Chr(34), #PB_Unicode)
  WriteStringN(rc_fileno, "{", #PB_Unicode)
  WriteStringN(rc_fileno, Chr(9)+"VALUE "+Chr(34)+"Translation"+Chr(34)+", 0x0000 0x04B0", #PB_Unicode)
  WriteStringN(rc_fileno, "}", #PB_Unicode)
  WriteStringN(rc_fileno, "}", #PB_Unicode)
 
  CloseFile(rc_fileno)
Else
  MessageRequester("ERROR RCFILE", "Don't create RCFILE")
EndIf

Global NewList Buffer.s()
ClearList(Buffer())

If file$ And FileSize(file$)>0
  Compiler = RunProgram(#PB_Compiler_Home+"\Compilers\pbcompiler", Chr(34)+file$+Chr(34)+" /MMX /UNICODE /commented", dir$, #PB_Program_Open | #PB_Program_Read)
  dir$+"PureBasic.asm" 
  ooos.i = 0
  Output$ = "" : Output_1$ = ""
  If Compiler
    While ProgramRunning(Compiler)
      If AvailableProgramOutput(Compiler)
        If ooos>50
          If ooos%2 = 1
            Output_1$ + ReadProgramString(Compiler) + Chr(13)
          Else
            Output_1$ + ReadProgramString(Compiler) + Space(2)
          EndIf
        Else
          If ooos%2 = 1
            Output$ + ReadProgramString(Compiler) + Chr(13)
          Else
            Output$ + ReadProgramString(Compiler) + Space(2)
          EndIf
        EndIf
        ooos + 1
      EndIf
    Wend
    Output$ + Chr(13) + Chr(13)
    Output_1$ + Chr(13) + Chr(13)
    Output$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
    Output_1$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
    CloseProgram(Compiler) ; Close the connection to the program
  EndIf
Else
  MessageRequester("Error!", "There was an error creating the assembly code file.")
EndIf

; End  ;;; If you read PureBasic.asm file.

Delay(3000)
If ReadFile(2, dir$)
  While Eof(2)=0
    AddElement(Buffer())
    Buffer() = ReadString(2)
  Wend
  CloseFile(2)
EndIf

Global NewList InstructionName.s()
ForEach Buffer()
  If FindString(Buffer(), "extrn ")
    AddElement(InstructionName())
    InstructionName() = RemoveString(Buffer(), "extrn ")
  EndIf
  If ListSize(InstructionName())>1
    If Left(Buffer(), 1)=";"
      Break
    EndIf
  EndIf 
Next
ForEach Buffer()
  If Left(Buffer(), 10) = "_Procedure" And Right(Buffer(), 1)=":"
    AddElement(InstructionName())
    InstructionName() = RemoveString(Buffer(), ":")
  EndIf
Next

Macro Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
  AddElement(Buffer()) : Buffer() = "NOP bx"
  AddElement(Buffer()) : Buffer() = "NOP Ebx"
  AddElement(Buffer()) : Buffer() = "NOP cx"
  AddElement(Buffer()) : Buffer() = "NOP Ecx"
  AddElement(Buffer()) : Buffer() = "NOP bp"
  AddElement(Buffer()) : Buffer() = "NOP Ebp"
  AddElement(Buffer()) : Buffer() = "NOP di"
  AddElement(Buffer()) : Buffer() = "NOP Edi"
  AddElement(Buffer()) : Buffer() = "NOP R8w"
  AddElement(Buffer()) : Buffer() = "NOP R8d"
  AddElement(Buffer()) : Buffer() = "NOP R10w"
  AddElement(Buffer()) : Buffer() = "NOP R10d"
  AddElement(Buffer()) : Buffer() = "NOP R12w"
  AddElement(Buffer()) : Buffer() = "NOP R12d"
  AddElement(Buffer()) : Buffer() = "NOP R14w"
  AddElement(Buffer()) : Buffer() = "NOP R14d"
  AddElement(Buffer()) : Buffer() = "NOP ax"
  AddElement(Buffer()) : Buffer() = "NOP Eax"
  AddElement(Buffer()) : Buffer() = "NOP dx"
  AddElement(Buffer()) : Buffer() = "NOP Edx"
  AddElement(Buffer()) : Buffer() = "NOP sp"
  AddElement(Buffer()) : Buffer() = "NOP Esp"
  AddElement(Buffer()) : Buffer() = "NOP si"
  AddElement(Buffer()) : Buffer() = "NOP Esi"
  AddElement(Buffer()) : Buffer() = "NOP R9w"
  AddElement(Buffer()) : Buffer() = "NOP R9d"
  AddElement(Buffer()) : Buffer() = "NOP R11w"
  AddElement(Buffer()) : Buffer() = "NOP R11d"
  AddElement(Buffer()) : Buffer() = "NOP R13w"
  AddElement(Buffer()) : Buffer() = "NOP R13d"
  AddElement(Buffer()) : Buffer() = "NOP R15w"
  AddElement(Buffer()) : Buffer() = "NOP R15d"
EndMacro

Macro Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
  AddElement(Buffer()) : Buffer() = "XCHG bh, bl"
  AddElement(Buffer()) : Buffer() = "XCHG bl, bh"
  AddElement(Buffer()) : Buffer() = "XCHG Ebx, Ebx"
  AddElement(Buffer()) : Buffer() = "XCHG ch, cl"
  AddElement(Buffer()) : Buffer() = "XCHG cl, ch"
  AddElement(Buffer()) : Buffer() = "XCHG Ecx, Ecx"
  AddElement(Buffer()) : Buffer() = "XCHG bp, bp"
  AddElement(Buffer()) : Buffer() = "XCHG Ebp, Ebp"
  AddElement(Buffer()) : Buffer() = "XCHG di, di"
  AddElement(Buffer()) : Buffer() = "XCHG Edi, Edi"
  AddElement(Buffer()) : Buffer() = "XCHG R8w, R8w"
  AddElement(Buffer()) : Buffer() = "XCHG R8d, R8d"
  AddElement(Buffer()) : Buffer() = "XCHG R10w, R10w"
  AddElement(Buffer()) : Buffer() = "XCHG R10d, R10d"
  AddElement(Buffer()) : Buffer() = "XCHG R12w, R12w"
  AddElement(Buffer()) : Buffer() = "XCHG R12d, R12d"
  AddElement(Buffer()) : Buffer() = "XCHG R14w, R14w"
  AddElement(Buffer()) : Buffer() = "XCHG R14d, R14d"
  AddElement(Buffer()) : Buffer() = "XCHG ah, al"
  AddElement(Buffer()) : Buffer() = "XCHG al, ah"
  AddElement(Buffer()) : Buffer() = "XCHG Eax, Eax"
  AddElement(Buffer()) : Buffer() = "XCHG dh, dl"
  AddElement(Buffer()) : Buffer() = "XCHG dl, dh"
  AddElement(Buffer()) : Buffer() = "XCHG Edx, Edx"
  AddElement(Buffer()) : Buffer() = "XCHG sp, sp"
  AddElement(Buffer()) : Buffer() = "XCHG Esp, Esp"
  AddElement(Buffer()) : Buffer() = "XCHG si, si"
  AddElement(Buffer()) : Buffer() = "XCHG Esi, Esi"
  AddElement(Buffer()) : Buffer() = "XCHG R9w, R9w"
  AddElement(Buffer()) : Buffer() = "XCHG R9d, R9d"
  AddElement(Buffer()) : Buffer() = "XCHG R11w, R11w"
  AddElement(Buffer()) : Buffer() = "XCHG R11d, R11d"
  AddElement(Buffer()) : Buffer() = "XCHG R13w, R13w"
  AddElement(Buffer()) : Buffer() = "XCHG R13d, R13d"
  AddElement(Buffer()) : Buffer() = "XCHG R15w, R15w"
  AddElement(Buffer()) : Buffer() = "XCHG R15d, R15d"
EndMacro

ForEach Buffer()
  If Left(Buffer(), 5) = "  RET"
    PreviousElement(Buffer())
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    NextElement(Buffer())
    AddElement(Buffer()) : Buffer() = "JMP PureBasicStart"
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
  EndIf
Next

ForEach Buffer()
  If FindString(Buffer(), "; Procedure")
    If Not FindString(Buffer(), "; ProcedureReturn")
      Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
      Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    EndIf
  EndIf 
Next

Global CodeLoop.i, ReadStr.s

ForEach Buffer()
  If FindString(Buffer(), "PureBasicStart:")
    AddElement(Buffer()) : Buffer() = "WAIT"
    AddElement(Buffer()) : Buffer() = "WAIT"
    For CodeLoop=1 To 512
      AddElement(Buffer()) : Buffer() = "FNOP"
    Next
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    AddElement(Buffer()) : Buffer() = "JMP GateOfBabylon"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP GateOfBabylon"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP PureBasicStart"
    ForEach InstructionName()
      AddElement(Buffer()) : Buffer() = "FNOP"
      AddElement(Buffer()) : Buffer() = "FNOP"
      AddElement(Buffer()) : Buffer() = "JMP "+InstructionName()
    Next
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_END_Finish"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WASAPI_Proc_LOOP_Start"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WASAPI_Proc_LOOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiPorc_Process_A"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiPorc_Process_B"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_EndIf47"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_EndIf48"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_EndIf49"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP FillMemoryNatural_Start"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_NOP_XCHG_A"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_NOP_XCHG_B"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_NOP_XCHG_C"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP WasapiProc_NOP_XCHG_D"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "JMP MainThread_Repeat_Start"
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    For CodeLoop=1 To 66
      AddElement(Buffer()) : Buffer() = "JMP GateOfBabylon_WasapiProc_"+Str(CodeLoop)
      AddElement(Buffer()) : Buffer() = "FNOP"
      AddElement(Buffer()) : Buffer() = "FNOP"
    Next
    AddElement(Buffer()) : Buffer() = "GateOfBabylon:"
    For CodeLoop=1 To 2*1024*1024
      AddElement(Buffer()) : Buffer() = "FNOP"
    Next
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    fileno = ReadFile(#PB_Any, "WASAPI_OnlyMyRailgunProcess_Before.txt", #PB_UTF8)
    If fileno
      ReadStringFormat(fileno)
      While Eof(fileno) = 0
        ReadStr = ReadString(fileno, #PB_UTF8)
        If Not Left(ReadStr, 1)=";"
          AddElement(Buffer()) : Buffer() = ReadStr
        EndIf
      Wend
      CloseFile(fileno)
    Else
      MessageRequester("FILE","ERROR WASAPI_OnlyMyRailgunProcess_Before.txt")
    EndIf
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    fileno = ReadFile(#PB_Any, "WASAPI_Stabilizer_3_MMX.txt", #PB_UTF8)
    If fileno
      ReadStringFormat(fileno)
      While Eof(fileno) = 0
        ReadStr = ReadString(fileno, #PB_UTF8)
        If Not Left(ReadStr, 1)=";"
          AddElement(Buffer()) : Buffer() = ReadStr
        EndIf
      Wend
      CloseFile(fileno)
    Else
      MessageRequester("FILE","ERROR WASAPI_Stabilizer_3_MMX.txt")
    EndIf
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    fileno = ReadFile(#PB_Any, "WASAPI_OnlyMyRailgunProcess_Before.txt", #PB_UTF8)
    If fileno
      ReadStringFormat(fileno)
      While Eof(fileno) = 0
        ReadStr = ReadString(fileno, #PB_UTF8)
        If Not Left(ReadStr, 1)=";"
          AddElement(Buffer()) : Buffer() = ReadStr
        EndIf
      Wend
      CloseFile(fileno)
    Else
      MessageRequester("FILE","ERROR WASAPI_OnlyMyRailgunProcess_Before.txt")
    EndIf
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    fileno = ReadFile(#PB_Any, "WASAPI_Stabilizer_3_MMX.txt", #PB_UTF8)
    If fileno
      ReadStringFormat(fileno)
      While Eof(fileno) = 0
        ReadStr = ReadString(fileno, #PB_UTF8)
        If Not Left(ReadStr, 1)=";"
          AddElement(Buffer()) : Buffer() = ReadStr
        EndIf
      Wend
      CloseFile(fileno)
    Else
      MessageRequester("FILE","ERROR WASAPI_Stabilizer_3_MMX.txt")
    EndIf
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Nop_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    Xchg_bxEbxEcxR8d10d_axEaxEdxR9dR11d
    AddElement(Buffer()) : Buffer() = "XCHG spl, bpl"
    AddElement(Buffer()) : Buffer() = "XCHG Rsp, Rsp"
    AddElement(Buffer()) : Buffer() = "XCHG Rbp, Rbp"
    AddElement(Buffer()) : Buffer() = "XCHG bpl, spl"
    AddElement(Buffer()) : Buffer() = "XCHG Rsp, Rsp"
    AddElement(Buffer()) : Buffer() = "XCHG Rbp, Rbp"
    AddElement(Buffer()) : Buffer() = "XCHG spl, bpl"
    AddElement(Buffer()) : Buffer() = "XCHG Rsp, Rsp"
    AddElement(Buffer()) : Buffer() = "XCHG Rbp, Rbp"
    AddElement(Buffer()) : Buffer() = "XCHG bpl, spl"
    AddElement(Buffer()) : Buffer() = "AddFNOP32_S_PureBasicStart"
    AddFNOP_S_PureBasicStart_Loop:
    NextElement(Buffer())
    If Left(Buffer(), 18) <> "PureBasicStartEND:"
      Goto AddFNOP_S_PureBasicStart_Loop
    EndIf
    Buffer() = "AddFNOP32_E_PureBasicStart"
    Break
  EndIf
Next


Global NS_Find_1.i, NS_Find_2.i, NS_Find_3.i, NS_Find_4.i, NS_Find_5.i
ForEach Buffer()
  NS_Find_1 = FindString(Buffer(), "MOV ")
  If NS_Find_1
    NS_Find_2 = FindString(Buffer(), "[PB_")
    NS_Find_3 = FindString(Buffer(), ",")
    If NS_Find_2>0 And NS_Find_3>0 And NS_Find_2<NS_Find_3
      Buffer() = ReplaceString(Buffer(), "MOV", "MOVNTI")
    EndIf
  EndIf
Next


Global Sub_pos.i, Sub_max.i
ForEach Buffer()
  If FindString(Buffer(), " SUB    rsp,") And Val(StringField(Buffer(), 2, ","))>0
    Sub_pos = 0 : Sub_max =0
    Sub_max = Val(StringField(Buffer(), 2, ","))
    Buffer() = "FNOP"
    For Sub_pos=1 To Sub_max
      AddElement(Buffer()) : Buffer() = "DEC rsp" ; Sub
    Next
    AddElement(Buffer()) : Buffer() = "FNOP"
  EndIf
Next
Global Add_pos.i, Add_max.i
ForEach Buffer()
  If FindString(Buffer(), " ADD    rsp,") And Val(StringField(Buffer(), 2, ","))>0
    Add_max = 0 : Add_pos = 0
    Add_max = Val(StringField(Buffer(), 2, ","))
    Buffer() = "FNOP"
    For Add_pos=1 To Add_max
      AddElement(Buffer()) : Buffer() = "INC rsp" ; Add
    Next
    AddElement(Buffer()) : Buffer() = "FNOP"
  EndIf
Next
ForEach Buffer()
  If FindString(Buffer(), "PUSH ")
    PreviousElement(Buffer())
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    NextElement(Buffer())
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
  EndIf
Next
ForEach Buffer()
  If FindString(Buffer(), "POP ")
    PreviousElement(Buffer())
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
    NextElement(Buffer())
    AddElement(Buffer()) : Buffer() = "FNOP"
    AddElement(Buffer()) : Buffer() = "FNOP"
  EndIf
Next

ForEach Buffer()
  NS_Find_1 = FindString(Buffer(), "MOV ")
  If NS_Find_1
    NS_Find_2 = FindString(Buffer(), "[")
    NS_Find_3 = FindString(Buffer(), ",")
    NS_Find_5 = FindString(LCase(Buffer()), "qword")
    If Not NS_Find_5
      NS_Find_5 = FindString(LCase(Buffer()), "dword")
    EndIf
    NS_Find_4 = FindString(LCase(Buffer()), "a", NS_Find_3)
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "b", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "c", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "d", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "p", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "i", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r8", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r9", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r10", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r11", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r12", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r13", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r14", NS_Find_3)
    EndIf
    If Not NS_Find_4
      NS_Find_4 = FindString(LCase(Buffer()), "r15", NS_Find_3)
    EndIf
    If NS_Find_2>0 And NS_Find_3>0 And NS_Find_2<NS_Find_3 And NS_Find_5>0 And NS_Find_4>0
      Buffer() = ReplaceString(Buffer(), "MOV", "MOVNTI")
    EndIf
  EndIf
Next

;+++ Remove FNOP lines
ForEach Buffer()
  If Left(Buffer(),10) ="AddFNOP_S_"
    AddFNOP_loop:
    NextElement(Buffer())
    If Left(Buffer(), 4) = "FNOP"
      DeleteElement(Buffer())
      Goto AddFNOP_loop
    EndIf
    If Left(Buffer(),10) <> "AddFNOP_E_"
      Goto AddFNOP_loop
    EndIf
  EndIf
Next
;+++ Add FNOPx16
ForEach Buffer()
  If Left(Buffer(),10) ="AddFNOP_S_"
    DeleteElement(Buffer())
    AddFNOP_loop2:
    NextElement(Buffer())
    If FindString(Buffer(), ":")>0 Or Left(Buffer(), 1)=";"
      If Left(Buffer(), 10) <> "AddFNOP_E_"
        Goto AddFNOP_loop2
      EndIf
    EndIf
    If Left(Buffer(),10) <> "AddFNOP_E_"
      For CodeLoop=1 To 16
        AddElement(Buffer()) : Buffer() = "FNOP"
      Next
      Goto AddFNOP_loop2
    EndIf
    DeleteElement(Buffer())
    NextElement(Buffer())
 EndIf
Next
;+++ Add FNOPx32
ForEach Buffer()
  If Left(Buffer(),17) ="WASAPI_Proc_LOOP:"
    For CodeLoop=1 To 32
      AddElement(Buffer()) : Buffer() = "FNOP"
    Next
  EndIf 
Next

;+++ Add FNOPx32
ForEach Buffer()
  If Left(Buffer(),12) ="AddFNOP32_S_"
    DeleteElement(Buffer())
    AddFNOP_loop3:
    NextElement(Buffer())
    If FindString(Buffer(), ":")>0 Or Left(Buffer(), 1)=";"
      If Left(Buffer(), 12) <> "AddFNOP32_E_"
        Goto AddFNOP_loop3
      EndIf
    EndIf
    If Left(Buffer(),12) <> "AddFNOP32_E_"
      For CodeLoop=1 To 32
        AddElement(Buffer()) : Buffer() = "FNOP"
      Next
      Goto AddFNOP_loop3
    EndIf
    DeleteElement(Buffer())
    NextElement(Buffer())
 EndIf
Next

fileno = CreateFile(#PB_Any, dir$)
ForEach Buffer()
  WriteStringN(fileno, Buffer())
Next
FlushFileBuffers(fileno)
CloseFile(fileno)

ClearList(Buffer())
file$ = dir$
dir$ = GetPathPart(file$)

Delay(3000)

Compiler = RunProgram(#PB_Compiler_Home+"\Compilers\pbcompiler", Chr(34)+file$+Chr(34)+" /MMX /UNICODE /REASM /RESOURCE "+Chr(34)+#RCFILE+Chr(34)+" /EXE "+Chr(34)+#NBEXE+Chr(34), dir$, #PB_Program_Open | #PB_Program_Read)
If Compiler
  While ProgramRunning(Compiler)
    If AvailableProgramOutput(Compiler)
      Output2$ + ReadProgramString(Compiler) + Chr(13)
    EndIf
  Wend
  Output2$ + Chr(13) + Chr(13)
  Output2$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
  CloseProgram(Compiler) ; Close the connection to the program
EndIf

MessageRequester("Output", Output$)
MessageRequester("Output2", Output_1$)
MessageRequester("Output", Output2$)

End


Thank you.

_________________
My general site & Bug head technology - Ultimate high quality sound player by BASS
My facebook page.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye