Bert Posted March 26, 2008 Share Posted March 26, 2008 I'm working on this:http://www.autoitscript.com/forum/index.php?showtopic=67021I want to combine _SoundPanRight and _SoundPanLeft. The way it is designed, either command will be from 0 to 1000 for the sound volume on the respected speaker. What I want to do is have a range between -1000 to 1000. -1000 would be full left, and 1000 would be full right. I know if the number is negative, it is left, but I'm puzzled as to how to convert it to work correctly in _SoundPanLeft. My function would be named _SoundSetWaveBalance()Example:$sound1 = Soundplay("C:\example.mp3") _SoundSetWaveBalance($sound1, -800)Thoughts? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted March 26, 2008 Author Share Posted March 26, 2008 I'm working on this: http://www.autoitscript.com/forum/index.php?showtopic=67021 I want to combine _SoundPanRight and _SoundPanLeft. The way it is designed, either command will be from 0 to 1000 for the sound volume on the respected speaker. What I want to do is have a range between -1000 to 1000. -1000 would be full left, and 1000 would be full right. I know if the number is negative, it is left, but I'm puzzled as to how to convert it to work correctly in _SoundPanLeft. My function would be named _SoundSetWaveBalance() Example: $sound1 = Soundplay("C:\example.mp3") _SoundSetWaveBalance($sound1, -800) Thoughts?I came up with this, and I think it works, but it would be nice for someone else than me to test it. It works off of Kip's script: expandcollapse popupFunc _SoundSetWavebalance($sSnd_id, $Pan_base) if $Pan_base = 0 then $Pan = 1000 _SoundPanLeft($sSnd_id, $Pan) _SoundPanRight($sSnd_id, $Pan) EndIf if $Pan_base > 0 then $Pan = (1000-$Pan_base) _SoundPanRight($sSnd_id, 1000) _SoundPanLeft($sSnd_id, $Pan) EndIf if $Pan_base < 0 then $Pan = ($Pan_base+1000) _SoundPanLeft($sSnd_id, 1000) _SoundPanRight($sSnd_id, $Pan) EndIf EndFunc Func _SoundPanLeft($sSnd_id, $Pan); $Pan: 0 - 1000, 1000= normal ;Declare variables Local $iRet If StringInStr($sSnd_id,'!') Then Return SetError(3, 0, 0); invalid file/alias if $Pan < 0 or $Pan > 1000 Then Return SetError(1, 0, 0) $iRet = mciSendString("setaudio " & FileGetShortName($sSnd_id) & " left volume to "&$Pan) ;return If $iRet = 0 Then Return 1 Else Return SetError(1, 0, 0) EndIf EndFunc;==>_SoundPanLeft Func _SoundPanRight($sSnd_id, $Pan); $Pan: 0 - 1000, 1000= normal ;Declare variables Local $iRet If StringInStr($sSnd_id,'!') Then Return SetError(3, 0, 0); invalid file/alias if $Pan < 0 or $Pan > 1000 Then Return SetError(1, 0, 0) $iRet = mciSendString("setaudio " & FileGetShortName($sSnd_id) & " right volume to "&$Pan) ;return If $iRet = 0 Then Return 1 Else Return SetError(1, 0, 0) EndIf EndFunc;==>_SoundPanRight The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
weaponx Posted March 26, 2008 Share Posted March 26, 2008 I came up with this, -100% = Full Left, 100% = Full Right, 0% = Balanced: expandcollapse popup#include <Sound.au3> $testFile = "D:\Temp\Incoming Music\Paramore - My Hero.mp3" $Sound = _SoundOpen($testFile); Pick a song that is at least 1 minute long If @ERROR Then MsgBox(0,"File not found",$testFile) Exit EndIf _SoundPlay($Sound) ;Pan left to right (-100% -> 100%) For $i = -100 To 100 Step 10 _SoundPan($Sound, $i) ;ConsoleWrite("Pan: " & $i & @CRLF) Sleep(500) Next ;Pan right to left (100% -> -100%) For $i = 100 To -100 Step -10 _SoundPan($Sound, $i) ;ConsoleWrite("Pan: " & $i & @CRLF) Sleep(500) Next ;Reset _SoundPan($Sound, 0); Middle (0%) While 1 ;Exit when file ends If _SoundPos($Sound, 2) = _SoundLength($Sound, 2) Then ExitLoop WEnd Func _SoundPan($sSnd_id, $Pan); $Pan: -100% - 100% ;Declare variables Local $iRet If StringInStr($sSnd_id, '!') Then Return SetError(3, 0, 0); invalid file/alias If $Pan < -100 Or $Pan > 100 Then Return SetError(1, 0, 0) $PanABS = Abs($Pan * 10) If $Pan < 0 Then $PanLeft = 1000 $PanRight = 1000 - $PanABS Else $PanLeft = 1000 - $PanABS $PanRight = 1000 EndIf $iRetL = mciSendString("setaudio " & FileGetShortName($sSnd_id) & " left volume to " & $PanLeft) $iRetR = mciSendString("setaudio " & FileGetShortName($sSnd_id) & " right volume to " & $PanRight) ;return If $iRetL = 0 OR $iRetR = 0 Then Return 1 Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_SoundPanLeft Link to comment Share on other sites More sharing options...
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