This old wiki is now closed for editing. Articles which are still useful and up-to-date will be transfered to the new Wiki shortly.

For the official documentation, please look at the download page.

Things You Can Do with Scripts

From mAirListWiki

Jump to: navigation, search

We have compiled the sample Scripts and Script fragments below to help you learn just some of the capabilities of mAirListScript. We hope you find it useful. You'll find user-submitted Scripts in the Script section of the mAirList forum.

Contents

Send MIDI messages

Control Sound Card Mixers

You can control any input or output channel on any sound card on your PC by accessing it with Mixer(n), which returns an IMixer interface to sound card n (numbered from 0 upwards).

To use Mixer and the IMixer interface Methods, you need to know three numbers in advance:

  • mixer—a specific sound card
  • destination—the card's Recording or Playback mixer
  • connection—the mixer's channel number (for Speaker, Wave, CD Player, Microphone, etc.)

To find these numbers, start by running the two Scripts below. Look in mAirList's System Log dropdown at the left of the status bar for the messages returned by each Script.

Display all mixer numbers and corresponding sound card names:

var i: integer;

begin
  for i := 0 to MixerCount - 1 do
    SystemLog('Mixer ' + IntToStr(i)+ ': ' + Mixer(i).GetProductName);
end.

Examine the output and in the next Script, use the correct mixer number instead of 0.

Display the number of destinations for mixer 0:

begin
  SystemLog(IntToStr(Mixer(0).GetDestinationCount));
end.

The result will almost always be 2, corresponding to the Playback and Recording mixers on your sound card. Unfortunately, because there is no standard numbering scheme, the only way you can determine which destination is which is by trial and error. Like mixers, destinations are numbered from 0 upwards, so the number you need will usually be either 0 or 1.

Usually (but not always!), the connection number for the channel (Speaker, Wave, CD Player, Microphone, etc.) corresponds to the left-to-right order of the channels in the Windows mixer software, numbered from 0 upwards. Like destination numbers, you need to use trial and error to be sure that you are using the correct connection number for the channel you want to control.

The examples below all control a Playback Line In channel which is mixer 0, destination 1, connection 3.

Unmute a channel (for example, to activate a live feed):

Mixer(0).Unmute(1, 3);

Mute a channel (for example, when a live feed ends):

Mixer(0).Mute(1, 3);

Set left and right channel volumes to 50%:

Mixer(0).SetVolume(1, 3, 50, 50);

You can find a list of all the Methods of the IMixer interface in the mAirListScript help file.

Access SQL Databases

This is explained in a separate article.

Website Content

Using a 3rd party FTP client such as AutoFTP by Glenn Delahoy, you can upload details of the current song to your station's website.

This is a simple "Now Playing" script:

procedure OnPlayerStart(PlayerControl: IPlayerControl; Item: IPlaylistItem);
var sl: TStringList;
begin

sl := TStringList.Create;
sl.Add(Item.GetArtist + ' - ' + Item.GetTitle);
sl.SaveToFile('S:\nowplaying\nowplaying.php');
sl.Free;

SystemLog('Now Playing Information... updated with ' + Item.GetArtist + ' - ' + Item.GetTitle);
end;

begin
end.

This script can be run (from the Open button on the toolbar) or scheduled as part of a playlist. It will create a PHP file that can manipulate text and images on your station's homepage. Using PHP Includes, this information can be shown anywhere on your site.

var sl: TStringList;
begin
 sl := TStringList.Create;
 sl.Add('<img src="http://www.mystation.com/images/charlie.jpg" title="The Top10 at 10 with Charlie">');
 sl.SaveToFile('S:\nowplaying\imagename.php');
 sl.Free;

 sl := TStringList.Create;
 sl.Add('The Top10 at 10 with Charlie');
 sl.SaveToFile('S:\nowplaying\showname.php');
 sl.Free;

 SystemLog('OnAir - Top10 at 10 with Charlie... done!');

end.

Personal tools