Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Cheat Engine Lua Simple Piano V1.03

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Art
View previous topic :: View next topic  
Author Message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Mon May 25, 2020 7:49 am    Post subject: Cheat Engine Lua Simple Piano V1.03 Reply with quote

Cheat Engine Lua Simple Piano V1.03
Video: https://www.youtube.com/watch?v=ist7zL_fcIM&list=PL1yPHiegVpRqgru6H0J1qgpdQz_0J_u5G&index=2&t=0s
Download: https://www.dosyaupload.com/o6i0


Link

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 25, 2020 11:37 am    Post subject: Reply with quote

Thanks, good job. But unfortunately, no sound when tested on windows 7 64 bit.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Mon May 25, 2020 3:04 pm    Post subject: Reply with quote

Corroder wrote:
Thanks, good job. But unfortunately, no sound when tested on windows 7 64 bit.


It worked for Windows 10 64 bit.
The notes are in the global PlaySound function.
But for "Vocal", the mp3 code may sound different.
The code used is below;

Code:
function initializeMP3Player()
  if initializeMP3Player_done then return true end

local script64bit=[[loadlibrary(winmm.dll)
alloc(SimpleMp3Player,4096)
registersymbol(SimpleMp3Player)

SimpleMp3Player:
lea rsp,[rsp-28]
lea rsi,[rcx+400]

lea rdx,[rcx+300]
mov r8d,80
xor r9d,r9d
call mciSendStringW
mov rcx,rax
mov rdx,rsi
mov r8,200
call mciGetErrorStringW

lea rsp,[rsp+28]
ret]]

local script32bit=[[loadlibrary(winmm.dll)
alloc(SimpleMp3Player,4096)
registersymbol(SimpleMp3Player)

SimpleMp3Player:
push ebp
mov ebp,esp
push ebx

mov ebx,[ebp+8]

sub esp,10
mov [esp],ebx
lea ebx,[ebx+300]
mov [esp+4],ebx
mov [esp+8],80
mov [esp+c],0
call mciSendStringW

mov ebx,[ebp+8]
lea ebx,[ebx+400]

sub esp,0c
mov [esp],eax
mov [esp+0x4],ebx
mov [esp+0x8],200
call mciGetErrorStringW

pop ebx
leave
ret 004]]

  if cheatEngineIs64Bit() then script = script64bit else script = script32bit end

  if autoAssemble(script,true)
  then
    initializeMP3Player_done = true
    MP3PlayerCommandMS = createMemoryStream()
    MP3PlayerCommandMS.Size = 2048
    return true
  else
    return false
  end
end

function MP3PlayerSendCommand(command)
  writeStringLocal(MP3PlayerCommandMS.Memory, command, true)
  writeBytesLocal (MP3PlayerCommandMS.Memory+2*#command, 0, 0)
  executeCodeLocal('SimpleMp3Player',MP3PlayerCommandMS.Memory)
  return readStringLocal(MP3PlayerCommandMS.Memory+1024,512,true),
         readStringLocal(MP3PlayerCommandMS.Memory+768,128,true)
end

function playMP3(path)
  if not initializeMP3Player() then return end

  MP3PlayerSendCommand('resume MediaFile')--('close MediaFile')
  MP3PlayerSendCommand( string.format('open "%s" type mpegvideo alias MediaFile',path) )
  MP3PlayerSendCommand('play MediaFile')
end
---------------------------------------------------
---------------------------------------------------1

function play1(song1)
 if not initializeMP3Player() then return end
 local fileName
 fileName = song1
 MP3PlayerSendCommand("open "..fileName.." type mpegvideo alias FirstSound", 0, 0, 0)
 MP3PlayerSendCommand("play FirstSound", 0, 0, 0)
 end

function play2(song2)
 if not initializeMP3Player() then return end
 local fileName
 fileName = song2
 MP3PlayerSendCommand("open "..fileName.." type mpegvideo alias SecondSound", 0, 0, 0)
 MP3PlayerSendCommand("play SecondSound", 0, 0, 0)
 end
--etc. ..



PlaySound(mp3) ;

Code:
if oldcreateMemoryStream==nil then oldcreateMemoryStream = createMemoryStream end
function createMemoryStream()
  local obj = oldcreateMemoryStream()
  local oldwrite=obj.write

  obj.write = function (t,n)  -- override default write
              local count=0
              for _,v in ipairs(t) do
                if count==n then break end
                oldwrite({v},1)
                count=count+1
              end
            end

  obj.writeDword = function (v) obj.write(dwordToByteTable(v)) end
  obj.writeWord = function (v) obj.write(wordToByteTable(v)) end

  return obj
end


--convertMP3ToRIFFMP3(stream)
function convertMP3ToRIFFMP3(stream)
  local riffmp3 = createMemoryStream()

  local header = {
  0x46464952,0x00000000,0x45564157,0x20746D66,0x0000001E,0x00020055,
  0x0000AC44,0x00000000,0x00000001,0x0001000C,0x00000002,0x00010001,
  0x61660571,0x00047463,0x2FF80000,0x61640014
  } -- default is 44100Hz , Stereo

  local rateTable = {[0] = {11025,12000,8000},   --mpeg ver2.5
                     [2] = {22050,24000,16000},  --mpeg ver2
                     [3] = {44100,48000,32000}}  --mpeg ver1

  local bitrateTable = {[1]={32,64,96,128,160,192,224,256,288,320,352,384,416,448},
                        [2]={32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384},
                        [3]={32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320},
                        [4]={32,48,56, 64, 80, 96,112,128,144,160,176,192,224,256},
                        [5]={ 8,16,24, 32, 40, 48, 56, 64, 80, 96,112,128,144,160}}

  for i,v in ipairs(header) do riffmp3.writeDword(v) end
  riffmp3.writeWord(0x6174)
  riffmp3.writeDword(stream.Size)

  stream.Position = 0
  riffmp3.copyFrom(stream,stream.Size)
  riffmp3.Position = 0x4; riffmp3.writeDword(stream.Size+0x24)

  stream.Position = 0
  local chunk = stream.read( math.min(65536,stream.Size) )
  local DWORD = byteTableToDword( {chunk[4],chunk[3],chunk[2],chunk[1]} )

--[[ looking for MPEG Audio frame header
  bits 31 through 21 must all be set; Frame sync
  bit 18 and bit 17, at least one set; Layer
  bits 15 through 12, at least one clear; bitrate index
  bits 11 through 10, at least one clear; sample rate index
  also use above to find a header

  bit 20 and 19; MPEG audio id
  bit 7 and 6; channel mode
  ]]
  local i=0x1
  while (i<=#chunk-4) do


    if (bAnd(DWORD,0xFFE00000)==0xFFE00000) and
       (bAnd(DWORD,0x60000)~=0) and
       (bAnd(DWORD,0xF000)~=0xF000) and
       (bAnd(DWORD,0xC00)~=0xC00)
    then
       --probably MPEG Audio Layer I/II/III frame header
       local channels    =(bAnd(bShr(DWORD, 6), 3) == 3) and 1 or 2
       local layer       = 3 - bAnd(bShr(DWORD,17), 3) + 1;
       local mpegaudioid = bAnd(bShr(DWORD,19), 3)

       local rateindex   = bAnd(bShr(DWORD,10), 3)
       local bitrateindex= bAnd(bShr(DWORD,12),15)

       local samplerate  = rateTable[mpegaudioid][rateindex+1]

       local row
       if     mpegaudioid==3 then row=layer -- mpeg ver1
       elseif layer==1       then row=4     -- mpeg ver2 and ver2.5, Layer 1
       else                       row=5     -- mpeg ver2 and ver2.5, Layer 2 and 3
       end

       local bitrate = bitrateTable[row][bitrateindex]

       riffmp3.Position = 0x16;
       riffmp3.writeWord(channels)
       riffmp3.writeDword(samplerate)
       riffmp3.writeDword(math.floor(bitrate*1000/8))
       break
    end

    if (bAnd(DWORD,0xFFFFFF00)==0x49443300) and
       (bAnd(DWORD,0xFF)<0xFF)
    --ID3 tag found
    then
       local size = bOr(bShl(chunk[i+6],7),chunk[i+7])
             size = bOr(bShl(size,7),chunk[i+8])
             size = bOr(bShl(size,7),chunk[i+9])
             i=i+size
    end


    DWORD = bOr( bShl(DWORD,8) , chunk[i+4] ) % 0x100000000
    i=i+1
  end
  chunk = nil



  riffmp3.Position = riffmp3.Size - 1
  return riffmp3
end

function sound_prepare(track)
  if track==nil then return nil end
  if knownStreams==nil then knownStreams = {} end

  local stream,streamID

  -- set stream variable
  if type(track)=='string' then
    if knownStreams[track]~=nil then return track end -- check name as StreamID
    if findTableFile(track) then stream=findTableFile(track).Stream else return nil end
  elseif track.ClassName=='TMemoryStream' then
    stream=track else stream=track.Stream
  end

  streamID=userDataToInteger(stream)
  if knownStreams[streamID]~=nil then return streamID end

  stream.Position = 0
  if table.concat(stream.read(4),'-')=='82-73-70-70' then
    -- RIFF format (wave file, etc.)
    knownStreams[streamID]=stream
  else
    -- probably mp3 file, converting
    -- convertMP3ToRIFFMP3(stream)
    local riffmp3 = convertMP3ToRIFFMP3(stream)
    knownStreams[streamID]=riffmp3
  end

  -- if string, use it as streamID too
  if type(track)=='string' then knownStreams[track]=knownStreams[streamID] end

  return streamID
end


if oldplaySound==nil then oldplaySound=playSound end

function playSound(track, ...)
  local ID=sound_prepare(track)
  if ID then oldplaySound(knownStreams[ID], ...)
  else print('track not found') end
end


I think it can be edited for Windows 7. Wink

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 25, 2020 4:41 pm    Post subject: Reply with quote

Yes, I know the scripts. But you need to warn the users for this line:

Code:
local script64bit=[[loadlibrary(winmm.dll)


The above code will work on some computers. Not all.

Each user have different windows configurations, so if you want your project able to use your app. then need to fix something like this:

Code:
-- 64 bit
script64bit=[[loadlibrary(C:\Windows\SysWOW64\winmm.dll)...  -- or loadlibrary(C:\Windows\System32\winmm.dll)

-- and for 32bit
script32bit=[[loadlibrary(C:\Windows\System32\winmm.dll)... 

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Art All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites