Class: Wiretap::Audio
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
- #audio? ⇒ Boolean
- #clip? ⇒ Boolean
-
#dump(file) ⇒ Object
This is called on the node itself, but not on NodeFrames.
-
#format ⇒ Object
Returns the format of the audio node.
- #frames ⇒ Object
-
#import_audio!(filename) ⇒ Object
Importing music is possible on Audio clips.
- #to_s ⇒ Object
Methods inherited from Node
#==, #[], #children, #create_clip, #create_library, #create_node, #create_project, #create_reel, #destroy, #destroyed?, #find, #find_child, #hires?, #host?, #id, #id=, #import_image, #import_video, #library?, #lowres?, #ls, #meta, #metadata, #name, #node?, #project?, #reel?, #reload, #slate?, #type, #uri, #volume?
Instance Method Details
#audio? ⇒ Boolean
#clip? ⇒ Boolean
#dump(file) ⇒ Object
This is called on the node itself, but not on NodeFrames
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'ext/audio_format.cpp', line 189
static VALUE wiretap_audio_dump(VALUE self, VALUE file) {
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
WireTapAudioFormat format;
RUN(node->getClipFormat(format));
int num;
NODERUN_E(node, node->getNumFrames(num));
if(num <= 0) {
rb_warn("No frames in the audio stream");
return Qnil;
}
std::auto_ptr<unsigned char> frame(new unsigned char[format.frameBufferSize() * num]);
for(int i = 0; i < num; i++) {
if(!node->readFrame(i, frame.get() + i*format.frameBufferSize(), format.frameBufferSize())) {
frame.release();
NODERUN_E(node, false);
}
}
wiretap_write_audio_frame(format.numSamples(), int(format.sampleRate()),
format.bitsPerSample(), rb_intern(format.formatTag()), frame.get(), CSTR(file));
return self;
}
|
#format ⇒ Object
Returns the format of the audio node
320 321 322 323 324 325 326 327 328 329 330 |
# File 'ext/node.cpp', line 320
static VALUE wiretap_audio_format(VALUE self) {
Check_Node_Alive(self);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
WireTapAudioFormat audio_format;
NODERUN_E(node, node->getClipFormat(audio_format));
VALUE audioformat = Data_Wrap_Struct(cAudioFormat, 0, wiretap_format_free, new WireTapAudioFormat(audio_format));
rb_iv_set(audioformat, "@node", self);
return audioformat;
}
|
#frames ⇒ Object
344 345 346 347 348 349 350 351 352 |
# File 'ext/node.cpp', line 344 static VALUE wiretap_audio_frames(VALUE self) { Check_Node_Alive(self); WireTapNodeHandle* node; Data_Get_Struct(self, WireTapNodeHandle, node); VALUE audioframes = Data_Wrap_Struct(cAudioFrames, 0, node_leave, node); rb_iv_set(audioframes, "@node", self); return audioframes; } |
#import_audio!(filename) ⇒ Object
Importing music is possible on Audio clips
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'ext/audio_format.cpp', line 164
static VALUE wiretap_audio_import_audio_file(VALUE self, VALUE filename) {
Check_Type(filename, T_STRING);
SF_INFO sfinfo;
SNDFILE* snd = sf_open(CSTR(filename), SFM_READ, &sfinfo);
std::auto_ptr<short> frame(new short[sfinfo.frames]);
sf_count_t read_frames = sf_read_short(snd, frame.get(), sfinfo.frames);
if(read_frames != sfinfo.frames) {
rb_warn("Waited to read %lld audio frames, got only %lld", sfinfo.frames, read_frames);
sf_close(snd);
return Qnil;
}
sf_close(snd);
WireTapNodeHandle* node;
Data_Get_Struct(self, WireTapNodeHandle, node);
NODERUN_E(node, node->setNumFrames(1));
NODERUN_E(node, node->writeFrame(0, frame.get(), sfinfo.frames*2));
return self;
}
|
#to_s ⇒ Object
241 242 243 |
# File 'lib/wiretap.rb', line 241 def to_s "#<#{self.class.to_s} '#{self.name}'>" end |