Samples working in console mode

Subscribe to RSS news feed

Some examples do not require GUI and still can prove to be useful. To run console application is it better to go to command line prompt or use excellent file manager FAR.

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

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 samples 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 create one). 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.

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 sample 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 Sampler sample, 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. 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 already noticed, all these samples do not use VCL, so resulting executable files are very compact in size and has console target. If you are not going to use GUI and VCL in your applications, VC components still can be used efficiently. This applies for system services, custom DLLs and other kind of application where GUI is not needed.

Download

Precompiled binary of this sample is included in the Demos package.