Conditional chunk (of a DLS file)

The conditional chunk defines the conditions under which other chunks should be used.

The conditional chunk in the DLS file format has the following structure.

Byte sequence description Length in bytes Starts at byte in the chunk Value
chunk ID 4 0x00 The ASCII character string "cld " (note the space)
size various 0x04 The size of the chunk in number of bytes (unsigned integer) less 8 (less the size of "chunk ID" and the "size")
operations various 0x08 A sequence of operations, as defined below

Operations

An operation can have one of three forms.

  • Operation code (unsigned two-byte value)
  • Operation code (unsigned two-byte value), DLS ID (16-byte value; see DLS ID chunk (of a DLS file))
  • Operation code (unsigned two-byte value), unsigned long (eight-byte integer)

Operation codes

The following are the operation codes.

Operation code Value Interpretation (C code)
AND 0x0001 X & Y
OR 0x0002 X | Y
Exclusive OR 0x0003 X ^ Y
Add 0x0004 X + Y
Subtract 0x0005 X - Y
Multiply 0x0006 X * Y
Divide 0x0007 X / Y
Logical AND 0x0008 X && Y
Logical OR 0x0009 X || Y
Less than 0x000A X $lt; Y
Less than or equal to 0x000B X <= Y
Greater than 0x000C X > Y
Greater than or equal to 0x000D X >= Y
Equal 0x000E X == Y
NOT 0x000F ! X
Constant 0x0010 Z
Query 0x0011 Query DLS ID
Query supported 0x0012 Query supported DLS ID

Operations are computed on a stack. Each time an operation is to be performed, the needed number of values are popped off the stack and the computed result is pushed back on the stack. X is the top value on the stack and Y is the previous value on the stack. Z is a constant that is pushed on the stack by a constant operation. When the operation is a query, then the device is queried and the returned value is pushed on the stack. When the operation is a query supported one, the device is queried and the return value, either TRUE or FALSE, is pushed on the stack.

FALSE is represented by binary zeroes, whereas TRUE is represented by binary ones. A non-zero value will also be interpreted as TRUE, which means that a NOT operation must take care to zero out bits.

The minimum supported stack that must be implemented by a device that supports DLS Level 2 is a stack of eight 32-bit values.

Placement of conditional chunks

The conditional chunk is a DLS Level 2 construct. A conditional chunk is not required in a DLS file.

The conditional chunk can be a top-level DLS chunk or can exist within a list. When in a conditional chunk is at the top of the DLS file and the device fails the conditions specified in this chunk, the whole DLS file is ignored, and an error code is returned to the application using the DLS file. When the conditional chunk is in a list and a device fails the corresponding conditions, then the list is ignored. When in a list, it is preferred that the conditional chunk is the first chunk in the list.

Standard DLS Level 2 queries

All DLS Level 2 devices must support the following queries.

Query UUID value Return value
Supports DLS 1 0x178F2F27, 0xC364, 0x11D1, 0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12 Returns TRUE if the device supports DLS Level 1
Supports DLS 2 0xF14599E5, 0x4689, 0x11D2, 0xAF, 0xA6, 0x0, 0xAA, 0x0, 0x24, 0xD8, 0xB6 Returns TRUE if the device supports DLS Level 2
Manufacturer ID 0xB03E1181, 0x8095, 0x11D2, 0xA1, 0xEF, 0x0, 0x60, 0x8, 0x33, 0xDB, 0xD8 Returns the MIDI manufacturer ID in 24 bits
Product ID 0xB03E1182, 0x8095, 0x11D2, 0xA1, 0xEF, 0x0, 0x60, 0x8, 0x33, 0xDB, 0xD8 Returns the manufacturer specific product ID
General MIDI 0x178F2F24, 0xC364, 0x11D1, 0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12 Returns TRUE if the device hardware supports General MIDI
Sample memory size 0x178F2F28, 0xC364, 0x11D1, 0xA7, 0x60, 0x00, 0x00, 0xF8, 0x75, 0xAC, 0x12 Returns the amount of available memory in the device in samples
Sample playback rate 0x2A91F713, 0xA4BF, 0x11D2, 0xBB, 0xDF, 0x0, 0x60, 0x8, 0x33, 0xDB, 0xD8 Returns the sample playback rate in Hertz

See also:
Downloadable Sounds (DLS) format

Add new comment

Filtered HTML

  • Freelinking helps you easily create HTML links. Links take the form of [[indicator:target|Title]]. By default (no indicator): Click to view a local node.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.