JohnOne Posted September 19, 2011 Posted September 19, 2011 Indeed sir. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
tskedition Posted September 19, 2011 Author Posted September 19, 2011 Thanks JohnOne your script works great it changes rpm perfectly.Only when engine stays at constant rpm sound does not start over. 1 sound file is about 5 sec.i just try making them longer.
tskedition Posted September 19, 2011 Author Posted September 19, 2011 Thanks JohnOne your script chaiges rpm perfectly.Only when engine stays at constant rpm then audio does not loop. I just try making audio files longer.
JohnOne Posted September 19, 2011 Posted September 19, 2011 I imagine you could use some sort of timer to test if the file has been playing for over say 4500ms and restart if it has, rather than edit your sounds. Might need vulcan like logic to implement it though. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Moderators Melba23 Posted September 19, 2011 Moderators Posted September 19, 2011 tskedition,As I suggested above, use the Sound.au3 UDF to replay your sound as often as required.This shows how to do it - you have to fill the other cases: expandcollapse popup#include <Sound.au3> HotKeySet("{PAUSE}", "endscript") $done = 0 $iCurr_Colour = 0 ; This is to store the colour at the moment $aPlaying ; This is the sound playing at the moment ; Open the sound files $a100 = _SoundOpen("C:\arse\rpm 100.wav") $a150 = _SoundOpen("C:\arse\rpm 150.wav") $a200 = _SoundOpen("C:\arse\rpm 200.wav") $a250 = _SoundOpen("C:\arse\rpm 250.wav") $a300 = _SoundOpen("C:\arse\rpm 300.wav") $a350 = _SoundOpen("C:\arse\rpm 350.wav") $a400 = _SoundOpen("C:\arse\rpm 400.wav") Do $iColour = PixelGetColor(1179, 132) ; Get the current colour Switch $iColour Case 0x333333 ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a100 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf ; Add the other cases here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 _SoundClose($a100) _SoundClose($a150) _SoundClose($a200) _SoundClose($a250) _SoundClose($a300) _SoundClose($a350) _SoundClose($a350) _SoundClose($a400) Exit EndFuncIt works when I test it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
JohnOne Posted September 19, 2011 Posted September 19, 2011 You could try this, Untested. (make all conditions same (relatively) as first. expandcollapse popupHotKeySet("{PAUSE}", "endscript") $done = 0 $RPM = 0 $Timer = 0 Do If (PixelGetColor(1179, 132) = 0x333333) And ($RPM <> 100 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 100.wav") $RPM = 100 ; moved here for tiny performance increase $Timer = TimerInit() EndIf If (PixelGetColor(1179, 132) = 0x4C4C4C) And $RPM <> 150 Then $RPM = 150 SoundPlay("") SoundPlay("C:\arse\rpm 150.wav") EndIf If (PixelGetColor(1179, 132) = 0x666666) And $RPM <> 200 Then $RPM = 200 SoundPlay("") SoundPlay("C:\arse\rpm 200.wav") EndIf If (PixelGetColor(1179, 132) = 0x808080) And $RPM <> 250 Then $RPM = 250 SoundPlay("") SoundPlay("C:\arse\rpm 250.wav") EndIf If (PixelGetColor(1179, 132) = 0x999999) And $RPM <> 300 Then $RPM = 300 SoundPlay("") SoundPlay("C:\arse\rpm 300.wav") EndIf If (PixelGetColor(1179, 132) = 0xB2B2B2) And $RPM <> 350 Then $RPM = 350 SoundPlay("") SoundPlay("C:\arse\rpm 350.wav") EndIf If (PixelGetColor(1179, 132) = 0xCCCCCC) And $RPM <> 400 Then $RPM = 400 SoundPlay("") SoundPlay("C:\arse\rpm 400.wav") EndIf Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 Exit EndFunc ;==>endscript AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
tskedition Posted September 19, 2011 Author Posted September 19, 2011 I think i try making pixel color in Algodoo flash some different tone and back to what it was after 4500ms.But first i need to make better and more accurate audio files to make rpm change smoother.Is there really no pitch or audio playing speed function like in some audio editing program.This would sound much better if i could just use one audio loop and change its speed like in most computer games.
Moderators Melba23 Posted September 19, 2011 Moderators Posted September 19, 2011 tskedition, Are you reading my posts or am I just adding to Jon's bandwidth usage to no purpose? I have just shown you how to replay the sounds as often as needed. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
tskedition Posted September 19, 2011 Author Posted September 19, 2011 I did that and now it works like i wanted thanks for all your help if i finish all audio files and some other stuff i video on youtube so everyone could have Algodoo with audio now.expandcollapse popupHotKeySet("{PAUSE}", "endscript") $done = 0 $RPM = 0 $Timer = 0 Do If (PixelGetColor(1179, 132) = 0x333333) And ($RPM <> 100 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 100.wav") $RPM = 100 ; moved here for tiny performance increase $Timer = TimerInit() EndIf If (PixelGetColor(1179, 132) = 0x4C4C4C) And ($RPM <> 150 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 150.wav") $RPM = 150 $Timer = TimerInit() EndIf If (PixelGetColor(1179, 132) = 0x666666) And ($RPM <> 200 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 200.wav") $RPM = 200 $Timer = TimerInit() EndIf If (PixelGetColor(1179, 132) = 0x808080) And ($RPM <> 250 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 250.wav") $RPM = 250 $Timer = TimerInit() EndIf If (PixelGetColor(1179, 132) = 0x999999) And ($RPM <> 300 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 300.wav") $RPM = 300 $Timer = TimerInit() EndIf If (PixelGetColor(1179, 132) = 0xB2B2B2) And ($RPM <> 350 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 350.wav") $RPM = 350 $Timer = TimerInit() EndIf If (PixelGetColor(1179, 132) = 0xCCCCCC) And ($RPM <> 400 Or TimerDiff($Timer) > 4500) Then SoundPlay("") SoundPlay("C:\arse\rpm 400.wav") $RPM = 400 $Timer = TimerInit() EndIf Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 Exit EndFunc ;==>endscript
JohnOne Posted September 19, 2011 Posted September 19, 2011 Glad it works, but before you continue, I would give Melba23s option a whirl, as it looks as though it may have better performance because of the files all being loaded and ready to go. For a few extra minutes, it may be well worth it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
tskedition Posted September 19, 2011 Author Posted September 19, 2011 Melba23 your script works well and audio loops play nicely.Yes this is exactly what i needed.
Moderators Melba23 Posted September 19, 2011 Moderators Posted September 19, 2011 tskedition, Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
AdmiralAlkex Posted September 20, 2011 Posted September 20, 2011 Is there really no pitch or audio playing speed function like in some audio editing program.This would sound much better if i could just use one audio loop and change its speed like in most computer games.Sure there is. Do a search for _SoundSpeed(). The other UDF's probably have that functionality too if you actually search. .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
tskedition Posted September 20, 2011 Author Posted September 20, 2011 I did search forums and found BassFX Did some testing on changing sound speed and pitch with examples but i could change only one at a time.I could not figure out how to change pitch and speed together.and then i need to combine that with pixel color script it still too complicated for me
tskedition Posted September 20, 2011 Author Posted September 20, 2011 I think one way to do this with pest audio quality is using some audio editiong software Program called "Amazing Slow Downer"it changes audiospeed and pitch live.Program is just a window with buttons and scrollbars.There are two ways chaining these values first is moving scrollbars. Other way is to double click at the value Speed or Semitones(pitch) at the bottom and type new value. So the idea is Autoit script detects pixel color from Algodoo and changes speed and pitch in Amazing Slow Downer that runs on background Like this if pixelcolor 0x333333 speed 100 Pitch 1 if pixelcolor 0x4C4C4C speed 112 Pitch 2 if pixelcolor 0x666666 speed 118 Pitch 3 if pixelcolor 0x808080 speed 125 Pitch 4 if pixelcolor 0x999999 speed 132 Pitch 5 if pixelcolor 0xB2B2B2 speed 141 Pitch 6 I tried some example scripts and did get some buttons from Amazing Slow Downer to work but not scrollbars or those things at the bottom where you can type value.I am still beginner I hope someone can help me with that script maybe you can download this Amazing Slow Downer its small program 2.2mb to download and its free demo here is the link http://www.ronimusic.com/download/setup_amsldo.exe i post this old script from Melba23 that plays different audio files when pixel color chainges expandcollapse popup#include <Sound.au3> HotKeySet("{PAUSE}", "endscript") $done = 0 $iCurr_Colour = 0 ; This is to store the colour at the moment $aPlaying = 0 ; This is the sound playing at the moment; Open the sound files $a100 = _SoundOpen("C:\arse\rpm 100.wav") $a150 = _SoundOpen("C:\arse\rpm 150.wav") $a200 = _SoundOpen("C:\arse\rpm 200.wav") $a250 = _SoundOpen("C:\arse\rpm 250.wav") $a300 = _SoundOpen("C:\arse\rpm 300.wav") $a350 = _SoundOpen("C:\arse\rpm 350.wav") $a400 = _SoundOpen("C:\arse\rpm 400.wav") Do $iColour = PixelGetColor(626, 988) ; Get the current colour Switch $iColour Case 0x333333 ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a100 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf Case 0x4C4C4C ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a150 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf Case 0x666666 ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a200 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf Case 0x808080 ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a250 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf Case 0x999999 ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a300 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf Case 0xB2B2B2 ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a350 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf case 0xCCCCCC ; If it is this colour If $iCurr_Colour <> $iColour Then ; Has it changed? $iCurr_Colour = $iColour ; If so then store it so we do not keep restarting the same sound on each pass _SoundStop($aPlaying) ; Stop the current sound $aPlaying = $a400 _SoundPlay($aPlaying) ; Play the new sound only when the colour changes EndIf ; Check if the sound has stopped If _SoundStatus($aPlaying) = "stopped" Then _SoundPlay($aPlaying) ; Play it again EndIf ; Add the other cases here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch Sleep(10) Until $done = 1Func endscript() ToolTip("") $done = 1 _SoundClose($a100) _SoundClose($a150) _SoundClose($a200) _SoundClose($a250) _SoundClose($a300) _SoundClose($a350) _SoundClose($a350) _SoundClose($a400) Exit EndFunc
tskedition Posted September 20, 2011 Author Posted September 20, 2011 Maybe i should have started new topic for this.
tskedition Posted September 20, 2011 Author Posted September 20, 2011 I just got BassFX Working pixel color changes pitch and speed will test audio quality tomorrow its 1:29 at night here.Maybe i dont need then that "Amazing Slow Downer"script then
tskedition Posted September 21, 2011 Author Posted September 21, 2011 This script is combination of Melba23 script and BassFX example scripts,Seems to work but i dont understand what do i have to change to make audio to start over when it ends.expandcollapse popup#include <Sound.au3> #include <Bass.au3> #include <BassConstants.au3> #include <BassFX.au3> #include <BassFXConstants.au3> Global $playing_state = -1 ;Startup Bass & BassFX. Also check if loading failed. _BASS_STARTUP ("BASS.dll") If @error = -1 Then MsgBox (0, "", "DLL Does not exist? Please check file exists.") Exit EndIf _BASS_FX_Startup("bass_fx.dll") If @error = -1 Then MsgBox (0, "", "DLL Does not exist? Please check file exists.") Exit EndIf ;Initalize bass. Required for most functions. _BASS_Init(0, -1, 44100, 0, "") ;Check if bass iniated. If not, we cannot continue. If @error Then MsgBox(0, "Error", "Could not initialize audio") Exit EndIf ;Prompt the user to select a MP3 file $file = FileOpenDialog("Open...", "", "Wav Files (*.Wav)") ;Create a stream from that file. $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, $BASS_STREAM_DECODE) ;Check if we opened the file correctly. If @error Then MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error) Exit EndIf $tempo = _BASS_FX_TempoCreate ($MusicHandle, 0) ;Iniate playback _BASS_ChannelPlay($tempo, 1) ;Get the length of the song in bytes. $song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE) ;Create a timer $timer = TimerInit () ;So we can set it to something different each time. $numberchanges = 0 HotKeySet("{PAUSE}", "endscript") $done = 0 $iCurr_Colour = 0 ; This is to store the colour at the moment $aPlaying = 0 ; This is the sound playing at the moment Do $iColour = PixelGetColor(626, 988) ; Get the current colour Switch $iColour Case 0x333333 If $iCurr_Colour <> $iColour Then _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, 10) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO_PITCH, 0) EndIf Case 0x4C4C4C If $iCurr_Colour <> $iColour Then _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, 20) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO_PITCH, 1) EndIf Case 0x666666 If $iCurr_Colour <> $iColour Then _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, 30) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO_PITCH, 2) EndIf Case 0x808080 If $iCurr_Colour <> $iColour Then _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, 40) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO_PITCH, 3) EndIf Case 0x999999 If $iCurr_Colour <> $iColour Then _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, 50) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO_PITCH, 4) EndIf Case 0xB2B2B2 If $iCurr_Colour <> $iColour Then _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, 60) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO_PITCH, 5) EndIf Case 0xCCCCCC If $iCurr_Colour <> $iColour Then _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, 70) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO_PITCH, 6) EndIf ; Add the other cases here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch Sleep(10) Until $done = 1 Func endscript() ToolTip("") $done = 1 Exit EndFunc
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