BinaryBrother Posted May 15, 2009 Share Posted May 15, 2009 (edited) Alright, please don't look at the code without reading the question, as it is more important that all my mistakes in the code...I was trying to make this a 10 min Job, but it decided to kick my ass instead... Anyway...What is the easiest way to go 30 seconds back from the End of the WAV file? To clarify, I am recording the stream from a Scanner using Audacity, and it is automatically exported when the user decides they want to review it. The most important part is a box that pops up and says... "How many Mins:Seconds would you like to go back?" The user says 30 seconds, and the wav is then played 30 seconds from the end of the file, I know by trying to make it clearer I may be making it worse... Anyone have any ideas?I know this is probably some simple math, but I'm stumped...expandcollapse popup#RequireAdmin #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Sound.au3> $Change = 0 If ProcessExists("Audacity.exe") Then MsgBox(0,"WARNING","Please don't open Audacity before opening this program... Audacity has been closed for you...") MsgBox(0,"WARNING","The program will now re-open Audacity for internal use by the program only.") EndIf While ProcessExists("Audacity.exe") ProcessClose("Audacity.exe") WEnd RunWait("C:\Program Files\Audacity 1.3 Beta (Unicode)\audacity.exe","C:\Program Files\Audacity 1.3 Beta (Unicode)",@SW_MAXIMIZE) Sleep(2000) ControlClick("Audacity","","[CLASS:wxWindowClassNR; INSTANCE:8]","Primary") MsgBox(0,"NOTIFICATION","Audacity is now recording, please take note of what side the Switchbox is set to...") MsgBox(0,"NOTIFICATION","The Switchbox is the little gray box to your left, right in front of the TV.") MsgBox(0,"NOTIFICATION","A = WESTEND /n B = EASTEND") WinSetState("Audacity","",@SW_HIDE) Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Scanner Recorder", 612, 273, 212, 160) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Edit1 = GUICtrlCreateEdit("", 24, 32, 569, 153) GUICtrlSetData($Edit1, StringFormat("If you are reading this, then the Audio from the scanners is being recorded properly!\r\n\r\nPlease take note that: ONLY ONE SCANNER CAN BE RECORDED AT A TIME\r\n\r\nIn order you record the WESTEND make sure the switchbox is set to (A).\r\n\r\nIn order you record the EASTEND make sure the switchbox is set to (B).\r\n\r\nTo listen to the recorded stream click "&Chr(34)&"Playback Stream"&Chr(34)&" and type in the amount of time you wish to play back!")) GUICtrlSetOnEvent($Edit1, "Edit1Change") $Button1 = GUICtrlCreateButton("Playback Stream", 64, 208, 473, 49, 0) GUICtrlSetOnEvent($Button1, "Button1Click") WinSetOnTop("Scanner Recorder","",1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func Button1Click() $Time = InputBox("Hmm...","How many Minutes:Seconds would you like to go back? The Example below gives an example of going back 1 Minute and 30 seconds...","1:30") $Time = StringSplit($Time,":") WinSetState("Audacity","",@SW_SHOW) WinActivate("Audacity") ControlClick("Audacity","","[CLASS:wxWindowClassNR; INSTANCE:5]","Primary") Send("!fe") Sleep(1000) Send("{ENTER}") Sleep(1000) ControlSetText("Export File","","[CLASS:Edit; INSTANCE:1]","Scanner.wav") Sleep(1000) Send("{ENTER}") Sleep(4000) If WinExists("Warning") Then ControlClick("Warning","","[CLASS:Button; INSTANCE:1]","Primary") WEnd While WinExists("scanner") Sleep(2000) WEnd ProcessClose("Audacity.exe") ProcessClose("Audacity.exe") ProcessClose("Audacity.exe") $Scanner = _SoundOpen("C:\Users\Bryant\Desktop\scanner.wav","scanner") $Length = StringSplit(_SoundLength($Scanner,1),":") $Min = $Length[2] - $Time[2] $Sec = $Length[3] - $Time[3] _SoundSeek($Scanner,0, RunWait("C:\Program Files\Audacity 1.3 Beta (Unicode)\audacity.exe","C:\Program Files\Audacity 1.3 Beta (Unicode)",@SW_MAXIMIZE) Sleep(2000) ControlClick("Audacity","","[CLASS:wxWindowClassNR; INSTANCE:8]","Primary") MsgBox(0,"NOTIFICATION","Audacity is now recording, please take note of what side the Switchbox is set to...") MsgBox(0,"NOTIFICATION","The Switchbox is the little gray box to your left, right in front of the TV.") MsgBox(0,"NOTIFICATION","A = WESTEND /n B = EASTEND") WinSetState("Audacity","",@SW_HIDE) EndFunc Func Edit1Change() If Not $Change = 1 Then MsgBox(0,"HEY!","Why are you trying to change my help text silly? It's there for good reason!") MsgBox(0,"HEY!","If you really want to change it I guess you can... :(") $Change = 1 EndIf EndFunc Func Form1Close() MsgBox(0,"Bye Bye","You clicked the close button, so bye bye!!") EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Edited May 15, 2009 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 16, 2009 Share Posted May 16, 2009 You could use _TimeToTicks() on both values, do your math and then finally a _TicksToTime() before sending to _SoundSeek() .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
BinaryBrother Posted May 16, 2009 Author Share Posted May 16, 2009 Very nice answer AdmiralAlkex. That's quite a nice find there. SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now