?
Solved

Wavemix.dll

Posted on 2004-08-02
5
Medium Priority
?
533 Views
Last Modified: 2010-04-04
I'm trying to find a working set of code for the wavemix.dll. Downloaded a few from Torry but they either don't work, are for the wrong version, or have missing files. I'm using D7 Pro on XP Pro, but target machines range from NT4 to Win2k to XP Pro.

What I need is some free source code or a component to play several wave files simultaneously. I do actually have a nearly working version of the interface to Wavemix.dll, but the Play function crashes. Tried all the usual stuff like word/dword, stdcall etc, but I think I'm missing something obvious. WMixWave works; WMixPlay doesn't. Either fixing this or supplying new code/components will get the points!

Thanks

Geoff M.


----code follows----

unit Wmix; {WaveMix DLL import module May 1995 by Gavin R. Kujawa}

interface

uses
      Windows;

type
            TWMixInfo = packed record           {Storage record for WMixGetInfo}
                                    Size: word;            {Record size}
                                    Vmajor: byte;          {'Major' version # (i.e. '#.')}
                                    Vminor: byte;          {'Minor' version # (i.e. '.#')}
                                    Date: array[0..11] of char;{Compilation date as 'mmm dd yyyy[null]'}
                                    Formats: longint;      {PCM formats supported as flags}
            end;

type
            TWMixConfig = packed record         {Storage record for WMixConfigure}
                                          Size: word;          {Record size}
                                          Flags: longint;      {Flags (see below). Must OR with both...}
                                          Channels: word;      {1(mono) or 2(stereo) And ...}
                                          SampRate: word;      {11, 22, or 44 kHz}
            end;

type
            TWMixParams = packed record         {Storage record for WMixPlay}
                                          Size: word;          {Record size}
                                          Session: THandle;       {WaveMix session handle}
                                          Channel: integer;    {Play on channel(0 to 7)}
                                          Wave: Pointer;       {Memory pointer to Wave file}
                                          Notify: HWnd;        {Handle to send MM_WOM_DONE message to}
                                          Flags: dword;      {Play flags (see below)}
                                          Loops: word;         {# of times to loop ($FFFF = indefinite)}
            end;

type
            TWMixMessage = record        {Message record used by WMixPlay}
                                                 Msg: integer;     {Message #: $03BD (MM_WOM_DONE)}
                                                 Channel: integer; {Channel # just played}
                                                 Wave: pointer;    {Pointer to Wave file in memory}
                                                 Result: longint;  {Not used (?) by WaveMix}
            end;

const                                {WaveMix bit flags}
     WMix_File: longint = $0001;       {WMixOpen: from disk file}
     WMix_Resource: longint = $0002;   {WMixOpen: from system resource file}
     WMix_Memory: longint = $0004;     {WMixOpen: from memory}
     WMix_OpenSingle: longint = $0000; {WMixChannel: open one Play channel}
     WMix_OpenAll: longint = $0001;    {WMixChannel: open ALL eight channels}
     WMix_OpenCount: longint = $0002;  {WMixChannel: open # channels}
     WMix_FlushAll: longint = $0001;   {WMixFlush & Close: do ALL channels}
     WMix_NoRemix: longint = $0002;    {WMixFlush: don't remix sound data}
     WMix_Channels: longint = $0001;   {WMixConfigure: set channels}
     WMix_SamplingRate: longint = $0002;{WMixConfigure: set playback rate}
     WMix_QueueWave: longint = $0000;  {WMixPlay: play when previous finishes}
     WMix_ClearQueue: longint = $0001; {WMixPlay: play sound immediately}
             WMix_UseLRUChannel: longint = $0002;{WMixPlay: play on next available chan}
             WMix_HiPriority: longint = $0004; {WMixPlay: remix play buffer immediately}
             WMix_Wait: longint = $0008;       {WMixPlay: hold until next 'Play'}
             MM_WOM_DONE: integer = $03BD;     {Message used by WMixPlay when done}

function WMixInit: THandle; far; stdcall;
                         {WaveMixInit: returns WaveMix session handle}
function WMixConfigure(Config: TWMixConfig): word; far; stdcall;
                         {WaveMixConfigureInit: also returns WaveMix session handle}
procedure WMixActivate(Session: THandle; Activate: boolean); stdcall;
                              {WaveMixActivate: gains/releases Wave player}
function WMixWave(Session: THandle; Wave: PChar; Instance: longint; Flags: longint): Pointer; far; stdcall;
                         {WaveMixOpenWave: returns pointer to WaveMix Wave data}
procedure WMixChannel(Session: THandle; Channel: integer; Flags: longint); stdcall;
                              {WaveMixOpenChannel: opens play channels}
procedure WMixPlay(Params: TWMixParams); stdcall;
                              {WaveMixPlay: plays file using Params (see above)}
procedure WMixFlush(Session: THandle; Channel: integer; Flags: longint); stdcall;
                              {WaveMixFlushChannel: clears selected channel}
procedure WMixClose(Session: THandle; Channel: integer; Flags: longint); stdcall;
                              {WaveMixCloseChannel: closes selected channel}
procedure WMixFree(Session: THandle; Wpointer: Pointer); stdcall;
                              {WaveMixFreeWave: clears Wave file from memory}
procedure WMixExit(Session: THandle); stdcall;
                              {WaveMixCloseSession: stops & unloads WaveMix DLL}
procedure WMixPump; stdcall;
                              {WaveMixPump: play next mixing buffer}
function WMixGetInfo(Info: TWMixInfo): word; far; stdcall;
                         {WaveMixGetInfo: fills in Info record (see above)}

implementation  {Define WMix functions from WaveMix DLL}

const
      DLL_NAME = 'wavmix32.dll';

function WMixInit; external DLL_NAME name 'WaveMixInit';
function WMixConfigure; external DLL_NAME name 'WaveMixConfigureInit';
procedure WMixActivate; external DLL_NAME name 'WaveMixActivate';
function WMixWave; external DLL_NAME name 'WaveMixOpenWave';
procedure WMixChannel; external DLL_NAME name 'WaveMixOpenChannel';
procedure WMixPlay; external DLL_NAME name 'WaveMixPlay';
procedure WMixFlush; external DLL_NAME name 'WaveMixFlushChannel';
procedure WMixClose; external DLL_NAME name 'WaveMixCloseChannel';
procedure WMixFree; external DLL_NAME name 'WaveMixFreeWave';
procedure WMixExit; external DLL_NAME name 'WaveMixCloseSession';
procedure WMixPump; external DLL_NAME name 'WaveMixPump';
function WMixGetInfo; external DLL_NAME name 'WaveMixGetInfo';

end.
0
Comment
Question by:gmayo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 11696487
Another way is to utilise DirectSound and you can play all the wave files simultaneously.
0
 
LVL 8

Author Comment

by:gmayo
ID: 11702107
If only life were that simple... it took me months to learn Direct3d and there were some good examples. DirectSound does not have such good samples, either on MS or on Jedi. Direct3d doesn't even support loading WAV files - you have to write your own reader! Ever heard of "re-inventing the wheel" Microsoft?

There's also the problem of it not being fully supported on NT4.

But thanks anyway. I've got all the other functions in this DLL working fine, except the Play one - if only I could get that to work...

Geoff M.
0
 
LVL 2

Expert Comment

by:philipjc
ID: 11702813
If you use directshow it takes care of all file reading

       CoCreateInstance(CLSID_FilterGraph, Nil,  INPROC_SERVER,
                                    IID_IGraphBuilder, Graph);
        Graph.QueryInterface(IID_IMediaControl, MediaControl);
        Graph.QueryInterface(IID_IMediaEventEx, MediaEvent);
        Graph.QueryInterface(IID_IBasicAudio, BasicAudio);  
        if not Succeeded(Graph.RenderFile(Fname, Nil)) then
              raise Exception.create('Unable to Render File');
        MediaControl.Run();

May not be supported on NT4
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
ID: 11707985

Not sure if this helps, but it is my understanding that the WaveMixPlay function requires the parameter buffer "by reference", and not "by value".

type
  PWMixParams       =  ^TWMixParams;
  TWMixParams       =  packed record  {Storage record for WMixPlay}
     Size:          WORD;             {Record size}
     Session:       THandle;          {WaveMix session handle}
     Channel:       Integer;          {Play on channel(0 to 7)}
     Wave:          Pointer;          {Memory pointer to Wave file}
     Notify:        HWND;             {Handle to send MM_WOM_DONE message to}
     Flags:         DWORD;            {Play flags (see below)}
     Loops:         WORD;             {# of times to loop ($FFFF = indefinite)}
  end;

// The exported call would then needs to be defined as one of the following

procedure  WMixPlay(Params: PWMixParams); stdcall;

or

procedure WMixPlay(var Params: TWMixParams); stdcall;

---------

Regards,
Russell

0
 
LVL 8

Author Comment

by:gmayo
ID: 11713955
Thanks Russell, that did the trick! I don't know why I didn't think of that, oh well!

Cheers

Geoff M.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question