Krad Radio/Semi Official Plan

From MozillaWiki
Jump to: navigation, search

Taken from the old github-wiki (was: https://github.com/krad-radio/krad_radio/wiki/Krad-Radio-Plan) and moved here by kripton. Might be outdated but could help to understand the historic background of some concepts.

Krad Radio

The old model had Krad Mixer, Krad Link and Krad Websocket as three separate daemon binaries (among many other daemons) This can still be done, but it makes good sense to offer them all in a single process for administrative simplicity. Even in a combined binary you could choose to use only one or two of these if desired. The other advantage is the ability to have incoming Krad Link connections mixed, and sent to icecast without having to use Jack to route the audio back and forth. Using Jack for arbitrary input and output is still available and very powerful, but this removes the requirement for it in simple cases. The name for the combined binary is clearly Krad Radio.

Design and Interoperability Notes

Krad Link receives and transmits using only open codecs inside open container formats. When local to the software, Jack can be used to input and export audio from virtually anything in real time. Two pieces of software make this particularly appealing. Mplayer and XMMS2. With mplayer, you can play most any media file into jack, and hence Krad Link with the following command: mplayer -ao jack:port=PORTNAME FILENAME This is easily scriptable from any language using the usual techniques. XMMS2 is the ultimate music player, and its jack output support works very well. (I'm a developer on the XMMS2 project ;) With XMMS2 you get robust playlist and medialibrary support, including a thing called collections which could be considered a sort of super-duper search based playlist. It runs as a daemon and is remote controlled using a wide range of clients.

Krad IPC

Krad IPC is a remote control system that can be used over TCP or UNIX sockets. However it can also be used with a normal web browser thanks to WebSockets. Currently its a nonstandard but very basic delimited protocol. Switching to EBML and using Krad EBML is a clear win, it makes documenting, testing, using and developing the protocol much more concise and clear. It also serves as a very good test of Krad EBML.

Krad IPC consists of three main communications: commands, responses and broadcasts. A command is sent from a client to the server, and may generate a response, a broadcast, both or neither. If it does generate a broadcast, the broadcast is sent to all clients except for the client that generated it. For example, if a client sends a command to set the volume to 11 on the music input of krad mixer, a broadcast will be generated and sent to all other connected clients that the volume is now 11.

The design of Krad IPC is heavily influenced by the XMMS2 API.

Krad Websocket

Krad Websocket is a libwebsockets based websocket server that enables web browsers to access programs that use Krad IPC. Combined with a Javascript library that creates abstract objects for Krad Mixer and other daemons, designers can create any kind of interface that they can imagine and have it control Krad Mixer using only very simple Javascript.

Krad Mixer

Krad Mixer is an audio mixer daemon that operates on 32bit float samples and is real time safe. Control of the mixer is possible with command line, ncurses, GUI and web based tools, locally and remotely via Krad IPC. Multiple clients can connect simultaneously and all state is synchronized between them.

A portgroup is simply a group of one or more ports, the group is either an input or output group. An example portgroup would be “Music1” and it would consist of the Music1:Left and Music1:Right ports. Its the exactly the same idea as “Phono” and “Tape” on the back of a stereo receiver.

If a server was running 5 online radio stations, it would have a Krad Mixer for each station. By default the mixer starts with one portgroup, the ‘MainMix’ portgroup, which is the mix of all the input portgroups after effects and volume are applied. A very common case is the two turntables and a microphone setup. In this case there are three input portgroups, ‘Music1”, “Music2”, and “Mic1”. Music1 and Music2 would be part of Crossfade Group 1, so in addition to their volume, a crossfade volume is also applied to each of them. Each portgroup regardless of name used is also marked as as being a microphone input or not, for use by a one global effect, which is sidechain compression of all non-microphone inputs by the microphone inputs. What this means is that when the DJ speaks, the music level is automatically pushed down.

A SubMix is an output portgroup that is the same as the MainMix, except it has one input portgroup subtracted from its signal. For example, lets take the case of two DJ’s that are connected to the mixer, each would have a Mic input and each would have their own SubMix output, so that when they speak, they don’t hear there own voice in their headphones. (In many cases DJ’s do want to hear there own voice, in which case hardware monitoring must be used because even the slightest delay can make one insane) There is an option to enable monitoring of ones own signal, mainly for quick tests to ensure everything is sounding good.


Default Output Portgroups: MainMix, MonitorMix

Per Portgroup Options:

  • char Name
  • char[] Comments
  • int Channels
  • bool Mic
  • bool Submix
  • bool MainMix
  • bool MonitorMix
  • int Crossfade Group
  • float Volume

Portgroup comments are name/value pairs ala Vorbis comments, the two primary uses for them are to set an artist/title for music inputs, and the DJ’s name for mic inputs.

A Crossfade Group can have exactly two members, a crossfade volume is then applied on top of the standard volume.

Krad Mixer IPC Commands and Broadcasts:

A command is often a one way message from client to mixer with no response, for example to change the volume on a portgroup. List controls and List portgroups are commands that generate responses. Broadcasts are generated in two ways, as a response to a command or automatically in the case of peaks. Broadcasts are sent to all subscribers, except in the case of a command, the client that sent the command will not receive the broadcast it generated.

  • List Portgroups
  • Create Portgroup
  • Destroy Portgroup
  • Update Portgroup - (portgoup comment change)
  • Subscribe Portgroups - Subscribe to portgroup Create/Destroy, rename and comments changes
  • Unsubscribe Portgroups
  • Set Control
  • List Controls
  • Subscribe Controls - Subscribe to Control changes such as Volume.
  • Unsubscribe Controls
  • Get Active Input - The Active input is the the input portgroup with the highest volume setting that is not a microphone input.
  • Subscribe Active Input
  • Unsubscribe Active Input

What is this good for? If you have two music inputs, a Krad Mixer client program can determine which one is currently being heard by listeners, and therefor use the correct metadata.

  • Get Active Mic Inputs - Active microphone inputs are microphone inputs which have recently had an active level of audio.
  • Subscribe Active Mic Inputs
  • Unsubscribe Active Mic Inputs

What is this good for? A Krad Mixer client program can display the name of the person who is currently talking, or in too many cases the names of everyone who is talking.

  • Get Peak
  • Get Peaks
  • Subscribe Peak
  • Unsubscribe Peak
  • Subscribe Peaks
  • Unsubscribe Peaks

A Krad Mixer client program can easily show the audio levels.


Krad Link (note kripton: Now "Transponder")

Krad Link is designed to enable the creation of arbitrary audio and video connections over a network in the most robust and reliable ways possible. It can also read and write to files, for example recording audio from jack ports using the flac codec stored in a mkv container. In addition to TCP connections, ultra low latency UDP connections are also possible. Krad Link is both a server and client side program, for example, it can play a WebM or Ogg Theora video using a GLX X11 window, or it can be run as a daemon.

Krad Link Supports:

Video Capture:

X11, V4L2, Decklink, "Test Signal"

Audio Capture:

Jack, ALSA, PulseAudio, Decklink, "Test Tone"

Audio Playback:

Jack, ALSA, PulseAudio

Video Codecs:

VP8, Dirac, Theora

Audio Codecs:

Vorbis, FLAC, Opus, Codec2

Codec Todo:

Add Theora encoding (Encoder Tool ready)

Containers:

MKV, WebM, Ogg

Container Todo:

Ogg output (Code in krad_radio_legacy)

Container maybe Todo:

Native FLAC readonly (Code in flac tool test) Ogg Skeleton?

IO:

File Input/Output TCP Connect and Send, TCP Connect and Receive UDP Send/Receive (Opus only)

IO TODO:

TCP Listen and Send, TCP Listen and Receive UDP VP8, Codec2 UDP RTP/WebRTC Compatible

Krad Link IPC Commands and Broadcasts:

Create Link Destroy Link tdb.


Krad Radio Secondary Priorities

Somewhat less important but awesome

Krad IPC / OSC Bridge

This enables hardware devices to control Krad Mixer Sample code for intergrating OSC exists in kradlink in krad_radio_legacy

Automatic Port setup for Krad Link UDP Connections

Receiving low latency UDP behind a NAT requres UPNP, port busting or other techniques, sample codes for this exists in kradlink in krad_radio_legacy

Krad Mixer GTK and NCURSES GUI

In addition to command line, these would be nice, example code for both exists in legacy

Krad Sampler

Krad Sampler is a sampler daemon, ala Krad Mixer

code is found in krad_dsp in krad_radio_legacy

Krad Sampler IPC Commands:

/sampler/master/add_sample|%d|%d|%d*

/sampler/master/list_samples|%d|%d|%d*

/sampler/%d/crossfadelength|%d|%d|%d*"

/sampler/%d/startoffset|%d|%d|%d*

/sampler/%d/stopoffset|%d|%d|%d*

/sampler/%d/length|%d|%d|%d*

/sampler/%d/play|%d|%d|%d*

/sampler/%d/loop|%d|%d|%d*

/sampler/%d/record|%d|%d|%d*

/sampler/%d/writeseek|%d|%d|%d*

/sampler/%d/seek|%d|%d|%d*

/sampler/%d/load|%d|%d|%d*

/sampler/%d/save|%d|%d|%d*

/sampler/%d/remove|%d|%d|%d*