Tip : Bulk Set Item Attributes

Note: This script has been updated - please read http://forum.mairlist.com/index.php/topic,2558.msg20142.html#msg20142 for an updated script and description

This script is really useful in setting Icons, EndTypes and Colours on common Playlist items. Simply load your items into a Playlist and run the script. It’s a good idea to enable the CueIn and FadeOut settings in order for songs to overlap properly in automation - When I do this, I tag my songs with an EndType of “t” to signify temporary. Later on, I go in and set the Ramp and double-check the FadeOut marker etc.

[code]// Set Item Attributes
// Remove the comments to perform a task
// by Charlie Davy

// Drag all common items into a Playlist and run this script
// Enable CueIn and FadeOut options for this to top and tail your audio

var
i: integer;

begin
for i := 0 to CurrentPlaylist.GetCount - 1 do

// If EndType is empty, then do it
//if CurrentPlaylist.GetItem(i).GetEndType = ‘’ then

begin

// Set End Type to temporary - useful to indicate an automatically generated CueOut
//CurrentPlaylist.GetItem(i).SetEndType(‘t’);

// Set Playlist Icon
//CurrentPlaylist.GetItem(i).LoadIconFromFile(‘C:\Program Files\mAirList\icons\Icon - Advert.png’);
//CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - ID Link.png’);
//CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Pre Rec Show.png’);
//CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Voicetrack.ico’);
//CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Song.png’);

// If you want to colour an item, use this line:
//CurrentPlaylist.GetItem(i).SetColored(true);

// Adverts and Promos
//CurrentPlaylist.GetItem(i).SetColor($80FF80);

//CurrentPlaylist.GetItem(i).SetArtist(‘Sweeper’);
//CurrentPlaylist.GetItem(i).SetComment(‘VoiceTrack’);

// Beds
//CurrentPlaylist.GetItem(i).SetColor($FFFF00);

// Jingles
//CurrentPlaylist.GetItem(i).SetColor($00FFFF);

// Pre Rec
//CurrentPlaylist.GetItem(i).SetColor($D3E09E);
//CurrentPlaylist.GetItem(i).SetColor($9EE0D3);

// VoiceTracks
//CurrentPlaylist.GetItem(i).SetColor($FF80FF);

// Save MMD Data File
CurrentPlaylist.GetItem(i).SaveMMD;

end;
end.
[/code]

This is another handy script to have on the Actions button… I have attached my icons to this post 8)


icons.zip (2.64 KB)

Cool script, Charlie!

Here’s an easy way to make scripts which iterate Playlist items both neater and easier to write, type, and read: declare a var of type IPlaylistItem and assign the current Playlist item to that variable at the start of the Playlist iteration loop (see below). The assignment makes the IPlaylistItem var a pointer to the actual Playlist item. If you prefer: when you execute a method on the var, you are executing it on the actual Playlist item and not any sort of copy (instance) of it.

My IVP script uses this technique and I must say it’s much, MUCH easier to write the code using (say) currentItem than CurrentPlaylist.GetItem(i) every time!

[code]// Set Item Attributes
// Remove the comments to perform a task
// by Charlie Davy

// Drag all common items into a Playlist and run this script
// Enable CueIn and FadeOut options for this to top and tail your audio

var
i: integer
item: IPlaylistItem;

begin
for i := 0 to CurrentPlaylist.GetCount - 1 do

item := CurrentPlaylist.GetItem(i);

// If EndType is empty, then do it
//if item.GetEndType = ‘’ then

begin

// Set End Type to temporary - useful to indicate an automatically generated CueOut
//item.SetEndType(‘t’);

// Set Playlist Icon
//item.LoadIconFromFile(‘C:\Program Files\mAirList\icons\Icon - Advert.png’);
//item.GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - ID Link.png’);
//item.GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Pre Rec Show.png’);
//item.GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Voicetrack.ico’);
//item.GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Song.png’);

// If you want to colour an item, use this line:
//item.SetColored(true);

// Adverts and Promos
//item.SetColor($80FF80);

//item.SetArtist(‘Sweeper’);
//item.SetComment(‘VoiceTrack’);

// Beds
//item.SetColor($FFFF00);

// Jingles
//item.SetColor($00FFFF);

// Pre Rec
//item.SetColor($D3E09E);
//item.SetColor($9EE0D3);

// VoiceTracks
//item.SetColor($FF80FF);

// Save MMD Data File
item.SaveMMD;

end;
end.
[/code]

BFN
CAD

Im beggining to understand scripts!!

But i have no idea on writing them…

My question therefore is, can you set a script so that for pre-rec’d items, the font colour when in the playlist changes. What i mean by this is that they would be highlighted in grey with red writing. a normal item in the playlist for me currently is white backing with black text when not loaded in a player.

Being able to see what is an item thats supposed to be there e.g. station idents/trails/tracks and an item added by me e.g. pre-recs.

If it is possible it would be very useful. I hope this makes sense. :slight_smile:

Unless Torben adds a variety of options within the config program to allow mAirList to automatically import certain audio files/folders as “types” (like Advert, Jingle, Music, Sweeper etc), I doubt it’d be possible. The only other way is a NotificationScript that runs off something like “OnPlaylistDrop” - when an item is dropped into the Playlist, it then runs through my script and tags accordingly.

That sounds like an option. is it possible to define though, as i wouldnt want that to happen to a track dragged from a browser, although dragging from a explorer window would be good
???

Do you have custom ID3 tags set for each type?

If you do (or could have, wouldnt take much to bulk add if they are all in folders) then you could create a script which as Charie said runs off “OnPlaylistDrop”. It would read the tag from the file and then set the colour which matches it?

There is no “OnPlaylistDrop” at the moment.

In mAirList 3.0, thanks to its better internal architecture, I could introduce “OnImportFile” or so.

I wasnt sure there was - the other possibility is ‘ntPlayerStart’ or timer as Torben suggested in the other post. Or just a simple script on a shortcut.

matt, i do set the tags for all. do you mean that i could add another line, maybe in attributes, which defines e.g. track, trail, station ID. then a script will read this, and define a colour to the style.

Could it be made so that it treats all files without a tag in a certain way and then all with to the corresponding script, if that makes sense…

Torben, if you could re-introduce this option or “onimportfile” then that would be a great way around things i think.

Thanks guys

Yeh thats it. Something like this:

[code]begin

//Set the item state to colored
CurrentPlaylist.GetItem(i).SetColored(true);

//Select the custom attribute
case CurrentPlaylist.GetItem(i).GetAttribute(<-- PUT CUSTOM TAG HERE -->) Of

//If its a jingle then setcolor. 
'Jingle': CurrentPlaylist.GetItem(i).SetColor($80FF80);

//If its a promo then setcolor.
'Promo': CurrentPlaylist.GetItem(i).SetColor($808080);

else

//If it was none of the attributes listed, set this color.
CurrentPlaylist.GetItem(i).SetColor($800000);

end;

end.[/code]

I think that will work, I havnt tested it. My pascal is a bit rusty, but I think thats how case works. You might also want to check that the GetAttribute is right - I sort of guessed that one!

If you want to add different types then just keep adding more and more lines like the ones in the case above.

The “timer” Notification (as Torben said on the other thread) would work in association with my Item Attributes script. Here’s a basic idea - it’s not complete, but it gives you an idea of how to implement what you want.

[code]if CurrentPlaylist.GetItem(i).GetArtist = ‘Pre Rec’ then
begin
CurrentPlaylist.GetItem(i).SetColored(true);
CurrentPlaylist.GetItem(i).SetColor($00FFFF);
CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Pre Rec.png’);
end;

if CurrentPlaylist.GetItem(i).GetArtist = ‘Sweeper’ then
begin
CurrentPlaylist.GetItem(i).SetColored(true);
CurrentPlaylist.GetItem(i).SetColor($9EE0D3);
CurrentPlaylist.GetItem(i).GetPicture.LoadFromFile(‘C:\Program Files\mAirList\icons\Icon - Sweeper.png’);[/code]

This assume that you name your files in the Artist - Title.ext format. I generally use Jingle - or Sweeper - or even Dry - to signify various types of Jingle ID.

thanks guys for such a speedy response. will have a play later on to see if i can get it to work.

Hmm … so everyone is still going for the long-winded CurrentPlaylist.GetItem(i) every time, and ignoring my other tip? Oh well! If you prefer to write it that way, fine. :stuck_out_tongue:

Also, as far as I know, the Delphi case statement only allows values/variables which are ordinal numbers and not text strings.

BFN
CAD

We prefer the retro coding Cad :wink:

The case statement does allow text strings - however im not sure the ’ quotes are required.

In Pascal/Delphi, case statements do not allow strings, but only cardinal values. If this really works in a script, which I doubt (but haven’t tried), it must be a Pascal Script extension.

Regarding the “GetItem()” discussion, Cad’s solution is more efficient, because it calls GetItem only once. As the Playlist is thread-safe to some extend, calling GetItem involves locking and unlocking of synchronization objects. The performance penalty should not be noticable, but anway :wink:

Actually, if it was Delphi, I would use “with … do”, just like

with CurrentPlaylist.GetItem(i) do begin
  SetColored(true);
  SetColor($9EE0D3);
  // and so on
end;

Unfortunately, Pascal Script does not support this language feature. Cad’s suggestion is the preferable solution then.

Thats odd, i was very sure you could. I must be mistaken. Although this site says that it is possible: http://www.delphibasics.co.uk/RTL.asp?Name=Case

Back to the school of Delphi for me!

Ok, shoot me! I didnt read that last link properly. You cant, you were all right ! :S

Maybe this might help, do scripts allow seperate functions?

http://delphi.about.com/cs/adptips2002/a/bltip0202_5.htm

Sure, you can declare custom functions. But I’m not sure whether the constant array parameter can be used in Pascal Script. And I think the 0,1,2,3 thing is very hard to read.

I’d just stick to the ordinary if then else.

Yep that sounds fair enough to me. Just thining about other things I can do with scripts, and if functions work then i can do some different things!

Cheers Torben

Many new mAirList users wish to know how to get automating quickly and smoothly and perhaps have some custom icons/colours for their items. The attached script is used to bulk-process items in the mAirList Playlist window - Using script commands, we can set various attributes like EndType, Colour etc in a matter of seconds.

  1. Ensure that Enable CueIn and Enable FadeOut are set via mAirListConfig, -40dB and -13dB are good values
  2. Open the script in Notepad, read the comments and decide what you wish to do first and enable the lines you want to run
  3. Place all the audio items into the Playlist - either selecting a load from the Browser or opening an M3U file
  4. Click Open - Run Script and find the script file…

mAirList may freeze if you have lots of files, but a second or so later you will see the changes and they’ll have been saved to the MMD files for future recall… and that’s it!

My own personal preference is to give the EndType a t for Temporary, and you can edit it to E or F later. It’s simply an indication that mAirList has automatically detected the CueIn/FadeOut points for you - most of the time, these are fairly accurate but you may want to alter the -dB threshold values.


Set Item Attributes.mls (2.56 KB)