gmayo
asked on
Wavemix.dll
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.
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.
Another way is to utilise DirectSound and you can play all the wave files simultaneously.
ASKER
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.
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.
If you use directshow it takes care of all file reading
CoCreateInstance(CLSID_Fil terGraph, Nil, INPROC_SERVER,
IID_IGraphBuilder, Graph);
Graph.QueryInterface(IID_I MediaContr ol, MediaControl);
Graph.QueryInterface(IID_I MediaEvent Ex, MediaEvent);
Graph.QueryInterface(IID_I BasicAudio , BasicAudio);
if not Succeeded(Graph.RenderFile (Fname, Nil)) then
raise Exception.create('Unable to Render File');
MediaControl.Run();
May not be supported on NT4
CoCreateInstance(CLSID_Fil
IID_IGraphBuilder, Graph);
Graph.QueryInterface(IID_I
Graph.QueryInterface(IID_I
Graph.QueryInterface(IID_I
if not Succeeded(Graph.RenderFile
raise Exception.create('Unable to Render File');
MediaControl.Run();
May not be supported on NT4
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Russell, that did the trick! I don't know why I didn't think of that, oh well!
Cheers
Geoff M.
Cheers
Geoff M.