バージョン 1.0, 2002年3月26日, Matt Wright
Open Sound Control (OSC)は、コンピュータ、サウンド シンセサイザ、その他のマルチメディアデバイスの通信用に開発された、オープンで、トランスポート独立で、メッセージ指向のプロトコルである。
このセクションではOSCデータの文法を定義する。
全てのOSCデータは以下の基礎データ型のいずれかによって構成される:
OSCの全てのアトミックデータ型のサイズは、32ビットの倍数となる。この事実により、もしOSCデータのブロックの先頭が32ビット境界にあれば、全てのOSCデータにおける数値が32ビットに揃えられることが保証される。
OSCの転送単位はOSCパケットである。OSCパケットを送信するアプリケーションはOSCクライアントである。OSCパケットを受信するアプリケーションはOSCサーバである。
OSCパケットは、バイナリデータの連続ブロックであるコンテンツと、8ビット バイトの整数で表されるサイズからなる。 OSCパケットのサイズは常に4の倍数となる。
OSCパケットを配信する下位ネットワークが、OSCアプリケーションにコンテンツとサイズの両方を配信する責務を負う。 OSCパケットは、UDPのようなネットワークプロトコルによって、データグラムとして自然に表現される。TCPのようなストリームベースのプロトコルでは、ストリームはint32で最初のパケットを送り、最初のパケットの内容を続け、次のパケットのサイズを送る…といった順序で行われることになろう。
OSCパケットのコンテンツは、OSCメッセージまたはOSCバンドルである。パケットのコンテンツの1バイト目が、この2種類を明確に区別する。
OSCメッセージは、OSCアドレスパターン、OSC型タグ文字列、任意の数のOSC引数からなる。
備考: OSCの古い実装のいくつかは、OSC型タグ文字列を省略することがある。そのような実装が全てアップデートされるまで、OSC実装はそのようなOSC型タグ文字列の欠落に耐えるよう作成されるべきである。
OSCアドレスパターンは、'/' 文字(前方向スラッシュ)で始まるOSC文字列である。
OSC型タグ文字列は、','(コンマ)で始まり、そのメッセージのOSC引数に一致する数の文字の列で続けられる、OSC文字列である。 コンマ以降の各文字はOSC型タグと呼ばれ、OSC引数に対応する型を表す。 (OSC型タグ文字列がコンマで始まるという要件は、OSCメッセージにOSC型タグ文字列が欠落しているかどうかを、メッセージ受信者が判別するために有用なものである。)
この表では、OSC型タグと対応するOSC引数の型の対応を示す:
OSC型タグ | 対応する引数の型 |
i | int32 |
f | float32 |
s | OSC文字列 |
b | OSC-blob |
OSCのアプリケーションには、この仕様で規定されていない、追加の非標準引数型を用いて通信するものがある。OSCアプリケーションは、これらの型を認識しなくてもよい。OSCアプリケーションは、OSC型タグ文字列のうちに認識できないOSC型タグを含むようなメッセージを、破棄すべきである。 追加の引数型を使用するアプリケーションは、次の表に示すOSC型タグを用いてそれらをエンコードしなければならない:
OSC型タグ | 対応する引数型 |
h | 64ビット、ビッグエンディアン、2の補数による整数 |
t | OSC時刻タグ |
d | 64ビット(倍精度)IEEE 754浮動小数点数 |
S | OSC文字列として表現される型(例えば、"symbols" を "strings"と区別するシステム) |
c | 32ビットで送信されるASCII文字 |
r | 32ビットのRGBA色 |
m | 4バイトMIDIメッセージ. MSBからLSBの順に: ポートID、ステータスバイト、データ1、データ2 |
T | 真。引数データ バイトには何も確保されない。 |
F | 偽。引数データ バイトには何も確保されない。 |
N | Nil値。引数データ バイトには何も確保されない。 |
I | 無限。引数データ バイトには何も確保されない。 |
[ | Indicates the beginning of an array. The tags following are for data in the Array until a close brace tag is reached. |
] | Indicates the end of an array. |
OSC引数の列は、それぞれの引数のバイナリ表現の連続列として表現される。
OSCバンドルは、順に、OSC文字列 "#bundle"、OSC時刻タグ、任意の数のOSCバンドル要素から成る。OSC時刻タグは、64ビットの固定小数点時刻タグであり、その意味は以下で説明する。
1つのOSCバンドル要素は、サイズとコンテンツからなる。 サイズは8ビットバイトの数を表すint32であり、常に4の倍数となる。 コンテンツは1つのOSCメッセージまたは1つのOSCバンドルとなる。
再帰的な定義であることに注意: バンドルにはバンドルが含まれうる。
この表は、2つ以上の要素を有するOSCバンドルの部分とそれぞれのサイズを8ビットバイトで示している。
データ | サイズ | 目的 |
OSC文字列 "#bundle" | 8バイト | これがバンドルであることを認識する手段 |
OSC時刻タグ | 8バイト | このバンドル全体に適用される時刻タグ |
最初のバンドル要素のサイズ | int32 = 4バイト | 最初のバンドル要素 |
最初のバンドル要素の内容 | 「最初のバンドル要素のサイズ」で指定されたバイト数 | |
2番目のバンドル要素のサイズ | int32 = 4バイト | 2番目のバンドル要素 |
2番目のバンドル要素の内容 | 「2番目のバンドル要素のサイズ」で指定されたバイト数 | |
etc. | さらなるバンドル要素 |
このセクションではOSCデータのセマンティクス(意味)を定義する。
全てのOSCサーバには、OSCメソッドの集合が含まれる。 OSCメソッドは、OSCサーバが受信したOSCメッセージの潜在的な目的地であり、アプリケーションが利用可能にしている、それぞれの制御点に該当する。OSCメソッドを「呼び出す」というのは、プロシージャ コールに類するものである。メソッドと引数を渡して、そのメソッドを実行するということを意味するものといえる。
OSCサーバに含まれるOSCメソッドは、OSCアドレス空間と呼ばれるツリー構造に並べられる。このツリーのリーフノードはOSCメソッドであり、ブランチノードはOSCコンテナと呼ばれる。 OSCサーバのOSCアドレス空間は動的なものでありうる。つまり、そのコンテンツおよび形体は、時間とともに変化しうる。
ツリーのルート以外の各OSCメソッドおよび各OSCコンテナには、以下のものを除く印刷可能文字のASCII文字列からなるシンボル名がある:
文字 | 名前 | ASCIIコード (整数) |
' ' | 空白 | 32 |
# | ナンバーサイン(いげた) | 35 |
* | アスタリスク | 42 |
, | コンマ | 44 |
/ | 前方向スラッシュ | 47 |
? | 疑問符 | 63 |
[ | 開き角括弧 | 91 |
] | 閉じ角括弧 | 93 |
{ | 開き中括弧 | 123 |
} | 閉じ中括弧 | 125 |
The OSC Address of an OSC Method is a symbolic name giving the full path to the OSC Method in the OSC Address Space, starting from the root of the tree. An OSC Method's OSC Address begins with the character '/' (forward slash), followed by the names of all the containers, in order, along the path from the root of the tree to the OSC Method, separated by forward slash characters, followed by the name of the OSC Method. The syntax of OSC Addresses was chosen to match the syntax of URLs. (OSC Address Examples)
When an OSC server receives an OSC Message, it must invoke the appropriate OSC Methods in its OSC Address Space based on the OSC Message's OSC Address Pattern. This process is called dispatching the OSC Message to the OSC Methods that match its OSC Address Pattern. All the matching OSC Methods are invoked with the same argument data, namely, the OSC Arguments in the OSC Message.
The parts of an OSC Address or an OSC Address Pattern are the substrings between adjacent pairs of forward slash characters and the substring after the last forward slash character. (examples)
A received OSC Message must be disptched to every OSC method in the current OSC Address Space whose OSC Address matches the OSC Message's OSC Address Pattern. An OSC Address Pattern matches an OSC Address if
A part of an OSC Address Pattern matches a part of an OSC Address if every consecutive character in the OSC Address Pattern matches the next consecutive substring of the OSC Address and every character in the OSC Address is matched by something in the OSC Address Pattern. These are the matching rules for characters in the OSC Address Pattern:
An OSC server must have access to a representation of the correct current absolute time. OSC does not provide any mechanism for clock synchronization.
When a received OSC Packet contains only a single OSC Message, the OSC Server should invoke the correponding OSC Methods immediately, i.e., as soon as possible after receipt of the packet. Otherwise a received OSC Packet contains an OSC Bundle, in which case the OSC Bundle's OSC Time Tag determines when the OSC Bundle's OSC Messages' corresponding OSC Methods should be invoked. If the time represented by the OSC Time Tag is before or equal to the current time, the OSC Server should invoke the methods immediately (unless the user has configured the OSC Server to discard messages that arrive too late). Otherwise the OSC Time Tag represents a time in the future, and the OSC server must store the OSC Bundle until the specified time and then invoke the appropriate OSC Methods.
Time tags are represented by a 64 bit fixed point number. The first 32 bits specify the number of seconds since midnight on January 1, 1900, and the last 32 bits specify fractional parts of a second to a precision of about 200 picoseconds. This is the representation used by Internet NTP timestamps.The time tag value consisting of 63 zero bits followed by a one in the least signifigant bit is a special case meaning "immediately."
OSC Messages in the same OSC Bundle are atomic; their corresponding OSC Methods should be invoked in immediate succession as if no other processing took place between the OSC Method invocations.
When an OSC Address Pattern is dispatched to multiple OSC Methods, the order in which the matching OSC Methods are invoked is unspecified. When an OSC Bundle contains multiple OSC Messages, the sets of OSC Methods corresponding to the OSC Messages must be invoked in the same order as the OSC Messages appear in the packet. (example)
When bundles contain other bundles, the OSC Time Tag of the enclosed bundle must be greater than or equal to the OSC Time Tag of the enclosing bundle. The atomicity requirement for OSC Messages in the same OSC Bundle does not apply to OSC Bundles within an OSC Bundle.