Sign in to follow this  
Followers 0
RazerM

Sound UDF

60 posts in this topic

#21 ·  Posted

good program

Share this post


Link to post
Share on other sites



#22 ·  Posted

#include "audio.au3"


;Kudos to RazeRM on his audio.au3 but i had to chop some of his soundseek in order for my trick to work

Func _SoundSeek2($sSnd_id, $iMs)
;Declare variables
;Local $iMs = 0
    Local $iRet
;prepare mci to recieve time in milliseconds
    mciSendString("set " & FileGetShortName($sSnd_id) & " time format miliseconds")
;modify the $iHour, $iMin and $iSec parameters to be in milliseconds
;and add to $iMs
;$iMs += $iSec * 1000
;$iMs += $iMin * 60 * 1000
;$iMs += $iHour * 60 * 60 * 1000
; seek sound to time ($iMs)
    $iRet = mciSendString("seek " & FileGetShortName($sSnd_id) & " to " & $iMs)
;return
    If $iRet = 0 Then
        Return 1
    Else
        Return SetError(1, 0, 0)
    EndIf
EndFunc  ;==>_SoundSeek


;$sID and $sID2 being the same sounds just 2 opened instances
;$lowpoint is the param of how low you want your sound to fade
;$time self explanatory in [ms] respectively
;CrossFade1 should be used when you want to loop the same tune with crossfading

Func CrossFade1($sID,$sID2,$time,$lowpoint = 20)
    for $i = 100 to $lowpoint step -1
        sleep($time/(100-$lowpoint)/2)
        _SoundSetMasterVolume($i)
    Next
    _SoundPlay($sID2)
    Sleep(500)
    _SoundStop($sID)
    _SoundSeek2($sID,_SoundPos($sID2,2))
    _soundPlay($sID)
    _soundStop($sID2)
    for $i = $lowpoint to 100 step 1
        sleep($time/(100-$lowpoint)/2)
        _SoundSetMasterVolume($i)
    Next
EndFunc

;a bit of chopping
;/me gets binary axe :P

Func CrossFade2($sID,$sID2,$time,$lowpoint = 20)
    for $i = 100 to $lowpoint step -1
        sleep($time/(100-$lowpoint)/2)
        _SoundSetMasterVolume($i)
    Next
    _SoundPlay($sID2)
    Sleep(500)
    _SoundStop($sID)
    for $i = $lowpoint to 100 step 1
        sleep($time/(100-$lowpoint)/2)
        _SoundSetMasterVolume($i)
    Next
EndFunc
$sound = _SoundOpen("song.mp3", "music")
$sound2 = _SoundOpen("song2.mp3", "same_music")
_SoundPlay($sound)
sleep(3000)
MsgBox(4096,"Test","CrossFade sounds good?")
CrossFade1($sound,$sound2,5000)
MsgBox(4096,"test","what do you think? want to make it stop?")
_soundstop($sound)
MsgBox(4096,"C2C","I hope you make use of mine code if you can call it that :) Peace")

hope somebody finds this useful. im probably gonna get burnt or something because this is just basic for mambo jumbo but i thoaght why not :D


----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Share this post


Link to post
Share on other sites

#23 ·  Posted

Nobody likes my crossfader?


----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Share this post


Link to post
Share on other sites

#24 ·  Posted

Testers Needed to help fix bug with mp3's.

I need testers from as many versions of windows as possible, as I can only test on XP myself.

Instructions:

  • Run the script below.
  • Choose any mp3 file in the open dialog.
  • The sound will not play, and the script will finish very quickly.
  • A file called "SoundTest.txt" will be created on your desktop, please post the contents of this file here, even if it has errors.

#NoTrayIcon
#include <Array.au3>
#include <File.au3>

$hDebugFile = FileOpen(@DesktopDir & "\SoundTest.txt", 2)

$sFile = FileOpenDialog("Open MP3 File", @MyDocumentsDir, "MP3 Files (*.mp3)")
If @error Then
    FileWrite($hDebugFIle, "ERR: No File Opened" & @CRLF)
    Exit
EndIf
Local $szDrive, $szDir, $szFName, $szExt ;$szExt is ".mp3" anyway
_PathSplit($sFile, $szDrive, $szDir, $szFName, $szExt)

$Dir_Name = $szDrive & $szDir
$File_Name = $szFName & $szExt

$DOS_Dir = FileGetShortName($Dir_Name, 1)

$ShellApp = ObjCreate("shell.application")
If IsObj($ShellApp) Then
    $Dir = $ShellApp.NameSpace ($DOS_Dir)
    If IsObj($Dir) Then
        $File = $Dir.Parsename ($File_Name)
        If IsObj($File) Then
            $sRaw = $Dir.GetDetailsOf ($File, -1)
            FileWrite($hDebugFIle, "RAW--------------------------" & @CRLF & $sRaw & @CRLF & "END--------------------------" & @CRLF)
            $aInfo = StringRegExp($sRaw, "Duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})", 3)
            If Not IsArray($aInfo) Then
                FileWrite($hDebugFIle, "ERR: $aInfo Not Array")
                Exit
            EndIf
            FileWrite($hDebugFIle, "$aInfo = [" & _ArrayToString($aInfo, ",") & "]" & @CRLF)
            $Track_Length = $aInfo[0]
            FileWrite($hDebugFIle, "$Track_Length = '" & $Track_Length & "'" & @CRLF)
        EndIf
    EndIf
EndIf

FileClose($hDebugFile)
MsgBox(262144, "Done", "Thanks for testing.")

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.

Share this post


Link to post
Share on other sites

#25 ·  Posted

Vista SP1 Ultimate, 32-bit

HP dv8000t laptop, Intel Core2Duo

RAW--------------------------

Type: MPEG layer 3

Size: 7.34 MB

Artists: bitmud

Length: 00:05:20

END--------------------------

ERR: $aInfo Not Array

Share this post


Link to post
Share on other sites

#26 ·  Posted (edited)

Thanks a lot, looks like vista uses "Length" rather than "duration".

Edit: Another Vista test (from someone else) would be good just to make sure.

Tests from other Windows versions still needed, thanks.

Edited by RazerM

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.

Share this post


Link to post
Share on other sites

#27 ·  Posted

Tests from other Windows versions still needed, thanks.

Windows 2000 w/ SP4:

SoundTest.txt is empty!

Share this post


Link to post
Share on other sites

#28 ·  Posted (edited)

Windows 2000 w/ SP4:

SoundTest.txt is empty!

Try running in scite, and replace all "FileWrite($hDebugFile, " with "ConsoleWrite("

Edited by RazerM

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.

Share this post


Link to post
Share on other sites

#29 ·  Posted

Try running in scite, and replace all "FileWrite($hDebugFile, " with "ConsoleWrite("

That produced no output either!

But then I looked at the code and had a thought: I was selecting an mp3 that was in the root of my drive.

When I moved it into a folder, I get

RAW--------------------------

Type: MP3 Format Sound

Size: 2.12 MB

END--------------------------

ERR: $aInfo Not Array

Share this post


Link to post
Share on other sites

#30 ·  Posted (edited)

Looks like maybe windows 2000 won't be able to use the corrected functions.

Edited by RazerM

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.

Share this post


Link to post
Share on other sites

#31 ·  Posted (edited)

Sound.au3 (sort of) beta.

I'm looking for people to test Variable Bit Rate (VBR) songs, which are now supported properly unless the windows version doesn't support the shell.application object.

If the object fails/isn't supported then the functions operate normally, albeit with possibly incorrect VBR length of sound file. (As old versions of Sound.au3 do)

I've added Melba23 into authors, because the modifications were ultimately his, just modified to work within the functions rather than correcting my broken ones.

See Post #39 for latest sound.au3 beta

Edited by RazerM

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.

Share this post


Link to post
Share on other sites

#32 ·  Posted (edited)

Sound.au3 (sort of) beta.

I'm looking for people to test Variable Bit Rate (VBR) songs, which are now supported properly unless the windows version doesn't support the shell.application object.

If the object fails/isn't supported then the functions operate normally, albeit with possibly incorrect VBR length of sound file. (As old versions of Sound.au3 do)

I've added Melba23 into authors, because the modifications were ultimately his, just modified to work within the functions rather than correcting my broken ones.

I no longer need to know if the object works on different windows versions, just the new code needs tested.

Hi!

Just tested with a fresh encoded mp3 file ( Lame V2 ), and playback worked fine.

The sound length is however not reported correctly.

Got 00:04:12 when in fact the song was 00:03:17 long.

Edit: The song was also encoded with the --vbr-new flag.

Edit2: The song position is also wrong.

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#33 ·  Posted (edited)

That must mean the object is failing for you, hence the correct sound length is not reported.

Can you tell me what windows version you are using and then run the test script I posted yesterday (a few posts back in this topic).

Ideally a universal method will be found for the length of VBR sound files.

Edit: Yeah _SoundPos and _SoundSeek share this bug.

But really it's a bug with MCI, the new sound.au3 applies a correction ratio where possible.

Edited by RazerM

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.

Share this post


Link to post
Share on other sites

#34 ·  Posted

Here's the output from the earlier script (this fetched the right time, yay!):

RAW--------------------------
Typ: VLC media file (.mp3)
Storlek: 3,84 MB
Artister: Linkin Park
Längd: 00:03:16
END--------------------------
ERR: $aInfo Not Array

My OS is Win Vista x86 Ultimate with Service Pack 1 applied.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#35 ·  Posted

Ah that's the problem, Längd instead of Length.

I should probably just make a regular expression to find the actual 00:00:00 part, I'll do that tomorrow.


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.

Share this post


Link to post
Share on other sites

#36 ·  Posted

RazerM,

The beta works fine for me (Vista 32 SP1) - but then I would be surprised if it didn't!

RAW--------------------------

Type: MP3 File

Size: 6.41 MB

Artists: Glow

Length: 00:05:50

END--------------------------

ERR: $aInfo Not Array+

The only thing I noticed in this rather longer testing phase was that multiple seeks within the file nearly always led to larger errors in the overall playing time - i.e. the file ended slightly early. This is no doubt because of the rounding to the nearest thousand ms that occurs when the file properties time is converted. Multiple seeks = multiple rounding errors = larger errors. But I cannot see any way of avoiding this as it is inherent in the accuracy of the input data used. Besides, how often will you seek multiple times? And in the case of restarting long audio books or podcasts (which was the original question in the other thread if you remember!) a second or two is not really that important.

M23

PS I have added a post to the other thread concerning the origin of the "file properties" code snippet.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#37 ·  Posted

Vista SP1 Ultimate :

RAW--------------------------

Type: MP3 Format Sound

Size: 3.34 MB

Artists: POPS

Length: 00:03:38

END--------------------------

ERR: $aInfo Not Array


[size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent]

Share this post


Link to post
Share on other sites

#38 ·  Posted (edited)

RazerM,

The beta works fine for me (Vista 32 SP1) - but then I would be surprised if it didn't!

RAW--------------------------

Type: MP3 File

Size: 6.41 MB

Artists: Glow

Length: 00:05:50

END--------------------------

ERR: $aInfo Not Array+

The only thing I noticed in this rather longer testing phase was that multiple seeks within the file nearly always led to larger errors in the overall playing time - i.e. the file ended slightly early. This is no doubt because of the rounding to the nearest thousand ms that occurs when the file properties time is converted. Multiple seeks = multiple rounding errors = larger errors. But I cannot see any way of avoiding this as it is inherent in the accuracy of the input data used. Besides, how often will you seek multiple times? And in the case of restarting long audio books or podcasts (which was the original question in the other thread if you remember!) a second or two is not really that important.

M23

PS I have added a post to the other thread concerning the origin of the "file properties" code snippet.

Vista SP1 Ultimate :

RAW--------------------------

Type: MP3 Format Sound

Size: 3.34 MB

Artists: POPS

Length: 00:03:38

END--------------------------

ERR: $aInfo Not Array

Just so you know, the "ERR: $aInfo not array" only happens in the test script, this bug is not present in sound.au3

New beta, updated to work with any language:

[see next post for latest beta]

Added credits for Simucal and PsaltyDS

Edited by RazerM

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.

Share this post


Link to post
Share on other sites

#39 ·  Posted (edited)

New beta available:

Latest Beta in post #43

I've fixed _SoundPos() both normally and when using _SoundSeek()

Edited by RazerM

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.

Share this post


Link to post
Share on other sites

#40 ·  Posted (edited)

_SoundPos() in mode 1 returns 01:60:00 one second after 00:59:59 after two hours _SoundPos returns 02:120:00

Glad I could help test on long/strange files :P

*edit*

I added

$iSnd_pos_min = Int($iSnd_pos_min - ($iSnd_pos_hour * 60))

just before the format string in _SoundPos and that seemed to clear it up. Thanks so much!

Edited by Skizmata

AutoIt changed my life.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0