Menu

Snowmix Libraries - System

Peter Maersk-Moller

Snowmix Libraries - system.slib

As of version 0.4.4 of Snowmix, the following applies.

The system.slib library defines basic functions used by most other libraries and import some basic settings into the Tcl interpreter such as system video geometry, framerate and version. This library MUST be the first slib library to be included in the ini file AFTER system geometry and frame rate has been set. Any Snowmix command using the maxplaces command to change a maxplace value SHOULD be executed before including this library.

You include this library by adding the following line to you ini file:

include ../slib/system.slib
Variables

The library, when included, offers the following global variables in the Tcl interpreter:

  • system(width) : system width in pixels
  • system(height) : system height in pixels
  • system(framerate) : system video frame rate.
  • system(frame_no,pre) : Number of times the pre video mixer loop was called.
  • system(frame_no,post) : Number of times the post video mixer loop was called
  • system(version) : Snowmix version.
  • system(maxplaces,key) : Various maxplaces values where key is one of : string, font, placedtext, shape, placedshape.
  • system(start_shape) : The id that ReserveNextAvail{shape} will return will be >= this value or -1.
  • system(start_placedshape) : The id that ReserveNextAvail{placedshape ...} will return will be >= this value or -1.
  • system(start_string) : The id that ReserveNextAvail{string ...} will return will be >= this value or -1.
  • system(start_font) : The id that ReserveNextAvail{font ...} will return will be >= this value or -1.
  • system(start_placedtext) : The id that ReserveNextAvail{placedtext ...} will return will be >= this value or -1.

It is not recommended that these variables are changed once the library has been loaded/included.

Functions Overview

The library, when included, offers the following functions in the Tcl Interpreter:

  • GetFromKey : Get a specific Snowmix value using a query valye and key as entry.
  • GetFromKeyId : Get a specific Snowmix value using a query valye, key and id as entry.
  • Add2Update : Add a function to be called at every pre or post mix loop
  • GetNextAvail : Get next available id for string, font placed text etc.
  • ReserveNextAvail Get AND reserve next available id for string, font placed text etc.
Functions Description

GetFromKey

Name

GetFromKey - Get a specific Snowmix value using a query valye and key as entry.

Synopsis

GetFromKey query key

Description

The function will query Snowmix using the commands [snowmix info $query format] and [snowmix info $query] and return the value identified by the index key. Using this command to import Snowmix settings into the Tcl interpreter is strongly recommended instead of using the command snowmix info directly. The command helps ensure that your script/function may still work if changes in later versions of Snowmix is made to the snowmix info command.

Example

set a [GetFromKey "system overlay" overlay_pre]

This sets the variable a to the name of the command macro that Snowmix will call for every frame before (pre) it starts mixing a new video frame for output.

The example is assumed to be part of a tcl script excuted using the Snowmix command tcl exec. It can also be executed as a single command using the Snowmix command tcl eval like this:

tcl eval set a [GetFromKey "system overlay" overlay_pre]

See Also

GetKeyFromId, snowmix info

GetFromKeyId

Name

GetFromKeyId - Get a specific Snowmix value using a query valye, key and id as entry.

Synopsis

GetFromKeyId query key id

Description

The function will query Snowmix using the commands [snowmix info $query format] and [snowmix info $query] and return the value identified by the index key AND id. Using this command to import Snowmix settings into the Tcl interpreter is strongly recommended instead of using the command snowmix info directly. The command helps ensure that your script/function may still work if changes in later versions of Snowmix is made to the snowmix info command.

Example

set geometry [GetFromKeyId "image load" geometry 3]
set width [lindex $geometry 0]
set height [lindex $geometry 1]

This sets the variable geometry to the geometry of the image loaded number 3. The variable is the a list with two items, the width and the height. The examples are assumed to be part of a tcl script excuted using the Snowmix command tcl exec. It can also be executed as a single command using the Snowmix command tcl eval like this:

tcl eval set geometry [GetFromKeyId "image load" geometry 3] ; set width [lindex $geometry 0] ; set height [lindex $geometry 1]

See Also

GetFromKey, snowmix info

Add2Update

Name

Add2Update - Add a function to be called at every pre or post mix loop.

Synopsis

Add2Update order command

Description

This function can used to add a function to be called for every frame. The argument order, which can be either "pre" or "post" defines whether the function will be called before a video frame for output is being mixed or after it may have been mixed, but not yet outputted. The post function is only activated if a shmsrc is connected to Snowmix requesting mixed frames while the pre loop is always executed as long Snowmix runs.

Example

Add2Update pre RadarUpdate
Add2Update post ScenesUpdate

The first example adds the RadarUpdate function to the pre loop. The second example adds the ScenesUpdate function to the post loop. Both function names are arbitrary selected.

The examples are assumed to be part of a tcl script excuted using the Snowmix command tcl exec. It can also be executed as a single command using the Snowmix command tcl eval like this:

    tcl eval Add2Update pre RadarUpdate

See Also

GetNextAvail

Name

GetNextAvail - Get next available id for string, font placed text etc.

Synopsis

GetNextAvail type

Description

This functions returns the next available not used string id, font id, text placed id etc. The argument type is used to determine what is type of id it should return. The type argument can be one of the following: string, font, placedtext, shape, placedshape. This function does not actually create a new string. If the function returned the next available string id, this id can be used to create a new string using the commands. The function returns -1 if no id is available.

Example

set id [GetNextAvail string]
snowmix parse "text string $id This is the text"

The example is assumed to be part of a tcl script excuted using the Snowmix command tcl exec. It can also be executed as a single command using the Snowmix command tcl eval like this:

tcl eval set id [GetNextAvail string] ; snowmix parse "text string $id This is the text"

See Also

ReserveNextAvail

ReserveNextAvail

Name

ReserveNextAvail - Get AND reserve next available id for string, font placed text etc.

Synopsis

ReserveNextAvail type args

Description

This functions returns the next available not used string id, font id, text placed id etc. The argument type is used to determine what is type of id it should return. The type argument can be one of the following: string, font, placedtext, shape, placedshape. The function not only returns the next available id, but it also creates it. For this it may need an extra argument. The function returns -1 if no id is available. The id returned will be larger than or equal to the value set by the global variables:

  • system(start_shape)
  • system(start_placedshape)
  • set system(start_string)
  • set system(start_font)
  • set system(start_placedtext)

These variables was set by the SystemInit function that was executed when the library was loaded or included.

Example

set string_id [ReserveNextAvail string "Some string text"]
set font_id [ReserveNextAvail  font "Sans Bold 12"]
set text_id [ReserveNextAvail placedtext $string_id $font_id]
set shape_id [ReserveNextAvail shape]
set placed_shape_id [ReserveNextAvail placedshape $shape_id]

The first example gets an unused string id and creates a string with this id and fills it with the text "Some text string". The second does it for a font id etc. After the string, font etc. has been created, it can be altered using normal Snowmix commands.

The examples are assumed to be part of a tcl script excuted using the Snowmix command tcl exec. It can also be executed as a single command using the Snowmix command tcl eval like this:

tcl eval set string_id [ReserveNextAvail string "Some string text"]
tcl eval set font_id [ReserveNextAvail  font "Sans Bold 12"]
tcl eval set text_id [ReserveNextAvail placedtext $string_id $font_id]
tcl eval set shape_id [ReserveNextAvail shape]
tcl eval set placed_shape_id [ReserveNextAvail placedshape $shape_id]

See Also

GetNextAvail


Related

Wiki: Snowmix Libraries
Wiki: Snowmix Tutorials - Scenes
Wiki: Tcl Interpreter

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.