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 


May I ask questions related to bass.ll

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 194

PostPosted: Mon Nov 04, 2024 4:23 am    Post subject: May I ask questions related to bass.ll Reply with quote

As shown in the figure, I would like to call the following function:
Can you help me check? It always draws a straight line.
Code:
local BASS_STREAM_DECODE = 0x200000
local mp3File='C:\\Users\\Administrator\\Desktop\\Test.mp3'
if not bass.BASS_Init(-1, 44100, 0, 0, nil).vDword then
    error("BASS Erro")
end
local hs2 = bass.BASS_StreamCreateFile(false, Utf8ToAnsi(mp3File), 0, 0, BASS_STREAM_DECODE).vPointer


      bass.BASS_ChannelPlay(hs2, 0)--play music
      local byteLength=bass.BASS_ChannelGetLength(hs2,0).vPointer
      local time=bass.BASS_ChannelBytes2Seconds(hs2,byteLength).vDouble
      len3=os.date('%M:%S',math.floor(time))
     
    dataLength = math.floor(time * 50 + 1)
Data={}
for i = 1,dataLength do
  Data[i]={left=0, right=0}
end
for i = 1, dataLength do
    local level = bass.BASS_ChannelGetLevel(hs2, 0).vDword
    Data[i].left = (level & 0xFFFF)/32768.0
    Data[i].right= ((level >> 16) & 0xFFFF)/32768.0
end

function Trunc(x)
    if x >= 0 then
        return math.floor(x)
    else
        return math.ceil(x)
    end
end

function Draw(control)
    if pi then pi.Destroy() end   
    pi = createPicture()
    --pi.Bitmap.Canvas.Clear()
    cc.Repaint()
    local ww=#Data
    local hh=128
    local ch=hh/2
    --pi.Bitmap.Width=ww
    --pi.Bitmap.Height=hh
    cc.Canvas.FillRect(0,0,ww,hh)
    cc.Canvas.Pen.Color=0xff
    for i = 1, #Data do 
        local L = Data[i].left
        local R = Data[i].right
        local y1 = ch - Trunc(L*32768 * ch)
        local y2 = ch + Trunc(R*32768 * ch)
        --print(y1,y2)
        --y1 = math.max(0, math.min(y1, hh))
        --y2 = math.max(0, math.min(y2, hh))
        --if i<=700 then print(yZ) end
        cc.Canvas.LineTo(i, y1)
        cc.Canvas.MoveTo(i, y2)
    end
    cc.getCanvas().draw(0,0,pi.getBitmap())
end
Draw(UDF1.Image)



image.png
 Description:
 Filesize:  10.62 KB
 Viewed:  605 Time(s)

image.png


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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