Audio Repeater Application

Virtual Audio Cable

Audio Repeater Application

Audio Repeater is a simple application that transfers a real-time audio stream from any Wave In MME recording port to any Wave Out playback port. Audio Repeater can be used with VAC to transport audio data from a real sound card to a Virtual Cable, monitor a signal going through a Virtual Cable with a real sound card, transport audio data from between two Virtual Cables etc.

Audio Repeater uses MME interface to access audio devices. It means that playback to Virtual Cables goes via System Audio Engine layer and Audio Repeater cannot fully control actual audio format used by System Audio Engine pin instance creation (see audio layering issues). To access via WDM/KS interface, use Kernel Streaming version.

To supply a Virtual Cable with a real audio signal, choose a sound adapter (card) port in the Wave In field of the Audio Repeater, and choose Virtual Cable N in the Wave Out field. To monitor an audio signal transferred through the Virtual Cable, choose Virtual Cable N in the Wave In field and the sound adapter (card) port in the Wave Out field.

In some simple cases, you can use the Listen feature (available since Win7) instead of Audio Repeater.

You can leave "None" in the Wave Out field. In such case, Audio Repeater will only record from the device specified inĀ  Wave In field, without playing the data back. It can be useful for visual signal level monitoring if you don't need to pass the signal to another device.

In MME, device name length is limited to 31 characters so you will not always see full endpoint names.

Before starting a transfer with the Audio Repeater, select format parameters possibly close to formats used by other applications connected to this Virtual Cable. To eliminate redundant format conversions, pay attention to the audio layering issues.

The Channel config parameter specifies a typical channel configuration (mono, stereo, surround etc.) or a custom mode that allows you to select any channel combination.

Transfer is started as you click the Start button. Audio Repeater opens both audio ports and maintains a circular buffer movement between them. When a buffer filled with data is received from the In recording port, it is immediately passed to the Out playback port, and vice versa.

The Queue gauges show how much data buffers are held in device queues. If a gauge goes to the right, it means that data amount if the queue is increased, and vice versa. In the most stable state, both queues are half-filled.

Both queues start near to a medium state to minimize a clock difference effect. But the longer is transfer time, the larger is the difference, and the higher is stream interruption probability. Side activity, such as disk read/write, application launch, high CPU load can affect stream stability.

Gauge indicators under channel configuration checkboxes show peak signal levels in appropriate channels.

Overflow and underflow counters

There are two counters, Overflows and Underflows. Overflows counter is incremented when Audio Repeater has no free buffers for recorded data (input queue gauge comes to the left). Underflows counter is incremented when Audio Repeater has no buffers to play back (output queue gauge comes to the left).

Overflows and underflows can occur as a result of a clock difference effect, heavy system load (when Audio Repeater does not receive enough CPU time) etc.

Using Virtual Cable devices in Audio Repeater, please note that these application's overflows and underflows are opposite to cable's overflows and underflows. For example, when Audio Repeater has no free buffer to pass to cable's recording end, it registers an underflow (there are no data). On the contrary, the cable has data but cannot give them because there are no buffers so the cable registers an overflow (there is no room for data).

Queue exhaust and overflows/underflows may occur due to different timing event periods. Each device has its own time period to notify the driver and/or client application about streaming progress. For example, if the device issues a notification event each 15 milliseconds and you have specified total buffering time of 40 milliseconds in 8 parts (5 ms each), every notification will indicate that 3-4 parts are recorded/played. It is a significant portion of the entire buffer so the streaming will be rough and unstable. You will need to increase buffering time and/or number of buffer parts to smoother the stream. Unfortunately, only Virtual Cables allow to specify a timing event period; other devices don't expose this information and you should determine it by experiment.

Clock rate indicators

Clock fields near overflow/underflow counters show clock rates for each port in relation to another port. If clocks of both ports have the same rate, "100%" is shown. If port clock is faster than other port clock, the value is over 100%, otherwise it is below 100%.

Clock rate values may help to specify the clock difference value for a Virtual Cable.

Please note that clock rates are calculated roughly because data amount is counted in portions (buffers).

Choosing proper buffering parameters

To optimize audio transfer, you can vary the buffering time (total buffer) and number of buffers (a number of individual parts, or data blocks). The total buffering time (in milliseconds) specifies how much audio data reserve a device driver will have. The larger is buffering time, the more robust is the transfer, the less is chance of sound interruption due to task switching, disk operations etc. But the larger is the buffering time, the larger is latency value, and the larger is a delay between incoming and outgoing audio data. Typical buffering times are from 200-300 to 1000-2000 ms.

The number of buffers defines how many parts of the total buffering memory will be used. The more buffers are used, the smoother is the transfer even the total buffering time is small. But large number of buffers raises system overhead and use of more than 15..20 buffers doesl not make data transfer smoother.

To avoid sound interruptions, each audio buffer part should contain at least 3..7 ms of audio. Therefore, having 100 ms total buffering time, you can divide it into 8-12 parts but for 20 ms, it is not recommended to use more than 4 parts.

The priority field controls priority of the Audio Repeater process. The higher is priority value, the smoother a process is executing, the less time is rest for another processes. Most processes have Normal priority value, Audio Repeater has Normal value by default.

By default, Realtime priority is available only for users with administrative privileges. Be careful setting this priority value because it can cause Windows to freeze. If you want to use this priority under a limited user account, enable the "Increase scheduling priority" policy for this account (or for a group), using local security policy editor from an administrative account. The editor can be accessed from the "Administrative tools" folder in Windows Control Panel or by typing "secpol.msc" in the Start-Run dialog.

Please note that clock difference effect can be lowered but cannot be eliminated at all. Therefore don't rely on Audio Repeater as a robust audio transfer tool. A Virtual Cable can do a robust, smooth and long-time transfer between two applications but there is no way to establish a robust transfer between two Windows audio devices. You can try to minimize a clock difference effect by using VAC clock correction feature.

Format descriptor selection

When opening a wave device, Audio Repeater uses the WAVEFORMATEX format descriptor if sample size if 16 bits or less and number or channels is 1 or 2. If sample size is greater than 16 bits and/or number of channels is greater than two, Audio Repeater opens the device with a modern WAVEFORMATEXTENSIBLE descriptor.

Command line options

Audio Repeater accepts several command-line options, allowing to pre-configure it:

/Input:<str> Input (capture, recording) device name
/Output:<str> Output (playback, rendering) device name
/SamplingRate:<num> Sampling rate (samples per second)
/BitsPerSample:<num> Bits per sample
/Channels:<num> Number of channels
/ChanCfg:<str> Channel configuration
/BufferMs:<num> Total buffering length in milliseconds
/Buffers:<num> Number of buffers (parts of buffering space)
/Priority:<str> Process priority
/WindowName:<str> Name of application instance window
/AutoStart Start audio transfer automatically
/CloseInstance:<str> Close a specified Audio Repeater instance by its window name

Option names are case-insensitive. <Num> means a number, <str> means a string. Specify option values exactly as you see them in Audio Repeater window, even they are cut. Device names must be specified exactly as they are shown in Audio Repeater Input and Output menus. Don't specify names shown in Device Manager or in Sound/Multimedia applet.

If a string contains spaces or other special characters, enclose it in double quotemarks ("). To avoid name matching problems, leading/trailing spaces are stripped, space groups between words are replaced with a single space. To insert a quotemark, specify two consecutive quotemarks in the string.

If you want to enter a command line from a console and a string contains national characters that don't exist in a console code page, create a command (batch) file, placing the command line into it, and insert CHCP command before the command line. See Windows Help and Support for CHCP command description. Save this file in UTF-8 encoding to allow the command interpreter (cmd.exe) to recognize it.

With /Input and /Output options, you can specify device numbers as #n, where n is a device number in Audio Repeater device menu, starting from zero.

The custom channel configuration option has the following format:

/ChanCfg:custom=<num>

where <num> is a hexadecimal channel mask as defined for the KSAUDIO_CHANNEL_CONFIG.

For example, to configure Audio Repeater with "Virtual Cable 1" as input device, "USB Speakers" as output device, sampling rate 48000, 16 bits per sample, two channels (stereo), command line parameters should be the following (a single, continuous line):

/Input:"Virtual Cable 1" /Output:"USB Speakers" /SamplingRate:48000 /BitsPerSample:16 /Channels:2

/CloseInstance option has a special meaning. Instead of specifying a parameter for a newly started Audio Repeater instance, it instructs to close an existing instance that has a specified window name (specified earlier by /WindowName option). If used, it must be the only option in command line. If a named window exists (even if hidden), the window close message is sent to it. The option can be used to close any application window, not only Audio Repeater's.

Automation

You can create a shortcut for Audio Repeater or invoke it from a batch (command) file to achieve better automation. See Windows Help and Support center for details (type "create shortcut" in the Search field to see how to create and edit shortcuts, type "batch files" to see how to use batch files).

To create a shortcut, locate either Audio Repeater executable file in VAC installation directory or default Audio Repeater shortcut in VAC folder in the Start Menu. Command-line parameters should be appended (space separated) to the executable file path in the "Target" field.

In a batch file, use Start command (type "start /?" in the Windows Command Prompt window for explanation) to start several instances simultaneously.

To run Audio Repeater instances automatically after a logon, place shortcuts to the Startup folder of the Start Menu. See Windows Help and Support for details.

Minimizing to tray icon

Audio Repeater supports tray minimizing. To restore, left-click the icon. To open a context menu, right-click the icon.

To start Audio Repeater minimized to the tray, use either the start command with /min option (see "start /?" for details) or a shortcut with the "Minimized" running mode.

Kernel Streaming version

This Audio Repeater version is intended to access audio devices via through high-performance and low-latency Kernel Streaming (WDM/KS). It looks and works like standard MME version but has some important differences.

Using KS version, please note it accesses device pins directly, not using System Audio Engine or other intermediate layers. It means no format conversion is performed by System Audio Engine, only device and/or its driver format conversion features will work, if any.

Additionally, KS version allocates a pin instance directly, so if device driver does not allow multiple pin instances, this pin cannot be used simultaneously by several applications and/or Windows itself. Since you have opened such device in KS version, you will be unable to open another instance, even via other Windows audio interfaces.

See audio layering issues for details.

Therefore, don't use KS version if you don't clearly understand how it works and how it differs from the basic MME version.

Queue indicators in Kernel Streaming version behave slightly different than in MME version due to intermediate buffering. The input queue is fully filled at the start but the output queue is only half-filled to minimize clock difference effect. In a stable state, input queue indicator should be near its right side and output queue indicator should be near its center.

Please note that KS device names are usually different from MME names. If you use KS version in a command file, copy device name from KS version, not from MME one.

Additionally to the /ChanCfg option, KS version supports separate channel configurationsĀ for both input and output (/ChanCfgIn and /ChanCfgOut with the same syntax). Mostly, it is intended to be used with cable channel scatter/gather feature but can be used for other channel mapping purposes. See the example of scatter/gather feature usage.

Audio drivers support only a limited set of formats (format ranges) at WDM/KS level. If a given format is not supported by device pins, Audio Repeater displays an error message ("No appropriate pin found"). In such case, try to use another format (for example, 48000 samples per second instead of 44100 or vice versa). If you don't know what formats are supported by the driver, use ASIO2KS that can show supported format ranges.

Please note that Kernel Streaming version interacts directly with an audio device driver and uses a different communication technique than standard Windows audio subsystem. Most audio drivers, even WHQL certified, are tested only using standard Windows audio subsystem requests. On non-standard requests, such drivers may generate errors and even BSODs. For example, some Realtek WHQL-certified drivers generate BSODs if a sampling rate less than 8000 is selected for a capture operation.

Such driver behavior is definitely incorrect and should not be considered as Audio Repeater's problem because a well-built driver never causes BSODs. If a hardware driver causes a BSOD, please contact driver's vendor instead of complaining to Audio Repeater.