multisnd.gifOn older versions of Microsoft Windows, most notably Windows 98, Windows ME, and Windows NT, it is not possible to play back multiple audio streams simultaneously. The MultiSND server solves this problem by implementing digital audio mixing. The present implementation of MultiSND implements audio mixing for 8000 samples/s, 8-bit audio streams.

The following sample program demonstrates the operation of the MultiSND server, invoked from a command-line C++ program using only standard Windows API calls (no ATL or MFC):

// To compile, type: CL HCL.CPP OLE32.LIB OLEAUT32.LIB

#include <windows.h>
#include <olectl.h>
#include <stdio.h>
#include <conio.h>

void main(void)
{
    CLSID clsid;
    LPUNKNOWN punk;
    IClassFactory2 *pcls;
    LPDISPATCH pdisp;
    DISPID dispid;
    OLECHAR *pszProp = L"Play";
    DISPPARAMS dispparams;
    UINT uArgErr;
    VARIANTARG vArg;

    // Allocate buffer, fill with modulated sinusoid sound
    vArg.bstrVal = SysAllocStringByteLen(NULL, 5120);
    char *pB = (char *)vArg.bstrVal;
    for (int i = 0; i < 2560; i++)
        pB[i] = pB[i + 2560] = ((i >> 8) << 3) * ((i % 13 > 8) ? 1 : 0);

    // Obtain required COM interface pointers
    OleInitialize(NULL);
    CLSIDFromProgID(OLESTR("MULTISND.MultiSound"), &clsid);
    CoGetClassObject(clsid, CLSCTX_SERVER, NULL, IID_IClassFactory2,
                     (LPVOID *)&pcls);
    // ***TODO: Replace license string with YOUR VALID license key!
    pcls->CreateInstanceLic(NULL, NULL, IID_IUnknown,
                            L"00000000:licensed@user.com", (LPVOID *)&punk);
    punk->QueryInterface(IID_IDispatch, (LPVOID *)&pdisp);
    punk->Release();
    pcls->Release();

    // Invoke Play method up to 100 times; terminate on keystroke
    pdisp->GetIDsOfNames(IID_NULL, &pszProp, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
    dispparams.cArgs = 1;
    dispparams.cNamedArgs = 0;
    dispparams.rgdispidNamedArgs = NULL;
    dispparams.rgvarg = &vArg;
    vArg.vt = VT_BSTR;
    for (i = 0; i < 100; i++)
    {
        if (_kbhit()) break;
        pdisp->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD,
        &dispparams, NULL, NULL, &uArgErr);
        Sleep(300);
    }

    // Clean-up and termination
    SysFreeString(vArg.bstrVal);
    pdisp->Release();
    OleUninitialize();
}

Multiple programs like this HCL.EXE can run simultaneously, and the resulting audio stream will be a combination of all inputs, as described in my article about this topic.

The functionality of the MultiSND server is exposed through two properties and one ActiveX method:

Properties

Jitter A value between 0 and 3 indicating how many audio data packets must be buffered by the server prior to playback. It is most useful when the audio stream is received through an unreliable connection and timing is not guaranteed.
Volume The output audio volume. Must be between 0 and 255. Note that this does NOT adjust the sound card settings, only the amplitude of the audio stream.

Methods

Play Play back audio. Audio data is represented in the form of a 5120-byte BSTR value: i.e., approximately 0.32 seconds worth of stereo audio (2 times 2560 bytes at a sample rate of 8000 bytes per second.)

To download the MultiSND server to your computer, right click on this link and select "Save Target As..." from the context menu. Note that the downloaded DLL is of little use by itself; you must also purchase a license.

The MultiSND server cannot be used in your own projects, or redistributed to end-users without a license. You can purchase a license online. When you purchase a single developer or site license, your license information will be e-mailed to you automatically. When you purchase an unrestricted license, your purchase will be reviewed, and a full source archive will be e-mailed to you, usually within 24 hours of your purchase.

License type

Price in USD

Buy Now!
Single Developer License
Authorizes a single developer to use the control in his or her projects, and redistribute the control to end-users. No source code is included.
$50.00

Site License
Authorizes a group of developers working together at the same geographic location to use the control in their projects, and redistribute the control to end-users. No source code is included.
$250.00

Unrestricted License
Provides a non-exclusive license to do as you please with the control. Includes the license to modify the control, redistribute the control in source or object form, or incorporate the control or any parts thereof into your projects. Source code included.
$1500.00