#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Icon=C:\Windows\beep1.ico #AutoIt3Wrapper_Outfile=BeepSongEditor.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Description=Create Beep Songs #AutoIt3Wrapper_Res_Fileversion=1.0.2.4 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=P #AutoIt3Wrapper_Res_LegalCopyright=Copyright © wakillon 2012 #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time% #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Region ;************ Includes ************ #Include #Include #Include #Include #Include #Include #include #include #Include #Include #Include #Include #EndRegion ;************ Includes ************ #cs ---------------------------------------------------------------------------- AutoIt Version : 3.3.8.1 Author : wakillon Script Function : Create easily Beep Songs and mp3 ringtones. #ce ---------------------------------------------------------------------------- If Not _Singleton ( @ScriptName, 1 ) Then Exit Opt ( 'MustDeclareVars', 1 ) Opt ( 'GUIResizeMode', $GUI_DOCKLEFT + $GUI_DOCKWIDTH ) Opt ( 'GUICloseOnESC', 0 ) Opt ( 'GUIOnEventMode', 1 ) Opt ( 'TrayIconHide', 0 ) Opt ( 'TrayOnEventMode', 1 ) Opt ( 'TrayMenuMode', 1 ) #Region ------ Global Variables ------------------------------ Global $_EditorLength = ( @DesktopWidth -153 ) / 20 Global $_NotesNumber = 25 Global $_EditorLengthMin = 32 Global $_Notes[$_NotesNumber][$_EditorLength][2], $_StartLab[$_EditorLength] Global $_Notation[$_NotesNumber+1] Global $_Frequency[$_NotesNumber+1] = [1046.5,987.767,932.328,880,830.609,783.991,739.989,698.456,659.255,622.254,587.33, _ 554.365,523.251,493.883,466.164,440,415.305,391.995,369.994,349.228,329.628,311.127,293.665,277.183,261.626] Global $_BeepDuration[$_EditorLength], $_BeepDurationLab[$_EditorLength] Global $_BeepDurationDef = 500, $_IniFilePath, $_GreenLine, $_Flash = False, $_StartFlashLab, $_Index, $_EnterDurationLab, $_LastIniLoad, $_Resize, $_Playing, $_Ask = 1, $_Exit Global $_Gui, $_ButtonPlay, $hButtonPlay, $_ButtonLoad, $_ButtonSave, $_ButtonClear, $_ButtonConvert, $_ButtonSet, $_ButtonUp, $_ButtonDown, $_ButtonInsert, $_ButtonDeleteColumn Global $_ButtonSetRecordDevice, $_ButtonRecord, $_SliderTempo, $hSliderTempo, $_LabTempo, $_CheckLoop, $_RecordDevice, $_GuiChild1, $_RecordInput, $_Radio Global $_GuiChild2, $_Radio1, $_Radio2, $_Radio3, $_Input1, $_Input2, $_Input3, $_EnableCheckForUpdates, $_UpdateLink Global $_TopicItem, $_OnTopItem, $_UpdateItem, $_MinimizeItem, $_AboutItem, $_ExitItem, $_ChangeDirItem, $_OutputDirItem Global $_RegKeySettings = 'HKCU\Software\BeepSongEditor\Settings' Global $_SoftTitle = 'BeepSongEditor v' & _GetScriptVersion ( ) & ' © wakillon 2012' Global $_OutputDirPath = RegRead ( $_RegKeySettings, 'OutputDir' ) Global $_LabelColorDef = 0xBD821C Global $_Timer = _NowCalc ( ), $_EditorNotesNumber, $_EditorNotesNumberOld, $_TimeLabel Global $_TempDir = @TempDir & '\BSE' #EndRegion --- Global Variables ------------------------------ #Region ------ Init ------------------------------ If _FileMissing ( ) Then _FileInstall ( ) _BeepSongEditorSetNotation ( ) If @DesktopHeight < 605 Then ; for netbook. $_NotesNumber = 21 ReDim $_Frequency[$_NotesNumber+1] ReDim $_Notation[$_NotesNumber+1] EndIf _TrayMenuSet ( ) If $_EnableCheckForUpdates Then _LookForUpdate ( ) _GuiMain ( ) $_StartFlashLab = $_StartLab[0] AdlibRegister ( '_GuiCtrlLabelStartFlash', 1000 ) _StartDSBeep ( ) #EndRegion --- Init ------------------------------ #Region ------ Main Loop ------------------------------ While 1 If $_Playing Then TrayItemSetState ( $_AboutItem, $TRAY_DISABLE ) _BeepSongEditorPlay ( ) TrayItemSetState ( $_AboutItem, $TRAY_ENABLE ) EndIf If $_EnterDurationLab Then Local $_InputBox = InputBox ( $_SoftTitle, @CRLF & 'Enter duration for ' & $_Index + 1 & '° Note' & @CRLF & '[ 100 - 2000 ms] ', '', '', 330, 150, Default, Default, 0, $_Gui ) If Not @error And StringIsDigit ( $_InputBox ) Then $_BeepDuration[$_Index] = _Min ( _Max ( 100, Number ( $_InputBox ) ), 2000 ) GUICtrlSetData ( $_EnterDurationLab, $_BeepDuration[$_Index] ) EndIf $_EnterDurationLab = 0 $_Index = 0 EndIf Local $_NowCalc = _NowCalc ( ) If _DateDiff ( 's', $_Timer, $_NowCalc ) >= 1 And Not _IsPressed ( '01' ) Then Local $_WinPos = WinGetPos ( $_Gui ) If Not @error Then $_EditorNotesNumber = _BeepSongEditorGetVisibleNotesCapacity ( ) If $_EditorNotesNumberOld <> $_EditorNotesNumber Or $_Resize Then WinMove ( $_Gui, '', _Max ( $_WinPos[0]- ( ( $_EditorNotesNumber*20 +153 ) - $_WinPos[2] ), 0 ), Default, $_EditorNotesNumber*20 +153 ) For $j = $_EditorLengthMin To $_EditorNotesNumber -1 If $j <= UBound ( $_StartLab ) -1 Then GUICtrlSetState ( $_StartLab[$j], $GUI_SHOW + $GUI_ENABLE ) GUICtrlSetState ( $_BeepDurationLab[$j], $GUI_SHOW + $GUI_ENABLE ) EndIf Next $_Resize = 0 $_EditorNotesNumberOld = $_EditorNotesNumber EndIf EndIf If _IsMinimized ( $_Gui ) Then TrayItemSetText ( $_MinimizeItem, 'Restore Window' ) GUISetState ( @SW_HIDE, $_Gui ) EndIf $_Timer = $_NowCalc EndIf If $_Exit Then _Exit ( ) Sleep ( 100 ) WEnd #EndRegion --- Main Loop ------------------------------ Func _About ( ) TrayItemSetState ( $_AboutItem, $TRAY_UNCHECKED ) TrayItemSetState ( $_AboutItem, $TRAY_DISABLE ) Local $_AboutText = @CRLF & 'Informations / Help' & @CRLF & @CRLF & $_SoftTitle & @CRLF & @CRLF _ & 'Beep Party is back !!!' & @CRLF & @CRLF _ & 'Now you can easily create Beep Songs without being musician !' & @CRLF _ & 'Simply set a note by a click and an other on it for remove it.' & @CRLF _ & 'The flashing green triangle indicate the first note to play ( even in loop )' & @CRLF _ & 'Click on another column number for change it.' & @CRLF _ & "Note's or silence's duration are indicate in the bottom of each column" & @CRLF _ & 'Click on it for enter a new value, or use "Set All Durations"' & @CRLF _ & 'button for access to differents durations operations.' & @CRLF _ & 'You can save to a ini file.(notes, duration and tempo are saved)' & @CRLF _ & 'if you want to keep a silence at the end, set duration different of ' & $_BeepDurationDef & @CRLF _ & 'With "Save To Au3" button you can save to AutoIt classic beep format' & @CRLF _ & 'or if you hold Left Shift key, you can save to DSBeep Au3 format.' & @CRLF _ & 'In this both cases tempo and repeat mode are saved.' & @CRLF _ & '4 buttons with arrows permit some handy operations :' & @CRLF _ & @TAB & '1 : Shift editor content to one line up' & @CRLF _ & @TAB & '2 : Shift editor content to one line down' & @CRLF _ & @TAB & '3 : Insert a note ( shift to Right of the right part )' & @CRLF _ & @TAB & '4 : Remove a column ( shift to Left of the right part )' & @CRLF _ & '"Set Rec Dev" button permit to select the Record device.' & @CRLF _ & '"Stereo Mix" is recommended instead of microphone, but some times' & @CRLF _ & 'it can not be found or enabled.(depends of your PC)' & @CRLF & @CRLF _ & 'The "Record" button save your BeepSong to mp3 file as a ringtone.' & @CRLF _ & 'You can use repeat mode and modify tempo while recording.' & @CRLF _ & 'Record stop when playback stop ( if song is finished or you click on "Stop" )' & @CRLF _ & 'Editor can be resized for have more place.( depends of your Screen Width )' & @CRLF _ & 'Click on Tempo label for Reset Tempo to 1.' & @CRLF _ & 'Playback stop if there is 2 empty columns.' & @CRLF _ & 'Double click on tray icon for restore/minimize Gui.' & @CRLF _ & 'See Tray menu for options.' & @CRLF & @CRLF _ & 'Thanks to AutoIt Community.' & @CRLF & @CRLF _ & 'wakillon.' MsgBox ( 262144+4096+64, 'About', $_AboutText ) TrayItemSetState ( $_AboutItem, $TRAY_ENABLE ) EndFunc ;==> _About ( ) Func _AccessToSoundRecordingTab ( ) Run ( 'rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,1' ) _GuiChildClose ( ) EndFunc ;==> _AccessToSoundRecordingTab ( ) Func _BeepSongEditorClear ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return If $_Ask And MsgBox ( 262144+4+4096+48, 'Confirm', @CRLF & 'Are you sure ' & @CRLF & @CRLF & 'to Clear BeepSong Editor ?' & @CRLF ) <> 6 Then Return GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) For $j = 0 To $_EditorLength -1 For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then $_Notes[$i][$j][1] = False GUICtrlSetData ( $_Notes[$i][$j][0], '' ) $_BeepDuration[$j] = $_BeepDurationDef GUICtrlSetData ( $_BeepDurationLab[$j], $_BeepDuration[$j] ) EndIf Next Next WinSetTitle ( $_Gui, '', $_SoftTitle ) GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) EndFunc ;==> _BeepSongEditorClear ( ) Func _BeepSongEditorConvertToAu3 ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return If _IsPressed ( '10' ) Then ; 10 = Left SHIFT key. _BeepSongEditorConvertToDSBeepAu3 ( ) Return EndIf GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) Local $_Au3Code, $_var, $_InputBox Local $_Loop = _GetCheckState ( $_Gui, $_CheckLoop ) If $_Loop Then $_InputBox = InputBox ( $_SoftTitle, 'Repeat is Checked,' & @CRLF & 'Enter Loops Number you want.' & @CRLF, '', '', 330, 150, Default, Default, 0, $_Gui ) If @error Or Not StringIsDigit ( $_InputBox ) Then MsgBox ( 262144+4096+16, 'error', @CRLF & 'No valid value was entered !' & @CRLF & @CRLF, 4 ) Return EndIf $_Au3Code &= 'Global $i' & @CRLF & 'Do' & @CRLF & @TAB & '$i += 1' & @CRLF EndIf For $j = 0 To $_EditorLength -1 $_var = 0 For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then If $_Loop Then $_Au3Code &= @TAB $_Au3Code &= 'Beep ( ' & $_Frequency[$i] & ', ' & $_BeepDuration[$j] & ' )' & @CRLF Else $_var +=1 EndIf Next If $_var = $_NotesNumber And $_BeepDuration[$j] Then If $_Loop Then $_Au3Code &= @TAB $_Au3Code &= 'Sleep ( ' & $_BeepDuration[$j] & ' ) ' & @CRLF EndIf Next If StringInStr ( $_Au3Code, 'Beep' ) Then Local $_StringSplit = StringSplit ( StringStripWS ( $_Au3Code, 2 ), @CRLF, 1 ) For $_I = UBound ( $_StringSplit ) -1 To 1 Step -1 If StringInStr ( $_StringSplit[$_I], 'sleep' ) Then If $_Loop Then If $_I > 1 And StringInStr ( $_StringSplit[$_I-1], 'sleep' ) Then _ArrayDelete ( $_StringSplit, $_I ) Else _ArrayDelete ( $_StringSplit, $_I ) EndIf Else ExitLoop EndIf Next $_Au3Code = _ArrayToString ( $_StringSplit, @CRLF, 1 ) If $_Loop Then $_Au3Code &= @CRLF & 'Until $i = ' & $_InputBox ClipPut ( $_Au3Code ) MsgBox ( 262144+4096+64, 'Success', @CRLF & 'Beep Song in Classic au3 Code format' & @CRLF & @CRLF & 'is now copied to the clipboard !' & @CRLF, 5 ) Else MsgBox ( 262144+4096+16, 'Failed', @CRLF & 'There is no notes in editor !' & @CRLF & @CRLF, 5 ) EndIf GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) EndFunc ;==> _BeepSongEditorConvertToAu3 ( ) Func _BeepSongEditorConvertToDSBeepAu3 ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) Local $_Tempo = GUICtrlRead ( $_SliderTempo )/100 $_Tempo = _Min ( _Max ( 0.2, Number ( $_Tempo ) ), 4 ) Local $_Au3Code = '#include ' & @CRLF & @CRLF & 'Global $_Tempo = ' & $_Tempo & @CRLF & '_StartDSBeep ( )' & @CRLF, $_var, $_InputBox Local $_Loop = _GetCheckState ( $_Gui, $_CheckLoop ) If $_Loop Then $_InputBox = InputBox ( $_SoftTitle, 'Repeat is Checked,' & @CRLF & 'Enter Loops Number you want.' & @CRLF, '', '', 330, 150, Default, Default, 0, $_Gui ) If @error Or Not StringIsDigit ( $_InputBox ) Then MsgBox ( 262144+4096+16, 'error', @CRLF & 'No valid value was entered !' & @CRLF & @CRLF, 4 ) Return EndIf $_Au3Code &= 'Global $i' & @CRLF & 'Do' & @CRLF & @TAB & '$i += 1' & @CRLF EndIf For $j = 0 To $_EditorLength -1 $_var = 0 For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then If $_Loop Then $_Au3Code &= @TAB $_Au3Code &= '_Beep ( ' & $_NotesNumber - $i & ', 3, ' & $_BeepDuration[$j] & ', 1, $_Tempo )' & @CRLF Else $_var +=1 EndIf Next If $_var = $_NotesNumber And $_BeepDuration[$j] Then If $_Loop Then $_Au3Code &= @TAB $_Au3Code &= 'Sleep ( ' & $_BeepDuration[$j] & ' / $_Tempo ) ' & @CRLF EndIf Next If StringInStr ( $_Au3Code, 'Beep' ) Then Local $_StringSplit = StringSplit ( StringStripWS ( $_Au3Code, 2 ), @CRLF, 1 ) For $_I = UBound ( $_StringSplit ) -1 To 1 Step -1 If StringInStr ( $_StringSplit[$_I], 'sleep' ) Then If $_Loop Then If $_I > 1 And StringInStr ( $_StringSplit[$_I-1], 'sleep' ) Then _ArrayDelete ( $_StringSplit, $_I ) Else _ArrayDelete ( $_StringSplit, $_I ) EndIf Else ExitLoop EndIf Next $_Au3Code = _ArrayToString ( $_StringSplit, @CRLF, 1 ) If $_Loop Then $_Au3Code &= @CRLF & 'Until $i = ' & $_InputBox $_Au3Code &= @CRLF & '_StopDSBeep ( )' ClipPut ( $_Au3Code ) MsgBox ( 262144+4096+64, 'Success', @CRLF & 'Beep Song in DSBeep au3 Code format' & @CRLF & @CRLF & 'is now copied to the clipboard !' & @CRLF, 5 ) Else MsgBox ( 262144+4096+16, 'Failed', @CRLF & 'There is no notes in editor !' & @CRLF & @CRLF, 5 ) EndIf GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) EndFunc ;==> _BeepSongEditorConvertToDSBeepAu3 ( ) Func _BeepSongEditorDeleteColumn ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return Local $_InputBox = InputBox ( $_SoftTitle, 'Enter Column Number you want Delete.' & @CRLF & 'The deletion will cause the shift to left of all notes placed on his right side.' & @CRLF, '', '', 330, 150, Default, Default, 0, $_Gui ) If Not @error And StringIsDigit ( $_InputBox ) Then GUISetState ( @SW_LOCK, $_Gui ) For $j = $_InputBox -1 To UBound ( $_Notes, 2 ) -1 If $j+1 <= UBound ( $_Notes, 2 ) -1 Then $_BeepDuration[$j] = $_BeepDuration[$j+1] GUICtrlSetData ( $_BeepDurationLab[$j], $_BeepDuration[$j] ) EndIf For $i = $_NotesNumber -1 To 0 Step -1 $_Notes[$i][$j][1] = False GUICtrlSetData ( $_Notes[$i][$j][0], '' ) If $j+1 <= UBound ( $_Notes, 2 ) -1 Then $_Notes[$i][$j][1] = $_Notes[$i][$j+1][1] $_Notes[$i][$j+1][1] = False EndIf Next Next GUISetState ( @SW_UNLOCK, $_Gui ) _BeepSongEditorSetNotes ( ) EndIf EndFunc ;==> _BeepSongEditorDeleteColumn ( ) Func _BeepSongEditorEditIni ( ) If $_Playing Then Return Local $_LastPath = RegRead ( $_RegKeySettings, 'LastPath' ), $_SongLength, $_WinPos If Not FileExists ( $_LastPath ) Then $_LastPath = @DesktopDir $_IniFilePath = FileOpenDialog ( 'Edit ini file', $_LastPath, '(*.ini)', 1+2, '', $_Gui ) If Not @error And FileExists ( $_IniFilePath ) Then Run ( 'notepad ' & $_IniFilePath ) EndFunc ;==> _BeepSongEditorEditIni ( ) Func _BeepSongEditorGetConnectedRecordDeviceListNames ( ) Local $_I = 0, $_DeviceInfo, $_Rec[1] _BASS_STARTUP ( $_TempDir & '\Bass.dll' ) While 1 $_DeviceInfo = _BASS_RecordGetDeviceInfo ( $_I ) If @error Then ExitLoop _ArrayAdd ( $_Rec, $_DeviceInfo[0] ) $_I +=1 WEnd _ArrayDelete ( $_Rec, 0 ) _BASS_Free ( ) Return $_Rec EndFunc ;==> _BeepSongEditorGetConnectedRecordDeviceListNames ( ) Func _BeepSongEditorGetVisibleNotesCapacity ( ) Local $_WinPos = WinGetPos ( $_Gui ) If Not @error Then Return Floor ( ( $_WinPos[2] -153 ) / 20 ) EndFunc ;==> _BeepSongEditorGetVisibleNotesCapacity ( ) Func _BeepSongEditorInsertNote ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return Local $_InputBox = InputBox ( $_SoftTitle, 'Enter Column Number where you want Insert a Note.' & @CRLF & 'The insertion will cause the shift to right of all notes placed on his right side.' & @CRLF, '', '', 330, 150, Default, Default, 0, $_Gui ) If Not @error And StringIsDigit ( $_InputBox ) Then GUISetState ( @SW_LOCK, $_Gui ) For $j = Ceiling ( $_EditorLength ) -1 To $_InputBox -1 Step -1 If $j+1 <= UBound ( $_Notes, 2 ) -1 Then $_BeepDuration[$j+1] = $_BeepDuration[$j] GUICtrlSetData ( $_BeepDurationLab[$j+1], $_BeepDuration[$j+1] ) EndIf For $i = $_NotesNumber -1 To 0 Step -1 If $j+1 <= UBound ( $_Notes, 2 ) -1 Then $_Notes[$i][$j+1][1] = $_Notes[$i][$j][1] $_Notes[$i][$j][1] = False GUICtrlSetData ( $_Notes[$i][$j][0], '' ) If $j = $_InputBox -1 Then $_Notes[$i][$j][1] = False EndIf Next Next GUISetState ( @SW_UNLOCK, $_Gui ) _BeepSongEditorSetNotes ( ) EndIf EndFunc ;==> _BeepSongEditorInsertNote ( ) Func _BeepSongEditorIntro ( ) _Beep ( 25, 3, 350, 1, 1 ) _Beep ( 21, 3, 150, 1, 1 ) _Beep ( 21, 3, 150, 1, 1 ) _Beep ( 20, 3, 250, 1, 1 ) _Beep ( 21, 3, 550, 1, 1 ) EndFunc ;==> _BeepSongEditorIntro ( ) Func _BeepSongEditorIsEmpty ( ) For $j = 0 To $_EditorLength -1 For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then Return 0 Next Next Return 1 EndFunc ;==> _BeepSongEditorIsEmpty ( ) Func _BeepSongEditorLoadIni ( ) If $_Playing Then Return _BeepSongEditorResetTempo ( ) Local $_LastPath = RegRead ( $_RegKeySettings, 'LastPath' ), $_SongLength, $_WinPos, $_Color, $Value, $_Var4, $_Tempo If Not FileExists ( $_LastPath ) Then $_LastPath = @DesktopDir $_IniFilePath = FileOpenDialog ( 'Load ini file', $_LastPath, '(*.ini)', 1+2, 'BeepSong', $_Gui ) If Not @error And FileExists ( $_IniFilePath ) Then GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) RegWrite ( $_RegKeySettings, 'LastPath', 'REG_SZ', _GetParentFolderPathByFullPath ( $_IniFilePath ) ) $_Ask = 0 If Not _BeepSongEditorIsEmpty ( ) Then _BeepSongEditorClear ( ) $_Ask = 1 $_LastIniLoad = _GetFullNameByFullPath ( $_IniFilePath ) WinSetTitle ( $_Gui, '', $_SoftTitle & ' - ' & $_LastIniLoad ) GUISetState ( @SW_LOCK, $_Gui ) For $j = 0 To $_EditorLength -1 $_BeepDuration[$j] = IniRead ( $_IniFilePath, 'LONG', $j + 1, $_BeepDurationDef ) GUICtrlSetData ( $_BeepDurationLab[$j], $_BeepDuration[$j] ) $Value = Number ( IniRead ( $_IniFilePath, 'NOTE', $j + 1, 0 ) ) For $i = 0 To $_NotesNumber -1 $_Notes[$i][$j][1] = False If $Value <> 0 Then $_Color = _SetColorByParity ( $j ) GUICtrlSetColor ( $_Notes[$i][$j][0], $_Color ) GUICtrlSetData ( $_Notes[$Value-1][$j][0], ChrW ( 0x266A ) ) ; 0x266B $_Notes[$Value-1 ][$j][1] = True EndIf Next Next Else Return EndIf $_Tempo = Number ( IniRead ( $_IniFilePath, 'Tempo', 1, 1 ) ) If $_Tempo <> '' Then GUICtrlSetData ( $_SliderTempo, $_Tempo*100 ) GUICtrlSetData ( $_LabTempo, 'Tempo : ' & $_Tempo ) EndIf StringReplace ( FileRead ( $_IniFilePath ), '=', '=' ) If Not @error Then $_SongLength = @extended/2 $_WinPos = WinGetPos ( $_Gui, '' ) If Not @error Then $_Var4 = _BeepSongEditorGetVisibleNotesCapacity ( ) If $_SongLength > $_Var4 Then WinMove ( $_Gui, '', _Max ( $_WinPos[0]- ( ( $_SongLength*20 +153 ) - $_WinPos[2] ), 0 ), Default, $_SongLength*20 +153 ) For $j = $_EditorLengthMin To $_Var4 If $j <= UBound ( $_StartLab ) -1 Then GUICtrlSetState ( $_StartLab[$j], $GUI_SHOW + $GUI_ENABLE ) GUICtrlSetState ( $_BeepDurationLab[$j], $GUI_SHOW + $GUI_ENABLE ) EndIf Next GUICtrlSetState ( $_ButtonSet, $GUI_SHOW ) EndIf EndIf EndIf GUISetState ( @SW_UNLOCK, $_Gui ) GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) EndFunc ;==> _BeepSongEditorLoadIni ( ) Func _BeepSongEditorOneLineDown ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return GUICtrlSetState ( $_ButtonDown, $GUI_DISABLE ) For $j = 0 To $_EditorLength -1 If $_Notes[$_NotesNumber -1][$j][1] = True Then If MsgBox ( 262144+4+4096+48, 'Attention', @CRLF & 'There is note(s) on Last line' & @CRLF & 'They will be deleted !' & @CRLF & 'Continue ?' & @CRLF ) <> 6 Then GUICtrlSetState ( $_ButtonDown, $GUI_ENABLE ) Return Else ExitLoop EndIf EndIf Next GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) For $j = 0 To $_EditorLength -1 For $i = $_NotesNumber -1 To 0 Step -1 If $i-1 >= 0 Then $_Notes[$i][$j][1] = $_Notes[$i-1][$j][1] Next $_Notes[0][$j][1] = False Next _BeepSongEditorSetNotes ( ) GUICtrlSetState ( $_ButtonDown, $GUI_ENABLE ) GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) EndFunc ;==> _BeepSongEditorOneLineDown ( ) Func _BeepSongEditorOneLineUp ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return GUICtrlSetState ( $_ButtonUp, $GUI_DISABLE ) For $j = 0 To $_EditorLength -1 If $_Notes[0][$j][1] = True Then If MsgBox ( 262144+4+4096+48, 'Attention', @CRLF & 'There is note(s) on first line' & @CRLF & 'They will be deleted !' & @CRLF & 'Continue ?' & @CRLF ) <> 6 Then GUICtrlSetState ( $_ButtonUp, $GUI_ENABLE ) Return Else ExitLoop EndIf EndIf Next GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) For $j = 0 To $_EditorLength -1 For $i = 0 To $_NotesNumber -1 If $i+1 <= $_NotesNumber -1 Then $_Notes[$i][$j][1] = $_Notes[$i+1][$j][1] Next $_Notes[$_NotesNumber -1][$j][1] = False Next _BeepSongEditorSetNotes ( ) GUICtrlSetState ( $_ButtonUp, $GUI_ENABLE ) GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) EndFunc ;==> _BeepSongEditorOneLineUp ( ) Func _BeepSongEditorPlay ( ) If Not _BeepSongEditorIsEmpty ( ) Then Local $_Start, $_Var5, $_Tempo, $_TimerInit, $_TimerDiff GUICtrlSetData ( $_ButtonPlay, 'Stop' ) Opt ( 'TrayIconHide', 1 ) $_Playing = 1 Local $_Sleep = 0 $_Start = 0 For $j = 0 To $_EditorLength -1 If Not StringIsDigit ( GUICtrlRead ( $_StartLab[$j] ) ) Then $_Start = $j ExitLoop EndIf Next $_Var5 = _BeepSongEditorGetVisibleNotesCapacity ( ) If $_Start > $_Var5 Then If MsgBox ( 262144+4+4096+48, 'Attention', @CRLF & 'You have selected the ' & $_Start & '° Note to play at first' & @CRLF & @CRLF & 'but currently BeepSongEditor is only showing ' & $_Var5 & ' notes ! ' & @CRLF & @CRLF & 'Continue ?' & @CRLF ) <> 6 Then GUICtrlSetData ( $_ButtonPlay, 'Play' ) $_Playing = 0 Opt ( 'TrayIconHide', 0 ) Return EndIf EndIf $_TimerInit = TimerInit ( ) While 1 For $j = $_Start To $_EditorLength -1 If Not $_Playing Then ExitLoop 2 If $_BeepDuration[$j] Then $_GreenLine = 0 For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then $_GreenLine = 1 ExitLoop EndIf Next For $i = $_NotesNumber -1 To 0 Step -1 If Not $_Playing Then ExitLoop 3 If $_Notes[$i][$j][1] = True Then ExitLoop Else If $_GreenLine Then GUICtrlSetColor ( $_Notes[$i][$j][0], 0x00FF00 ) GUICtrlSetData ( $_Notes[$i][$j][0], ChrW ( 0x2502 ) ) $_Sleep = 0 Else $_Sleep += 1 If $_Sleep > 1+( $_NotesNumber -1 )*2 Then ExitLoop 3 -_GetCheckState ( $_Gui, $_CheckLoop ) EndIf EndIf Next If $i+1 Then $_Tempo = GUICtrlRead ( $_SliderTempo )/100 _Beep ( $_NotesNumber -$i, 3, $_BeepDuration[$j], 1, $_Tempo ) ConsoleWrite ( '!->-- ' & @ScriptLineNumber & ' _Beep ( ' & $_NotesNumber -$i & ', 3, ' & $_BeepDuration[$j] & ', 1, ' & $_Tempo & ' )' & @Crlf ) ;Beep ( $_Frequency[$i], $_BeepDuration[$j] ) _RemoveGreenLine ( $i+1, $j ) Else Sleep ( $_BeepDuration[$j]/$_Tempo ) EndIf $_TimerDiff = TimerDiff ( $_TimerInit )/1000 GUICtrlSetData ( $_TimeLabel, 'Time : ' & StringFormat ( '%02i' & ':' & '%02i' & ':' & '%02i', Int ( $_TimerDiff / 3600 ), Int ( $_TimerDiff / 60 ), Round ( Mod ( $_TimerDiff, 60 ) ) ) ) EndIf Next If Not _GetCheckState ( $_Gui, $_CheckLoop ) Then ExitLoop WEnd If $j <= $_EditorLength -1 Then _RemoveGreenLine ( 0, $j ) GUICtrlSetData ( $_ButtonPlay, 'Play' ) EndIf $_Playing = 0 Opt ( 'TrayIconHide', 0 ) EndFunc ;==> _BeepSongEditorPlay ( ) Func _BeepSongEditorRecord ( ) GUICtrlSetState ( $_ButtonPlay, $GUI_FOCUS ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return Local $_RecordDevice, $_Record, $_BassCbDll, $_TmpWavPath = $_TempDir & '\tmp.wav', $_TmpMp3Path = $_TempDir & '\tmp.mp3', $_DefaultName, $_Mp3FilePath, $_Size FileDelete ( $_TmpWavPath ) FileDelete ( $_TmpMp3Path ) _BASS_STARTUP ( $_TempDir & '\Bass.dll' ) _BASS_Encode_STARTUP ( $_TempDir & '\BassEnc.dll' ) $_BassCbDll = DllOpen ( $_TempDir & '\BASSCB.dll' ) $_RecordDevice = RegRead ( $_RegKeySettings, 'RecordDevice' ) If $_RecordDevice = '' Then _GuiChild1 ( ) $_RecordDevice = RegRead ( $_RegKeySettings, 'RecordDevice' ) EndIf $_RecordInput = _BeepSongEditorGetConnectedRecordDeviceListNames ( ) For $_I = 0 To UBound ( $_RecordInput ) -1 If $_RecordDevice = $_RecordInput[$_I] Then _BASS_RecordInit ( $_I ) If @error Then MsgBox ( 262144+4096+16, 'error', @CRLF & 'Record can not be initialized !' & @CRLF & @CRLF, 5 ) Return EndIf ExitLoop EndIf Next _BASS_SetConfig ( $BASS_CONFIG_GVOL_MUSIC, 10000 ) _GuiSetButtonsState ( $GUI_DISABLE ) $_Record = DllCall ( $_BassCbDll, 'dword', 'RecordStart', 'dword', 44100, 'dword', 2, 'dword', BitOR ( BitShift ( 10, -16 ), BitAND ( $BASS_SAMPLE_FX, 0xFFFF ) ) ) _BASS_Encode_Start ( $_Record[0], $_TmpWavPath, $BASS_ENCODE_PCM + $BASS_ENCODE_AUTOFREE ) _BeepSongEditorPlay ( ) _BASS_Encode_Stop ( $_Record[0] ) _BASS_Free ( ) _BASS_RecordFree ( ) _GuiSetButtonsState ( $GUI_ENABLE ) If FileGetSize ( $_TmpWavPath ) Then $_Size = FileGetSize ( $_TmpWavPath ) > 2*1024*1024 If $_Size Then SplashTextOn ( $_SoftTitle, @CRLF & 'Please Wait While Normalizing and Encoding BeepSong to mp3', 300, 150, -1, -1, 0, -1, 14, 900 ) RunWait ( '"' & $_TempDir & '\normalize.exe" -m 85 "' & $_TmpWavPath & '"', '', @SW_HIDE ) RunWait ( '"' & $_TempDir & '\lame.exe" -q0 "' & $_TmpWavPath & '" "' & $_TmpMp3Path & '"', '', @SW_HIDE ) ; -q0 : highest quality If $_Size Then SplashOff ( ) ;Local $_LastPath = RegRead ( $_RegKeySettings, 'LastPath' ) Local $_WinTitle = WinGetTitle ( $_Gui ) If StringInStr ( $_WinTitle, $_LastIniLoad ) Then $_DefaultName = StringReplace ( $_LastIniLoad, '.ini', '.mp3' ) Else If StringInStr ( $_WinTitle, '.ini' ) Then $_DefaultName = StringReplace ( StringReplace ( StringReplace ( $_WinTitle, $_SoftTitle, '' ), ' - ', '' ), '.ini', '.mp3' ) Else $_DefaultName = 'BeepSong.mp3' EndIf EndIf $_OutputDirPath = RegRead ( $_RegKeySettings, 'OutputDir' ) If $_OutputDirPath = '' Then $_OutputDirPath = @DesktopDir $_Mp3FilePath = FileSaveDialog ( 'Save Mp3 file', $_OutputDirPath, '(*.mp3)', 2 + 16, $_DefaultName, $_Gui ) If Not @error Then ;RegWrite ( $_RegKeySettings, 'OutputDir', 'REG_SZ', $_OutputDirPath ) FileMove ( $_TmpMp3Path, $_Mp3FilePath, 9 ) Else FileDelete ( $_TmpMp3Path ) EndIf Else MsgBox ( 262144+16, 'Error', 'Record Failed !' & @CRLF & 'Choose another Record Device' & @CRLF, 6 ) EndIf EndFunc ;==> _BeepSongEditorRecord ( ) Func _BeepSongEditorResetTempo ( ) GUICtrlSetData ( $_SliderTempo, 100 ) GUICtrlSetData ( $_LabTempo, 'Tempo : 1' ) EndFunc ;==> _BeepSongEditorResetTempo ( ) Func _BeepSongEditorSaveToIni ( ) If $_Playing Or _BeepSongEditorIsEmpty ( ) Then Return Local $_Save, $_LastPath = RegRead ( $_RegKeySettings, 'LastPath' ), $_Var2=1, $_DefaultName, $_FileOpen, $_Tempo If Not FileExists ( $_LastPath ) Then $_LastPath = @DesktopDir Local $_WinTitle = WinGetTitle ( $_Gui ) If StringInStr ( $_WinTitle, $_LastIniLoad ) Then $_DefaultName = $_LastIniLoad Else If StringInStr ( $_WinTitle, '.ini' ) Then $_DefaultName = StringReplace ( StringReplace ( $_WinTitle, $_SoftTitle, '' ), ' - ', '' ) Else $_DefaultName = 'BeepSong.ini' EndIf EndIf $_IniFilePath = FileSaveDialog ( 'Save ini file', $_LastPath, '(*.ini)', 2 + 16, $_DefaultName, $_Gui ) If Not @error Then If StringRight ( $_IniFilePath, 4 ) <> '.ini' Then $_IniFilePath &= '.ini' WinSetTitle ( $_Gui, '', $_SoftTitle & ' - ' & _GetFullNameByFullPath ( $_IniFilePath ) ) For $j = $_EditorLength -1 To 0 Step -1 For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then $_Var2 = $j If $j < $_EditorLength And $_BeepDuration[$j+1] <> $_BeepDurationDef Then $_Var2 += 1 ExitLoop 2 EndIf Next Next If $_Var2 = 1 Then $_Var2 = $_EditorLength -1 $_Save = '[LONG]' & @CRLF For $j = 0 To $_Var2 $_Save &= $j + 1 & '=' & _Iif ( $_BeepDuration[$j], $_BeepDuration[$j], $_BeepDurationDef )& @CRLF Next $_Save &= '[NOTE]' & @CRLF For $j = 0 To $_Var2 $_Save &= $j + 1 & '=' For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then $_Save &= _Iif ( $_Notes[$i][$j][1], $i+1, '' ) & @CRLF ExitLoop EndIf Next If $i = $_NotesNumber Then $_Save &= @CRLF Next $_Tempo = GUICtrlRead ( $_SliderTempo ) /100 If $_Tempo <> 1 Then $_Save &= '[Tempo]' & @CRLF & '1=' & $_Tempo & @CRLF $_FileOpen = FileOpen ( $_IniFilePath, 2+8 ) FileWrite ( $_FileOpen, StringStripWS ( $_Save, 2 ) ) FileClose ( $_FileOpen ) EndIf EndFunc ;==> _BeepSongEditorSaveToIni ( ) Func _BeepSongEditorSelectRecordDevice ( ) For $_I = 0 To UBound ( $_RecordInput ) -1 If BitAND ( GUICtrlRead ( $_Radio[$_I] ), $GUI_CHECKED ) = $GUI_CHECKED Then RegWrite ( $_RegKeySettings, 'RecordDevice', 'REG_SZ', $_RecordInput[$_I] ) GUICtrlSetState ( $_ButtonRecord, $GUI_ENABLE ) ExitLoop EndIf Next _GuiChildClose ( ) EndFunc ;==> _BeepSongEditorSelectRecordDevice ( ) Func _BeepSongEditorSetAllDurations ( ) Local $_Val Select Case BitAND ( GUICtrlRead ( $_Radio1 ), $GUI_CHECKED ) = $GUI_CHECKED $_Val = GUICtrlRead ( $_Input1 ) If Not @error And StringIsDigit ( $_Val ) Then For $j = 0 To $_EditorLength -1 $_BeepDuration[$j] = _Min ( _Max ( 100, Number ( $_Val ) ), 2000 ) GUICtrlSetData ( $_BeepDurationLab[$j], $_BeepDuration[$j] ) Next EndIf Case BitAND ( GUICtrlRead ( $_Radio2 ), $GUI_CHECKED ) = $GUI_CHECKED $_Val = GUICtrlRead ( $_Input2 ) If Not @error And StringIsDigit ( $_Val ) Then For $j = 0 To $_EditorLength -1 $_BeepDuration[$j] = _Min ( _Max ( 10, $_BeepDuration[$j] + Number ( $_Val ) ), 2000 ) GUICtrlSetData ( $_BeepDurationLab[$j], $_BeepDuration[$j] ) Next EndIf Case BitAND ( GUICtrlRead ( $_Radio3 ), $GUI_CHECKED ) = $GUI_CHECKED $_Val = GUICtrlRead ( $_Input3 ) If Not @error And StringIsDigit ( $_Val ) Then For $j = 0 To $_EditorLength -1 $_BeepDuration[$j] = _Min ( _Max ( 10, $_BeepDuration[$j] - Number ( $_Val ) ), 2000 ) GUICtrlSetData ( $_BeepDurationLab[$j], $_BeepDuration[$j] ) Next EndIf EndSelect GUIDelete ( $_GuiChild2 ) GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) EndFunc ;==> _BeepSongEditorSetAllDurations ( ) Func _BeepSongEditorSetNotation ( ) If _IsOsFrenchLanguage ( ) Then Dim $_Notation[$_NotesNumber+1] = ['DO5','SI4','LA4# / SI4b','LA4','SOL4# / LA4b','SOL4','FA4# / SOL4b','FA4','MI4','Ré4# / MI4b','Ré4','DO4# / Ré4b','DO4','SI3','LA3# / SI3b','LA3','SOL3# / LA3b','SOL3','FA3# / SOL3b','FA3','MI3','Ré3# / MI3b','Ré3','DO3# / Ré3b','DO3'] Else Dim $_Notation[$_NotesNumber+1] = ['C5','B4','A#4 / Bb4','A4','G#4 / Ab4','G4','F#4 / Gb4','F4','E4','D#4 / Eb4','D4','C#4 / Db4','C4','B3','A#3 / Bb3','A3','G#3 / Ab3','G3','F#3 / Gb3','F3','E3','D#3 / Eb3','D3','C#3 / Db3','C3' ] EndIf EndFunc ;==> _BeepSongEditorSetNotation ( ) Func _BeepSongEditorSetNotes ( ) Local $_Color, $_Var6 GUISetState ( @SW_LOCK, $_Gui ) For $j = 0 To $_EditorLength -1 $_Var6+=1 For $i = 0 To $_NotesNumber -1 If $_Notes[$i][$j][1] = True Then $_Color = _SetColorByParity ( $j ) GUICtrlSetColor ( $_Notes[$i][$j][0], $_Color ) GUICtrlSetData ( $_Notes[$i][$j][0], ChrW ( 0x266A ) ); 0x266B $_Var6 = 0 Else GUICtrlSetData ( $_Notes[$i][$j][0], '' ) $_Notes[$i][$j][1] = False If Not $_Var6 Then ExitLoop ;If $_Var6 > 5 Then Return EndIf Next Next GUISetState ( @SW_UNLOCK, $_Gui ) EndFunc ;==> _BeepSongEditorSetNotes ( ) Func _EnableCheckForUpdates ( ) $_EnableCheckForUpdates = _IsTrayItemChecked ( $_UpdateItem ) RegWrite ( $_RegKeySettings, 'EnableCheckForUpdates', 'REG_SZ', $_EnableCheckForUpdates ) EndFunc ;==> _EnableCheckForUpdates ( ) Func _ErrFunc ( $oError ) ConsoleWrite ( 'COM Error, ScriptLine ( ' & $oError.scriptline & ' ) : Number 0x' & Hex ( $oError.number, 8 ) & ' - ' & $oError.windescription & @CRLF ) EndFunc ;==> _ErrFunc ( ) Func _Exit ( ) If $_Playing Then _SendMessage ( GUICtrlGetHandle ( $_ButtonPlay ), $BM_CLICK ) $_Exit = 1 Return EndIf _StopDSBeep ( ) FileDelete ( $_TempDir & '\*.wav' ) FileDelete ( $_TempDir & '\*.mp3' ) Exit EndFunc ;==> _Exit ( ) Func _FileInstall ( ) Local $_Url = 'http://tinyurl.com/9pjpl9y' If Not _IsConnected ( ) Then Exit MsgBox ( 262144+16, 'Error', 'You are Not Connected !' & @CRLF & 'Retry Later' & @CRLF & 'Exiting...', 5 ) If Not FileExists ( $_TempDir ) Then Dircreate ( $_TempDir ) If Not FileExists ( @WindowsDir & '\beep1.ico' ) Then InetGet ( $_Url & '/beep1.ico', @WindowsDir & '\beep1.ico', 9, 0 ) If Not FileExists ( $_TempDir & '\normalize.exe' ) Then InetGet ( $_Url & '/normalize.exe', $_TempDir & '\normalize.exe', 9, 1 ) If Not FileExists ( $_TempDir & '\lame.exe' ) Then InetGet ( $_Url & '/lame.exe', $_TempDir & '\lame.exe', 9, 1 ) If Not FileExists ( $_TempDir & '\Bass.dll' ) Then InetGet ( $_Url & '/Bass.dll', $_TempDir & '\Bass.dll', 9, 1 ) If Not FileExists ( $_TempDir & '\basscb.dll' ) Then InetGet ( $_Url & '/basscb.dll', $_TempDir & '\basscb.dll', 9, 1 ) If Not FileExists ( $_TempDir & '\BassENC.dll' ) Then InetGet ( $_Url & '/BassENC.dll', $_TempDir & '\BassENC.dll', 9, 1 ) _BeepSongEditorIntro ( ) EndFunc ;==> _FileInstall ( ) Func _FileMissing ( ) If Not FileExists ( $_TempDir ) Then Return True If Not FileExists ( $_TempDir & '\normalize.exe' ) Then Return True If Not FileExists ( $_TempDir & '\lame.exe' ) Then Return True If Not FileExists ( $_TempDir & '\Bass.dll' ) Then Return True If Not FileExists ( $_TempDir & '\basscb.dll' ) Then Return True If Not FileExists ( $_TempDir & '\BassENC.dll' ) Then Return True If Not FileExists ( @WindowsDir & '\beep1.ico' ) Then Return True EndFunc ;==> _FileMissing ( ) Func _GetCheckState ( $_GuiTitle, $_Check ) Return ControlCommand ( $_GuiTitle, '', $_Check, 'IsChecked', '' ) EndFunc ;==> _GetCheckState ( ) Func _GetDefaultBrowser ( ) Local $_DefautBrowser = StringRegExp ( RegRead ( 'HKCR\http\shell\open\command', '' ), '(?s)(?i)"(.*?)"', 3 ) If Not @error And FileExists ( $_DefautBrowser[0] ) Then Return $_DefautBrowser[0] Local $_UserChoice = RegRead ( 'HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice', 'Progid' ) If Not @error Then $_DefautBrowser = StringRegExp ( RegRead ( 'HKLM\Software\Classes\' & $_UserChoice & '\shell\open\command', '' ), '(?s)(?i)"(.*?)"', 3 ) If Not @error And FileExists ( $_DefautBrowser[0] ) Then Return $_DefautBrowser[0] EndIf Return 'iexplore.exe' EndFunc ;==> _GetDefaultBrowser ( ) Func _GetFullNameByFullPath ( $_FullPath ) Local $_FileName = StringSplit ( $_FullPath, '\' ) If Not @error Then Return $_FileName[$_FileName[0]] EndFunc ;==> _GetFullNameByFullPath ( ) Func _GetParentFolderPathByFullPath ( $_FullPath ) Local $_FilePath = StringLeft ( $_FullPath, StringInStr ( $_FullPath, '\', 0, -1 ) - 1 ) If Not @error Then Return $_FilePath EndFunc ;==> _GetParentFolderPathByFullPath ( ) Func _GetScriptVersion ( ) Local $_FileVersion If @Compiled Then $_FileVersion = FileGetVersion ( @ScriptFullPath, 'FileVersion' ) Else $_FileVersion = _StringBetween ( FileRead ( @ScriptFullPath ), '#AutoIt3Wrapper_Res_Fileversion=', @CR ) If Not @error Then $_FileVersion = $_FileVersion[0] Else $_FileVersion = '0.0.0.0' EndIf EndIf RegWrite ( $_RegKeySettings, 'Version', 'REG_SZ', $_FileVersion ) Return $_FileVersion EndFunc ;==> _GetScriptVersion ( ) Func _GuiChild1 ( ) If $_Playing Then Return $_RecordInput = _BeepSongEditorGetConnectedRecordDeviceListNames ( ) Dim $_Radio[UBound ( $_RecordInput ) ] $_GuiChild1 = GUICreate ( 'Select Record Device', 500, UBound ( $_RecordInput )*20 +300, -1, -1, -1, -1, $_Gui ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_GuiChildClose', $_GuiChild1 ) GUISetBkColor ( 0xFCC81A, $_GuiChild2 ) GUISwitch ( $_GuiChild1 ) GUICtrlCreateLabel ( 'Connected Record Devices List', 20, 20, 460, 20, 0x01 ) GUICtrlSetFont ( -1, 11, 900 ) $_RecordDevice = RegRead ( $_RegKeySettings, 'RecordDevice' ) For $_I = 0 To UBound ( $_RecordInput )-1 $_Radio[$_I] = GUICtrlCreateRadio ( $_RecordInput[$_I], 140, 50 + $_I*25, 300, 20 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorSelectRecordDevice' ) If $_RecordDevice = $_RecordInput[$_I] Then GUICtrlSetState ( $_Radio[$_I], $GUI_CHECKED ) Next GUICtrlCreateLabel ( 'For Win 7 if you do not see "Stereo Mix" or "What U Hear" or ' & @CRLF & _ '"Waveout mix" then click on the above button.' & @CRLF & _ 'When Sound Recording Tab window is opened' & @CRLF & _ 'right click on it and choose "show disabled devices"' & @CRLF & _ 'and activate one called "Stereo Mix"' & @CRLF & 'or equivalent in your language.' & @CRLF & _ 'Then restart BeepSongEditor.', 20, 110+$_I*20, 460, 150, 0x01 ) GUICtrlSetFont ( -1, 11, 900 ) GUICtrlSetColor ( -1, 0xFF0000 ) If @OSVersion = 'WIN_7' Then RegWrite ( 'HKCU\Software\Microsoft\Multimedia\Audio\DeviceCpl', 'ShowHiddenDevices', 'REG_DWORD', 0x00000001 ) Local $_Button1 = GUICtrlCreateButton ( 'Access To Sound Recording Tab', 70, 260 + $_I*20, 360, 20 ) GUICtrlSetFont ( -1, 11, 900 ) GUICtrlSetOnEvent ( -1, '_AccessToSoundRecordingTab' ) GUISetState ( @SW_SHOW, $_GuiChild1 ) EndFunc ;==> _GuiChild1 ( ) Func _GuiChild2 ( ) If $_Playing Then Return GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) $_GuiChild2 = GUICreate ( 'Select Duration Modification', 400, 220, -1, -1, -1, -1, $_Gui ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_GuiChildClose', $_GuiChild2 ) GUISetBkColor ( 0xFCC81A, $_GuiChild2 ) GUISwitch ( $_GuiChild2 ) GUICtrlCreateLabel ( 'Available Duration Operations', 20, 20, 360, 20, 0x01 ) GUICtrlSetFont ( -1, 11, 900 ) GUICtrlSetColor ( -1, 0xFF0000 ) $_Radio1 = GUICtrlCreateRadio ( 'Set all durations to the Same value : ', 40, 70, 220, 20 ) GUICtrlSetFont ( -1, 8, 800 ) GUICtrlSetOnEvent ( -1, '_GuiChild2EnableInput1Ctrl' ) $_Input1 = GUICtrlCreateInput ( '', 260, 70, 40, 20 ) GUICtrlSetState ( -1, $GUI_DISABLE ) GUICtrlCreateLabel ( 'ms', 310, 73, 30, 20 ) GUICtrlSetFont ( -1, 8, 800 ) $_Radio2 = GUICtrlCreateRadio ( 'Increase all durations of ', 40, 100, 200, 20 ) GUICtrlSetFont ( -1, 8, 800 ) GUICtrlSetOnEvent ( -1, '_GuiChild2EnableInput2Ctrl' ) $_Input2 = GUICtrlCreateInput ( '', 260, 100, 40, 20 ) GUICtrlSetState ( -1, $GUI_DISABLE ) GUICtrlCreateLabel ( 'ms', 310, 103, 30, 20 ) GUICtrlSetFont ( -1, 8, 800 ) $_Radio3 = GUICtrlCreateRadio ( 'Decrease all durations of ', 40, 130, 200, 20 ) GUICtrlSetFont ( -1, 8, 800 ) GUICtrlSetOnEvent ( -1, '_GuiChild2EnableInput3Ctrl' ) $_Input3 = GUICtrlCreateInput ( '', 260, 130, 40, 20 ) GUICtrlSetState ( -1, $GUI_DISABLE ) GUICtrlCreateLabel ( 'ms', 310, 133, 30, 20 ) GUICtrlSetFont ( -1, 8, 800 ) Local $_Button1 = GUICtrlCreateButton ( 'Apply', 20, 180, 360, 20 ) GUICtrlSetFont ( -1, 11, 900 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorSetAllDurations' ) GUISetState ( @SW_SHOW, $_GuiChild2 ) EndFunc ;==> _GuiChild2 ( ) Func _GuiChild2EnableInput1Ctrl ( ) GUICtrlSetState ( $_Input1, $GUI_ENABLE ) GUICtrlSetState ( $_Input1, $GUI_FOCUS ) GUICtrlSetState ( $_Input2, $GUI_DISABLE ) GUICtrlSetState ( $_Input3, $GUI_DISABLE ) EndFunc ;==> _GuiChild2EnableInput1Ctrl ( ) Func _GuiChild2EnableInput2Ctrl ( ) GUICtrlSetState ( $_Input2, $GUI_ENABLE ) GUICtrlSetState ( $_Input2, $GUI_FOCUS ) GUICtrlSetState ( $_Input1, $GUI_DISABLE ) GUICtrlSetState ( $_Input3, $GUI_DISABLE ) EndFunc ;==> _GuiChild2EnableInput2Ctrl ( ) Func _GuiChild2EnableInput3Ctrl ( ) GUICtrlSetState ( $_Input3, $GUI_ENABLE ) GUICtrlSetState ( $_Input3, $GUI_FOCUS ) GUICtrlSetState ( $_Input2, $GUI_DISABLE ) GUICtrlSetState ( $_Input1, $GUI_DISABLE ) EndFunc ;==> _GuiChild2EnableInput3Ctrl ( ) Func _GuiChildClose ( ) If WinExists ( $_GuiChild1 ) Then GUIDelete ( $_GuiChild1 ) ElseIf WinExists ( $_GuiChild2 ) Then GUIDelete ( $_GuiChild2 ) EndIf GUISwitch ( $_Gui ) GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) Return EndFunc ;==> _GuiChildClose ( ) Func _GuiCtrlLabelStartFlash ( ) $_Flash = Not $_Flash If $_Flash = True Then GUICtrlSetColor ( $_StartFlashLab, 0x00FF00 ) GUICtrlSetFont ( $_StartFlashLab, 14 ) GUICtrlSetData ( $_StartFlashLab, ChrW ( 0x25BC ) ) Else GUICtrlSetFont ( $_StartFlashLab, 9 ) GUICtrlSetData ( $_StartFlashLab, '' ) EndIf EndFunc ;==> _GuiCtrlLabelStartFlash ( ) Func _GuiMain ( ) $_Gui = GUICreate ( $_SoftTitle, 20 + ( _Min ( $_EditorLength, $_EditorLengthMin ) ) *20 +120, $_NotesNumber * 20 +120, Default, Default, BitOR ( $GUI_SS_DEFAULT_GUI , $WS_SIZEBOX ) ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_Exit' ) GUISetIcon ( @WindowsDir & '\beep1.ico', $_Gui ) GUISetBkColor ( 0xFCC81A, $_Gui ) Local $_ButtonYpos = $_NotesNumber * 20 + 60 $_ButtonPlay = GUICtrlCreateButton('Play', 20, $_ButtonYpos, 88, 20 ) GUICtrlSetTip ( -1, 'Play editor content', '', 1, 1 ) GUICtrlSetFont ( -1, 8, 800 ) $hButtonPlay = GUICtrlGetHandle ( $_ButtonPlay ) $_CheckLoop = GUICtrlCreateCheckbox ( 'Repeat', 20, $_ButtonYpos + 30, 88, 20 ) GUICtrlSetFont ( -1, 7, 600 ) GUICtrlSetTip ( -1, 'Check for play editor content in loop', '', 1, 1 ) $_ButtonLoad = GUICtrlCreateButton ( 'Load', 129, $_ButtonYpos, 88, 20 ) GUICtrlSetFont ( -1, 8, 800 ) GUICtrlSetTip ( -1, 'Load a ini file', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorLoadIni' ) $_ButtonClear = GUICtrlCreateButton ( 'Clear', 129, $_ButtonYpos + 30, 88, 20) GUICtrlSetFont ( -1, 8, 800 ) GUICtrlSetTip ( -1, 'Clear BeepSong editor content', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorClear' ) $_ButtonUp = GUICtrlCreateButton ( ChrW ( 0x25B2 ), 238, $_ButtonYpos, 20, 20 ) GUICtrlSetFont ( -1, 12, 400 ) GUICtrlSetTip ( -1, 'Shift editor content of one line up', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorOneLineUp' ) $_ButtonDown = GUICtrlCreateButton ( ChrW ( 0x25BC ), 278, $_ButtonYpos, 20, 20 ) GUICtrlSetFont ( -1, 12, 400 ) GUICtrlSetTip ( -1, 'Shift editor content of one line down', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorOneLineDown' ) $_ButtonInsert = GUICtrlCreateButton ( ChrW ( 0x25BA ), 238, $_ButtonYpos+30, 20, 20 ) GUICtrlSetFont ( -1, 12, 400 ) GUICtrlSetTip ( -1, 'Choose a column for Insert a note', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorInsertNote' ) $_ButtonDeleteColumn = GUICtrlCreateButton ( ChrW ( 0x25C4 ), 278, $_ButtonYpos+30, 20, 20 ) GUICtrlSetFont ( -1, 12, 400 ) GUICtrlSetTip ( -1, 'Choose a Column to Remove', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorDeleteColumn' ) $_ButtonSave = GUICtrlCreateButton ( 'Save To ini', 318, $_ButtonYpos, 88, 20 ) GUICtrlSetFont ( -1, 8, 800 ) GUICtrlSetTip ( -1, 'Save editor content to a ini file', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorSaveToIni' ) $_ButtonConvert = GUICtrlCreateButton ( 'Save To Au3', 318, $_ButtonYpos+30, 88, 20 ) GUICtrlSetFont ( -1, 7, 600 ) GUICtrlSetTip ( -1, 'Convert and copy to clipboard editor content ' & @CRLF & 'to classic Beep au3 code format' & @CRLF & 'Or Hold Left SHIFT key and click Button' & @CRLF & 'for get Beep Song in DSBeep au3 Code format.', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorConvertToAu3' ) $_ButtonSetRecordDevice = GUICtrlCreateButton ( 'Set Rec Dev', 426, $_ButtonYpos, 88, 20 ) GUICtrlSetFont ( -1, 8, 800 ) GUICtrlSetTip ( -1, 'Select the Record Device for save to mp3', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_GuiChild1' ) $_RecordDevice = RegRead ( $_RegKeySettings, 'RecordDevice' ) $_ButtonRecord = GUICtrlCreateButton ( ChrW ( 0x25CF ) & ' Record', 426, $_ButtonYpos+30, 88, 22 ) GUICtrlSetFont ( -1, 10, 800 ) GUICtrlSetColor ( -1, 0xFF0000 ) GUICtrlSetTip ( -1, 'Start recording editor content until playback is finished' & @CRLF & 'or you click on Stop Button and save song to mp3.', '', 1, 1 ) GUICtrlSetOnEvent ( -1, '_BeepSongEditorRecord' ) If $_RecordDevice = '' Then GUICtrlSetState ( $_ButtonRecord, $GUI_DISABLE ) $_LabTempo = GUICtrlCreateLabel ( 'Tempo : ', 560, $_ButtonYpos-4, 80, 10 ) GUICtrlSetTip ( -1, 'Click here for reset Tempo to 1', '', 1, 1 ) GUICtrlSetFont ( -1, 7, 600 ) GUICtrlSetTip ( -1, 'Click for Reset Normal Tempo to 1', '', 1, 1 ) $_SliderTempo = GUICtrlCreateSlider ( 530, $_ButtonYpos+8, 120, 20, $TBS_NOTICKS ) GUICtrlSetLimit ( -1, 400, 20 ) GUICtrlSetData ( -1, 100 ) GUICtrlSetBkColor ( -1, 0xFCC81A ) $hSliderTempo = GUICtrlGetHandle ( $_SliderTempo ) GUICtrlSetData ( $_LabTempo, 'Tempo : ' & GUICtrlRead ( $_SliderTempo ) /100 ) $_TimeLabel = GUICtrlCreateLabel ( '', 560, $_ButtonYpos+35, 80, 20 ) GUICtrlSetFont ( -1, 7, 600 ) Local $_Color For $i = 0 To $_NotesNumber -1 For $j = 0 To $_EditorLength -1 If $i = 0 Then $_Color = _SetColorByParity ( $j ) $_StartLab[$j] = GUICtrlCreateLabel( StringFormat ( '%02i', $j +1 ), 23 + $j*20, 3, 19, 19, BitOR ( $SS_CENTERIMAGE, $SS_CENTER ) ) GUICtrlSetColor ( -1, $_Color ) GUICtrlSetFont ( -1, 9 ) GUICtrlSetTip ( -1, 'Click here for select this note' & @CRLF & 'who will be play at first !', '', 1, 1 ) $_BeepDurationLab[$j] = GUICtrlCreateLabel( $_BeepDurationDef, 20 + $j*20, $_NotesNumber * 20 + 30, 19, 19, 0x01 ) $_BeepDuration[$j] = $_BeepDurationDef GUICtrlSetFont ( -1, 6, 500 ) GUICtrlSetColor ( -1, $_Color ) GUICtrlSetTip ( -1, 'Click here for adjust the ' & $j +1 & "° note or silence duration", '', 1, 1 ) If $j >= $_EditorLengthMin Then GUICtrlSetState ( $_StartLab[$j], $GUI_HIDE + $GUI_DISABLE ) GUICtrlSetState ( $_BeepDurationLab[$j], $GUI_HIDE + $GUI_DISABLE ) EndIf EndIf If $j = 0 Then $_Color = _SetColorByParity ( $i ) GUICtrlCreateLabel( StringFormat ( '%02i', $i+1 ), 3, 23 + $i*20, 19, 19 ) GUICtrlSetColor ( -1, $_Color ) EndIf $_Notes[$i][$j][0] = GUICtrlCreateLabel ( '', 20 + $j*20, 20 + $i*20, 19, 19, BitOR ( $SS_CENTERIMAGE, $SS_CENTER ) ) GUICtrlSetFont ( -1, 20 ) GUICtrlSetColor ( -1, $_LabelColorDef ) GUICtrlSetBkColor ( -1, $_LabelColorDef ) $_Notes[$i][$j][1] = False Next $_Color = _SetColorByParity ( $i, 1 ) GUICtrlCreateLabel ( ' ' & $_Notation[$i], 20 + ( _Min ( $_EditorLength, $_EditorLengthMin ) ) *20, 20 + $i*20, 120, 19 ) GUICtrlSetFont ( -1, 11, 900 ) GUICtrlSetColor ( -1, $_Color ) GUICtrlSetResizing ( -1, $GUI_DOCKRIGHT+$GUI_DOCKWIDTH ) Next GUICtrlCreateLabel ( '', 23 + ( _Min ( $_EditorLength, $_EditorLengthMin ) ) *20, 0, 120, 19 ) GUICtrlSetResizing ( -1, $GUI_DOCKRIGHT+$GUI_DOCKWIDTH ) GUICtrlSetBkColor ( -1, 0xFCC81A ) GUICtrlSetState ( -1, $GUI_DISABLE ) GUICtrlCreateLabel ( '', 23 + ( _Min ( $_EditorLength, $_EditorLengthMin ) ) *20, $_NotesNumber * 20 + 25, 120, 19 ) GUICtrlSetResizing ( -1, $GUI_DOCKRIGHT+$GUI_DOCKWIDTH ) GUICtrlSetState ( -1, $GUI_DISABLE ) $_ButtonSet = GUICtrlCreateButton ( 'Set All Durations', 25 + ( _Min ( $_EditorLength, $_EditorLengthMin ) ) *20, $_NotesNumber * 20 + 25, 100, 20 ) GUICtrlSetFont ( -1, 7, 600 ) GUICtrlSetTip ( -1, 'Choose and Set durations for all notes' & @CRLF, '', 1, 1 ) GUICtrlSetResizing ( -1, $GUI_DOCKRIGHT+$GUI_DOCKWIDTH ) GUICtrlSetState ( -1, $GUI_FOCUS ) GUICtrlSetOnEvent ( -1, '_GuiChild2' ) WinSetTrans ( $_Gui, '', 230 ) GUIRegisterMsg ( $WM_GetMinMaxInfo, '_WM_GetMinMaxInfo' ) GUIRegisterMsg ( $WM_Command, '_WM_Command' ) GUIRegisterMsg ( $WM_Size, '_WM_Size' ) GUIRegisterMsg ( $WM_HScroll, '_WM_HScroll' ) GUISetState ( ) $_EditorNotesNumberOld = _BeepSongEditorGetVisibleNotesCapacity ( ) _OnTop ( ) EndFunc ;==> _GuiMain ( ) Func _GuiSetButtonsState ( $_State ) GUICtrlSetState ( $_ButtonClear, $_State ) GUICtrlSetState ( $_ButtonConvert, $_State ) GUICtrlSetState ( $_ButtonDown, $_State ) GUICtrlSetState ( $_ButtonInsert, $_State ) GUICtrlSetState ( $_ButtonLoad, $_State ) GUICtrlSetState ( $_ButtonSave, $_State ) GUICtrlSetState ( $_ButtonSet, $_State ) GUICtrlSetState ( $_ButtonUp, $_State ) GUICtrlSetState ( $_ButtonDeleteColumn, $_State ) GUICtrlSetState ( $_ButtonSetRecordDevice, $_State ) GUICtrlSetState ( $_ButtonRecord, $_State ) EndFunc ;==> _GuiSetButtonsState ( ) Func _IsConnected ( ) If Ping ( 'www.bing.com', 1 ) _ Or InetRead ( 'http://www.google.com/humans.txt', 19 ) Then Return True EndFunc ;==> _IsConnected ( ) Func _IsMinimized ( $_Hwnd ) If BitAnd ( WinGetState ( $_Hwnd ), 16 ) Then Return 1 EndFunc ;==> _IsMinimized ( ) Func _IsOsFrenchLanguage ( ) Local $OsLang = @OSLang Select Case StringInStr ( '040c 080c 0c0c 100c 140c 180c', $OsLang ) Return 1 Case Else Return 0 EndSelect EndFunc ;==> _IsOsFrenchLanguage ( ) Func _IsTrayItemChecked ( $_TrayItem ) Return BitAND ( TrayItemGetState ( $_TrayItem ), $TRAY_CHECKED ) EndFunc ;==> _IsTrayItemChecked ( ) Func _IsVisible ( $_Hwnd ) If BitAnd ( WinGetState ( $_Hwnd ), 2 ) Then Return 1 EndFunc ;==> _IsVisible ( ) Func _LookForUpdate ( ) Local $__LastVersion, $_UpdateDatText, $_VersionCompare $_UpdateDatText = BinaryToString ( InetRead ( 'http://tinyurl.com/9pjpl9y/update.ini' ) ) $__LastVersion = _ReadIni ( $_UpdateDatText ) Local $_ScriptVersion = _GetScriptVersion ( ) If $_ScriptVersion <> '0.0.0.0' And $__LastVersion <> '0.0.0.0' Then $_VersionCompare = _VersionCompare ( $__LastVersion, $_ScriptVersion ) Switch $_VersionCompare Case 0 Return Case 1 If MsgBox ( 262144+4+4096+64, 'Info', @CRLF & 'An Update is Available' & @CRLF & @CRLF & _ 'BeepSongEditor Version : ' & $__LastVersion & @CRLF & @CRLF & _ 'Do you want to Download it ?' & @CRLF ) = 6 Then Exit _OpenInDefaultBrowser ( $_UpdateLink ) EndSwitch EndIf EndFunc ;==> _LookForUpdate ( ) Func _Minimize ( ) TrayItemSetState ( $_MinimizeItem, $TRAY_UNCHECKED ) If _IsVisible ( $_Gui ) Then TrayItemSetText ( $_MinimizeItem, 'Restore Window' ) GUISetState ( @SW_HIDE, $_Gui ) Else TrayItemSetText ( $_MinimizeItem, 'Minimize To Tray' ) GUISetState ( @SW_SHOW, $_Gui ) GUISetState ( @SW_RESTORE, $_Gui ) WinActivate ( $_Gui ) EndIf EndFunc ;==> _Minimize ( ) Func _OnTop ( ) Local $_State = _IsTrayItemChecked ( $_OnTopItem ) RegWrite ( $_RegKeySettings, 'OnTop', 'REG_SZ', $_State ) WinSetOnTop ( $_Gui, '', $_State ) EndFunc ;==> _OnTop ( ) Func _OpenInDefaultBrowser ( $_Url ) Local $_DefaultBrowser = _GetDefaultBrowser ( ) If FileExists ( $_DefaultBrowser ) Then ShellExecute ( $_Url ) Else ShellExecute ( 'iexplore.exe', $_Url ) EndIf EndFunc ;==> _OpenInDefaultBrowser ( ) Func _OpenTopic ( ) _OpenInDefaultBrowser ( 'http://www.autoitscript.com/forum/topic/145528-beepsongeditor-v1024-create-beep-songs-and-mp3-ringtones/' ) EndFunc ;==> _OpenTopic ( ) Func _OutputDirChange ( ) TrayItemSetState ( $_ChangeDirItem, $TRAY_UNCHECKED ) Local $_SelectFolder = FileSelectFolder ( 'Select MP3 Output Dir', '', 3, @DesktopDir, $_Gui ) If Not FileExists ( $_SelectFolder ) Then Return $_OutputDirPath = $_SelectFolder RegWrite ( $_RegKeySettings, 'OutputDir', 'REG_SZ', $_OutputDirPath ) EndFunc ;==> _OutputDirChange ( ) Func _OutputDirOpen ( ) $_OutputDirPath = RegRead ( $_RegKeySettings, 'OutputDir' ) If $_OutputDirPath = '' Then $_OutputDirPath = @DesktopDir TrayItemSetState ( $_OutputDirItem, $TRAY_UNCHECKED ) ShellExecute ( $_OutputDirPath ) EndFunc ;==> _OutputDirOpen ( ) Func _ReadIni ( $_Ini ) ; Get last version and download link. Local $__LastVersion $_UpdateLink = _StringBetween ( $_Ini, 'UpdateLink=', @CR ) If Not @error Then $_UpdateLink = $_UpdateLink[0] $__LastVersion = _StringBetween ( $_Ini, 'version=', @CR ) If Not @error Then Return $__LastVersion[0] Return '0.0.0.0' EndFunc ;=> _ReadIni ( ) Func _RemoveGreenLine ( $m, $k ) For $i = $m To $_NotesNumber -1 If $_Notes[$i][$k][1] = False Then GUICtrlSetData ( $_Notes[$i][$k][0], '' ) Next EndFunc ;==> _RemoveGreenLine ( ) Func _SetColorByParity ( $_Int, $_ColorRange=0 ) If Mod ( $_Int, 2 ) = 0 Then Switch $_ColorRange Case 0 Return 0x0000FF Case 1 Return 0x000000 EndSwitch Else Switch $_ColorRange Case 0 Return 0xFF0000 Case 1 Return 0xFFFFFF EndSwitch EndIf EndFunc ;==> _SetColorByParity ( ) Func _TrayMenuSet ( ) TraySetIcon ( @WindowsDir & '\beep1.ico' ) $_TopicItem = TrayCreateItem ( 'Topic of ' & $_SoftTitle ) TrayItemSetOnEvent ( -1, '_OpenTopic' ) TrayCreateItem ( '' ) $_OnTopItem = TrayCreateItem ( 'Always on Top' ) TrayItemSetOnEvent ( -1, '_OnTop' ) Local $_RegRead = RegRead ( $_RegKeySettings, 'OnTop' ) If $_RegRead = '' Or $_RegRead = 1 Then TrayItemSetState ( $_OnTopItem, $TRAY_CHECKED ) Else TrayItemSetState ( $_OnTopItem, $TRAY_UNCHECKED ) EndIf TrayCreateItem ( '' ) $_UpdateItem = TrayCreateItem ( 'Enable Check for Updates at Start' ) TrayItemSetOnEvent ( -1, '_EnableCheckForUpdates' ) $_RegRead = RegRead ( $_RegKeySettings, 'EnableCheckForUpdates' ) If $_RegRead = '' Or $_RegRead = 1 Then $_EnableCheckForUpdates = 1 TrayItemSetState ( $_UpdateItem, $TRAY_CHECKED ) Else $_EnableCheckForUpdates = 0 TrayItemSetState ( $_UpdateItem, $TRAY_UNCHECKED ) EndIf TrayCreateItem ( '' ) If $_OutputDirPath = '' Then $_OutputDirPath = @DesktopDir RegWrite ( $_RegKeySettings, 'OutputDir', 'REG_SZ', $_OutputDirPath ) EndIf $_ChangeDirItem = TrayCreateItem ( 'Change Mp3 Directory' ) TrayItemSetOnEvent ( -1, '_OutputDirChange' ) TrayItemSetState ( $_ChangeDirItem, $TRAY_UNCHECKED ) TrayCreateItem ( '' ) $_OutputDirItem = TrayCreateItem ( 'Open Mp3 Directory' ) TrayItemSetOnEvent ( -1, '_OutputDirOpen' ) TrayCreateItem ( '' ) $_MinimizeItem = TrayCreateItem ( 'Minimize To Tray' ) TrayItemSetOnEvent ( -1, '_Minimize' ) TrayCreateItem ( '' ) $_AboutItem = TrayCreateItem ( 'About / Help' ) TrayItemSetOnEvent ( -1, '_About' ) TrayCreateItem ( '' ) $_ExitItem = TrayCreateItem ( 'Exit' ) TrayItemSetOnEvent ( -1, '_Exit' ) TraySetClick ( 16 ) TraySetState ( 4 ) TraySetOnEvent ( $TRAY_EVENT_PRIMARYDOUBLE, '_Minimize' ) TraySetToolTip ( $_SoftTitle ) EndFunc ;==> _TrayMenuSet ( ) Func _WM_Command ( $hWnd, $Msg, $wParam, $lParam ) Local $nNotifyCode = BitShift ( $wParam, 16 ) Local $nCtrlID = BitAND ( $wParam, 0x0000FFFF ) Local $hCtrl = $lParam, $_Color, $_Tempo, $_Var5, $_WinPos Switch $nNotifyCode Case $BN_CLICKED Switch $hCtrl Case $hButtonPlay $_Playing = Not $_Playing Case Else If $nCtrlID = $_LabTempo Then _BeepSongEditorResetTempo ( ) Return $GUI_RUNDEFMSG EndIf If Not $_Playing Then $_Var5 = _BeepSongEditorGetVisibleNotesCapacity ( ) -1 For $i = 0 To $_NotesNumber -1 For $j = 0 To $_Var5 Switch $nCtrlID Case $_Notes[$i][$j][0] If $_Notes[$i][$j][1] = False Then For $k = 0 To $_NotesNumber -1 If $_Notes[$k][$j][1] = True Then GUICtrlSetData ( $_Notes[$k][$j][0], '' ) $_Notes[$k][$j][1] = False EndIf Next $_Color = _SetColorByParity ( $j ) GUICtrlSetColor ( $_Notes[$i][$j][0], $_Color ) GUICtrlSetData ( $_Notes[$i][$j][0], ChrW ( 0x266A ) ); 0x266B $_Notes[$i][$j][1] = True $_Tempo = GUICtrlRead ( $_SliderTempo )/50 _Beep ( $_NotesNumber -$i, 3, $_BeepDuration[$j], 1, $_Tempo ) ConsoleWrite ( '!->-- ' & @ScriptLineNumber & ' _Beep ( ' & $_NotesNumber -$i & ', 3, ' & $_BeepDuration[$j] & ', 1, ' & $_Tempo & ' )' & @Crlf ) ; Beep ( $_Frequency[$i], $_BeepDuration[$j] ) If $j = $_Var5 Then $_WinPos = WinGetPos ( $_Gui ) If Not @error And $_Var5 +2 < $_EditorLength Then WinMove ( $_Gui, '', _Max ( $_WinPos[0]- ( ( ( $_Var5 +2 )*20 +153 ) - $_WinPos[2] ), 0 ), Default, ( $_Var5 +2 )*20 +153 ) EndIf ExitLoop 2 Else GUICtrlSetData ( $_Notes[$i][$j][0], '' ) $_Notes[$i][$j][1] = False EndIf Case $_BeepDurationLab[$j] $_EnterDurationLab = $_BeepDurationLab[$j] $_Index = $j ExitLoop 2 Case $_StartLab[$j] GUICtrlSetState ( $_ButtonPlay, $GUI_DISABLE ) $_StartFlashLab = $_StartLab[$j] AdlibUnRegister ( '_GuiCtrlLabelStartFlash' ) For $j = 0 To $_EditorLength -1 $_Color = _SetColorByParity ( $j ) GUICtrlSetFont ( $_StartLab[$j], 9 ) GUICtrlSetData ( $_StartLab[$j], StringFormat ( '%02i', $j +1 ) ) GUICtrlSetColor ( $_StartLab[$j], $_Color ) Next AdlibRegister ( '_GuiCtrlLabelStartFlash', 1000 ) GUICtrlSetState ( $_ButtonPlay, $GUI_ENABLE ) ExitLoop 2 EndSwitch Next Next EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==> _WM_Command ( ) Func _WM_GetMinMaxInfo ( $hWnd, $Msg, $wParam, $lParam ) Local $_MinMaxInfo, $_EditorNotesNumber, $_Var3 Switch $hWnd Case $_Gui $_MinMaxInfo = DllStructCreate ( 'int;int;int;int;int;int;int;int;int;int', $lParam ) If Not @error Then $_Var3 = _BeepSongEditorGetVisibleNotesCapacity ( ) If $_Resize Then For $j = $_EditorLengthMin To $_EditorLength - 1 GUICtrlSetState ( $_StartLab[$j], $GUI_HIDE + $GUI_DISABLE ) GUICtrlSetState ( $_BeepDurationLab[$j], $GUI_HIDE + $GUI_DISABLE ) Next EndIf DllStructSetData ( $_MinMaxInfo, 7, ( _Min ( $_EditorLength, $_EditorLengthMin ) ) *20 +153 ) DllStructSetData ( $_MinMaxInfo, 8, $_NotesNumber*20 +117 ) DllStructSetData ( $_MinMaxInfo, 9, $_EditorLength*20 +158 ) If Not _IsPressed ( '01' ) Then For $j = $_EditorLengthMin To $_Var3 -1 If $j <= UBound ( $_StartLab ) -1 Then GUICtrlSetState ( $_StartLab[$j], $GUI_SHOW + $GUI_ENABLE ) GUICtrlSetState ( $_BeepDurationLab[$j], $GUI_SHOW + $GUI_ENABLE ) EndIf Next EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==> _WM_GetMinMaxInfo ( ) Func _WM_HScroll ( $hWnd, $Msg, $wParam, $lParam ) Switch $Msg Case $WM_HSCROLL, $WM_VSCROLL Switch $lParam Case $hSliderTempo GUICtrlSetData ( $_LabTempo, 'Tempo : ' & GUICtrlRead ( $_SliderTempo ) /100 ) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==> _WM_HScroll ( ) Func _WM_Size ( $hWnd, $Msg, $wParam, $lParam ) $_Resize = 1 Return $GUI_RUNDEFMSG EndFunc ;==> _WM_Size ( )