Scr1pter Posted February 15, 2018 Posted February 15, 2018 Hi, Can AutoIt play multiple sound files at the same time? (Making it sound as a chord) As far as I know, your rival can't. I tried it this way: SoundPlay("C:\Users\USER\Documents\A1.mp3", 1) SoundPlay("C:\Users\USER\Documents\A2.mp3", 1) It plays the first sound file, then the other, but not both together. Thanks for any help
BrewManNH Posted February 15, 2018 Posted February 15, 2018 It doesn't appear to be possible using SoundPlay, but you might get it to work with the BASS UDF. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Au3Builder Posted February 17, 2018 Posted February 17, 2018 (edited) This should do the trick.place two compiled script sound.au3 and sound2.au3 in the same directory next open sound.exe.You can delete sound2.exe now since sound.exe extracts sound2.exe on startup) sound.au3 FileInstall("sound2.exe","sound2.exe",0) Run("sound2.exe") Sleep(100) SoundPlay(@WindowsDir & "\media\tada.wav",1) sound2.au3 SoundPlay(@WindowsDir & "\media\tada.wav",1) Edited February 17, 2018 by Au3Builder
Moderators Melba23 Posted February 17, 2018 Moderators Posted February 17, 2018 (edited) Scr1pter, Why not use the standard Sound UDF: #include "Sound.au3" Global $sFilePath_1 = "C:\Users\USER\Documents\A1.mp3" Global $sFilePath_2 = "C:\Users\USER\Documents\A2.mp3" $vSound_ID1 = _SoundOpen($sFilePath_1) $vSound_ID2 = _SoundOpen($sFilePath_2) _SoundPlay($vSound_ID1) ; Play and return immediately _SoundPlay($vSound_ID2, 1) ; Play and wait until it finishes _SoundClose($vSound_ID1) _SoundClose($vSound_ID2) M23 Edited February 17, 2018 by Melba23 Helps if you attach the code! 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
Au3Builder Posted February 17, 2018 Posted February 17, 2018 (edited) Your script does not work for me at all. no sound is played.I only changed FilePath variables. Edited February 17, 2018 by Melba23 Quote removed
Moderators Melba23 Posted February 17, 2018 Moderators Posted February 17, 2018 Au3Builder, Well, it works for me or else I would not have posted it - I do test my code. M23 P.S. And when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. 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
Au3Builder Posted February 17, 2018 Posted February 17, 2018 (edited) I'm telling the truth.Your script does not play any sound on my laptop.I'm running Windows 10. Wait! I already know why... I had to write 1 to second parametr in both cases. it's okay now. My version is v3.3.14.2 _SoundPlay($vSound_ID1, 1) _SoundPlay($vSound_ID2, 1) What are your thoughts on that? Edited February 17, 2018 by Au3Builder
Moderators Melba23 Posted February 17, 2018 Moderators Posted February 17, 2018 Au3Builder, That will play the sounds sequentially, not simultaneously. The Sound UDF has not been updated for some time, so I fail to see why it does not work for you - it has in the past: 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
Moderators JLogan3o13 Posted February 18, 2018 Moderators Posted February 18, 2018 @Au3Builder, I am going to make the assumption you are not doing something silly like failing to change the file path to point at mp3 files that actually exist on your computer. Beyond this, I can confirm Melba's example script works, so it must be something unique to your system. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Au3Builder Posted February 18, 2018 Posted February 18, 2018 5 hours ago, JLogan3o13 said: @Au3Builder, I am going to make the assumption you are not doing something silly like failing to change the file path to point at mp3 files that actually exist on your computer. Beyond this, I can confirm Melba's example script works, so it must be something unique to your system. of course not. I changed the file path to these below and i use windows 10 v1709 aka Fall Creators Update. It might be something wrong with my system as my machine is quite old and is not designed to work with win 10.I will try out the script on another computer.I will keep you posted on the results. Global $sFilePath_1 = @WindowsDir & "\media\tada.wav" Global $sFilePath_2 = @WindowsDir & "\media\akord.wav"
gwinter Posted May 17, 2020 Posted May 17, 2020 (edited) Just for to clarify for anyone: The default AutoIt function SoundPlay() is made to only play one sound at a time. When playing a new sound it automatically stops the current sound. Bypassing the SoundPlay function and accessing Sound.au3 yourself is okay, and @Melba23's script will work, however the first sound played has to have the flag set as 0 and the 2nd sound as 1, otherwise it playes the first sound and waits until the sound is finished playing, and never plays the 2nd sound. The script (or EXE) has to keep running, or the sound will stop playing. For example, if you attempt to play a sound without waiting for it to finish playing (either by SoundPlay() or _SoundPlay) and you don't make a While loop or Sleep (or some other way to keep the script from ending), then AutoIt will play the sound but end the program before it is played. So making the first sound play without waiting (flag=0) then playing the second sound waiting for it to finish (flag=1) will work, because it plays the first sound is played, then the second sound is played, then the program waits until that sound is finished before exiting the script. *There is a problem with that method though, it will only work in that order and your script will be "stuck" until that sound is finished playing. The Exit option can not even be acessed from the system tray and the script can't be exited until that sound finishes playing. @Au3Builder's answer was better in my opinion, it works well, but there can be downsides to running multiple scripts, such as focus issues. I am currently working on a related system for AutoIt, an AutoIt framework that uses a "controller-script" that operates independently of the main script(s). One of the reasons for that is to bypass some of AutoIt's limitations without having to add more UDF's, DLL's or includes to a script. Having a script that operates independently of the main scripts can be beneficial in other ways too in AutoIt, such as for "scene-management" or controlling the main application's flow. That "controller-script" is part of a larger AutoIt project I am working on to add to AutoIt's functionality, and to help Auto-It function more like a modern-day game-engine. I am researching and testing different methods of supplying audio in AutoIt, such as rewriting the core Audio.au3, using FMOD or BASS, or like @Au3Builder mentioned, using a "controller-script" to handle sound management. The final application will also include automatic script generation, "prefabs", resource-management, GUI templates, 3D templates, etc. The AutoIt-Assistant Project (final name still to be determined) will be released here and on my temporary site: http://honorsoft.tripod.com/ Edited May 17, 2020 by gwinter Clarification
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