VC components. Samples

News

Demo package includes a set of rich-featured sample applications which show the power of the product.

This package can be freely downloaded and includes binary files as well as actual sources of samples for a reference.

Sample appliactions do not require much to be running: Microsoft Windows 98 or later, TCP/IP stack and one or more sound card. To install the package simply follow the instruction of setup program. To remove it, use uninstall program located in Start Menu group for VC 2.5 Demos (or the root folder of installation directory). Alternatively select VC 2.5 Demos from Settings \ Control Panel \ Add Remove Programs.

Title, status Description
Simple console samples Just a quick show of basic tasks, such as audio recording, playback and encoding.
Format converters Several converters for OGG/MP3/WAV file formats. All use third-party external encoders.
Wave Player A simple WAV file player with tempo and volume controls.
Sampler Software audio mixer, resampler, recorder and playback application.
Pulse Gen Real-time sine generator with WAV recorder and frequency band display.
Loopback
updated
Loops recording to playback and shows the latency. Also shows how to change the size of chunk at run-time.
Voice Recording
updated
Records a voice, detects silence and removes it from target file.
DAF Simple delayed audio feedback (DAF) sample, which shows how to achieve controllable latency of 20 ms or higher.
Frequency Bands Creates and shows a number of frequency bands displays connected to one source.
EQ and Splitter
new
Shows how to use equalizer and frequency splitter from DSP Library.
Noise Detector
new
Displays how different configuration parameters affect the level and noise detectors from DSP Library.
Tape Recorder A simple sound recording sample features a digital tape recorder functions.
Mixer Demo Shows how to use system mixer control. Similar to VolumeControl system application.
Voice Chat Basic TCP/IP voice and text chat sample.
Push BMP Shows how to exchange data (pictures) while streaming using one connection.
Talk Now
updated
Basic TCP/IP peer-to-peer audio streaming application with bandwidth display.
Net Talk More advanced TCP/IP peer-to-peer audio streaming sample.
Audio Tunnel A simple peer-to-peer audio TCP/IP tunnel, which allows two parties to communicate with each other via proxy server.
Broadcast Shows how to broadcast compressed audio over LAN.
DLL Encoder Demo Records and plays back MP3/OGG streams. Can also stream audio over TCP/IP connection in real time. Uses third-party external audio encoders.
Scriptor Shows how to create and execute simple but powerful scripts, making it possible to create any kind of audio streaming at run-time.
Icy Streamer Stream to and/or listens for audio from SHOUTcast compatible server. Uses third-party external audio encoders.
RAW Streamer
new
Streams raw audiod data over TCP/IP. No custom packet headers or protocol is used.
Multi-consumer Shows how to distribute one audio source to any number of audio consumers, such as IP Server, WAV file recorder and others.
One-to-many streaming Server and Client Receives and distributes one audio stream to several clients over TCP/IP network.
Multicast source and end-point Multicast source and end-point samples. Show how to create a multicast source, join a multicast group and stream real-time audio over multicast connection.
Conference Server and Client An audio conference sample, where several clients can communicate with each other at the same time.

Simple console samples

Basic tasks, such as audio recording, playback, mixing, stream encoding and decoding are easy to do with VC components. These tasks are demonstrated in a set of simple samples. Every sample performs exactly one task. You can skip this section if you are interested in more advanced examples.

We will start with deviceEnum application. It lists all audio devices installed on a system. To save the output, redirect it to a file:

deviceEnum.exe > devices.xml

Then open devices.xml file with Internet browser. Or you can use the GUI window provided with this application to view the output.

The deviceEnum.dpr source file shows that we are using unaWaveInDevice and unaWaveOutDevice classes from unaMsAcmClasses.pas unit for device enumeration.

Similar acmEnum application enumerates audio codecs installed on a system. It uses Microsoft Multimedia Audio API and Audio Compression Manager (ACM) routines to perform the enumeration.

recorder and player demos show how to record and playback audio streams with different sampling parameters. Review configuration parameters of these demos by editing the recorder.ini and player.ini files.

Audio streams encoding and decoding is also one of the basic task, which is usually performed with VC components. The codec application uses unaMsAcmCodec class which wraps the ACM API. Before encoding a file with PCM audio stream should be created (use recorder demo to do so). Default input file name is rec_buf.dat. Output will be saved in out_buf.dat file. Refer to the codec.ini file for configuration details. To decode the stream back to PCM format, start the demo with "/rev" command line switch:

>codec.exe /rev out_buf.dat

Some applications require several audio streams to be mixed together to be played back at the same time. While many sound card drivers allow several wave streams to be played back at the same time (so they will be mixed by hardware), sometimes it is more advisable to mix audio inside your application, and that is what our mixer application does. By default it mixes two input PCM files--rec_buf1.dat and rec_buf2.dat, but it is possible to supply any number of files when starting the demo from command line, or by editing the mixer.ini configuration file. Mixing result will be saved in mix_buf.dat file. Note, that audio streams with different sampling parameters will not be mixed properly. Refer to the vcSampler application, which can mix any streams.

The volLevel demo is a simple wave volume meter application, which demonstrates the usage of volume detection mechanism, supported by unaWaveInDevice class (voiceRecDemo application uses the same feature for voice detection). Refer to the volLevel.ini configuration file, where minVolumeLevel and minActiveTime parameters are used to specify the minimum volume level and activation timeout values.

As you may have noticed, all these demos do not use VCL, so resulting executable files are very compact in size. If you are not going to use GUI and VCL in your applications, VC components still can be used efficiently.

Format converters

wav2mp3 shot, click for full sized image.

Wav2mp3, Wav2ogg and Ogg2wav demos use one of the external encoder/decoder to convert WAV into MP3 or Ogg files and Ogg files back to WAV. Currently supported are Blade and Lame MP3 encoders and Ogg/Vorbis encoder and decoder. You need the encoder library files (one or more DLLs) for this demos to work properly. Original WAV file does not has to have required sampling rate, bits or channels number. It even does not has to be in PCM format. All necessary conversion will be done by RIFF reader and PCM resampler used in our demos. The vcMp3Demo demo uses same classes to create or read real-time MP3 or Ogg/Vorbis streams.

Wave Player

Wave Player, click for full sized image.

Wave Player is a basic WAVe file playback sample with position, volume and tempo control, auto rewind feature and graphics display of audio data.

Sampler

Sampler, click for full sized image. Sampler source, click for full sized image.

A more advanced example, Sampler includes the following features: real-time recording and playback, mixing, resampling, WAVe files reading and writing. It is possible to select any of the supported PCM formats for playback and recording. When playback device is active, you can add several wave channels to be mixed together. The source of audio could be any WAVe file stored on your disks.

Every source wave can be resampled at different frequency, which leads to change in tempo it is played back by device. You can also change the volume and pan the wave between channels.

In the bin\Free\samples\ folder of VC demos installation you can find several WAVe files, which can be used as source wave streams for this demo.

Pulse Gen

Pulse Gen, click for full sized image. Pulse Gen source, click for full sized image.

The Pulse Gen sample shows how to generate a sine audio waves, mix and playback them in real time and optionally save the result into a WAVe file.

Loopback

Loopback, click for full sized image.

It is possible to fine-tune internal chunk size used by all VC components to achieve smaller latency or better CPU performance according to special needs. Loopback demo shows how to change the chunk size programmatically, and displays codec compression ratio as well as current recording/playback latency.

To calculate the latency this demo compares actual number of samples being recorded and played back. Some audio drivers or sound cards may return incorrect values, so correct calculation is not always possible.

Voice Recording

Voice Recording, click for full sized image.

Silence detection feature is important to save the network traffic when recording and sending a human voice. Try to record your voice with Voice Recording sample. Change the vertical slider to adjust minimum volume level you wish to record. When playing back notice that silence gaps were not included in final recording.

This demo also shows how to create non-PCM (compressed) WAVe files to save the disk space.

Refer to Voice Chat sample which shows how to send compressed voice over network, and use silence detection to save the traffic.

DAF

DAF, click for full sized image.

Sometimes it may be needed to control the audio chunks manually to achieve some special functionalty. For example, in DAF sample we pass audio chunks from recording device to playback device. Although it may be done by simply linking waveIn with waveOut component, we need to ensure very short delay, of about 20 ms. Due to buffering, it only possible if we take control of the process and pass audio chunks to playback device as soon as they arrive from recording device.

Main job is done by the unaAudioFeedbackClass class declared in unaAudioFeedback unit. It intercept audio chunks by assigning onDataAvailable event handler for waveIn component. Then chunk is being delayed by specified number of milliseconds (or no delayed at all) and sent to internal waveOut component.

Frequency Bands

Frequency Bands, click for full sized image.

The simple Frequency Bands sample shows different kinds of frequency bands displays, all connected to one audio source. It uses TunadspFFTControl component for rendering. Small bands can be placed on a form to attract end-users and make your applications more live and bright.

EQ and Splitter

DSP EQ, click for full sized image.

This demo shows how to use equalizer and frequency splitter from DSP library.

Noise detector

Noise Detector, click for full sized image.

Displays how different configuration parameters affect the level and noise detectors from DSP Library.

Tape Recorder

Tape Recorder, click for full sized image.

Audio data may be stored in memory before it is saved in a file. That allows end-user to master the recording, making small corrections, overwriting or inserting new recording data. The most common application of the Tape Recorder sample is a digital voice recording.

Mixer Demo

Mixer Demo, click for full sized image.

Despite the name, Mixer Demo does not mix audio streams. It simply shows how to use classes from the unaMsMixer unit, designed to work with system mixer devices. You can select recording source line, control the volume levels and do other tasks, which usually can be done with standard Volume Control application.

Voice Chat

Voice Chat, click for full sized image.

Voice Chat is the voice chat sample where TCP/IP network streaming components are used to send and receive audio and text. It includes server and client parts. Server part should be running on one machine while client part on another. Streaming is done in both directions using one connection. No configuration is required for the server. Client must know the IP address (or DNS name) of server machine. This demo uses GSM codec to save the network traffic, and you can choose the sampling rate.

This demo can also use silence detection mechanism to reduce the network traffic. In addition to voice, you can exchange with short text messages.

For more advanced audio streaming application, refer to Talk Now or Net Talk demos.

Push BMP

pushBMP, click for full sized image.

In addition to audio and text, you can exchange any custom data with remote side. Our Push BMP demo creates audio conversation channel, after that it is possible to use it to send a picture from one side to another. There is no need to create a new connection for custom data exchange.

NOTE: Although VC will care about re-packing big data blocks into smaller ones, avoid sending more than 16 KB at a time. Create a loop and send smaller chunks one by one instead. Collect these chunks on remote side (VC will ensure proper order of packets even for UDP). Be also sure not to overload the bandwidth (in this case, for UDP some data will be lost, for TCP there will be some delays and gaps in real-time audio streaming).

Talk Now

Talk Now, click for full sized image.

Talk Now is a more advanced audio streaming application. It includes server and client parts. You start server part on one machine and client on another. Streaming is done in both directions using one connection. Specify port number and socket type for server. Client must specify the IP address (or DNS name) of server machine and streaming port number, as well as socket type (TCP or UDP). It is also possible select any installed codec to be used for audio compressing with this demo.

For long-latency networks, such as satellite connection, it is recommended to use UDP sockets. This demo can also large pre-buffers to avoid audio loss in such networks. This options can be turned on and off in Options menu.

In addition, vaTalkNow Server can handle more than one Client connection, enabling conference-like audio streaming. Maximum number of clients may be specified in Options menu. Source of audio distributed among Clients is live recording done on Server side. For demonstration of how to distribute remote audio source, lease refer to Distribution Server and Client demo.

Another advanced audio streaming application is Net Talk demo.

Net Talk

Net Talk server, click for full sized image. Net Talk client, click for full sized image.

Real time audio streaming requires some advanced techniques to be used, such as audio compression, real time streaming protocol and others. Net Talk demo combines all of this features and demonstrates the power of VC components.

Both server and client can use any installed ACM codec to compress the stream. Both can mix real time recording with WAVe file stored on your disk. You can disconnect and connect the client at any time, without restarting the server. If you stop the server, the client must be reconnected.

As with Talk Now demo, there are server and client parts in the same application, and only one part should be active at a time on one machine.

Both UDP (datagram) and TCP (streaming) sockets can be used for connection.

Server and client can use different ACM audio codecs, but make sure the codec selected on one side is installed on remote side.

RAW Streamer

Raw Streamer, click for full sized image.

Sometimes audio data must be sent over network as it is, without additional headers and protocol.

This demo shows how to setup client and/or server for raw streaming mode.

Audio Tunnel

Audio Tunnel, click for full sized image.

Audio Tunnel sample was designed to allow TCP/IP clients and servers located behind proxy/firewall to communicate with outer world by maintaining an virtual "audio tunnel" connection.

This application should be running on a router machine, which has access to both Internet and local network. It should also be configured to listen for incoming request from local or remote client, and to redirect this request to local or remote server. One instance of this application can support one peer-to-peer connection:

CLIENT <--> Audio Tunnel <--> SERVER

Broadcast

Broadcast server, click for full sized image. Broadcast client, click for full sized image.

Broadcasting is a feature, supported in LAN (Local Area Networks) only. Broadcast server does not know about how many clients will listen for distributed audio stream. Clients usually do not send any data back to server, so it is very similar to usual radio broadcasting.

Broadcast sample shows how to use classes from VC components to build efficient audio broadcasting system.

You can restart Clients and Server at any time. If changes were made in the format of audio stream being distributed by Server, Clients will synchronize with new format automatically without end-user interaction.

DLL Encoder Demo (Mp3Demo)

DLL Encoder Demo Server, click for full sized image. DLL Encoder Demo Client, click for full sized image.

It is possible to integrate external PCM stream encoders and decoders with VC components to produce custom audio files and streams, such as MP3 or Ogg/Vorbis. These formats may be not supported by installed ACM codecs and therefore external libraries are required.

VC components has native support for Blade and Lame MP3 encoders, Vorbis/Ogg encoder and decoder, BASS library and MpgLib MP3 decoder library. Press the Copyrights button to get more information about these libraries.

In DLL Encoder Demo all operations are performed in real-time, making it possible to use these engines for real-time audio streaming.

Scriptor

Scriptor, click for full sized image.

TunavclScriptor component is a simple run-time script interpreter. It can be used to create components from VC set at run time, link and activate them. It also allows to retrieve or modify most of the properties of created components. Script source could be modified by end-user (or application itself) and executed at any time.

Scriptor sample shows what and how you can do with that powerful tool.

Icy Streamer

Icy Streamer Client, click for full sized image. Icy Streamer Source, click for full sized image.

Icy Streamer sample shows how to stream live audio to specified SHOUTcast server, and how to receive and listen live stream from it. It uses Lame library to encode audio in MP3 format, and BASS or MpgLib library to decode it to PCM for playback.

SHOUTCAST(TM) are copyright protected and are the property of Nullsoft, Inc.

Multi-Consumer

Multi-Consumer, click for full sized image.

It is now possible to link one component with any number of other components (consumers). This makes it simple to distribute audio from one source to several destinations. In our Multi-Consumer sample you can add any number of consumers to live recording source at run-time.

For example, it is possible to stream audio to remote server(s) or client(s), save it into local WAVe file(s) or listen it on live playback, all at the same time. Programmatically all you have to do is to use the addConsumer() method to link one component with another. VC components will care for proper format negotiation and component activation.

This feature dramatically reduces development time of complex audio processing applications.

Distribution Server and Client (mediaGate)

Distribution Server, click for full sized image. Distribution Client, click for full sized image.

Making conference-like communication applications with VC components is as easy as making peer-to-peer voice chat projects. Distribution Server and Client samples show how to distribute audio stream being received from remote source among several Clients. The process is shown on a picture below.

mediaGate scheme, click to enlarge

One designated Client working in "speaker" mode connects to mediaGate server, which in turn distribute audio to "listeners". Listeners can connect and disconnect at any time, and Server will automatically assign next available channel for new Listener.

In addition, this demo shows how to enable/disable audio distribution from server to selected clients. Disabled client remains connected, but does not receive any audio.

Multicast source and end-point

Multicast Source, click for full sized image. Multicast End Point, click for full sized image.

UDP sockets have many applications which are not possible to achieve with TCP sockets. One of the application is multicast technology, where data is delivered to a group of recipients simultaneously. There should be a data source, which creates a group, produces the data and sends it over network, and number of end-points, which join some group or groups, announcing their interest, so network hardware may create the most efficient routing.

Unlike with broadcasting, shows in our Broadcast demo, multicast streams may reach clients connected through Internet, not only LAN, and preserve hardware resource (like bandwidth) so much larger number of clients may be served at the same time.

All job is done by the unaMulticastSocket class declared in unaSockets.pas unit, and Multicast source and Multicast end-point samples show how to use this class for live audio streaming.

Conference Server and Client

Conference Server, click for full sized image. Conference Client, click for full sized image.

In many applications it may be needed to provide the ability for several clients to participate in one audio meeting or conference, where everyone can hear each other, just like in real life. When more than two clients are considered, some special audio processing may be needed to fulfill this task. Although it actually can be done with VC components and classes, not all developers are willing to dive into the details, and would rather prefer to re-use already working solution.

That is why we have included the Conference Server and Conference Client samples into our package. The Server is responsible for accepting client connections, mixing audio data and feeding the clients with proper audio streams. It also provides ability for participants to exchange text information. Client can be any application based on our IpClient component, such as Talk Now, Voice Chat or similar samples, but we have also included another custom client with some additional features.

All job is done by unaConfClientClass and unaConfServerClass classes declared in unaConfClient.pas and unaConfServer.pas units.