Giter Club home page Giter Club logo

pyvban's Introduction

pyVBAN

PyPI - Python Version

Python implementation of the VBAN (VB Audio network) protocol

Original specifications here: https://www.vb-audio.com/Voicemeeter/VBANProtocol_Specifications.pdf

Supported sub-protocols:

  • Audio
  • Serial (To verify)
  • Text
  • Service

As I'm currently not using VBAN nor VB-Audio products I have no plans to implement this further. I will do my best to maintain it!

For any feature request, the specs are open, feel free to open a PR 😀

Using the built-in utilities

List devices

$ python -m pyvban.utils.device_list
import logging
import pyvban
logging.basicConfig(level=logging.DEBUG)
pyvban.utils.device_list()

Receiver

$ python -m pyvban.utils.receiver --address 127.0.0.1 --port 6980 --stream Stream1 --device 11
import logging
import pyvban
logging.basicConfig(level=logging.DEBUG)
receiver = pyvban.utils.VBAN_Receiver(
    sender_ip="127.0.0.1",
    stream_name="Stream1",
    port=6980,
    device_index=11
)
receiver.run()

Sender

$ python -m pyvban.utils.sender --address 127.0.0.1 --port 6980 --stream Stream1 --rate 48000 --channels 2 --device 1
import logging
import pyvban
logging.basicConfig(level=logging.DEBUG)
sender = pyvban.utils.VBAN_Sender(
    receiver_ip="127.0.0.1",
    receiver_port=6980,
    stream_name="Stream1",
    sample_rate=48000,
    channels=2,
    device_index=1
)
sender.run()

Send text

$ python -m pyvban.utils.send_text --address 127.0.0.1 --port 6980 --stream Command1 "Strip[5].Mute = 0"
import logging
import pyvban
import time
logging.basicConfig(level=logging.DEBUG)
send_text = pyvban.utils.VBAN_SendText(
    receiver_ip="127.0.0.1",
    receiver_port=6980,
    stream_name="Command1"
)
state = False
while True:
    state = not state
    if state:
        send_text.send("Strip[5].Mute = 0")
    else:
        send_text.send("Strip[5].Mute = 1")
    time.sleep(1)

Craft a packet manually

import pyvban

pcm_data = b""  # 128 sample stereo data
header = pyvban.VBANAudioHeader(
    sample_rate=pyvban.subprotocols.audio.VBANSampleRates.RATE_48000,
    samples_per_frame=128,
    channels=2,
    format=pyvban.subprotocols.audio.VBANBitResolution.VBAN_BITFMT_16_INT,
    codec=pyvban.subprotocols.audio.VBANCodec.VBAN_CODEC_PCM,
    stream_name="Stream1",
    frame_counter=0,
)

vban_packet = header.to_bytes() + pcm_data
vban_packet = vban_packet[:pyvban.const.VBAN_PROTOCOL_MAX_SIZE]

Parse a packet manually

import pyvban

def run_once(self):
    data, addr = socket.recvfrom(pyvban.const.VBAN_PROTOCOL_MAX_SIZE)
    packet = pyvban.VBANPacket(data)
    if packet.header:
        if packet.header.sub_protocol != pyvban.const.VBANProtocols.VBAN_PROTOCOL_AUDIO:
            print(f"Received non audio packet {packet}")
            return
        if packet.header.stream_name != self._stream_name:
            print(f"Unexpected stream name \"{packet.header.stream_name}\" != \"{self._stream_name}\"")
            return
        if addr[0] != self._sender_ip:
            print(f"Unexpected sender \"{addr[0]}\" != \"{self._sender_ip}\"")
            return

pyvban's People

Contributors

thestaticturtle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyvban's Issues

Publish on PyPI

I'm using this project to transmit my mic (via pipewire) to my remote gaming rig (running Voicemeeter Banana on Windows). It works well, thx @TheStaticTurtle!

I would like to have some tooling based on this library, maybe with some GUI, but your code isn't available on PyPI. This hinders the ease of use, as I need to either fork, or bundle your code somehow. I rather just use it as a regular PyPI dependency.

Would you mind publishing it on PyPI?

VBAN_Send aborts after a while.

VBAN_Send runs for a while then quits with the following message:-
src/hostapi/alsa/pa_linux_alsa.c:3641: PaAlsaStreamComponent_BeginPolling: Assertion 'ret == self->nfds' failed

I have tried different sample rates but no change and the time before aborting varies.
Looking at htop the system (Intel© Core™ i3-3110M CPU @ 2.40GHz × 2 Linux Mint 20.1 Cinnamon) is not stressed, process taking about 5% CPU and total CPU load ~30%.

VBAN_Recv runs without stopping.

Project License?

I was curious if you had preferences on the license for this project? Others in the same space have seemed to have gone with either the GPL 3.0 or Apache 2.0, and I was wondering if you had any thoughts on this?

Both VBAN_Recv and VBAN_Send return an error

Hi, I was playing around with this and I found the following problems:

  • When I run VBAN_Recv(), it yields the following error: struct.error: unpack requires a buffer of 8 bytes on the line self.stream_frameCounter = struct.unpack("l",data[24:28])[0]. I just tried to replace the line with self.stream_frameCounter = struct.unpack("l",data[24:32])[0] and it works fine. Not sure why this 8 bytes constraint was not the case on your system...

  • When I run VBAN_Send(), it keeps yielding the following error [Errno 56] Socket is already connected. I tried to change the PORT number, assuming socket refers to that, without success.

Any idea of why that might be?

README script for PyAudio is broken in python3

Hi, I just got around to trying out pyVBAN, and your updates could not have been better timed.

However, the README may still need to be updated for Python 3, specifically the print statements in the PyAudio script to list devices.

Thanks!

Can't get connection

I was able to troubleshoot the code to the point of getting verbose=true to output to console, however no sound is being transmitted.

Interested in Contributions?

Hi there! Awesome project! 🎉

I've been poking around, and found a few ways that I think I could help offer some enhancements. Are you open to contributions?

Multiple send stream and send + recv not working

Hello,

I failed to send multiple streams, either to two separate devices or to one, even with different ports.
I then tried with Python Process but the result is the same.
I also cannot use send and receive at the same time.
Here is my code:

import pyVBAN
from multiprocessing import Process

def send(ip, port, streamName, sampleRate, deviceId):
    vbanSendSlot = pyVBAN.VBAN_Send(ip, port, streamName, sampleRate, deviceId, verbose=False)
    vbanSendSlot.runforever()

def recv(ip, port, streamName, deviceId):
    vbanRecvSlot = pyVBAN.VBAN_Recv(ip, streamName, port, deviceId, verbose=True)
    vbanRecvSlot.runforever()

def startSend1():
    sendSlot1 = Process(target=send, args=("10.0.254.6", 6980, "Stream1", 48000, 12))
    sendSlot1.start()
    sendSlot1.join()

def startSend2():
    sendSlot2 = Process(target=send, args=("10.0.254.6", 6981, "Stream2", 44100, 12))
    sendSlot2.start()
    sendSlot2.join()

def startRecv1():
    recvSlot1 = Process(target=recv, args=("10.0.254.6", 6980, "RECV", 14))
    recvSlot1.start()
    recvSlot1.join()


if __name__ == '__main__':
    startSend1()
    startSend2()
    startRecv1()

Is this normal or is there a specific setting to be made?

Sorry if my English is not very good, I use Google Translate.

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.