EOS Audio Tutorial for beginners

All about the past, current and future webteases and the art of webteasing in general.
---
User avatar
lolol2
Explorer At Heart
Explorer At Heart
Posts: 518
Joined: Mon Feb 20, 2017 10:33 am
Gender: Male
Sexual Orientation: Straight

EOS Audio Tutorial for beginners

Post by lolol2 »

Hello together,
I have got some questions about how to make audio volume control in EOS teases after I released my last tease.
This is mostly interesting for the estim community but maybe someone else is also interesting in playing audio on different volume levels.

So I want here to give a very short, simple but hopefully usefull tutorial how to play with the EOS audio and volume control feature.
This tutorial is very very very basic! To be specially focused on people who are not familiar with using javascript in any way!

Here is the sample tease we are talking about below, this is what we are going to do:
https://milovana.com/webteases/showteas ... 9bfd8e1548


First we need to create a tease :wave: -> https://milovana.com/eos/editor/teases

1. Define a variable and enable audio module

We need a variable to keep track about the current volume and need to enable the EOS audio module.
So we will add a variable called "volume" and set it at default to 50.

2020-01-01 15_16_26-Eos Editor.png
2020-01-01 15_16_26-Eos Editor.png (78.24 KiB) Viewed 6955 times


2. Play an audio file

Next we want to play an audio file from the start page.
I would always recommend to play a sound file with 0% volume when creating an estim based tease!
This is always the save method, when you have a bug in your script and the following volume command is skipped or just not working you could get a massive volume jump.
It's always better to have no sound instead of a massive jump!

So we will select a sound file we have uploaded before in the files section, set the volume to 0%, set the loop option to infinity in the tutorial to make sure the file is running all the time.

Then we will select the option to play across pages, if this is not selected the file will stop by the next page change.
To control this file later we need to set an identifier, in our tutorial we will use "audio123" for this.

2020-01-01 15_23_38-Eos Editor.png
2020-01-01 15_23_38-Eos Editor.png (174.51 KiB) Viewed 6955 times

At the end we will add a simple go to action to get to our next page.


3. Show current volume and buttons

On our main page in that tutorial we want first to show the current value of our volume variable.
You can very simple show variables with the say function.

2020-01-01 15_31_54-Eos Editor.png
2020-01-01 15_31_54-Eos Editor.png (126.95 KiB) Viewed 6955 times

Next we will add two simple buttons, one for 10% volume increase and one for 10% decrease.
This button have a simple go to function to our next two pages.

2020-01-01 15_36_56-Eos Editor.png
2020-01-01 15_36_56-Eos Editor.png (142.34 KiB) Viewed 6955 times



4. "Script" to change the volume

Okay now to the "fency" javascript part. ;-)
You can add javascript code on pages just by adding the "Eval" function, this will allow to run you nearly everything.

The order on the left is important, we need to add the eval function before the goto action or it will be skipped.
In most cases it makes sense to run the code part of a page very early.

Our code is very simple, we will just add "10" to our volume variable.
It's like we are saying the programm please use the variable "volume" and use the current value of volume and add 10.
In our first run that would be "60 = 50 + 10" because the initial value is 50, we defined it at the beginning.
Of course you can input here nearly everything it's simple math and follows all the math rules with all that things like "- + / * ()" etc...! ;-)
So you can also do for example crazy stuff like "volume = (volume/50) * (2+10) - 10" if you want :-P

2020-01-01 15_44_30-Eos Editor.png
2020-01-01 15_44_30-Eos Editor.png (117.46 KiB) Viewed 6955 times

After that code we go back to our audio-check page with a go to command and create the same page for volume decrease but this time we will put in "volume = volume - 10" -> still simple math.



5. Set the new volume value

Okay now we have updated the variable from 50 -> 60 or 50 -> 40, depending on which button the user clicked.
But now we also have to say the soundfile to run with that new value, because at the moment we only have a variable with a number, nothing else happend so far.

To get this done we will jump to our audio-check page and at a little eval function to the top of the page. (important to set the eval funtion above the buttons!)

In this eval function we will set the new value to our running audio file.

2020-01-01 15_56_46-Eos Editor.png
2020-01-01 15_56_46-Eos Editor.png (149.36 KiB) Viewed 6955 times

This might be looking a bit complex if you have never seen any programcode but it's very easy to use.
The two important parts are:

identifier = The name we set when we played the audio file, in our case "audio123".

volume variable = In this part of the function we will hand over our volume variable to the function to give the new volume.

The important part is that this function is expecting a value between 0 and 1.
For example:
0,3 -> 30%
0,5 -> 50%
1 - 100%

But because our human brian can easier calculate with volume numbers between 0 - 100 we will set our variable with "normal" full numbers.
That is why we have to input "volume/100" -> this will just do a simple math calculation again -> " 50 / 100 = 0,5".

2020-01-01 16_00_34-Eos Editor.png
2020-01-01 16_00_34-Eos Editor.png (17.41 KiB) Viewed 6955 times


And this is everything you need to do a basic volume control, now it's running in a simple loop.

2020-01-01 16_14_03-Eos Editor.png
2020-01-01 16_14_03-Eos Editor.png (42.52 KiB) Viewed 6955 times

In a real tease you could add a volume increase of course everywhere, this loop is just a simple example.



6. Extra: Make it more stable!

What I showed you will work absolutely easy and perfect if you stay in a range from 0 to 100.
In our case when you click 6x on the increase button you will end with a volume of 110 in our variable.

This is a problem because it's not possible to set a volume of 110% in EOS, 100% is the max value.
So there are two options to take care about this issue.

1) You will design your tease in a way that you always keep track about the volume in your head, this will work when you start at a fixed volume point and know exactly how many times you add or reduce it to never get above 100%.
Very easy but very static and could lead into problems when your tease is very long and you lost control about everything. :-D

2) You will let javascript take care about that. ;-)


So lets see how we can do this.
We will need to add some simple code to our audio-check page in the eval section before we set the new volume!
In an eval function you can do endless amount of code, you don't need to create an eval function for every line you want to do.

2020-01-01 16_25_04-Eos Editor.png
2020-01-01 16_25_04-Eos Editor.png (163.14 KiB) Viewed 6955 times

Okay what the heck is that?!
In this very short "if loop" we are checking the volume value and if the volume is above 100 it will jump in and set the volume variable to 99.
99 because you can then see it better when it's happening.

Like:
2020-01-01 16_28_14-Eos Editor.png
2020-01-01 16_28_14-Eos Editor.png (17.53 KiB) Viewed 6948 times

In all other cases when the value of volume for example is 50, 60, 70, 80 etc... the part with the "volume = 99" get skipped.
Of course we need to do this check in both directions, so we will add a check if it's below 0 too.

Our full eval command:
2020-01-01 16_32_00-Eos Editor.png
2020-01-01 16_32_00-Eos Editor.png (34.8 KiB) Viewed 6955 times

I would always recommend to check the volume every time about this two possible issues when you have a tease which is using a lot of volume control!
Of course setting the values to 1 or 99 (You can use 0 or 100 of course too!) isn't a good solution for every situation because then all new volume changes get ignored.

Maybe it is better to jump to a new page instead and trigger a recalibration on that new page for the user.
Like:
2020-01-01 16_37_21-Eos Editor.png
2020-01-01 16_37_21-Eos Editor.png (39.69 KiB) Viewed 6955 times


7. Extra: Changing audio files

Okay when we talk about an estim based tease we mostly don't want to play one file over and over again for the whole tease.
So we need to change the file, for this action there are a lot of possible solutions, I will show you one very easy that will make the job without a lot complexity.
Maybe when you are familiar with a bit more javascript you can do it on your own way, but we keep it simple for this tutorial.

Let us add a third button to our tease where the user can stop the audio file.
2020-01-01 16_58_25-Eos Editor.png
2020-01-01 16_58_25-Eos Editor.png (159.8 KiB) Viewed 6955 times

On the new page we will add an eval function and stop the audio file.
That's very easy and similiar to the volume control.

2020-01-01 17_02_47-Eos Editor.png
2020-01-01 17_02_47-Eos Editor.png (128.56 KiB) Viewed 6955 times

Now the file stops playing and we got back to the main page and can still change the volume, but the audio file is stopped so nothing happens for your ears.

So let us add another button to our audio-check page and lets start a different sound file this time!

2020-01-01 17_08_04-Eos Editor.png
2020-01-01 17_08_04-Eos Editor.png (185.19 KiB) Viewed 6955 times

In the audio-start we can just add a normal Audio Play function and select this time the test2.mp3 file, start it again with 0% volume and set the same identifier!
To keep it simple it's possible to use the same identifier again and again, so you always know that you control the correct sound file.
You can also start a file when the old one is still running, the file just gets overwritten.

2020-01-01 17_13_59-Eos Editor.png
2020-01-01 17_13_59-Eos Editor.png (156.3 KiB) Viewed 6955 times

The new audio file will start on that page with 0% volume and jump than to our audio-check page where the correct volume will be set again.
In a real tease it mostly make sense to add an eval function after the audio play function and set the volume again, like:

2020-01-01 17_16_31-Eos Editor.png
2020-01-01 17_16_31-Eos Editor.png (124.74 KiB) Viewed 6955 times



8: Try it out and start your own tease!.

And if you have questions about the audio features, just write it here, I will try to help.

If you have improvements, ideas or want to add something about the audio feature, feel free to also comment here! :wave:


Here you can find the .json file as a download, it's a copy of the tease above you can directly import into the EOS editor.
Create a new tease, don't import this file into one of your existing teases, because everything gets overwritten by importing a .json file!
https://mega.nz/#!9A8QmIgY!RFt3kE-voqlQ ... RU8vl4Rbdc

2020-01-01 17_27_17-Eos Editor.png
2020-01-01 17_27_17-Eos Editor.png (93.06 KiB) Viewed 6934 times
Last edited by lolol2 on Wed Jan 01, 2020 8:24 pm, edited 1 time in total.
My creations:
Spoiler: show

[Tutorial] Building your own DIY E-Stim Stereo Device

Videos:
06/2020 - Estim Sync Hero Vol. 01

Teases:
04/2020 - Estim Mansion under Quarantine
12/2019 - Estim Challenge
12/2018 - Estim Distraction
03/2018 - The Estim Tower - Endless Mode
01/2018 - The Estim Tower
05/2017 - The Estim Mansion
alexfayer
Explorer
Explorer
Posts: 42
Joined: Sun Jan 04, 2015 7:22 pm
Gender: Male
Sexual Orientation: Straight

Re: EOS Audio Tutorial for beginners

Post by alexfayer »

Thank you for writing this tutorial!

I still think there should be an EOS wiki. As well as make the EOS editor public by adding a link to the homepage.

EDIT: There actually is a wiki in the help section of EOS editor. Most of the time help pages are useless so i straight on ignored it. Should not have done that here. :rolleyes:
Ghramd22
Explorer
Explorer
Posts: 7
Joined: Wed Jun 28, 2017 10:46 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: EOS Audio Tutorial for beginners

Post by Ghramd22 »

Hey! I know this may not be the right place to ask this but i cant seem to find a thread for general EOS questions. I can't seem to find where I can make an EOS tease just where you make the "Regular" basic click through teases. If y'all tell me where I can go to make them that'd be awesome! Thanks!
Ghramd22
Explorer
Explorer
Posts: 7
Joined: Wed Jun 28, 2017 10:46 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: EOS Audio Tutorial for beginners

Post by Ghramd22 »

Ghramd22 wrote: Thu Jan 02, 2020 8:03 am Hey! I know this may not be the right place to ask this but i cant seem to find a thread for general EOS questions. I can't seem to find where I can make an EOS tease just where you make the "Regular" basic click through teases. If y'all tell me where I can go to make them that'd be awesome! Thanks!
never mind, saw the link in the original post of this thread so i can just use that
User avatar
boundupone
Explorer At Heart
Explorer At Heart
Posts: 614
Joined: Sat Jun 01, 2013 8:01 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: EOS Audio Tutorial for beginners

Post by boundupone »

Awesome post, we definately need more help and documentation like this. I have zero programming experience (unless html counts) so would not be able to figure this detail out by myself.

I do have a question. In a large tease, how do you take the user to a calibration page and then back to where they were in the tease. For example, you could automatically take the user to a calibration page when volume is >95% to stop the tease breaking, but is it possible to have just one calibration page, and somehow push the user back to the stage they were at. Or do you need to have multiple calibration options set at certain points in the tease?


Also, I am trying to figure out how to use questions in a tease and count score and use this to determine sound files used and volume level. So for example if you score 10 out of 10 you get a nice file at a pleasant volume, 7 out of 10 a mid file at high volume, 4 out of ten a pain file at very high volume etc.

Thanks for all your hard work on this tease and in general
Try anything once!
User avatar
lolol2
Explorer At Heart
Explorer At Heart
Posts: 518
Joined: Mon Feb 20, 2017 10:33 am
Gender: Male
Sexual Orientation: Straight

Re: EOS Audio Tutorial for beginners

Post by lolol2 »

For the calibration part, nothing easier than that. :-)

I guess you talking about something like that showcase?
https://milovana.com/webteases/showteas ... d0fea6c5c1


1. Add a variable to the init script like:

Code: Select all

var currentpage="none"
2. Set this variable with the current page id before you change the page:

Code: Select all

currentpage = pages.getCurrentPageId()
For example:
2020-01-03 12_08_04-Eos Editor.png
2020-01-03 12_08_04-Eos Editor.png (13.05 KiB) Viewed 6571 times


3. Make the recalibration stuff an than jump back to the page with a simple eval command, button or whatever:

2020-01-03 12_09_37-Eos Editor.png
2020-01-03 12_09_37-Eos Editor.png (104.73 KiB) Viewed 6571 times





The quiz part is nearly same level of complexity.

1. Define a variable... nearly like evertime when you want to store or check something ;-)

Code: Select all

var answercount=0

2. Add +1 to that count when the user clicked on the correct button.

This could happen with a simple eval function like in the audio tease like:

Code: Select all

answercount = answercount + 1
Or directly on a button, or whereever you want.


3. Check at the end the count, we could use this for example with a simple if loop and add a say and audio play option like:

">" higher than
"<" lower than
"==" equal to (not a mistake that there are two!)

2020-01-03 12_17_06-Eos Editor.png
2020-01-03 12_17_06-Eos Editor.png (151.25 KiB) Viewed 6571 times


Here the .json file for the example above:
https://mega.nz/#!1FEnGKxC!o_fmg4ZW9DAP ... 7WxojkPzHI
My creations:
Spoiler: show

[Tutorial] Building your own DIY E-Stim Stereo Device

Videos:
06/2020 - Estim Sync Hero Vol. 01

Teases:
04/2020 - Estim Mansion under Quarantine
12/2019 - Estim Challenge
12/2018 - Estim Distraction
03/2018 - The Estim Tower - Endless Mode
01/2018 - The Estim Tower
05/2017 - The Estim Mansion
User avatar
boundupone
Explorer At Heart
Explorer At Heart
Posts: 614
Joined: Sat Jun 01, 2013 8:01 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: EOS Audio Tutorial for beginners

Post by boundupone »

Thanks, that makes sense. I have the basic scoring working now, and can jump to a page and back to where I was in the tease.

Brilliant stuff
Try anything once!
User avatar
boundupone
Explorer At Heart
Explorer At Heart
Posts: 614
Joined: Sat Jun 01, 2013 8:01 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: EOS Audio Tutorial for beginners

Post by boundupone »

Also got the volume control working as well.

Looks like I am going to have to play around with this sort of stuff, but i can see some ways to simplify complexity

For example, use the same idea as for the recalibration discussed above, but use this to go to a page where there is randomness. For example you could have a few pages to create a lot of randomness rather than dozens of hundreds of pages.

I think I need to plan out my next tease carefully, but it will probably be a while before I have any time to work on it :-(
Try anything once!
Orion_be
Explorer
Explorer
Posts: 71
Joined: Wed Mar 04, 2009 9:19 am

Re: EOS Audio Tutorial for beginners

Post by Orion_be »

I just build my self a stereo stim. And I really enjoyed playing The Estim Mansion.
Now I am planning to contribute to the community, but I encounter a first problem. Since I enjoy the Mansion so much, I started playing around with the audio files I downloaded. But the audio file used by Alissiya are to intense to use after calibration. I looked into the script for GuideMe, but there is no volume controle on the audiofiles.
Can someone explain where I make a mistake?

Regards
User avatar
lolol2
Explorer At Heart
Explorer At Heart
Posts: 518
Joined: Mon Feb 20, 2017 10:33 am
Gender: Male
Sexual Orientation: Straight

Re: EOS Audio Tutorial for beginners

Post by lolol2 »

The Mansion and Tower tease were created with the old flash editor, there was no option of volume control.
GuideMe supports volume control but I just converted the scripts without any adjustment.
So the volume is all controlled with the stim files, not sure if I did this in the Mansion but maybe I raised the volume in the files for the girls coming later then the first ones.

I would recommend to download the nice little tool "Audacity" and take a visual look on these files.

Important, the Mansion files are mono channel created and just copied the channel into stereo and sometimes delayed it a bit.
The frequency is around 400hz.

The Tower files are created in stereo with triphase effects at around 900hz, so you can't mix these files because the Mansion files should feel way stronger because the lower frequency.

If you want to use my files with EOS volume control, I would recommend to stick for one Tease and don't mix them.
My creations:
Spoiler: show

[Tutorial] Building your own DIY E-Stim Stereo Device

Videos:
06/2020 - Estim Sync Hero Vol. 01

Teases:
04/2020 - Estim Mansion under Quarantine
12/2019 - Estim Challenge
12/2018 - Estim Distraction
03/2018 - The Estim Tower - Endless Mode
01/2018 - The Estim Tower
05/2017 - The Estim Mansion
Orion_be
Explorer
Explorer
Posts: 71
Joined: Wed Mar 04, 2009 9:19 am

Re: EOS Audio Tutorial for beginners

Post by Orion_be »

Hello lolol2,
"Audacity" showed the files used by Alissiya (and most other girls) as stereo and the calibration file is mono, Lilly also uses mono files. When used in GuideMe this doesn't make a difference, but when I use them in mediaplayer or MP3 player the stereo files feel much harder, even if i use only one channel. I hear them all trough both speakers but this conversion makes the files feel not nice.
I think this helps me allot.

I used Audacity to convert the calibration file and the Lilly file into Stereo. After testing this has been the problem. :thumbsup:
Now I can start developing my first estim tease.
User avatar
lolol2
Explorer At Heart
Explorer At Heart
Posts: 518
Joined: Mon Feb 20, 2017 10:33 am
Gender: Male
Sexual Orientation: Straight

Re: EOS Audio Tutorial for beginners

Post by lolol2 »

This should be easy with the "Asynchronous" mode of the timers.
You can add actions which will be played after the given time, this will not pause the page, so you can set images, text etc...
2020-02-08 12_03_31-.png
2020-02-08 12_03_31-.png (130.89 KiB) Viewed 5896 times


You can also stack asynchronous timers in each other, but I would be very carefully to overdo this feature, can get very confusing, specially when you use random timers.

2020-02-08 12_04_41-.png
2020-02-08 12_04_41-.png (144.22 KiB) Viewed 5896 times
My creations:
Spoiler: show

[Tutorial] Building your own DIY E-Stim Stereo Device

Videos:
06/2020 - Estim Sync Hero Vol. 01

Teases:
04/2020 - Estim Mansion under Quarantine
12/2019 - Estim Challenge
12/2018 - Estim Distraction
03/2018 - The Estim Tower - Endless Mode
01/2018 - The Estim Tower
05/2017 - The Estim Mansion
User avatar
lolol2
Explorer At Heart
Explorer At Heart
Posts: 518
Joined: Mon Feb 20, 2017 10:33 am
Gender: Male
Sexual Orientation: Straight

Re: EOS Audio Tutorial for beginners

Post by lolol2 »

I guess you can just use the nativ sleep command for creating a delay in javascript?

Code: Select all

sleep(2000);
How many times you want to do this loop?
I would always recommend to use EOS function instead of script loops etc...
You can just let a page loop with a simple if else query.

drahdewixpfeifferl wrote: Sat Feb 08, 2020 12:50 pm Btw, anybody know where to find a list of commands that EOS can do?
I don't think the help page contains all of them?
Sadly no... Api reference will be added over time.
In the eval functions you can nearly use every javascript calls.
My creations:
Spoiler: show

[Tutorial] Building your own DIY E-Stim Stereo Device

Videos:
06/2020 - Estim Sync Hero Vol. 01

Teases:
04/2020 - Estim Mansion under Quarantine
12/2019 - Estim Challenge
12/2018 - Estim Distraction
03/2018 - The Estim Tower - Endless Mode
01/2018 - The Estim Tower
05/2017 - The Estim Mansion
User avatar
lolol2
Explorer At Heart
Explorer At Heart
Posts: 518
Joined: Mon Feb 20, 2017 10:33 am
Gender: Male
Sexual Orientation: Straight

Re: EOS Audio Tutorial for beginners

Post by lolol2 »

Looks like sleep commands get ignored... never tried this.
When you want to play a sound from the beginning it's better to make a .stop before the next .play.
Because .play will continue the sound if not finished.

I guess the only solution is to let a page loop and do the audio stuff there with normal timers.
A for loop function is still missing on EOS, but the only limitation of let a page loop is that the text cannot be persistent.
If this is no problem do it that way.

Of course your example is just very easy a combination of timers and audio commands.
How many times you want to let this thing loop?
If it's a low amount <10 you can also just add EOS 10 timers + EOS 10 audio play commands and check with an if loop between the files if the count is reached how many times you wanted to play the file and then just jump out of the line with a goto page command. ;-)

If you want to do a big amount you can let this page loop and still check the same count.
In that way the text is more persistent and gets not renewed with every sound file.

All roads lead to Rome, just be creative. :-D
I would still not recommend to do timers in javascript.
My creations:
Spoiler: show

[Tutorial] Building your own DIY E-Stim Stereo Device

Videos:
06/2020 - Estim Sync Hero Vol. 01

Teases:
04/2020 - Estim Mansion under Quarantine
12/2019 - Estim Challenge
12/2018 - Estim Distraction
03/2018 - The Estim Tower - Endless Mode
01/2018 - The Estim Tower
05/2017 - The Estim Mansion
undeniable_denial
Explorer At Heart
Explorer At Heart
Posts: 109
Joined: Sat Aug 24, 2019 11:42 am
Gender: Male
Location: Germany

Re: EOS Audio Tutorial for beginners

Post by undeniable_denial »

drahdewixpfeifferl wrote: Sat Feb 08, 2020 9:55 am How do I write a setTimeout - like function in EOS in Eval?
Want to play a sound after an amount of time and couldn't find anything in the forums/EOS help
setTimeout is mysteriously missing in EOS, despite it being mentioned in the API help page.

A trick that i've used is playing a silent mp3 that's - let's say - 5 seconds long. You can tell EOS to execute code once playback is done like so:

Code: Select all

Sound.get("pause").addEventListener("end", function () {
  Sound.get("signal").play();
});
You can chain-play audio files like this.


There is definitely no sleep-command in JavaScript. It is event-based and such a command would freeze the UI.
Post Reply