XWidgetSoft Forum
https://www.bbs.xwidget.com/

HELP: playing a sound continuously - CLOSED
https://www.bbs.xwidget.com/viewtopic.php?f=8&t=3428
Page 1 of 1

Author:  yereverluvinuncleber [ July 29th, 2013, 2:39 pm ]
Post subject:  HELP: playing a sound continuously - CLOSED

Is there a way of getting a OnMouseMove event on an object to play a sound multiple times / continuously? At the moment it plays just once when the movement is completed. I just want the sound to be played each and every time the mouse movement occurs.

Author:  qiancang [ July 29th, 2013, 7:34 pm ]
Post subject:  Re: playing a sound continuously

function text1OnMouseMove(Sender,Shift,X,Y,Dx,Dy)
{
PlaySound2("abc.wav")
}

Author:  yereverluvinuncleber [ July 30th, 2013, 3:21 am ]
Post subject:  Re: playing a sound continuously

Yes, that almost works but it seems to play the sound synchronously, ie. it plays the sound before it lets the next mouse movement complete so mouse movement is interrupted while the sound plays.
I was hoping that the sound would play in parallel whilst the movement continued. In this way each movement of the mouse would cause a sound to play, one sound overlapping the other. A simple buzz would then be played multiple times whilst the mouse was dragged giving the impression of a electrical interference whilst the mouse is dragged.

On YWE the sounds are played as objects in an asynchronous fashion and I am trying to replicate that behaviour. any thoughts?

Thanks for the quick response.

Author:  qiancang [ July 30th, 2013, 7:06 am ]
Post subject:  Re: playing a sound continuously

yereverluvinuncleber wrote:
Yes, that almost works but it seems to play the sound synchronously, ie. it plays the sound before it lets the next mouse movement complete so mouse movement is interrupted while the sound plays.
I was hoping that the sound would play in parallel whilst the movement continued. In this way each movement of the mouse would cause a sound to play, one sound overlapping the other. A simple buzz would then be played multiple times whilst the mouse was dragged giving the impression of a electrical interference whilst the mouse is dragged.

On YWE the sounds are played as objects in an asynchronous fashion and I am trying to replicate that behaviour. any thoughts?

Thanks for the quick response.


playsound("abc.wav") meets your request :D

Author:  yereverluvinuncleber [ July 30th, 2013, 10:05 am ]
Post subject:  Re: playing a sound continuously

It only plays the sound once though on a mousemove and only at the end of the mousemove.

Author:  yereverluvinuncleber [ August 8th, 2013, 7:43 am ]
Post subject:  Re: HELP: playing a sound continuously

I'm looking to play the sound asynchronously, one sound is kicked off immediately the mouse is moved - and when the next mouse movement happens the next sound plays. The end result is that the sounds overlap, ie. they play asynchronously. I suppose if this is not possible then I should raise it as a feature request.

Author:  hamid [ November 2nd, 2013, 8:07 pm ]
Post subject:  Re: HELP: playing a sound continuously

playsound("abc.wav") meets your request and works ok

the problem is from OnMouseMove Function:
if you don't move your mouse (your mouse stay on Object without movement) it still run the function multiple times.

This means when you are inside object it will play a moment of sound multiple times and maybe you don't hear that (because it's too little that sounds a noise) and when you get out of object it will get out of last function and you hear last play fully played

i tested with PhotoAlbum and !Next Command in the OnMouseMove Function:
Even when don't move the mouse it will do !Next until i get out of the Object

=============

Solution:
use your own sound in [yoursound.wav] and create an empty sound for [empty.wav] and use following code:

Code:
var x1=0
var y1=0
function text1OnMouseMove(Sender,Shift,X,Y,Dx,Dy)
{
  if(X!=x1|Y!=y1)    //Only Play if Mouse Moves
  {
   PlaySound("yoursound.wav")
  }
  else      //to Stop sound when Stop Mouse Movement
  {
    PlaySound("empty.wav")
  }
 
  x1=X
  y1=Y
}


//to prevent last play after getting out of object
//remember to set text1OnMouseLeave in OnMouseLeave of Object
function text1OnMouseLeave(Sender)
{
  PlaySound("empty.wav")
}

Author:  yereverluvinuncleber [ June 1st, 2014, 5:36 am ]
Post subject:  Re: HELP: playing a sound continuously

I will try that though I think that is not exactly what I wanted to achieve, will respond later, thanks.

Author:  yereverluvinuncleber [ October 19th, 2014, 12:29 pm ]
Post subject:  Re: HELP: playing a sound continuously

Hamid, in fact it is the opposite of what you describe.

On the OnMouseMove function it is meant to play the sound multiple times but it plays the sound only once.

On the other engine I use, the onMouseMove function, every mouse movement the sound plays and the sounds are combined as you would expect. The sound builds up and each sound layers upon the previous.

On the Xwidget engine, although I see the function running multiple times I only hear the sound running once when the onMouseMove function has completed. It plays just once. It is as if the Xwidget engine can only play one sound synchronously.

Author:  hamid [ October 25th, 2014, 10:22 pm ]
Post subject:  Re: HELP: playing a sound continuously

my explanation for my above code is correct for that code,
i thought you want it to create a scratch sound,
so on moving of mouse, it will stop the running one and start another one,
if your sound is placed at the beginning of the soundfile (at the 00:00:00),
it should generate a noise for movement of mouse

=============

but as i understand from your new post,
you want it to play multiple times and all of them together,
so they will get mixed up with each other,

for this one:
since only one instance of playsound() function will be ran on Xwidget,
it will need to call multiple instances of playsound() function in widget,
and i don't know a way to do that,
so maybe it's not possible right now

Author:  yereverluvinuncleber [ October 26th, 2014, 4:28 am ]
Post subject:  Re: HELP: playing a sound continuously

Thanks Hamid, the previous widget engine would allow a sound to be played multiple times altogether and I took advantage of that. I can do without that function for now, perhaps I will simply create a new sound.

Marked as CLOSED.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/