Jump to content



Photo

Audio.au3


  • Please log in to reply
59 replies to this topic

#1 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 05:15 PM

Audio.au3 is designed for XP. I do not plan to offer support for Vista for I do not own a Vista PC. The only workaround I know of is to run your app in XP mode if using Vista. At this time I also do not plan to offer support for Windows 7. If someone wishes to help out with that, that would be great!
-----------------------------------------------------------------------------

This expands on sound.au3, and can be used as a replacement. I combinds mixer.au3 and sound.au3, along with functions to make using mixer.au3 easier. With audio.au3, you can control the same thing as sound.au3, but with extra commands:
_SoundSetMasterVolume($iVolume) - Sets the Master Volume. Does not control an application's volume
_SoundGetMasterVolume - Gets the Master Volume level
_SoundSetMicrophoneVolume - Sets the Microphone input volume
_SoundGetMicrophoneVolume - Gets the Microphone volume level
_SoundGetPhoneVolume - Gets the Phone volume on the modem
_SoundSetVolumeCD - Sets the Volume level on the CDRom
_SoundSetMasterWaveVolume - Sets the Master Wave Volume level

Enjoy!

Edit: added the code as a attachment due to cut and paste issues with the forum.
Edit2: If you want info on items for MP3, Mega came up with this: http://www.autoitscript.com/forum/index.ph...mp;#entry410387
I may add it to Audio.au3 later seeing how it has to do with audio files.
Edit: _Ismute added. Thanks Xenobiologist

Previous version # of downloads - 605
Attached File  audio.au3   33.47KB   4247 downloads

Edit: asbeer450 came up with this as a different way to handle audio controls. His method also works well, but has the same limitations as mine. Feel free to use both to see what works good for you.
Attached File  SoundGetSetQuery.au3   55.24KB   2362 downloads
Attached File  SoundExample.au3   3.37KB   2029 downloads - Examples for SoundGetSetQuery.au3

Edited by Volly, 04 January 2010 - 01:03 PM.








#2 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 26 September 2007 - 05:27 PM

Nice job, thanks! :)

Do you have a definitive list of the types of files that can be _SoundOpen() 'ed? .wav and .mp3 I assume, but what about .m4a, .wma and the like? I'm going to give a .m4a file a try now, but it'd be nice if you noted in the _SoundOpen() function which files are available, since I don't even know all the different versions of audio files out there...

Thanks again for the great work!

Edit: for anyone's information, IF the modifications I listed in the below post are correct, .m4a files don't appear to play, but also don't return an error anywhere.

Edited by james3mg, 26 September 2007 - 05:43 PM.

Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#3 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 26 September 2007 - 05:35 PM

I copied and pasted your code into Audio.au3 on my desktop, then #included it in a test script, and I got this:

{my user profile}\Desktop\audio.au3(687,64) : ERROR: _SetVolume() already defined.
Func _SetVolume(ByRef $mixers, ByRef $curmixer, ByRef $percent)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
{my user profile}\Desktop\audio.au3(794,40) : ERROR: syntax error (illegal character)
Local $mixerline = DllStructCreate("
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
{my user profile}\Desktop\audio.au3(800,5) : ERROR: syntax error
EndIf
~~~~^
{my user profile}\Desktop\audio.au3(659,26) : ERROR: OpenAllMixers(): undefined function.
OpenAllMixers($mixers)
~~~~~~~~~~~~~~~~~~~~~~~~~^
{my user profile}\Desktop\audio.au3(661,109) : ERROR: MixerOpen(): undefined function.
$hmxobj = MixerOpen($curmixer, 0, $MM_MIXM_CONTROL_CHANGE, BitOR($CALLBACK_WINDOW, $MIXER_OBJECTF_MIXER))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



~~~~~~~~^
{my user profile}\Desktop\audio.au3(664,23) : ERROR: MixerClose(): undefined function.
MixerClose($hmxobj)
~~~~~~~~~~~~~~~~~~~~~~^
{my user profile}\Desktop\audio.au3(665,27) : ERROR: CloseAllMixers(): undefined function.
CloseAllMixers($mixers)
~~~~~~~~~~~~~~~~~~~~~~~~~~^
{my user profile}\Desktop\audio.au3 - 7 error(s), 0 warning(s)

Same thing happens if I just try to run audio.au3...AFAIK, running a typical UDF #include file should just run w/o errors and close, apparently without doing anything because it just defines functions, right?

I'm running AutoIt 3.2.8.1 Production version.

Edit: I'm looking at the file, and I see _SetVolume() being defined on line 646 AND again on 687...the only obvious difference (I didn't examine it with a microscope) is the addition of a comment in the second definition. I deleted the first definition in my file, and that first error went away.

Line 787 is unterminated...if I add a ") at the end of the line, the rest of the errors go away and the UDF seems to run OK, but I don't know if the comments on the following lines should be added to the end, or if it should just stop there. I don't know how to test to see if it works correctly now, so I'll leave it to you to finish fixing now. :-)

Edited by james3mg, 26 September 2007 - 05:44 PM.

Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#4 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 06:16 PM

Fixed. try it again

#5 Nahuel

Nahuel

    To Err is human, to Arr is pirate.

  • Active Members
  • PipPipPipPipPipPip
  • 1,841 posts

Posted 26 September 2007 - 06:29 PM

I get this:

: ==> Unterminated string.:
Local $mixerline = DllStructCreate("dword;dword;dword;dword;dword;dword;dword;dword;dword;dword;char[16];char[64];dword;dword;short

Line 786.


The _SoundSetMasterVolume() function works perfectly :)
I'll try the other ones.

#6 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 06:31 PM

I see the problem. When I cut and paste the code in, it is putting a return on 786 and putting the rest of the line on 788. Let me try to fix that again.

#7 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 06:40 PM

Ok, I think I got it. If it doesn't work, I will just upload the file directly so it works right.

#8 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 26 September 2007 - 09:29 PM

_SoundPlay() isn't working now, though it was when I made the two changes I mentioned before to your original post. I've tried both .mp3 files and .wav files, and neither play, nor do they return an error.
Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#9 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 10:58 PM

:) what happens when you use sound.au3 instead? I took Sound.au3 and combined it with mixer.au3.

#10 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 11:00 PM

I'm going to add the script as it is from my PC as a attachment. try that and see if that works. If so, it must be the way the forum is behaving when you cut and paste the code.

#11 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 11:13 PM

Nice job, thanks! :)

Do you have a definitive list of the types of files that can be _SoundOpen() 'ed? .wav and .mp3 I assume, but what about .m4a, .wma and the like? I'm going to give a .m4a file a try now, but it'd be nice if you noted in the _SoundOpen() function which files are available, since I don't even know all the different versions of audio files out there...

Thanks again for the great work!

Edit: for anyone's information, IF the modifications I listed in the below post are correct, .m4a files don't appear to play, but also don't return an error anywhere.


Try testing with sound.au3 and report back. If it doesn't work, we can look to see what needs to be done to make it work.

#12 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 26 September 2007 - 11:35 PM

It doesn't work with sound.au3 either.
-I just tried adding a sleep(1000) call after _SoundPlay("TheSound",1), and now it plays! Seems that the 1 telling it to wait until it's done playing isn't working in either sound or audio.au3.

Maybe it's another vista thing (I'm using business). Odd it was working earlier before your latest edits!

As to your latest post, I've tried with audio and sound.au3, and .m4a files don't play, nor do they return an error. I don't know about .wma files, or other types I'm unfamiliar with. It'd be nice if these functions could support them - I'm trying to write a podcast-feed creator script, and I'd like to be able to look up how long a .m4a file is. :)

Thanks for all your work again!

Edited by james3mg, 27 September 2007 - 02:23 PM.

Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#13 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 26 September 2007 - 11:40 PM

long day for me. Try it again. I think it is right this time.

:) :P :P :) :(

#14 smashly

smashly

  • Active Members
  • PipPipPipPipPipPip
  • 1,635 posts

Posted 27 September 2007 - 12:38 AM

As to your latest post, I've tried with audio and sound.au3, and .m4a files don't play, nor do they return an error. I don't know about .wma files, or other types I'm unfamiliar with. It'd be nice if these functions could support them - I'm trying to write a podcast-feed creator script, and I'd like to be able to look up how long a .m4a file is. :)

Thanks for all your work again!

To make any audio file work (providing your pc can play the audio file normally in any other player), then try associating the file ext with the mci device. In other words a small regedit can make it so any file will play...
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MCI Extensions] "m4a"="mpegvideo"

Yes associate most file ext in the same manner to the mpegvideo mci device..
Even avi, mp4, wmv, wma, ogg.. etc
Tip: Install current FFDshow filters, and associate any file ext you want with "mpegvideo" as in the example above.
Then you'll find nearly any file format will play with the _SoundOpen & _SoundPlay functions

Cheers

#15 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 27 September 2007 - 02:36 PM

@Volly - Brilliant, _SoundPlay() seems to work perfectly now, and audio.au3 doesn't have any errors! :P

@smashley - I've never poked around in the MCI Extensions part of the registry before, but I did what I think you're saying...I opened up HKLM\Software\Microsoft\Windows NT\CurrentVersion\MCIExtensions, and since m4a wasn't listed in there, I created a new String Value, named it m4a and gave it a value of MPEGVideo to match most of the other values in that key. I didn't installFFDshow filters (as I don't even know what it/they is/are), but I think I understand you that what I've done is all I'd need to do, correct?

Unfortunately, it didn't work. If I choose to play an m4a file, it immediately returns with no error and without playing it. If I stick a Sleep(50000) in after the call to play, I just get 50 seconds of silence. Any other ideas?

@anyone interested: So it looks like the sound.au3 and audio.au3 (and maybe mixer.au3 ?) only works with .wav and .mp3 files...are there any others that you know of? Again, it'd be nice if anyone had a definitive list :P :) :)
Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#16 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 27 September 2007 - 03:25 PM

@james3mg

The _Sound functions were created by me and are included with AutoIt, if you find any problems try the sound.au3 from autoit's include folder.
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#17 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 27 September 2007 - 05:39 PM

Audio.au3 has the entire sound.au3 embedded without any code changes to it. It is perfect the way RazerM coded it. I just wanted to expand on it so more functions were available. My hat goes off for RazerM for the work he as done. Nice job! :)

#18 james3mg

james3mg

    I resent the title "Spammer!" ;-)

  • Active Members
  • PipPipPipPipPipPip
  • 730 posts

Posted 27 September 2007 - 08:47 PM

@james3mg

The _Sound functions were created by me and are included with AutoIt, if you find any problems try the sound.au3 from autoit's include folder.

I realize that, but I can't find a list of what audio filetypes the _Sound functions work with! That's the list I'm trying to compile.

Thanks :)
Posted ImagePosted Image"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

#19 YogiBear

YogiBear

    deFinitely not yoUr average bear!

  • MVPs
  • 9,952 posts

Posted 27 September 2007 - 09:33 PM

you will have to test it to see what works and what doesn't. Report back what you find, and mayby others will do the same. Currently I'm busy as a beaver, so I won't be much help. I may have time next week to see what works.

#20 therks

therks

    Witty quote

  • Active Members
  • PipPipPipPipPipPip
  • 2,167 posts

Posted 30 September 2007 - 11:20 PM

Haha, it works with wmv files! Check this out:

#include <Sound.au3> $file = 'C:\WINDOWS\system32\oobe\images\intro.wmv' ;open sound file $sound = _SoundOpen($file) If @error = 2 Then     MsgBox(0, "Error", "The file does not exist")     Exit ElseIf @error = 3 Then     MsgBox(0, "Error", "The alias was invalid")     Exit EndIf _SoundPlay($sound) Sleep(_SoundLength($sound, 2)) _SoundClose($sound)


It also played an mpg, but _SoundLength didn't return the right time. It told me that a 2 minute video was 4 seconds. I also tried .avi, and it wouldn't play at all, the window that appears is just glitched out (visually), and the _SoundLength for that was way off as well.
But wmv seems to work fine!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users