Oolite Bulletins

For information and discussion about Oolite.
It is currently Tue Sep 26, 2017 5:32 am

All times are UTC




Post new topic  Reply to topic  [ 26 posts ]  Go to page Previous 1 2
Author Message
PostPosted: Thu Oct 27, 2016 6:23 am 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 4937
Just Sound.playMusic("trackFilename.ogg", true) works fine here. Not sure why you need the lines above and below the playMusic one.


Top
   
PostPosted: Thu Oct 27, 2016 10:07 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Oct 20, 2007 2:52 pm
Posts: 2264
Quote:
Just Sound.playMusic("trackFilename.ogg", true) works fine here. Not sure why you need the lines above and below the playMusic one.
Yep. Same here .-)

Just as sidenote: [wiki]Library[/wiki] contains a script Lib_Music.js which handles these things.
To add a file to the docking playlist use worldScripts.Lib_Music._addChannel({name:"docking",sounds:[{snd:"trackFilename.ogg",dur:10}]}); (dur is length in seconds)


Top
   
PostPosted: Thu Oct 27, 2016 7:15 pm 
Offline
Average
Average

Joined: Tue Dec 18, 2012 4:18 pm
Posts: 8
Quote:
Just Sound.playMusic("trackFilename.ogg", true) works fine here. Not sure why you need the lines above and below the playMusic one.
I quoted the lines before and after the one I changed to give a little context.
The edits I made are in my downloaded version of RandomDockingMusic.js by Dennis Thony Pedersen (Frame).
I wanted to make as little changes as possible since it was my first oxp-script edit.

I wonder why it doesn't repeat as described in the doc of the Sound.PlayMusic method.
Instead I can play Blue Danube by clicking 's' and stop it like the description says.
Only after the random song has ended.

It is not so important. I can always substitute that short track with a bunch of longer pieces. I'm just curious.

Thank you for taking the time to help me.

washuu_de


Top
   
PostPosted: Fri Oct 28, 2016 1:44 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Oct 20, 2007 2:52 pm
Posts: 2264
Quote:
... aaaand here we go. Commit 74bb815 should enable an optional third parameter in the JS Sound class function playMusic, representing the desired volume of the music to play. The parameter is a float capped between 0.0 and 1.0 and is relative to the master gain, which means that a value of 1.0 gives it its full gain at the current master volume setting. Feel free to test and let us know what you think.
Cool, a_c! Looks good .-)
Quote:
Instead I can play Blue Danube by clicking 's' and stop it like the description says.
Scripts (like Frames RandomDockingMusic) would need a handler for the 's' toggle... *wink*


Top
   
PostPosted: Fri Oct 28, 2016 7:03 pm 
Offline
Average
Average

Joined: Tue Dec 18, 2012 4:18 pm
Posts: 8
Quote:
Quote:
Instead I can play Blue Danube by clicking 's' and stop it like the description says.
Scripts (like Frames RandomDockingMusic) would need a handler for the 's' toggle... *wink*
Ok, now I understand the concept. I think there is enough documentation on doing such stuff. I should be able to include a handler.
Maybe I will even learn how to write my own OXP/OKZ if fiddling with other works isn't enough for me.

washuu_de


Top
   
PostPosted: Fri Oct 28, 2016 7:18 pm 
Offline
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
User avatar

Joined: Sat Jul 04, 2009 9:31 pm
Posts: 12792
Location: Corke's Drift
Quote:
Maybe I will even learn how to write my own OXP/OKZ if fiddling with other works isn't enough for me.
<chortles> That's how it starts - welcome to the Darkside!

_________________
The only good fnord is a dead fnord!


Top
   
PostPosted: Sun Oct 30, 2016 11:24 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Oct 20, 2007 2:52 pm
Posts: 2264
@a_c: If I get this right, volume updates on playing music is not possible...? It's not a biggie, just something we should be aware of.

@washuu_de: Have a cookie .-)


Top
   
PostPosted: Sun Oct 30, 2016 12:51 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 4937
Quote:
@a_c: If I get this right, volume updates on playing music is not possible...? It's not a biggie, just something we should be aware of.
I was totally expecting this request next. :-)

I was planning to see what can be done about it during the weekend but some RL popped up and there you go. I'll see about it as soon as I manage to get a chance.


Top
   
PostPosted: Sun Oct 30, 2016 4:27 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Oct 20, 2007 2:52 pm
Posts: 2264
Quote:
Quote:
@a_c: If I get this right, volume updates on playing music is not possible...? It's not a biggie, just something we should be aware of.
I was totally expecting this request next. :-)
°sigh°


Top
   
PostPosted: Mon Oct 31, 2016 7:49 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 4937
So, in the next nightly we should be able to control music volume, loop status, position etc in real time. Due to the way sound and music are set up internally, it is not entirely straightforward in the current implementation and it is possible that a better way to handle this exists, I just couldn't see it. Having said that, it's not difficult either, thankfully.

In order to enable this kind of control, I have exposed to Javascript the sound source object of the music currently playing. So, once we have access to that object, we can work with it like we do with any other sound source. The new function that does it is part of the Sound JS class and is called musicSoundSource. More specifically, if I want to adjust on the fly, say, the volume of the music currently playing, what I would do is something like this:
Code:
myMusicSoundSource = Sound.musicSoundSource();
myMusicSoundSource.volume = 0.4;
If the music file is a 44KHz mono ogg, we can also do stuff like
Code:
myMusicSoundSource.position = [-1,0,0]; // throw the currently playing music to the left channel


Top
   
PostPosted: Tue Nov 01, 2016 11:19 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Sat Oct 20, 2007 2:52 pm
Posts: 2264
Muchas gracias, a_c! 8)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 26 posts ]  Go to page Previous 1 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 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

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited