Class: CZMQ::FFI::Zosc

Inherits:
Object
  • Object
show all
Defined in:
lib/czmq-ffi-gen/czmq/ffi/zosc.rb

Overview

Note:

This class is 100% generated using zproject.

Create and decode Open Sound Control messages. (OSC)

OSC is a serialisation format (and usually transported over UDP) which is supported by many applications and appliances. It is a de facto protocol for networking sound synthesizers, computers, and other multimedia devices for purposes such as musical performance or show control. It is also often used for rapid prototyping purposes due to the support by many applications and frameworks in this field. With ZeroMQ’s DGRAM sockets it is possible to use ZeroMQ to send and receive OSC messages which can be understood by any device supporting OSC.

Example creating an OSC message:

zosc_t* conm = zosc_create("/someaddress", "iihfdscF",
                    1, 2, 3, 3.14, 6.283185307179586, "greetings", 'q');

Decoding a message:

int rc = zosc_retr(oscmsg, "iihfdscF", &intx, &inty, &intz, &floatz,
                    &doublez, &strings, &charq, &someBool);

See the class’s test method for more examples how to use the class.

Defined Under Namespace

Classes: DestroyedError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr, finalize = true) ⇒ Zosc

Attaches the pointer ptr to this instance and defines a finalizer for it if necessary.

Parameters:

  • ptr (::FFI::Pointer)
  • finalize (Boolean) (defaults to: true)


45
46
47
48
49
50
51
52
53
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 45

def initialize(ptr, finalize = true)
  @ptr = ptr
  if @ptr.null?
    @ptr = nil # Remove null pointers so we don't have to test for them.
  elsif finalize
    @finalizer = self.class.create_finalizer_for @ptr
    ObjectSpace.define_finalizer self, @finalizer
  end
end

Class Method Details

.__newObject



39
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 39

alias :__new :new

.create(address, format, *args) ⇒ CZMQ::Zosc

Create a new zosc message from the given format and arguments. The format type tags are as follows:

i - 32bit integer
h - 64bit integer
f - 32bit floating point number (IEEE)
d - 64bit (double) floating point number
s - string (NULL terminated)
t = timetag: an OSC timetag in NTP format (uint64_t)
S - symbol
c - char
m - 4 byte midi packet (8 digits hexadecimal)
T - TRUE (no value required)
F - FALSE (no value required)
N - NIL (no value required)
I - Impulse (for triggers) or INFINITUM (no value required)
b - binary blob

Parameters:

  • address (String, #to_s, nil)
  • format (String, #to_s, nil)
  • args (Array<Object>)

Returns:

  • (CZMQ::Zosc)


147
148
149
150
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 147

def self.create(address, format, *args)
  ptr = ::CZMQ::FFI.zosc_create(address, format, *args)
  __new ptr
end

.create_finalizer_for(ptr) ⇒ Proc

Parameters:

  • ptr (::FFI::Pointer)

Returns:

  • (Proc)


56
57
58
59
60
61
62
63
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 56

def self.create_finalizer_for(ptr)
  ptr_ptr = ::FFI::MemoryPointer.new :pointer

  Proc.new do
    ptr_ptr.write_pointer ptr
    ::CZMQ::FFI.zosc_destroy ptr_ptr
  end
end

.fromframe(frame) ⇒ CZMQ::Zosc

Create a new OSC message from the specified zframe. Takes ownership of the zframe.

Parameters:

Returns:

  • (CZMQ::Zosc)


110
111
112
113
114
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 110

def self.fromframe(frame)
  frame = frame.__ptr if frame
  ptr = ::CZMQ::FFI.zosc_fromframe(frame)
  __new ptr
end

.frommem(data, size) ⇒ CZMQ::Zosc

Create a new zosc message from memory. Take ownership of the memory and calling free on the data after construction.

Parameters:

  • data (::FFI::Pointer, #to_ptr)
  • size (Integer, #to_int, #to_i)

Returns:

  • (CZMQ::Zosc)


121
122
123
124
125
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 121

def self.frommem(data, size)
  size = Integer(size)
  ptr = ::CZMQ::FFI.zosc_frommem(data, size)
  __new ptr
end

.is(self_) ⇒ Boolean

Probe the supplied object, and report if it looks like a zosc_t.

Parameters:

  • self_ (::FFI::Pointer, #to_ptr)

Returns:

  • (Boolean)


324
325
326
327
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 324

def self.is(self_)
  result = ::CZMQ::FFI.zosc_is(self_)
  result
end

.new(address) ⇒ CZMQ::Zosc

Create a new empty OSC message with the specified address string.

Parameters:

  • address (String, #to_s, nil)

Returns:

  • (CZMQ::Zosc)


101
102
103
104
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 101

def self.new(address)
  ptr = ::CZMQ::FFI.zosc_new(address)
  __new ptr
end

.packx(self_p) ⇒ Zframe

Transform zosc into a zframe that can be sent in a message. Take ownership of the chunk.

Parameters:

Returns:



292
293
294
295
296
297
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 292

def self.packx(self_p)
  self_p = self_p.__ptr_give_ref
  result = ::CZMQ::FFI.zosc_packx(self_p)
  result = Zframe.__new result, true
  result
end

.test(verbose) ⇒ void

This method returns an undefined value.

Self test of this class.

Parameters:

  • verbose (Boolean)


476
477
478
479
480
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 476

def self.test(verbose)
  verbose = !(0==verbose||!verbose) # boolean
  result = ::CZMQ::FFI.zosc_test(verbose)
  result
end

.unpack(frame) ⇒ Zosc

Transform a zframe into a zosc.

Parameters:

Returns:



303
304
305
306
307
308
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 303

def self.unpack(frame)
  frame = frame.__ptr if frame
  result = ::CZMQ::FFI.zosc_unpack(frame)
  result = Zosc.__new result, true
  result
end

Instance Method Details

#__ptr::FFI::Pointer Also known as: to_ptr

Return internal pointer

Returns:

  • (::FFI::Pointer)

Raises:



70
71
72
73
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 70

def __ptr
  raise DestroyedError unless @ptr
  @ptr
end

#__ptr_give_ref::FFI::MemoryPointer

Note:

This detaches the current instance from the native object and thus makes it unusable.

Nullify internal pointer and return pointer pointer.

Returns:

  • (::FFI::MemoryPointer)

    the pointer pointing to a pointer pointing to the native object

Raises:



81
82
83
84
85
86
87
88
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 81

def __ptr_give_ref
  raise DestroyedError unless @ptr
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
  ptr_ptr.write_pointer @ptr
  __undef_finalizer if @finalizer
  @ptr = nil
  ptr_ptr
end

#__undef_finalizervoid

Note:

Only use this if you need to and can guarantee that the native object will be freed by other means.

This method returns an undefined value.

Undefines the finalizer for this object.



93
94
95
96
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 93

def __undef_finalizer
  ObjectSpace.undefine_finalizer self
  @finalizer = nil
end

#addressString

Return the OSC address string

Returns:

  • (String)

Raises:



185
186
187
188
189
190
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 185

def address()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_address(self_p)
  result
end

#append(format, *args) ⇒ Integer

Append data to the osc message. The format describes the data that needs to be appended in the message. This essentially relocates all data! The format type tags are as follows:

i - 32bit integer
h - 64bit integer
f - 32bit floating point number (IEEE)
d - 64bit (double) floating point number
s - string (NULL terminated)
t = timetag: an OSC timetag in NTP format (uint64_t)
S - symbol
c - char
m - 4 byte midi packet (8 digits hexadecimal)
T - TRUE (no value required)
F - FALSE (no value required)
N - NIL (no value required)
I - Impulse (for triggers) or INFINITUM (no value required)
b - binary blob

Parameters:

Returns:

  • (Integer)

Raises:



238
239
240
241
242
243
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 238

def append(format, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_append(self_p, format, *args)
  result
end

#data::FFI::Pointer

Return OSC chunk data. Caller does not own the data!

Returns:

  • (::FFI::Pointer)

Raises:



175
176
177
178
179
180
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 175

def data()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_data(self_p)
  result
end

#destroyvoid

This method returns an undefined value.

Destroy an OSC message



155
156
157
158
159
160
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 155

def destroy()
  return unless @ptr
  self_p = __ptr_give_ref
  result = ::CZMQ::FFI.zosc_destroy(self_p)
  result
end

#dupZosc

Create copy of the message, as new chunk object. Returns a fresh zosc_t object, or null if there was not enough heap memory. If chunk is null, returns null.

Returns:

Raises:



268
269
270
271
272
273
274
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 268

def dup()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_dup(self_p)
  result = Zosc.__new result, true
  result
end

#first(type) ⇒ ::FFI::Pointer

Return a pointer to the item at the head of the OSC data. Sets the given char argument to the type tag of the data. If the message is empty, returns NULL and the sets the given char to NULL.

Parameters:

  • type (::FFI::Pointer, #to_ptr)

Returns:

  • (::FFI::Pointer)

Raises:



336
337
338
339
340
341
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 336

def first(type)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_first(self_p, type)
  result
end

#formatString

Return the OSC format of the message.

i - 32bit integer
h - 64bit integer
f - 32bit floating point number (IEEE)
d - 64bit (double) floating point number
s - string (NULL terminated)
t = timetag: an OSC timetag in NTP format (uint64_t)
S - symbol
c - char
m - 4 byte midi packet (8 digits hexadecimal)
T - TRUE (no value required)
F - FALSE (no value required)
N - NIL (no value required)
I - Impulse (for triggers) or INFINITUM (no value required)
b - binary blob

Returns:

  • (String)

Raises:



209
210
211
212
213
214
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 209

def format()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_format(self_p)
  result
end

#last(type) ⇒ ::FFI::Pointer

Return a pointer to the item at the tail of the OSC message. Sets the given char argument to the type tag of the data. If the message is empty, returns NULL.

Parameters:

  • type (::FFI::Pointer, #to_ptr)

Returns:

  • (::FFI::Pointer)

Raises:



361
362
363
364
365
366
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 361

def last(type)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_last(self_p, type)
  result
end

#next(type) ⇒ ::FFI::Pointer

Return the next item of the OSC message. If the list is empty, returns NULL. To move to the start of the OSC message call zosc_first ().

Parameters:

  • type (::FFI::Pointer, #to_ptr)

Returns:

  • (::FFI::Pointer)

Raises:



348
349
350
351
352
353
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 348

def next(type)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_next(self_p, type)
  result
end

#null?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 65

def null?
  !@ptr or @ptr.null?
end

#packZframe

Transform zosc into a zframe that can be sent in a message.

Returns:

Raises:



279
280
281
282
283
284
285
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 279

def pack()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pack(self_p)
  result = Zframe.__new result, true
  result
end

#pop_bool(val) ⇒ Integer

Set the provided boolean from the type tag in the message. Booleans are not represented in the data in the message, only in the type tag. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success.

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



452
453
454
455
456
457
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 452

def pop_bool(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_bool(self_p, val)
  result
end

#pop_char(val) ⇒ Integer

Set the provided char from the value at the current cursor position in the message. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success.

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



439
440
441
442
443
444
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 439

def pop_char(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_char(self_p, val)
  result
end

#pop_double(val) ⇒ Integer

Set the provided double from the value at the current cursor position in the message. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success.

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



413
414
415
416
417
418
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 413

def pop_double(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_double(self_p, val)
  result
end

#pop_float(val) ⇒ Integer

Set the provided float from the value at the current cursor position in the message. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success.

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



400
401
402
403
404
405
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 400

def pop_float(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_float(self_p, val)
  result
end

#pop_int32(val) ⇒ Integer

Set the provided 32 bit integer from value at the current cursor position in the message. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success.

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



374
375
376
377
378
379
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 374

def pop_int32(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_int32(self_p, val)
  result
end

#pop_int64(val) ⇒ Integer

Set the provided 64 bit integer from the value at the current cursor position in the message. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success.

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



387
388
389
390
391
392
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 387

def pop_int64(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_int64(self_p, val)
  result
end

#pop_midi(val) ⇒ Integer

Set the provided 4 bytes (unsigned 32bit int) from the value at the current cursor position in the message. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success.

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



465
466
467
468
469
470
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 465

def pop_midi(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_midi(self_p, val)
  result
end

#pop_string(val) ⇒ Integer

Set the provided string from the value at the current cursor position in the message. If the type tag at the current position does not correspond it will fail and return -1. Returns 0 on success. Caller owns the string!

Parameters:

  • val (::FFI::Pointer, #to_ptr)

Returns:

  • (Integer)

Raises:



426
427
428
429
430
431
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 426

def pop_string(val)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_pop_string(self_p, val)
  result
end

This method returns an undefined value.

Dump OSC message to stdout, for debugging and tracing.

Raises:



313
314
315
316
317
318
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 313

def print()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_print(self_p)
  result
end

#retr(format, *args) ⇒ Integer

Retrieve the values provided by the given format. Note that zosc_retr creates the objects and the caller must destroy them when finished. The supplied pointers do not need to be initialized. Returns 0 if successful, or -1 if it failed to retrieve a value in which case the pointers are not modified. If an argument pointer is NULL is skips the value. See the format method for a detailed list op type tags for the format string.

Parameters:

Returns:

  • (Integer)

Raises:



256
257
258
259
260
261
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 256

def retr(format, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_retr(self_p, format, *args)
  result
end

#sizeInteger

Return chunk data size

Returns:

  • (Integer)

Raises:



165
166
167
168
169
170
# File 'lib/czmq-ffi-gen/czmq/ffi/zosc.rb', line 165

def size()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zosc_size(self_p)
  result
end