Module: Wiretap

Defined in:
lib/wiretap.rb,
ext/wiretap.cpp,
ext/testserver/testserver.rb

Defined Under Namespace

Modules: PPM, ThreadWorker Classes: Audio, AudioFormat, AudioFrames, Clip, ClipFormat, Error, Host, Library, Node, NodeChildren, NodeFrames, NodeMetaData, Project, Reel, Server, ServerDead, ServerInfo, ServerList, TestServer, Volume

Constant Summary collapse

FRAMES_PATTERN =
/[A-Z]_-(\d){10}_[A-Z]_(\d){10}_[A-Z]_(\d){6}/

Class Method Summary collapse

Class Method Details

.audio_format(filename) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'ext/audio_format.cpp', line 145

static VALUE wiretap_get_audio_format(VALUE self, VALUE filename) {
  Check_Type(filename, T_STRING);
  
  SF_INFO sfinfo;
  SNDFILE* snd = sf_open(CSTR(filename), SFM_READ, &sfinfo);
  
  WireTapAudioFormat audio_format;
  audio_format.setNumSamples(sfinfo.frames);
  audio_format.setBitsPerSample(16);
  audio_format.setSampleRate(sfinfo.samplerate);
  audio_format.setFrameBufferSize(2*sfinfo.frames);
  audio_format.setFormatTag("dlaudio_int16_le");
  sf_close(snd);
  return Data_Wrap_Struct(cAudioFormat, 0, wiretap_format_free, new WireTapAudioFormat(audio_format));
}

.dump_audio_data(samples, rate, bps, type, raw, filename) ⇒ Object



139
140
141
142
143
# File 'ext/audio_format.cpp', line 139

static VALUE wiretap_dump_audio_data(VALUE self, VALUE samples, VALUE rate, VALUE bps, VALUE type, VALUE raw, VALUE filename) {
  wiretap_write_audio_frame(NUM2INT(samples), NUM2INT(rb_funcall(rate, rb_intern("to_i"), 0)), NUM2INT(bps), SYM2ID(type), 
     (unsigned char* )STR(raw), CSTR(filename));
  return Qtrue;
}

.dump_image_data(width, height, bpp, raw, filename) ⇒ Object



159
160
161
162
# File 'ext/image_format.cpp', line 159

VALUE wiretap_dump_image_data(VALUE self, VALUE width, VALUE height, VALUE bpp, VALUE raw, VALUE filename) {
  wiretap_write_image_frame(NUM2INT(width), NUM2INT(height), NUM2INT(bpp), (unsigned char* )STR(raw), CSTR(filename));
  return Qtrue;
}

.dump_image_formatObject



181
182
183
184
185
186
187
# File 'ext/image_format.cpp', line 181

VALUE wiretap_get_dump_image_format(VALUE self) {
  switch(img_format) {
    case IMAGE_SGI: return ID2SYM(rb_intern("sgi"));
    case IMAGE_BMP: return ID2SYM(rb_intern("bmp"));
  }
  return Qnil;
}

.dump_image_format=(format) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'ext/image_format.cpp', line 164

VALUE wiretap_set_dump_image_format(VALUE self, VALUE format) {
  ID bmp, sgi, format_id;
  bmp = rb_intern("bmp");
  sgi = rb_intern("sgi");
  Check_Type(format, T_SYMBOL);
  format_id = SYM2ID(format);
  
  if(format_id == bmp ) {
    img_format = IMAGE_BMP;
  } else if(format_id == sgi) {
    img_format = IMAGE_SGI;
  } else {
    THROW("Unknown format");
  }
  return self;
}

.open(uri) ⇒ Object



268
269
270
271
272
273
274
275
# File 'lib/wiretap.rb', line 268

def self.open(uri)
  return unless match_data = uri.match(/([^\/]+)(\/?)(.*)/)
  server = Server.new(match_data.captures.first)
  raise Wiretap::ServerDead, "Could not connect to Wiretap host #{match_data.captures.first}" unless server.alive?
  
  return server if match_data.captures.last.empty?
  server.find(match_data.captures.last)
end

.server_runObject



191
192
193
194
195
196
# File 'ext/testserver/server.cpp', line 191

VALUE server_run(VALUE self) {
  TestServer server;
  int argc = 1;
  char *argv[1] = {"server"};
  return server.mainLoop(argc, argv);
}

.supports_audio?(*args) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'ext/wiretap.cpp', line 18

VALUE wiretap_true(int argc, VALUE* argv, VALUE self) {
  return Qtrue;
}