Open RubenSandwich opened 8 years ago
Actually one should be able to wire the internal ScriptProcessorNode to any WebAudio sink. So you could use a GainNode to control volume. I'll think about ways of doing so.
Currently the internal ScriptProcessor Node is directly wired to the AudioDestination (speakers) with no nice way to intercept between. However you can try the hackish approach:
// create a GainNode
var gain = player.context.createGain()
// wire gain to speaker output
gain.connect(player.context.destination)
// disconnect internal ScriptProcessorNode from speakers
player.currentPlayingNode.disconnect()
// wire script processor to gain
player.currentPlayingNode.connect(gain)
// make it quieter
gain.gain.value = 0.5
You will have to do the rewiring after each call to play()
, because it creates a new currentPlayingNode
. I'll think of a nicer way of doing that.
Cool that works great. Thanks. Maybe make it part of the API though so it would be more easily accessible and hide the implementation details.
Note that you can also set the gain directly in libopenmpt via openmpt::module::set_render_param.
@deskjet I once merged several input source to one output just by copying and adding the buffer to the output processor. Maybe you can use this method to maintain one currentPlayingNode
.
Another solution to this is using MediaSourceExtension
, which also solves the requirement for seek bar.
Note that you can also set the gain directly in libopenmpt via openmpt::module::set_render_param.
How exactly? I'm struggling to change the volume currently using any means
@KingPossum
Here is how set_render_param
is called to configure libopenmpt.
Try RENDER_MASTERGAIN_MILLIBEL
as the first parameter. If that is not defined use the value 1
as that's what it should be according to the original source code. The second paramter would be your desired gain in milliBels (e.g. -600 to lower the volume)
@KingPossum Here is how
set_render_param
is called to configure libopenmpt.Try
RENDER_MASTERGAIN_MILLIBEL
as the first parameter. If that is not defined use the value1
as that's what it should be according to the original source code. The second paramter would be your desired gain in milliBels (e.g. -600 to lower the volume)
Thank you so much for the quick and concise reply! I hope you can forgive my ignorance on the topic, I'm new to JS and website creation in general. Here's the current syntax I'm attempting to use, and it's still having no effect. I'm sure I'm just not using it correctly.
libopenmpt._openmpt_module_set_render_param(1, -600);
It would be helpful to be able to change the volume of the music being played.