Coder Social home page Coder Social logo

Positional Audio about node-mumble HOT 1 CLOSED

t1onz avatar t1onz commented on August 15, 2024
Positional Audio

from node-mumble.

Comments (1)

Rantanen avatar Rantanen commented on August 15, 2024 2

Not in the provided API. The input stream is also a bit tricky abstraction for it. Mumble doesn't handle positional audio as some hypothetical multichannel audio; instead the audio is still encoded as mono/stereo stream. The positional information is then added as extra metadata on the audio packets.

The input stream eats PCM audio, splits this in audio frames and encodes it. These encoded frames are then combined into a Mumble audio packet based on packet size settings. That audio packet has optional field for the positional data.

The issue here is that the input stream doesn't expose details/API on packet boundaries so there is no way to tell when the packet changes and positional data could be sent. Associating positional data with each sample would be quite expensive.

On the MumbleConnection-level the packets are formed in the sendEncodedFrame function:

// UDP tunnel prefix.
var prefix = new Buffer( 6 );
prefix.writeUInt16BE( Messages.idByName.UDPTunnel, 0 );
prefix.writeUInt32BE( voiceHeader.length + framesLength, 2 );
this.socket.write( prefix );
// Write the voice header
this.socket.write( voiceHeader );
// Write the frames.
for( var f in frames ) { this.socket.write( frames[ f ] ); }

The protocol docs indicate the positional data should follow the frames: https://mumble-protocol.readthedocs.io/en/latest/voice_data.html#encoded-audio-data-packet

Writing three float coordinates after the frames on line 396 would take care of that (and ensuring the length info on line 390 takes that added data into account).

A possible API for this would have current position as a state on the stream the user would keep up to date. Then when the stream queues the frames on the connection by invoking connection,sendVoiceFrame it would also pass the position data as a parameter. sendVoiceFrame would then pass the parameter to sendEncodedFrame. This would avoid the stream from having to expose the packet boundaries or from the user having to pass the location data with every sample.

Alternative to exposing the location as a field on the stream object would be to support some in-stream metadata that could be written to the stream through normal write APIs and the stream would update its internal state based on those - writing the location data would then proceed as above. I don't see much point with this though.

Now unfortunately this project is not only not maintained anymore, but I also lost the use of my other hand few months ago so I'm not going to be able to do any maintenance currently. The above instructions should enable you to make the necessary changes if you need them.

from node-mumble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.