Sound.playMusic("trackFilename.ogg", true)
works fine here. Not sure why you need the lines above and below the playMusic one.Separate Volume Controls
Moderators: winston, another_commander
-
- Quite Grand Sub-Admiral
- Posts: 6680
- Joined: Wed Feb 28, 2007 7:54 am
Re: Separate Volume Controls
Just
Re: Separate Volume Controls
Yep. Same here .-)another_commander wrote:JustSound.playMusic("trackFilename.ogg", true)
works fine here. Not sure why you need the lines above and below the playMusic one.
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)Re: Separate Volume Controls
I quoted the lines before and after the one I changed to give a little context.another_commander wrote:JustSound.playMusic("trackFilename.ogg", true)
works fine here. Not sure why you need the lines above and below the playMusic one.
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
Re: Separate Volume Controls
Cool, a_c! Looks good .-)another_commander wrote:... aaaand here we go. Commit 74bb815 should enable an optional third parameter in the JS Sound class functionplayMusic
, 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.
Scripts (like Frames RandomDockingMusic) would need a handler for the 's' toggle... *wink*washuu_de wrote:Instead I can play Blue Danube by clicking 's' and stop it like the description says.
Re: Separate Volume Controls
Ok, now I understand the concept. I think there is enough documentation on doing such stuff. I should be able to include a handler.Svengali wrote:Scripts (like Frames RandomDockingMusic) would need a handler for the 's' toggle... *wink*washuu_de wrote:Instead I can play Blue Danube by clicking 's' and stop it like the description says.
Maybe I will even learn how to write my own OXP/OKZ if fiddling with other works isn't enough for me.
washuu_de
- Cody
- Sharp Shooter Spam Assassin
- Posts: 16081
- Joined: Sat Jul 04, 2009 9:31 pm
- Location: The Lizard's Claw
- Contact:
Re: Separate Volume Controls
<chortles> That's how it starts - welcome to the Darkside!washuu_de wrote:Maybe I will even learn how to write my own OXP/OKZ if fiddling with other works isn't enough for me.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
And any survivors, their debts I will certainly pay. There's always a way!
Re: Separate Volume Controls
@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 .-)
@washuu_de: Have a cookie .-)
-
- Quite Grand Sub-Admiral
- Posts: 6680
- Joined: Wed Feb 28, 2007 7:54 am
Re: Separate Volume Controls
I was totally expecting this request next.Svengali wrote:@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 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.
Re: Separate Volume Controls
°sigh°another_commander wrote:I was totally expecting this request next.Svengali wrote:@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.
-
- Quite Grand Sub-Admiral
- Posts: 6680
- Joined: Wed Feb 28, 2007 7:54 am
Re: Separate Volume Controls
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 calledIf the music file is a 44KHz mono ogg, we can also do stuff like
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: Select all
myMusicSoundSource = Sound.musicSoundSource();
myMusicSoundSource.volume = 0.4;
Code: Select all
myMusicSoundSource.position = [-1,0,0]; // throw the currently playing music to the left channel
Re: Separate Volume Controls
Muchas gracias, a_c!