Jump to content

Play sound files simultaneously


Recommended Posts

Hi,

i'm playing around with some drum samples (*.wav) to create a little drum keyboard with AutoIt combining HotKeySet() with SoundPlay().

But it seems, there can only be played 1 sound file at the same time and this sounds a bit snatchy, if you want to play a little drum rhythm...

Is there a way to play multiple sound files simultaneously?

Andi

Link to comment
Share on other sites

Hi,

i'm playing around with some drum samples (*.wav) to create a little drum keyboard with AutoIt combining HotKeySet() with SoundPlay().

But it seems, there can only be played 1 sound file at the same time and this sounds a bit snatchy, if you want to play a little drum rhythm...

Is there a way to play multiple sound files simultaneously?

Andi

It would require coordinating multiple separate scripts, I think. Or finding an external player to work with that can do that, and that can be automated by AutoIt. AutoIt is not multi-threaded, and won't do that on its own.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

hi

it can be done with WMP.au3

just use multiple instance of the wmplayer.ocx object ..

CODE

Global $oPlayer1 = ObjCreate("WMPlayer.OCX")

Global $oPlayer2 = ObjCreate("WMPlayer.OCX")

$song1 = @ScriptDir & "\test1.mp3" ; requires full path name ...

$song2 = @ScriptDir & "\test2.mp3" ; requires full path name ...

$rc = WMLoadFile($oPlayer1, $song1)

MsgBox(0, "1 rc", $rc)

$rc = WMLoadFile($oPlayer2, $song2)

MsgBox(0, "2 rc", $rc)

$rc = WMGetDuration($oPlayer1);

MsgBox(0, "2 rc", $rc)

; turns the volume down and back up slowly... song 1

For $i = 100 To 0 Step - 1

WMSetVolume($oPlayer1, $i)

Sleep(10)

Next

For $i = 0 To 100

WMSetVolume($oPlayer1, $i)

Sleep(10)

Next

; turns the volume down and back up slowly... song2

For $i = 100 To 0 Step - 1

WMSetVolume($oPlayer2, $i)

Sleep(10)

Next

For $i = 0 To 100

WMSetVolume($oPlayer2, $i)

Sleep(10)

Next

MsgBox(0, "pause", "")

WMPause($oPlayer1)

Sleep(300)

MsgBox(0, "play", "")

$rc = WMGetPosition($oPlayer1)

MsgBox(0, "POS", $rc)

WMPlay($oPlayer1)

Sleep(3000)

MsgBox(0, "stop","")

WMStop($oPlayer1)

WMStop($oPlayer2)

exit ; ----------------------------

; some functions

Func WMLoadFile($wm_obj, $sFilename)

$wm_obj.url = $sFilename

While Not WMGetState($wm_obj) = "Playing"

Sleep(100)

WEnd

EndFunc ;==>WMLoadFile

Func WMSetVolume($wm_obj, $iVol)

;iVol can be between 0 and 100

$wm_obj.settings.volume = $iVol

EndFunc ;==>WMSetVolume

Func WMFastForward($wm_obj)

$wm_obj.controls.fastForward()

EndFunc ;==>WMFastForward

Func WMReverse($wm_obj)

$wm_obj.controls.fastReverse()

EndFunc ;==>WMReverse

Func WMPause($wm_obj)

$wm_obj.controls.pause()

EndFunc ;==>WMPause

Func WMPlay($wm_obj)

$wm_obj.controls.play()

EndFunc ;==>WMPlay

Func WMStop($wm_obj)

$wm_obj.controls.stop()

EndFunc ;==>WMStop

Func WMGetPosition($wm_obj)

local $pos

$pos = $wm_obj.controls.currentPosition ()

return $pos

EndFunc ;==>WMGetPosition

Func WMGetDuration($wm_obj)

Local $len

$len = $wm_obj.currentMedia.duration

Return $len

EndFunc ;==>WMGetDuration

Func WMGetState($wm_obj)

local $sStates = "Undefined,Stopped,Paused,Playing,ScanForward,ScanReverse,Buffering,"

$sStates &= "Waiting,MediaEnded,Transitioning,Ready,Reconnecting"

local $aStates = StringSplit($sStates, ",")

$iState = $wm_obj.playState ()

Return $aStates[$iState]

EndFunc ;==>WMGetState

Link to comment
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
 Share

  • Recently Browsing   0 members

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