Jump to content

Recommended Posts

Posted (edited)

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

audio.au3

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.

SoundGetSetQuery.au3

SoundExample.au3 - Examples for SoundGetSetQuery.au3

Edited by Volly
  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted (edited)

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
"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
Posted (edited)

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
"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
Posted

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.

Posted

_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.

"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
Posted

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.

Posted (edited)

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
"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
Posted

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

Posted

@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:):)

"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
Posted

@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.
Posted

@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 :)

"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
Posted

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!

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...