Page 1 of 1
Posted: Wed Feb 27, 2002 1:01 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.
Hi guys
Is there any way (using API commands only) to check if the Midi (play) is in use or not... For example when i start my pb program and want to play a midi in background, i will check if its ok or failed (because another app plays midi) - I use the MCI stuff "SendString_" for playing and so on...
Want something looks like:
Code: Select all
Procedure MyInitMidi()
...
EndProcedure
;
If MyInitMidi() = 0
Print "failed.. in use by another app..."
End
Endif
thanks in advance... btw the irc chat is really cool!
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Edited by - MrVainSCL on 27 February 2002 01:06:13
Posted: Wed Feb 27, 2002 8:54 am
by BackupUser
Restored from previous forum. Originally posted by Stan.
Hi,
This is what I got from the MS MCI doc :
*******************************************************************
open
The open command initializes a device. All MCI devices recognize this command.
wsprintf(lpstrCommand, "open %s %s %s", lpszDevice, lpszOpenFlags,
lpszFlags);
Parameters
lpszDevice
Identifier of an MCI device or device driver. This can be either a device name (as given in the registry or the SYSTEM.INI file) or the filename of the device driver. If you specify the filename of the device driver, you can optionally include the .DRV extension, but you should not include the path to the file.
lpszOpenFlags
Flag that identifies what to initialize. The following table lists device types that recognize the open command and the flags used by each type: cdaudio alias device_alias
shareable type device_type
digitalvideo alias device_alias
elementname
nostatic
parent hwnd
shareable style child
style overlapped
style popup
style style_type
type device_type
overlay alias device_alias
parent hwnd
shareable
style child style overlapped
style popup
style style_type
type device_type
sequencer alias device_alias
shareable type device_type
vcr alias device_alias
shareable type device_type
videodisc alias device_alias
shareable type device_type
waveaudio alias device_alias
buffer buffer_size shareable
type device_type
The following table lists the flags that can be specified in the lpszOpenFlags parameter and their meanings: alias device_alias Specifies an alternate name for the given device. If specified, it must be used as the device_id in subsequent commands.
elementname Specifies the name of the device element (file) loaded when the device opens.
buffer buffer_size Sets the size, in seconds, of the buffer used by the waveform-audio device. The default size of the buffer is set when the waveform-audio device is installed or configured. Typically the buffer size is set to 4 seconds. With the MCIWAVE device, the minimum size is 2 seconds and the maximum size is 9 seconds.
parent hwnd Specifies the window handle of the parent window.
shareable Initializes the device or file as shareable. Subsequent attempts to open the device or file fail unless you specify "shareable" in both the original and subsequent open commands.
MCI returns an invalid device error if the device is already open and not shareable.
The MCISEQ sequencer and MCIWAVE devices do not support shared files.
style child Opens a window with a child window style.
style overlapped Opens a window with an overlapped window style.
style popup Opens a window with a pop-up window style.
style style_type Indicates a window style.
type device_type Specifies the device type of a file.
lpszFlags
Can be "wait", "notify", or both. For more information about these flags, see The Wait, Notify, and Test Flags.
Return Values
Returns zero if successful or an error otherwise.
Remarks
MCI reserves "cdaudio" for the CD audio device type, "videodisc" for the videodisc device type, "sequencer" for the MIDI sequencer device type, "AVIVideo" for the digital-video device type, and "waveaudio" for the waveform-audio device type.
As an alternative to the "type" flag, MCI can select the device based on the extension used by the file, as recorded in the registry or the [mci extension] section of the SYSTEM.INI file.
MCI can open AVI files by using a file-interface pointer or a stream-interface pointer. To open a file by using either type of interface pointer, specify an at sign (@) followed by the interface pointer in place of the file or device name for the lpszDevice parameter. For more information about the file and stream interfaces, see "AVIFile Functions and Macros ."
The following command opens the "mysound" device:
open new type waveaudio alias mysound buffer 6
With device name "new", the waveform driver prepares a new waveform resource. The command assigns the device alias "mysound" and specifies a 6-second buffer.
You can eliminate the "type" flag if you combine the device name with the filename. MCI recognizes this combination when you use the following syntax:
device_name!element_name
The exclamation point separates the device name from the filename. The exclamation point should not be delimited by white spaces.
The following example opens the RIGHT.WAV file using the "waveaudio" device:
open waveaudio!right.wav
The MCIWAVE driver requires an asynchronous waveform-audio device.
QuickInfo
Version: Requires Windows NT Server Enterprise Edition 4.0.
Windows CE: Unsupported.
Header: Declared in resapi.h.
See Also
MCI Overview, MCI Command Strings
************************************************************************
I confess it's a bit complicated for me ... But may understand it better
than I do
Hope this helps
Learning and Love are what life is all about ... [ PB. registered user ]
Posted: Wed Feb 27, 2002 2:06 pm
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.
Hi Stan
Thanks for your help and the big posting of the MCI text

I still have the complete API and the small MCI helpfiles... I only dont really know how to use some of the API commands ;( (I have to learn about this
I can play/stop/loop midi tunes using API (thanks to El Choni!) and i tried something like following line, but it dont work ;(
Code: Select all
mciSendString_("capability song can play") ; How to use this API?
Anyway many thanks Stan... bye
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Posted: Wed Feb 27, 2002 3:14 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
Hi,
Code: Select all
mciSendString_("capability song can play", StatusString, 255, 0)
StatusString is a pointer to a buffer that receives the result, a string containing "false" or "true". 255 is the size of the buffer. For some reason, it's never less than 255. You know, Microsoft doesn't care too much about wasting memory. Anyway, MrVain, you have new mail

.
Bye,
El_Choni
Posted: Thu Feb 28, 2002 12:44 am
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.
El_Choni wrote:
StatusString is a pointer to a buffer that receives the result, a string containing "false" or "true". 255 is the size of the buffer. For some reason, it's never less than 255. You know, Microsoft doesn't care too much about wasting memory. Anyway, MrVain, you have new mail

.
hehe... thanks El_Choni... i will check your api example and check my emails now

Many thanks men! Stay cool... bye
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Posted: Thu Feb 28, 2002 3:21 am
by BackupUser
Restored from previous forum. Originally posted by El_Choni.
Sorry, MrVain, I misunderstood what you were trying to do. To check if a device is available, you must use:
Code: Select all
mciSendString_("status song ready", StatusString, 255, 0)
Returns "true" (in StatusString) if ready.
I'll send you the example tomorrow. Bye,
El_Choni
Posted: Thu Feb 28, 2002 5:09 pm
by BackupUser
Restored from previous forum. Originally posted by MrVainSCL.
El_Choni wrote:
Sorry, MrVain, I misunderstood what you were trying to do. To check if a device is available, you must use:
Hi El_Choni
First many thanks for your email... i think you saw now the problem with the funny result and the WinAmp stuff...!?
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten