Difference between revisions of "Action11"

From GRFSpecs
Jump to navigationJump to search
m (12 revisions)
(details on required sound format)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
  +
==Introduction==
 
  +
{{ottdp|0.6|2.5|ttdprev=2.0.1 alpha 57}}
'''''Define new sound data'''''
 
 
=Action 11=
 
 
Define new sound data
 
 
-=Description=-
 
   
 
This action allows the definition of binary included sound samples.
 
This action allows the definition of binary included sound samples.
   
 
Action 11 may only appear at most once per .grf file.
 
Action 11 may only appear at most once per .grf file.
 
 
The newly defined sounds will be numbered consecutively, starting from 73 (49h) (numbers 0..72 represent original sounds). When you need to refer to your new sounds, you will have to use this numbering.
 
The newly defined sounds will be numbered consecutively, starting from 73 (49h) (numbers 0..72 represent original sounds). When you need to refer to your new sounds, you will have to use this numbering.
   
  +
== Syntax ==
Available since 2.0.1 alpha 57.
 
 
-=Format=-
 
   
 
The data looks as follows:
 
The data looks as follows:
   
<pre>-+&lt;sprite-number&gt; * &lt;length&gt; 11 &lt;number&gt;+-</pre>
+
<pre><sprite-number> * <length> 11 <number></pre>
   
  +
{|
||'''Element'''|[[GRFActionsDetailed|'''Size''']]|'''Description'''
 
  +
!Element !![[GRFActionsDetailed|Size]] !! Description
  +
|-
  +
|<sprite-number> ||dec ||A sequential sprite number
  +
|-
  +
|<length> ||dec||The total number of bytes in the action
  +
|-
  +
|11 ||B||Action 11
  +
|-
  +
|<number> ||W ||Number of binary include sprites that follow
  +
|}
   
&lt;sprite-number&gt;|dec|A sequential sprite number
 
   
  +
== Description ==
&lt;length&gt;|dec|The total numer of bytes in the action
 
   
  +
=== sprite-number ===
11|B|Action 11
 
 
&lt;number&gt;|W|Number of binary include sprites that follow||
 
 
-=Filling in the terms=-
 
 
===sprite-number===
 
   
 
The current sprite number.
 
The current sprite number.
   
===length===
+
=== length ===
   
 
The total number of bytes in this action 11.
 
The total number of bytes in this action 11.
   
===number===
+
=== number ===
   
 
This defines the number of binary include sprites that follow.
 
This defines the number of binary include sprites that follow.
Line 48: Line 42:
 
These can only be added using GRFCodec 0.9.7 or later, using the following format:
 
These can only be added using GRFCodec 0.9.7 or later, using the following format:
   
<pre>-+ &nbsp; 17 ** sounds/e67_horn.wav+-
+
<pre>17 ** sounds/e67_horn.wav
  +
18 ** sounds/sheep.wav</pre>
   
  +
All files included this way must use WAV format, PCM encoding:
-+ &nbsp; 18 ** sounds/sheep.wav+-</pre>
 
  +
* mono
  +
* 8-bit or {{ottdp|1.0|no}} 16-bit
  +
* 11025 Hz, 22050 Hz, or {{ottdp|1.0|no}} 44100 Hz <ref>Technically OpenTTD 0.6 already supported resampling of any sample rate, but playback only used 11025 Hz anyway. Since OpenTTD 1.0 the default playback rate is 44100 Hz.</ref>
  +
When using [[Version_numbers#GRF_container_version|GRF container version 1]], the file size cannot exceed 64 kB.
   
  +
<references/>
All files included this way must be 8-bit mono sound files in WAV format, PCM encoding. There are two allowed frequencies: 11025 Hz and 22050 Hz. Due to some limitations of the GRF format, the file size cannot exceed 64KB.
 
   
 
For those need to know or are inordinately curious, the actual encoding of a binary include is the same as a pseudosprite:
 
For those need to know or are inordinately curious, the actual encoding of a binary include is the same as a pseudosprite:
   
<pre>-+&lt;sprite-number&gt; * &lt;length&gt; FF &lt;name-len&gt; &lt;name&gt; 00 &lt;data&gt;+-</pre>
+
<pre><sprite-number> * <length> FF <name-len> <name> 00 <data></pre>
   
  +
{|
||'''Element'''|[[GRFActionsDetailed|'''Size''']]|'''Description'''
 
  +
!Element !![[GRFActionsDetailed|Size]] !! Description
  +
|-
  +
|<name-len> ||B ||The return value of strlen(<name>);
  +
|-
  +
|<name> ||S ||The name of the included file, with any leading directories stripped
  +
|-
  +
|00 ||B ||Null byte terminating the string (not included in size)
  +
|-
  +
|<data> ||V ||A byte-for-byte copy of the contents of the file
  +
|}
   
  +
== Importing sound effects from other grf files ==
&lt;name-len&gt;|B|The return value of strlen(&lt;name&gt;);
 
  +
{{ottdp|0.6|2.5|ttdprev=2.0.1 alpha 61}}
 
  +
Since TTDPatch 2.0.1 alpha 61, it is possible to import sound effects from other grf files (or even the current file). &nbsp;This does not copy the sound effect data (thus reducing memory usage), but does provide a new sound effect entry with its own action 0 properties.
&lt;name&gt;|S|The name of the included file, with any leading directories stripped
 
 
00|B|Null byte terminating the string (not included in size)
 
 
&lt;data&gt;|variable|A byte-for-byte copy of the contents of the file||
 
 
==Importing sound effects from other grf files==
 
 
Since 2.0.1 alpha 61, it is possible to import sound effects from other grf files (or even the current file). &nbsp;This does not copy the sound effect data (thus reducing memory usage), but does provide a new sound effect entry with its own action 0 properties.
 
   
 
This is a way of either combining useful sound effects in a single grf file and using them in several, or to duplicate sounds with different amplification or priority settings without doubling the memory usage.
 
This is a way of either combining useful sound effects in a single grf file and using them in several, or to duplicate sounds with different amplification or priority settings without doubling the memory usage.
Line 76: Line 77:
 
The referenced grf file can be anywhere in newgrf(w).cfg and does not have to be active. &nbsp;If it is not loaded, no sound will be played but that is not an error condition. This makes it possible to separate sound effects and graphics into two files, to allow people with little memory to not load the sound effects yet get working graphics.
 
The referenced grf file can be anywhere in newgrf(w).cfg and does not have to be active. &nbsp;If it is not loaded, no sound will be played but that is not an error condition. This makes it possible to separate sound effects and graphics into two files, to allow people with little memory to not load the sound effects yet get working graphics.
   
The format of such an import sprite is the following (replacing a &quot;**&quot; binary sprite within the action 11 sprite block):
+
The format of such an import sprite is the following (replacing a "**" binary sprite within the action 11 sprite block):
   
<pre>-+&lt;sprite-number&gt; * &lt;length&gt; FE 00 &lt;grfid&gt; &lt;number&gt;+-</pre>
+
<pre><sprite-number> * <length> FE 00 <GRFID> <number></pre>
   
  +
{|
||'''Element'''|[[GRFActionsDetailed|'''Size''']]|'''Description'''
 
  +
!Element !![[GRFActionsDetailed|Size]] !! Description
 
  +
|-
&lt;sprite-number&gt;|dec|A sequential sprite number
 
  +
|<sprite-number> ||dec ||A sequential sprite number
 
  +
|-
&lt;length&gt;|dec|The total numer of bytes in the action
 
  +
|<length> ||dec||The total number of bytes in the action
 
  +
|-
FE|B|Code to identify a non-binary sprite in an action 11 block
 
  +
|FE ||B ||Code to identify a non-binary sprite in an action 11 block
 
  +
|-
00|B|Code to identify a sound effect import
 
  +
|00 ||B ||Code to identify a sound effect import
 
  +
|-
&lt;grfid&gt;|D|GRFID of grf file to import sound effect from, may be the current one too
 
  +
|<GRFID> ||D ||GRFID of grf file to import sound effect from, may be the current one too
 
  +
|-
&lt;number&gt;|W|Sound effect number to import||
 
  +
|<number> ||W ||Sound effect number to import
  +
|}
   
 
Note that unlike most other reference to sound numbers, the number here is simply the number within the referenced grf file's action 11 block, and does not refer to TTD's samples for numbers 0..72. Also, when importing the sound effect, the action 0 properties are not imported and have to be set separately.
 
Note that unlike most other reference to sound numbers, the number here is simply the number within the referenced grf file's action 11 block, and does not refer to TTD's samples for numbers 0..72. Also, when importing the sound effect, the action 0 properties are not imported and have to be set separately.
   
-=Example=-
+
== Example ==
 
Look at this tt-forums-page for how to add sounds to a train.
 
 
<nowiki>http://www.tt-forums.net/viewtopic.php?f=26&amp;t;=5033&amp;p;=735013#p735013
 
   
  +
Look at this tt-forums-page for how to add sounds to a train: [http://www.tt-forums.net/viewtopic.php?f=26&t=5033&p=735013#p735013]
</nowiki>
 

Latest revision as of 15:38, 15 May 2013

Introduction

Supported by OpenTTD 0.60.6 Supported by TTDPatch 2.5 (2.0.1 alpha 57)2.5

This action allows the definition of binary included sound samples.

Action 11 may only appear at most once per .grf file. The newly defined sounds will be numbered consecutively, starting from 73 (49h) (numbers 0..72 represent original sounds). When you need to refer to your new sounds, you will have to use this numbering.

Syntax

The data looks as follows:

<sprite-number> * <length> 11 <number>
Element Size Description
<sprite-number> dec A sequential sprite number
<length> dec The total number of bytes in the action
11 B Action 11
<number> W Number of binary include sprites that follow


Description

sprite-number

The current sprite number.

length

The total number of bytes in this action 11.

number

This defines the number of binary include sprites that follow.

These can only be added using GRFCodec 0.9.7 or later, using the following format:

17 ** sounds/e67_horn.wav
18 ** sounds/sheep.wav

All files included this way must use WAV format, PCM encoding:

  • mono
  • 8-bit or Supported by OpenTTD 1.01.0 Not supported by TTDPatch 16-bit
  • 11025 Hz, 22050 Hz, or Supported by OpenTTD 1.01.0 Not supported by TTDPatch 44100 Hz [1]

When using GRF container version 1, the file size cannot exceed 64 kB.

  1. Technically OpenTTD 0.6 already supported resampling of any sample rate, but playback only used 11025 Hz anyway. Since OpenTTD 1.0 the default playback rate is 44100 Hz.

For those need to know or are inordinately curious, the actual encoding of a binary include is the same as a pseudosprite:

<sprite-number> * <length> FF <name-len> <name> 00 <data>
Element Size Description
<name-len> B The return value of strlen(<name>);
<name> S The name of the included file, with any leading directories stripped
00 B Null byte terminating the string (not included in size)
V A byte-for-byte copy of the contents of the file

Importing sound effects from other grf files

Supported by OpenTTD 0.60.6 Supported by TTDPatch 2.5 (2.0.1 alpha 61)2.5 Since TTDPatch 2.0.1 alpha 61, it is possible to import sound effects from other grf files (or even the current file).  This does not copy the sound effect data (thus reducing memory usage), but does provide a new sound effect entry with its own action 0 properties.

This is a way of either combining useful sound effects in a single grf file and using them in several, or to duplicate sounds with different amplification or priority settings without doubling the memory usage.

The referenced grf file can be anywhere in newgrf(w).cfg and does not have to be active.  If it is not loaded, no sound will be played but that is not an error condition. This makes it possible to separate sound effects and graphics into two files, to allow people with little memory to not load the sound effects yet get working graphics.

The format of such an import sprite is the following (replacing a "**" binary sprite within the action 11 sprite block):

<sprite-number> * <length> FE 00 <GRFID> <number>
Element Size Description
<sprite-number> dec A sequential sprite number
<length> dec The total number of bytes in the action
FE B Code to identify a non-binary sprite in an action 11 block
00 B Code to identify a sound effect import
<GRFID> D GRFID of grf file to import sound effect from, may be the current one too
<number> W Sound effect number to import

Note that unlike most other reference to sound numbers, the number here is simply the number within the referenced grf file's action 11 block, and does not refer to TTD's samples for numbers 0..72. Also, when importing the sound effect, the action 0 properties are not imported and have to be set separately.

Example

Look at this tt-forums-page for how to add sounds to a train: [1]