IMixer Interface How-To

Hi.

I give a short explanation how to use the new IMixer interface from your scripts in order to control (mute, unmute, set volume) the Windows mixer. This can be used for automatic rebroadcast.

The number of mixers available usually corresponds to the number of sound cards installed in your system. You can determine this number with the global function

function GetMixerCount: integer;

To obtain the IMixer interface of a specific Mixer, use the following function. All indexes start with 0, so when GetMixerCount reports 3 mixers, these have the indexes 0, 1 and 2.

function GetMixer(iIndex: integer): IMixer;

The IMixer interface is defined as follows:

type IMixer = interface function GetProductName: string; function GetDestinationCount: integer; procedure Mute(iDestination, iConnection: integer); procedure Unmute(iDestination, iConnection: integer); function IsMuted(iDestination, iConnection: integer): boolean; procedure GetVolume(iDestination, iConnection: integer; var oLeft, oRight: integer); procedure SetVolume(iDestination, iConnection: integer; iLeft, iRight: integer); end;

GetProductName returns the name of the device, corresponds to the name of your sound card.

GetDestinationCount determines the number of “destinations” on that mixer device. Most have two, “Playback” and “Recording”. Unfortunately, you cannot determine which one is which, so you have to do trial-and-error.

Mute, Unmute, GetVolume and SetVolume affect the setting of a certain “connection” (Wave, Line In, …) on a specific destination. At this time, it is not possible to determine the names of the connections, trial-and-error again :slight_smile: Apparently, the order is the same as displayed in the Windows Mixer program, 0 is the leftmost connection. Master volume can be controlled by setting connection to -1.

Volume values go from 0 (virtually muted) to 65535 (full).

Note that, for the Recording destination, most sound cards have “Select” options instead of “Mute” buttons. The Mute/Unmute functions will then set this “Select” option, however, with inverse semantics (calling “Mute” sets “Select”, so the channel is not muted, but all other channels are).

Here’s an example: Let’s first determine the number of mixers and write their names to the system log:

[code]var i: integer;

begin
for i := 0 to GetMixerCount - 1 do
SystemLog('Mixer ’ + IntToStr(i)+ ': ’ + GetMixer(i).GetProductName);
end.[/code]

Assume that we want to control the first sound card, “Playback” is destination #0, “Line In” is connection #3. Then you can unmute Line In with

begin GetMixer(0).Unmute(0, 3); end.

Torben

Will this tutorial be translated to german? :slight_smile:

Thanks,
David

Go ahead :slight_smile:

I’m afraid, in the future, most official documentation (including the new manual for version 2.0) will be in English only. Just because we now have some international users, and we will (hopefully) have many more soon. And I have too little time to create two versions of each document.

But, come on, it’s not so hard to understand, is it?

Torben

Torben,
If you do need any help with the English side of the manual, please contact me privately. Providing I get a good explanation of the features you’ve put in - I’d be happy to write/maintain an English manual/user-guide. I dare say Tony would chip in, as well - He’s quite good with Acrobat, it would seem!

From the looks of the “users” page on your site, you’ve got more German/Dutch users than English :wink:

Yes. I would like to help maintain a manual or dedicated English site.

Tool I use for creating pdf files is called openoffice which includes spreadsheets, dtp, database etc and is Word compliant. Best of all its free (large download though).

http://www.openoffice.org/

Is it possible to save the scripts as reuseable files to insert where needed in a playlist from the event scheduler?

How would we script for the linein to be unmuted for 3 minutes and then muted again?

Playback of audio files would obviously e halted for this period of time to allow re-broadcast of another source (news)

Scripts must be saved as external .mls files, and are run through events by selecting “Run script” as action type and providing the script file name in the “file name” field below.

Forget about that old “Script” input box in the event editor. That was an old approach to enable scripting inside mAirList. That box will be removed in the next version.

There are three new standard event types as of 1.5.22: “Load playlist”, “Load and play playlist”, and “append playlist”. These standard tasks can then be performed without the need for an external script. However, these do only work with fixed file names, you will still need a script if you need to generate the file name dynamically.

Providing a set of pre-defined scripts with the mAirList distribution is a good idea. We can also collect them on the home page. I will also provide further methods to run a script inside mAirList, for example by drag & drop from Windows Explorer, and from mAirList’s main menu.

Regarding the manual, I will provide an official English manual (written in DocBook XML, and converted to HTML or PDF as needed). I feel that this is under my responsibility as the author of this software. However, I appreciate any assistance by writing how-to’s, articles on special features, or whatsoever. Any corrections to the manual, concerning content or language, are also welcome.

How about setting up a Wiki? This is where we could post all of our scripts :slight_smile:

Torben

hi,

A (script)-wiki is a really good idea, I think.

The Ideal case would be, that all functions of mls are in there with a short description and example:) [irony]“scripting for dummies”[/irony]

greetings, michi

Some really simple walkthroughs like: How To Load A Time+Date Playlist Each Hour / How To Open LineIn For News … etc

I’ve got some scripts which I’ll gladly share.

I setup some wiki software on my site the other day - not using it so I can rename the folder and dedicate it to mairlist if you like?

thats it:-)

and if we work with a wiki, it would be easy to manage this, i think…

and thinks like explations of elementary things like “What is GetTitle and how to use it in the code”

in many cases it takes very much time to find out, how to write it in the code to get the expected effect… u know what i mean?:wink:

greetings, michi

I have already prepared the official mAirList Wiki. Will be launched as soon as version 2.0 is out.

Torben

nice 1

greetings, michi

Awesome!

Well … not a big deal.

apt-get install mediawiki

:wink:

Torben

Well as they say “It’s the thought that counts.” :stuck_out_tongue: