Yes, but if lowering the rate makes them sound the same then you know the Hz difference may be the cause. I looked at the files and didn’t see anything else which may cause it.
I was able to compile the extension for HTML5, but it’s not producing any sound yet. However, it does the initialization. Further work is needed.
Still working on the HTML5 version. There is sound output, but it’s not positioned or pitched for some reason. Trying to figure this one out.
So the current JavaScript implementation of OpenAL for HTML5 is not stable, it lacks certain features like the doppler effect, pitch modification and changing the speed of sound. On Chrome it crashes with an error “missing function panner.setVelocity”. Different browsers have slightly different underlying audio API.
But sooner or later these issues will be resolved. I believe I can supply my own OpenAL wrapper as a JavaScript library, that would be the next step.
In the meantime, I’ve updated the extension source code on github and you can try HTML5 support for yourself.
Open in Firefox or Safari. https://lerg.github.io/extension-openal/
Can anybody please try the extension on Windows? And see if it just works?
I’ve made some minor modifications to make it compile and run on windows.
Pull request on github.
Yay! Thanks.
Just merged your pull request.
Awesome, now this extension runs on all platforms. But HTML5 version needs work.
Awesome extension, thanks for it.
I add it to my game and have some questions:
1)When i add my wav files, i get ERROR:openal: Invalid WAV data header. How can i fixed it?
2)In html looks like, sound volume not decresed when i move away from sound source.
3)You have a lot of distance_model. What is diference of them?
4)What is rolloff_factor?
function on_message(self, message_id, message, sender)
if(message_id==hashes.CONTROLLER_SPAWN_3D_SOUNDS)then
local sounds=world.map.data.sounds_3d
pprint(sounds)
for i,sound in ipairs(sounds) do
local sound_source = openal.new_source(SOUNDS[sound.sound])
sound_source.reference_distance=2
sound_source.rolloff_factor=50
--sound_source.max_distance=4
sound_source.x, sound_source.y = sound.x +0.5 , sound.y +0.5
sound_source.is_looping = true
sound_source:play()
sources[i]=sound_source
end
end
end
HTML has issues, haven’t finished it yet. Distance models calculate how exactly sound becomes quieter with distance. There are formulas in OpenAL reference, but you can pick one that just sounds better for you. “_clamped” means at max_distance the sound is muted.
Rolloff controls how far the sound goes, can’t tell exactly how.
Resave WAV files with Audacity, should help.
What about support of OGG or stream playing for big files (1 minute and longer)?
Streaming requires a bit more complex coding to manage buffers and OGG support need a decoder library integration. Not something that can be implemented easily.
Regarding stereo sound, is there any possibility to create a ‘dead space’ around an object, where both left and right speakers will be playing a looped sound and only will have 3D effects far (for example right speaker is working while far away from the center of the object to the right)? Now, in an example there is a ‘line’ (pos.x) on which I can’t stand with a listener to ‘feel’ like really near to the campfire, but instead, the listener is always on the right or left side of the campfire and the sound is always on the right or left side.
If you play with various settings, should be possible. Can’t tell for sure which ones.
Any plan to integrate the OpenAl extension into the core of Defold? The audio department still feels a bit too basic and could use some love.
No
Yes, I agree. Sound improvements will happen. It’s in our roadmap (we will share a 12 month plan soon).
Thanks! Looking forward to the new roadmap
Regarding a 3D sound dead space, @sergey.lerg, I still didn’t find a proper setting to achieve the desired effect maybe you have any idea of what can be done?
I think you can put the sound source a few units above the character. That way character will never intersect the source.
And when I’m back to OpenAl, I still have that problem with positioned sound playing either on the left or the right earphone, but never on both (except when the listener go is exactly in the pos.x of the sound source go). Positioning it above ore below, even far away, doesn’t change it, it looks like it checks only x axis and not y axis. Though, relative volume seems to be tuned according to the distance between a source and the listener.
Ok, will look into that more carefully.