| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Sound.Osc.Coding.Encode.Base
Description
Base-level encode function for Osc packets (slow).
For ordinary use see Builder.
Synopsis
- extend :: Word8 -> ByteString -> ByteString
- encode_datum :: Datum -> ByteString
- encodeMessage :: Message -> ByteString
- encode_message_blob :: Message -> Datum
- encodeBundle :: BundleOf Message -> ByteString
- encodePacket :: PacketOf Message -> ByteString
Documentation
extend :: Word8 -> ByteString -> ByteString Source #
Align byte string, if required.
encode_datum :: Datum -> ByteString Source #
Encode Osc Datum.
MidiData: Bytes from MSB to LSB are: port id, status byte, data1, data2.
>>>encode_datum (blob [1, 2, 3, 4]) == B.pack [0, 0, 0, 4, 1, 2, 3, 4]True
>>>encode_datum (Float 1) == B.pack [63, 128, 0, 0]True
>>>encode_datum (Float 2) == B.pack [64, 0, 0, 0]True
>>>encode_datum (Float 3) == B.pack [64, 64, 0, 0]True
>>>encode_datum (Float 4) == B.pack [64, 128, 0, 0]True
>>>encode_datum (Float 5) == B.pack [64, 160, 0, 0]True
>>>encode_datum (Int32 65536) == B.pack [0, 1, 0, 0]True
>>>encode_datum (Int32 (-65536)) == B.pack [255, 255, 0, 0]True
encodeMessage :: Message -> ByteString Source #
Encode Osc Message.
>>>blob_unpack (encodeMessage (Message "/x" []))[47,120,0,0,44,0,0,0]
>>>blob_unpack (encodeMessage (Message "/y" [float 3.141]))[47,121,0,0,44,102,0,0,64,73,6,37]
>>>let m = Message "/n_set" [int32 (-1), string "freq", float 440, string "amp", float 0.1]>>>let e = blob_unpack (encodeMessage m)>>>length e40
>>>take 20 e[47,110,95,115,101,116,0,0,44,105,115,102,115,102,0,0,255,255,255,255]
encodeBundle :: BundleOf Message -> ByteString Source #
Encode Osc BundleOf.
>>>blob_unpack (encodeBundle (Bundle immediately [Message "/x" []]))[35,98,117,110,100,108,101,0,0,0,0,0,0,0,0,1,0,0,0,8,47,120,0,0,44,0,0,0]
>>>let m = Message "/n_set" [int32 (-1), string "freq", float 440, string "amp", float 0.1]>>>let b = Bundle 0.0 [m]>>>let e = blob_unpack (encodeBundle b)>>>length e60
> take 20 e
- 35,98,117,110,100,108,101,0,0,0,0,0,0,0,0,0,0,0,0,40
encodePacket :: PacketOf Message -> ByteString Source #
Encode Osc Packet.