de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Looping background sound?
PostPosted: Thu Sep 10, 2015 12:55 pm 
Offline
Veteran
User avatar
Is there a way to loop a "playBackgroundSound" sound endlessly, until told to stop, such as for background music?

I'm guessing it's something obvious I'm missing, but so far trying to do this has resulted in the sound being played dozens of times at once (because it doesn't wait for the sound to finish before repeating it), and because the sound can change (various mp3s), I can't use a "wait(lengthofsound)" in the loop to avoid this, either.

If anyone can help, I'd really appreciate it!


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Sep 10, 2015 1:17 pm 
Offline
Site Admin
User avatar
No, perhaps you can try the last proposed solution, knowing the length of each one.


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Sep 10, 2015 1:24 pm 
Offline
Veteran
User avatar
I tried that with a bunch of "ifs" and setting the wait to each track's length... only to realize afterwards that of course this means nothing else works (buttons, etc.) since the program is "frozen" while waiting for the song to finish! :(

Is there anything else you (or anyone else) can suggest as an alternative to simulate looping background music?

This is something I've been trying to pull off with SexScripts for a while now, but it's only just become something I *need* to do.

Alternatively, is there any way a "playBackgroundSoundLoop" type function could be added, or is this just not possible at all with groovy?


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Sep 10, 2015 2:09 pm 
Offline
Site Admin
User avatar
You can check sometimes that the last sound duration has elapsed, sus starting another one
Code:
def lastEnd = 0
def sounds = [{"name":"s1.mp3", "duration":10},  {"name":"s2.mp3", "duration":27}, ...]

...

if(getTime()>lastEnd) {
  sound = sounds[getRandom(sounds.size())]
  playBackgroundSound(sound["name"])
  lastEnd = sound["duration"] + getTime()
}

...

if(getTime()>lastEnd) {
  sound = sounds[getRandom(sounds.size())]
  playBackgroundSound(sound["name"])
  lastEnd = sound["duration"] + getTime()
}

...


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Sep 10, 2015 5:52 pm 
Offline
Veteran
User avatar
Thanks for the help and example code, though sadly it's way beyond my understanding of groovy to get that implemented (I get errors right off bat, with "}" expected instead of ":") and so little idea of how this works that I can't begin to troubleshoot it, but it gave me enough ideas to hack up my own version along the same lines.

The issue is, though, how do I make the script keep checking if the music is looping or not? My version "works", in that I can play music, and then manually call a check to see if it needs to loop or not (and it restarts the song if it needs to, and doesn't if it doesn't)... but how do I make it check *without* waiting for the user to click something or advance the script? That is, if the user leaves the script running but doesn't click the continue button provided, it won't check for the loop so the music stops until they do, which doesn't really make it a "loop".

It's such a shame that such a "simple" (in terms of commonly found functionality, not presumably implementation) feature is so hard to implement. :( I just need music to play and repeat when it ends... but in the "background" so that it continues throughout other message changes and button clicks.

Will keep plugging away trying to get this to work, though! Again, thanks for the help, mate.


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Sep 10, 2015 7:00 pm 
Offline
Site Admin
User avatar
You can not do what you want there.

Perhaps you can put a big mp3 somewhere else on the web, then use useUrl()


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Fri Sep 11, 2015 7:38 am 
Offline
Veteran
User avatar
In that case, can I please make a feature request to implement something like:

Code:
playBackgroundMusic("nameofmusicfile")

... in a future SexScripts version, which works like playBackgroundSound but repeats the sound automatically when it ends (while playBackgroundSound keeps its current functionality)?

I don't want to be a pain, but this seems like a huge missing feature; it's something you can do in many other scripting engines, and not being able to do it in SexScripts is a real limitation.

In the meantime, I've *almost* got a workaround, but I need to know how to "time out" a getSelectedValue request (as you can with a showButton), like:

Code:
def timedbutton = showButton("This button will click itself in 10 seconds", 10);

How/can this be done with "getSelectedValue"? Either the script picking a value if the player makes no input or just returning 0 or even null would likely work for my use (all I need is some kind of "advancement without input", as with the showButton example above).

Alternately, if doing this just isn't possible AND if some sort of playBackgroundMusic function is totally impossible to implement (forgive me if I am asking the impossible there with groovy!), than could a similar optional parameter that "times out" a getSelectedValue input be added similar to showButton?


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Fri Sep 11, 2015 11:03 am 
Offline
Site Admin
User avatar
There will be perhaps a pool about adding some functions.

For you need here, you can wait with showButton(), before presenting the possibilities with getSelectedValue()


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Fri Sep 11, 2015 11:53 am 
Offline
Veteran
User avatar
doti wrote:
There will be perhaps a pool about adding some functions.

For you need here, you can wait with showButton(), before presenting the possibilities with getSelectedValue()


I would VERY much like such a function to be added to SexScripts, Doti. It's such a commonly-available one that I feel it really detracts not having it available. I don't know how many votes it would receive in an open pool, since I presume it isn't something many would think of until they need it, but I can see it as being very, very useful and really open up SexScripts to better and longer scripts.

As for using showButton, sadly that won't work for me; I need to present the player with multiple choices (getSelectedValue) which is of course where the sound will stop playing if the duration expires before they do. Hence why I wondered if adding "if nothing selected before time expires, select "x") could be added to getSelectedValue or a similar function, if it wasn't possible to add a simple playBackgroundMusic (loop) function (which is my preference).

I do appreciate the help trying to work around this, as I didn't know what I was asking was such a difficult thing to implement, however it seems I'll have to wait and hope for a new feature in a future update to finish the script.


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Tue Jun 14, 2016 7:08 am 
Offline
Veteran
User avatar
Just wanted to see if there has been any progress in adding some kind of "playBackgroundMusic("nameofmusicfile")" function to SexScripts?

I was working on my massive "RPG" script today and thinking how much I want to release it when it is done, but without a way to fix background music, I can't.

Anyway, just thought I'd check in and ask as it's been a while since discussing this issue.


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Jun 16, 2016 9:45 am 
Offline
Site Admin
User avatar
With only a loop flag, the sound still won't ends if another one if started (that mean, if it's an infinite loop, it'll end only at the end of the script).


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Jun 16, 2016 11:08 am 
Offline
Veteran
User avatar
doti wrote:
With only a loop flag, the sound still won't ends if another one if started (that mean, if it's an infinite loop, it'll end only at the end of the script).

If I am understanding you correctly, the problem is that a theoretical "playBackgroundSoundLoop" would keep playing until the script ends (which is good) but that if a second "playBackgroundSoundLoop" was called it TOO would play forever as WELL as the previous one... is that the issue?

If so, what about a "stopAllSounds" type function that - when called - ended any and all playing sounds? Would that be possible and solve the problem here?

What I like about that idea is that it would let multiple background sounds (music, sound effects, voices, etc) all play at once if needed, yet can be stopped (to change "music tracks", for example) with some kind of stop function being called when needed.

Just guessing here of course, trying to figure out how to get the functionality needed.


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Jun 16, 2016 12:40 pm 
Offline
Site Admin
User avatar
I see a lot of options, but it needs to stay quite simple.
(I think at the begining having some background track was not considered, as it doesn't exist in CM, Milo, etc.)


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Thu Jun 16, 2016 1:07 pm 
Offline
Veteran
User avatar
doti wrote:
I see a lot of options, but it needs to stay quite simple.
(I think at the begining having some background track was not considered, as it doesn't exist in CM, Milo, etc.)


As long as it can be possible in some way, I don't mind how it is implemented (like I said, mine were just guesses at how it could be done with as little stress as possible!).

I'm pretty sure it could be done in CyberMistress though, couldn't it? I seem to remember writing routines and having to remember to "stop all sounds" to stop a music/background noise track playing across multiple program "blocks".


Top
 Profile Send private message 
 
 Re: Looping background sound?
PostPosted: Wed Sep 07, 2016 10:08 am 
Offline
Site Admin
User avatar
It will be ok in the next release.

Changes in API 7
  • playBackgroundSound comes with a "times" parameter, set to number >1 to loop the sound
  • playBackgroundSound(null) stops all sounds


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.