Leaderboard
Popular Content
Showing content with the highest reputation on 07/12/2014 in all areas
-
guinness, And after all that, here is a suggested function which will play both mp3 and wav files: #AutoIt3Wrapper_Res_File_Add=Basic.mp3, RT_RCDATA, BASICMP3 #AutoIt3Wrapper_Res_File_Add=Basic.wav, SOUND, BASICWAV #include "ResourcesEx.au3" MsgBox($MB_SYSTEMMODAL, "Sound", "Play mp3") $iRet = _Resource_PlaySound_Mod("BASICMP3") MsgBox($MB_SYSTEMMODAL, "Sound", "Play wav") $iRet = _Resource_PlaySound_Mod("BASICWAV") Func _Resource_PlaySound_Mod($sResNameOrID, $iFlags = $SND_SYNC, $sDLL = Default) Local $bIsInternal = ($sDLL = Default Or $sDLL = -1) Local $hInstance = ($bIsInternal ? 0 : _WinAPI_LoadLibraryEx($sDLL, $LOAD_LIBRARY_AS_DATAFILE)) If $iFlags = Default Then $iFlags = $SND_SYNC Local $bReturn ; Try to read resource into memory Local $binSound = _Resource_GetAsBytes($sResNameOrID) ; Assume mp3 so look in RT_RCDATA ; Get file size Local $iFileSize = @extended If $iFileSize = 0 Then ; Assume a wav $bReturn = _WinAPI_PlaySound($sResNameOrID, BitOR($SND_RESOURCE, $iFlags), $hInstance) Else ; Convert mp3 to hybrid wav $sHdr_1 = "0x52494646" Local $sHdr_2 = "57415645666D74201E0000005500020044AC0000581B0000010000000C00010002000000B600010071056661637404000000640E060064617461" Local $sAlign_Buffer = "00" Local $sMp3 = StringTrimLeft(Binary($binSound), 2) Local $iMp3Size = StringLen($sMp3) ; Convert to required format Local $iMp3Size = StringRegExpReplace(Hex($iFileSize, 8), "(..)(..)(..)(..)", "$4$3$2$1") Local $iWavSize = StringRegExpReplace(Hex($iFileSize + 63, 8), "(..)(..)(..)(..)", "$4$3$2$1") ; Construct hybrid wav file Local $sHybridWav = $sHdr_1 & $iWavSize & $sHdr_2 & $iMp3Size & $sMp3 If Mod($iMp3Size, 2) Then $sHybridWav &= $sAlign_Buffer EndIf ; Create struct Local $tWave = DllStructCreate("byte[" & BinaryLen($sHybridWav) & "]") DllStructSetData($tWave, 1, $sHybridWav) ; Set flag $iFlags = BitOR($SND_MEMORY, $SND_NODEFAULT, $iFlags) ; Play sound DllCall("winmm.dll", "int", "PlaySoundW", "struct*", $tWave, "ptr", 0, "dword", $iFlags) $bReturn = (@error ? 0 : 1) EndIf If Not $bIsInternal Then _WinAPI_FreeLibrary($hInstance) Return $bReturn EndFunc ;==>_Resource_PlaySound_Mod Note that an mp3 needs to be inserted as RT_RCDATA and a wav as SOUND - that acts as the switch in the code. M232 points
-
GUICtrlSetData Flikers Label
careca reacted to AdmiralAlkex for a topic
I like to use Adlibs for that, then you can easily control how often you want updates without using timers. Example GUICreate("abc", 100, 30) GUICtrlCreateLabel("", 0, 0, 100, 30) GUISetState() Local $iNumber = 0 ;Change adlib time to change how often control is updated AdlibRegister(_updatelabel, 500) While GUIGetMsg() <> -3 $iNumber += 1 WEnd Func _updatelabel() GUICtrlSetData(-1, $iNumber) EndFunc1 point -
I'm sorry, I was asleep No, nothing like that. It's for a card game made in AutoIt. Here is the full code. The game is called Tichu, a very fun game! Card Module to give player's a new hand #include <Array.au3> Func _CreateHands() Global $FoundCard = 0 Dim $Cards[57], $Card[57], $Player1Cards[0], $Player2Cards[0], $Player3Cards[0], $Player4Cards[0] For $i = 1 To 56 $Cards[$i] = "0" Next $Card[1] = "2C" $Card[2] = "2S" $Card[3] = "2D" $Card[4] = "2H" $Card[5] = "3C" $Card[6] = "3S" $Card[7] = "3D" $Card[8] = "3H" $Card[9] = "4C" $Card[10] = "4S" $Card[11] = "4D" $Card[12] = "4H" $Card[13] = "5C" $Card[14] = "5S" $Card[15] = "5D" $Card[16] = "5H" $Card[17] = "6C" $Card[18] = "6S" $Card[19] = "6D" $Card[20] = "6H" $Card[21] = "7C" $Card[22] = "7S" $Card[23] = "7D" $Card[24] = "7H" $Card[25] = "8C" $Card[26] = "8S" $Card[27] = "8D" $Card[28] = "8H" $Card[29] = "9C" $Card[30] = "9S" $Card[31] = "9D" $Card[32] = "9H" $Card[33] = "10C" $Card[34] = "10S" $Card[35] = "10D" $Card[36] = "10H" $Card[37] = "JC" $Card[38] = "JS" $Card[39] = "JD" $Card[40] = "JH" $Card[41] = "QC" $Card[42] = "QS" $Card[43] = "QD" $Card[44] = "QH" $Card[45] = "KC" $Card[46] = "KS" $Card[47] = "KD" $Card[48] = "KH" $Card[49] = "AC" $Card[50] = "AS" $Card[51] = "AD" $Card[52] = "AH" $Card[53] = "Dog" $Card[54] = "Dragon" $Card[55] = "Bird" $Card[56] = "Phoenix" While $FoundCard < 14 $Random = Random(1, 56, 1) If $Cards[$Random] = "0" Then _arrayAdd($Player1Cards, $Card[$Random]) $FoundCard += 1 $Cards[$Random] = "1" EndIf WEnd $FoundCard = 0 While $FoundCard < 14 $Random = Random(1, 56, 1) If $Cards[$Random] = "0" Then _arrayAdd($Player2Cards, $Card[$Random]) $FoundCard += 1 $Cards[$Random] = "1" EndIf WEnd $FoundCard = 0 While $FoundCard < 14 $Random = Random(1, 56, 1) If $Cards[$Random] = "0" Then _arrayAdd($Player3Cards, $Card[$Random]) $FoundCard += 1 $Cards[$Random] = "1" EndIf WEnd $FoundCard = 0 While $FoundCard < 14 $Random = Random(1, 56, 1) If $Cards[$Random] = "0" Then _arrayAdd($Player4Cards, $Card[$Random]) $FoundCard += 1 $Cards[$Random] = "1" EndIf WEnd EndFunc ;~ _ArrayDisplay($Player1Cards) ;~ _ArrayDisplay($Player2Cards) ;~ _ArrayDisplay($Player3Cards) ;~ _ArrayDisplay($Player4Cards) The current code that I have made up, haven't gotten very far. #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include ".\Skins\Hex.au3" #include "_UskinLibrary.au3" #include "Cards Module.au3" _Uskin_LoadDLL() _USkin_Init(_Hex(True)) Opt("GUIOnEventMode", 1) Global $Player1Cards, $Player2Cards, $Player3Cards, $Player4Cards Global $CurrentGui, $MainGui, $HandGui, $CardCount Dim $Player1Card[20], $Player1Cards[20] _DealCards() _CreateGui() Func _CreateGui() $CurrentGui = "MainGui" $MainGui = GuiCreate("Tichu", 800,500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GuiSetFont(11) $DisplayTeamAName = GuiCtrlCreateInput("", 5,5,140,20, BitOr($ES_READONLY, $ES_Center)) $DisplayTeamAPoints = GuiCtrlCreateInput("0", 50, 30, 40,20, BitOr($ES_ReadOnly, $ES_Center)) $DisplayTeamBName = GuiCtrlCreateInput("", 655,5,140,20, BitOr($ES_READONLY, $ES_Center)) $DisplayTeamBPoints = GuiCtrlCreateInput("0", 705, 30, 40,20, BitOr($ES_ReadOnly, $ES_Center)) GuiCtrlCreateLabel("Player 1:", 0, 380) GuiCtrlCreateLabel("Player 2:", 0, 410) GuiCtrlCreateLabel("Player 3:", 0, 440) GuiCtrlCreateLabel("Player 4:", 0, 470) $DisplayPlayer1Name = GuiCtrlCreateInput("Prophete", 60, 378, 100,20, BitOr($ES_ReadOnly, $ES_Center)) $DisplayPlayer2Name = GuiCtrlCreateInput("Prophete", 60, 408, 100,20, BitOr($ES_ReadOnly, $ES_Center)) $DisplayPlayer3Name = GuiCtrlCreateInput("Prophete", 60, 438, 100,20, BitOr($ES_ReadOnly, $ES_Center)) $DisplayPlayer4Name = GuiCtrlCreateInput("Prophete", 60, 468, 100,20, BitOr($ES_ReadOnly, $ES_Center)) GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 350, 30, 80,130) GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 350, 340, 80,130) GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 30, 200, 80,130) GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuBackOfCard.Bmp", 680, 200, 80,130) $DisplayPlayer1CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 340, 3,100, 20, BitOr($ES_ReadOnly, $ES_Center)) $DisplayPlayer2CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 340, 475,100, 20, BitOr($ES_ReadOnly, $ES_Center)) $DisplayPlayer3CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 20, 335,100, 20, BitOr($ES_ReadOnly, $ES_Center)) $DisplayPlayer4CardsRemaining = GuiCtrlCreateInput("14 Cards Left", 670, 335,100, 20, BitOr($ES_ReadOnly, $ES_Center)) GuiCtrlCreatePic(@ScriptDIr & "/Images/TichuPlayingFIeld.bmp", 200, 180, 380,140) GuiCtrlCreatePic(@ScriptDIr & "/Images/Bomb.bmp", 200, 180, 380,140) $PlayButton = GuiCtrlCreateButton("Hand", 240, 470, 80,30) GuiCtrlSetOnEvent(-1, "_HandGUI") $PassButton = GuiCtrlCreateButton("Pass", 465, 470, 80,30) GuiSetState() EndFunc Func _HandGUI() $CurrentGui = "Hand" $HandGui = GuiCreate("Hand", 800,400) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GuiSetBkColor(0xFFFFFF) GuiSetFont(11) $Cards = _ArrayToString($Player1Cards, "|") $SplitCards = StringSplit($Cards, "|") $CardCount = $SplitCards[0] $X = 15 For $i = 0 To $CardCount - 1 If $i = 9 Then $X = 185 EndIf If $i < 9 Then $Player1Card[$i] = GuiCtrlCreatePic(@ScriptDir & "/Images/Deck/" & $Player1Cards[$i] & ".bmp", $X, 20, 80,130) $X += 85 Else $Player1Card[$i] = GuiCtrlCreatePic(@ScriptDir & "/Images/Deck/" & $Player1Cards[$i] & ".bmp", $X, 170, 80,130) $X += 85 EndIf Next $X = 50 For $i = 0 To 8 GuiCtrlCreateLabel($i, $X,0, 80,20) GuiCtrlSetFont(-1, 12) $X += 85 Next $X = 215 For $i = 9 To 13 GuiCtrlCreateLabel($i, $X, 150, 80, 20) GuiCtrlSetFont(-1, 12) $X += 85 Next $MoveCard = GuiCtrlCreateButton("Move Card", 10,360,120,40) GuiCtrlSetOnEvent(-1, "_MoveCard") $TradeCards = GuiCtrlCreateButton("Trade Cards", 10,360,120,40) GuiCtrlSetOnEvent(-1, "_TradeCards") $RemoveCard = GuiCtrlCreateButton("Remove Card", 300,360,120,40) GuiCtrlSetOnEvent(-1, "_RemoveCard") GuiSetState() EndFunc Func _TradeCards() $TradePlayer1 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3") $TradePlayer1Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13") $TradePlayer2 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3") $TradePlayer2Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13") $TradePlayer3 = InputBox("Trade Cards", "Please input the player you would like to trade with." & @CRLF & @CRLF & "IE: 1, 2 or 3") $TradePlayer3Card = InputBox("Trade Cards", "Please input the card you would like to trade." & @CRLF & @CRLF & "0 being position 1 - 13") EndFunc Func _RemoveCard() _ArrayDelete($Player1Cards, 3) GuiDelete($HandGui) _HandGui() EndFunc Func _MoveCard() $Card1ToMove = InputBox("Move Card", "Please type a number from 0-13 of the position of the first card to move." & @CRLF & "0 being position 1.") $Card2ToMove = InputBox("Move Card", "Please type a number from 0-13 of the position of the second card to move." & @CRLF & "0 being position 1.") $Card1ToMoveData = $Player1Cards[$Card1ToMove] $Card2ToMoveData = $Player1Cards[$Card2ToMove] If $Card2ToMoveData = "" Then SetError(1) Else _ArraySwap($Player1Cards[$Card1ToMove], $Player1Cards[$Card2ToMove]) GuiDelete($HandGui) _HandGui() EndIf EndFunc Func _DealCards() _CreateHands() EndFunc Func _Exit() If $CurrentGui = "Hand" Then GuiDelete($HandGui) $CurrentGui = "MainGui" ElseIf $CurrentGui = "MainGui" Then Exit EndIf EndFunc While 1 Sleep(10) WEnd There's a bunch of images and stuff related but that should be enough to prove that And thanks Shane for the info, I'll look into that.1 point
-
ResourcesEx UDF.
mesale0077 reacted to Melba23 for a topic
mesale0077, Do not forget UEZ's contribution. M231 point -
ResourcesEx UDF.
mesale0077 reacted to UEZ for a topic
I like the hybrid wave method because it doesn't require an external dll to play the mp3 file. Thanks Melba23 for it! This UDF isn't designed to extract any information from a mp3 file. What you can do is to read the mp3 file from the resource and use additional UDFs which can extract the information you want from a mp3. Br, UEZ1 point -
Shane0000, I believe I have fixed the bug and now I need to test a bit more. If you (or anyone else) would care to test as well, here is the new function: #include <Array.au3> Local $aArray[4][4] For $i = 0 To 3 For $j = 0 To 3 $aArray[$i][$j] = $i & $j Next Next _ArrayDisplay($aArray, "Original") Local $aExtract = _ArrayExtract_Mod($aArray, 0, 3, 1, 1) _ArrayDisplay($aExtract, "Row 0-3 column 1") Local $aExtract = _ArrayExtract_Mod($aArray, 0, 3, 0, 0) _ArrayDisplay($aExtract, "Row 0-3 column 0") Local $aExtract = _ArrayExtract_Mod($aArray, 1, 1, 1, 3) _ArrayDisplay($aExtract, "Row 1 column 1 - 3") Local $aExtract = _ArrayExtract_Mod($aArray, 0, 0, 1, 3) _ArrayDisplay($aExtract, "Row 0 column 1 - 3") Func _ArrayExtract_Mod(Const ByRef $avArray, $iStart_Row = -1, $iEnd_Row = -1, $iStart_Col = -1, $iEnd_Col = -1) If $iStart_Row = Default Then $iStart_Row = -1 If $iEnd_Row = Default Then $iEnd_Row = -1 If $iStart_Col = Default Then $iStart_Col = -1 If $iEnd_Col = Default Then $iEnd_Col = -1 If Not IsArray($avArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($avArray, $UBOUND_ROWS) - 1 If $iEnd_Row = -1 Then $iEnd_Row = $iDim_1 If $iStart_Row = -1 Then $iStart_Row = 0 If $iStart_Row < 0 Or $iEnd_Row < 0 Then Return SetError(3, 0, -1) If $iStart_Row > $iDim_1 Or $iEnd_Row > $iDim_1 Then Return SetError(3, 0, -1) If $iStart_Row > $iEnd_Row Then Return SetError(4, 0, -1) Switch UBound($avArray, $UBOUND_DIMENSIONS) Case 1 Local $aRetArray[$iEnd_Row - $iStart_Row + 1] For $i = 0 To $iEnd_Row - $iStart_Row $aRetArray[$i] = $avArray[$i + $iStart_Row] Next Return $aRetArray Case 2 Local $iDim_2 = UBound($avArray, $UBOUND_COLUMNS) - 1 If $iEnd_Col = -1 Then $iEnd_Col = $iDim_2 If $iStart_Col = -1 Then $iStart_Col = 0 If $iStart_Col < 0 Or $iEnd_Col < 0 Then Return SetError(5, 0, -1) If $iStart_Col > $iDim_2 Or $iEnd_Col > $iDim_2 Then Return SetError(5, 0, -1) If $iStart_Col > $iEnd_Col Then Return SetError(6, 0, -1) If $iStart_Col = $iEnd_Col Then Local $aRetArray[$iEnd_Row - $iStart_Row + 1] Else Local $aRetArray[$iEnd_Row - $iStart_Row + 1][$iEnd_Col - $iStart_Col + 1] EndIf For $i = 0 To $iEnd_Row - $iStart_Row For $j = 0 To $iEnd_Col - $iStart_Col If $iStart_Col = $iEnd_Col Then $aRetArray[$i] = $avArray[$i + $iStart_Row][$j + $iStart_Col] Else $aRetArray[$i][$j] = $avArray[$i + $iStart_Row][$j + $iStart_Col] EndIf Next Next Return $aRetArray Case Else Return SetError(2, 0, -1) EndSwitch Return 1 EndFunc ;==>_ArrayExtract_Mod M231 point
-
If you select "Syntax Check" in SciTE you should get error messages showing you where to change your script.1 point
-
gil900, You cannot save the timing in a wav header - there is nowhere to put it. What you will have to do is get the timing from the mp3 section of the resource before you play it. Anyway I have been having fun today with this! Here is my version of a script to convert an mp3 file to a hybrid wav fileL ; Basic wav header blocks $sHdr_1 = "0x52494646" $sHdr_2 = "57415645666D74201E0000005500020044AC0000581B0000010000000C00010002000000B600010071056661637404000000640E060064617461" $sAlign_Buffer = "00" ; Select mp3 file $sFile = FileOpenDialog("Select mp3 file to convert", @ScriptDir, "mp3 (*.mp3)") If Not $sFile Then Exit ; Read mp3 file $sMp3 = StringTrimLeft(Binary(FileRead($sFile)), 2) $iMp3Size = StringLen($sMp3) ; Get file size $iFileSize = FileGetSize($sFile) ; Convert to required format $iMp3Size = StringRegExpReplace(Hex($iFileSize, 8), "(..)(..)(..)(..)", "$4$3$2$1") $iWavSize = StringRegExpReplace(Hex($iFileSize + 63, 8), "(..)(..)(..)(..)", "$4$3$2$1") ; Construct hybrid wav file $sHybridWav = $sHdr_1 & $iWavSize & $sHdr_2 & $iMp3Size & $sMp3 If Mod($iMp3Size, 2) Then $sHybridWav &= $sAlign_Buffer EndIf ; Save new file $sFile = FileSaveDialog("Select filename for new file", @ScriptDir, "wav (*.wav)") If Not $sFile Then Exit $hFile = FileOpen($sFile, 2 + 16) FileWrite($hFile, $sHybridWav) FileClose($hFile) It will take any mp3 file - even one with an ID3 tag - and convert it to a hybrid wav file by adding a valid wav header (and padding the file by one byte if required). A valid wav header contains sizing data and so needs to be calculated for each file - you cannot just add the same string to every mp3. And then I developed this script to play the hybrid wav file from the resource table - reading the timing from the file itself: #AutoIt3Wrapper_Res_File_Add=Sound.wav, RT_RCDATA, SOUND #include <Date.au3> #include <Resources.au3> _Play_Resource_Sound("SOUND") Func _Play_Resource_Sound($sName) ; Read resource into memory $pResPointer = _ResourceGet($sName) $iResSize = @extended $tResStruct = DllStructCreate("byte[" & $iResSize & "]", $pResPointer) $sSound = DllStructGetData($tResStruct, 1) ; Calculate CBR timing $iTrackLen_CBR = _CBR_Timing(StringLeft($sSound, 5120), $iResSize) $iBitrate = @extended ; Look for VBR timing $iTrackLen_VBR = _VBR_Timing(StringLeft($sSound, 5120)) ; Play sound Local $SND_NODEFAULT = 2 Local $iFlag = BitOR($SND_MEMORY, $SND_ASYNC, $SND_NODEFAULT) DllCall("winmm.dll", "int", "sndPlaySound", "ptr", $pResPointer, "UINT", $iFlag) ; Show results If $iTrackLen_VBR = 0 Then MsgBox(0, "CBR", _Convert_Timing($iTrackLen_CBR) & @CRLF & $iBitrate & " - " & Hex($iBitrate * 100, 8)) Else MsgBox(0, "VBR", _Convert_Timing($iTrackLen_VBR) & @CRLF & $iBitrate & " - " & Hex($iBitrate * 100, 8)) EndIf EndFunc ;==>_Play_Resource_Sound Func _Convert_Timing($iMs) Local $iHours, $iMins, $iSecs _TicksToTime($iMs, $iHours, $iMins, $iSecs) Return StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs) EndFunc ;==>_Convert_Timing Func _CBR_Timing($sSound, $iResSize) ; Look for start of MP3 header Local $iMP3_Start = StringInStr($sSound, "FFF") If Not $iMP3_Start Then Return SetError(1, 0, 0) EndIf Local $sSound_Header = StringMid($sSound, $iMP3_Start, 8) ; Create look up table (this is only filled for MPEG-1 layer III) Local $aBit_Table[14] = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320] ; Look up bitrate $iBitrate = $aBit_Table[Number("0x" & StringMid($sSound_Header, 5, 1)) - 1] ; Length in ms Return SetExtended($iBitrate, Int($iResSize * 8 / $iBitrate)) EndFunc ;==>_CBR_Timing Func _VBR_Timing($sTag) Local $iXingPos = StringInStr($sTag, "58696E67") ; Xing If Not $iXingPos Then Return SetError(1, 0, 0) EndIf ; Read fields flag Local $iFrames, $iFlags = Number("0x" & StringMid($sTag, $iXingPos + 14, 2)) If BitAND($iFlags, 1) = 1 Then $iFrames = Number("0x" & StringMid($sTag, $iXingPos + 16, 8)) Else Return SetError(1, 0, 0); No frames field EndIf ; Now to find Samples per frame & Sampling rate ; Go back to the frame header start Local $sHeader = StringMid($sTag, $iXingPos - 72, 8) ; Read the relevant bytes Local $iMPEGByte = Number("0x" & StringMid($sHeader, 4, 1)) Local $iFreqByte = Number("0x" & StringMid($sHeader, 6, 1)) ; Decode them ; 8 = MPEG-1, 0 = MPEG-2 Local $iMPEGVer = BitAND($iMPEGByte, 8) ; 2 = Layer III, 4 = Layer II, 6 = Layer I Local $iLayerNum = BitAND($iMPEGByte, 6) Local $iSamples Switch $iLayerNum Case 6 $iSamples = 384 Case 4 $iSamples = 1152 Case 2 Switch $iMPEGVer Case 8 $iSamples = 1152 Case 0 $iSamples = 576 Case Else $iSamples = 0 EndSwitch Case Else $iSamples = 0 EndSwitch ; If not valid return If $iSamples = 0 Then Return SetError(1, 0, 0) ; 0 = bit 00, 4 = Bit 01, 8 = Bit 10 Local $iFrequency, $iFreqNum = BitAND($iFreqByte, 12) Switch $iFreqNum Case 0 $iFrequency = 44100 Case 4 $iFrequency = 48000 Case 8 $iFrequency = 32000 Case Else $iFrequency = 0 EndSwitch ; If not valid return If $iFrequency = 0 Then Return SetError(1, 0, 0) ; MPEG-2 halves the value If $iMPEGVer = 0 Then $iFrequency = $iFrequency / 2 ; Duration in ms = No of frames * Samples per frame / Sampling freq * 1000 Return Int(($iFrames * $iSamples / $iFrequency) * 1000) EndFunc ;==>_VBR_Timing Do not cancel the MsgBox if you want to verify the duration as the sound will stop immediately! Looking forward to some feedback. M231 point