Page 2 of 2
Re: mpg module MPEG1 Video decoder, MP2 Audio decoder
Posted: Sat Aug 23, 2025 1:00 am
by idle
minimy wrote: Fri Aug 22, 2025 4:05 pm
All is working, tested and really happy with your code. 3Dsound source fade in distance. Great!!
Yes, i try with canvas too. Thanks again for share!
I'm testing instancing in 3d, you can play the same video on multiple objects but unfortunately it appears you can't attach the 3Dsound to multiple nodes.
So I've added an array of sounds which isn't ideal but it means you can show the same MPG on multiple objects and they can play the same sound on them via index.
Though if your moving in a game and the player is out of range you can detach the node from an entity and attach it to the closest Entity playing the video.
but what if you have a scene like a drive in movie and the sounds are emanating from multiple speakers how are you supposed to do that? It's actually wasteful on memory as you need to load the sound multiple times.
So I need to limit the size of the array.
I can also abstract it to do mono and stereo by seting the sound instances as mono=0, left=1, right=2
and when I decode the MP2 I can create 3 temp files mono left right then load them to the array.
Then you can create 2 nodes per objects if you wanted the entity to play stereo in 3D
MPG_GetSound3D(mpg,instance,#Left)
MPG_GetSound3D(mpg,instance,#right)
Re: mpg module MPEG1 Video decoder, MP2 Audio decoder
Posted: Sat Aug 23, 2025 2:00 am
by minimy
The project continues to grow. That's very interesting.
I don't even dare to think about doing something like that.
An essential library for PB. Great job!
Re: mpg module MPEG1 Video decoder, MP2 Audio decoder
Posted: Sat Aug 23, 2025 4:07 am
by idle
minimy wrote: Sat Aug 23, 2025 2:00 am
The project continues to grow. That's very interesting.
I don't even dare to think about doing something like that.
An essential library for PB. Great job!
It's not hard to do, it's just that loading the sound multiple times isn't an ideal solution but I would sooner facilitate it so people don't feel like they have one hand tied behind their back expecting something to work only to find that it doesn't.
As for simulating stereo per object, it comes down to the spatial separation and volume attenuation for each channel.
so for an entity to emit stereo you'd have to create 3 nodes, left, right and one to contain them and position the entity.
I'm assuming that when you attach a node to a node it moves relative to the node containing it.
I guess the only way to find out is to try it!
Re: mpg module MPEG1 Video decoder, MP2 Audio decoder
Posted: Sat Aug 23, 2025 11:30 pm
by idle
added sound instances to sound3D to enable playing the same video on multiple objects with audio
as it appears you cant reuse the same sound on multiple objects.
3dtest plays same video on two cubes with 2 sound instances
sound = MPG_GetSound(mpg,0) ;get sound instance 0
sound1 = MPG_GetSound(mpg,1) ;get sound instance 1
Re: mpg module MPEG1 Video decoder, MP2 Audio decoder
Posted: Sat Aug 23, 2025 11:59 pm
by miso
Wow, that escalated quickly. Cool improvements!
Re: mpg module MPEG1 Video decoder, MP2 Audio decoder
Posted: Sun Aug 24, 2025 2:18 am
by idle
miso wrote: Sat Aug 23, 2025 11:59 pm
Wow, that escalated quickly. Cool improvements!
The only addition I will add for now is a LoadSoundChannel3D(mpg,channel) so it can be experimented with to make Fake Stereo. Though I don't know if it'll work. Idea is to add nodes for left and right add then a container node and then attach the entity.
It's also a shame there's no SetSoundPosition3D.