PremierePRO wrote:I have seen many examples of VU meter, but I can not place it in my code, as well as a password code for the software, but as always I can not insert it at the beginning of the code, it works by itself, but when I insert my from the error code after...
* the password for this example is texasinstruments:Code: Select all
InitSound()
UseOGGSoundDecoder()
Enumeration
#Vol_001 = 1
#Vol_002 = 2
#Vol_003 = 3
#Btn_001 = 4
#Btn_002 = 5
#Btn_003 = 6
#Btn_004
#Btn_005
#Win
#Text_
#labelTimer
#masterVolume
EndEnumeration
DataSection
IncludePath "E:\Music\"
s001: IncludeBinary "your1.ogg": End_s001:
s002: IncludeBinary "your2.ogg": End_s002:
s003: IncludeBinary "your3.ogg": End_s003:
EndDataSection
CatchSound(1, ?s001,?End_s001-?s001)
CatchSound(2, ?s002,?End_s002-?s002)
CatchSound(3, ?s003,?End_s003-?s003)
If OpenWindow(#Win, 0, 0, 640, 90, "DEMO", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
;##################
; PASSWORD ROUTINE START
;##################
Define.i tryAgain, tries = 0, authorized = 0
Define.s password, MD5Fpassword = "45aaf3660c8ae47332d334059041e15b" ;replace with your encrypted password
Repeat
password = InputRequester("", "Please enter your password:", "", #PB_InputRequester_Password)
If MD5Fingerprint(@password, StringByteLength(password)) <> MD5Fpassword
tries + 1
If tries > 2
MessageRequester ("Access Denied!", "Allowable tries exceeded. Program shutting down.")
CloseWindow(#Win) : End
EndIf
tryAgain = MessageRequester ("Access Denied!", "You entered an invalid password." +
#CRLF$ + "Try again?", #PB_MessageRequester_YesNo)
If tryAgain = #PB_MessageRequester_No
CloseWindow(#Win) : End
EndIf
Else
authorized = 1
EndIf
Until authorized = 1
;####################
; PASSWORD ROUTINE END
;####################
Dim buttonLabel.s(5)
buttonLabel(1) = "DEMO 1"
buttonLabel(2) = "DEMO 2"
buttonLabel(3) = "DEMO 3"
buttonLabel(4) = "QUIT"
buttonLabel(5) = "STOP"
ButtonGadget(#Btn_001, 0, 0, 160, 25, buttonLabel(1))
ButtonGadget(#Btn_002, 160, 0, 160, 25, buttonLabel(2))
ButtonGadget(#Btn_003, 320, 0, 160, 25, buttonLabel(3))
ButtonGadget(#Btn_004, 480, 45, 160, 45, buttonLabel(4))
ButtonGadget(#Btn_005, 480, 0, 160, 45, buttonLabel(5))
AddWindowTimer(#Win, #labelTimer, 1000)
Define.i L, tbGadget, xPos = 10, initialVolume = 10, volumeSelect
SoundVolume(#PB_All, initialVolume)
For tbGadget = 1 To 3
TrackBarGadget(tbGadget, xPos, 25, 140, 25, 0, 100)
SetGadgetState(tbGadget, initialVolume)
xPos + 160
Next tbGadget
TrackBarGadget(#masterVolume, 10, 50, 460, 30, 0, 100, #PB_TrackBar_Ticks)
SetGadgetState(#masterVolume, initialVolume)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case #masterVolume
SoundVolume(#PB_All, GetGadgetState(#masterVolume))
For volumeSelect = 1 To 3
SoundVolume(volumeSelect, GetGadgetState(volumeSelect))
SetGadgetState(volumeSelect, GetGadgetState(#masterVolume))
Next volumeSelect
Case #Vol_001, #Vol_002, #Vol_003
volumeSelect = EventGadget()
SoundVolume(volumeSelect, GetGadgetState(volumeSelect))
Case #Btn_001, #Btn_002, #Btn_003
buttonSelect = EventGadget()
Select SoundStatus(buttonSelect - 3)
Case #PB_Sound_Stopped
PlaySound(buttonSelect - 3)
SetGadgetText(buttonSelect, buttonLabel(buttonSelect - 3) + " (Playing)")
Case #PB_Sound_Paused
ResumeSound(buttonSelect - 3)
SetGadgetText(buttonSelect, buttonLabel(buttonSelect - 3) + " (Playing)")
Case #PB_Sound_Playing
PauseSound(buttonSelect - 3)
SetGadgetText(buttonSelect, buttonLabel(buttonSelect - 3) + " (Paused)")
EndSelect
Case #Btn_004
End
Case #Btn_005
StopSound(-1)
For L = 1 To 5
SetGadgetText(L + 3, buttonLabel(L))
Next L
EndSelect
Case #PB_Event_Timer
For L = 1 To 3
If SoundStatus(L) = #PB_Sound_Stopped
SetGadgetText(L + 3, buttonLabel(L))
EndIf
Next L
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf
I've inserted a fairly simple password protection into your example, and it uses PureBasic's MD5Fingerprint encryption to obscure the hardcoded string. Please do bear in mind that it is a very simple implementation of program security, and anyone with a reverse debugger would be able to bypass the routine and run the program.
You can use this simple routine to create your own MD5Fingerprint passwords, and paste them into the code above:
Code: Select all
;MD5Fingerprint-encrypted password creator:
password.s = InputRequester("", "Please enter your desired password:", "")
password = MD5Fingerprint(@password, StringByteLength(password))
SetClipboardText(password)
MessageRequester ("MD5Fingerprinting", "Your encrypted password is: " + password + #CRLF$ +
#CRLF$ + "It has also been copied to the clipboard for easy pasting into your code.")
; edit the main code: MD5Fpassword = "the newly generated password should be pasted here"
The implementation of a digital VU meter is a fairly complex process, and requires direct soundcard API calls, and would also not be a cross-platform solution. If you have any working examples, please do post them, and perhaps someone may be able to adapt it for your requirements.