Class: AudioToolbox::MusicSequence
- Inherits:
-
Object
- Object
- AudioToolbox::MusicSequence
- Defined in:
- lib/music_player.rb,
ext/music_player/music_player.c
Instance Attribute Summary collapse
-
#tracks ⇒ Object
readonly
Returns the value of attribute tracks.
Instance Method Summary collapse
- #initialize ⇒ Object constructor
- #load(path) ⇒ Object
- #midi_endpoint= ⇒ Object
- #save ⇒ Object
- #type ⇒ Object
- #type= ⇒ Object
Constructor Details
#initialize ⇒ Object
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'ext/music_player/music_player.c', line 306
static VALUE
sequence_init (VALUE self)
{
MusicSequence *seq;
OSStatus err;
Data_Get_Struct(self, MusicSequence, seq);
require_noerr( err = NewMusicSequence(seq), fail );
rb_iv_set(self, "@tracks",
rb_funcall(rb_cMusicTrackCollection, rb_intern("new"), 1, self));
return self;
fail:
RAISE_OSSTATUS(err, "NewMusicSequence()");
}
|
Instance Attribute Details
#tracks ⇒ Object (readonly)
Returns the value of attribute tracks.
7 8 9 |
# File 'lib/music_player.rb', line 7 def tracks @tracks end |
Instance Method Details
#load(path) ⇒ Object
9 10 11 12 13 |
# File 'lib/music_player.rb', line 9 def load(path) @tracks.lock.synchronize do load_internal(path) end end |
#midi_endpoint= ⇒ Object
322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'ext/music_player/music_player.c', line 322
static VALUE
sequence_set_midi_endpoint (VALUE self, VALUE rb_endpoint_ref)
{
MusicSequence *seq;
UInt32 ref = NUM2ULONG(rb_funcall(rb_mKernel, rb_intern("Integer"), 1, rb_endpoint_ref));
OSStatus err;
Data_Get_Struct(self, MusicSequence, seq);
require_noerr( err = MusicSequenceSetMIDIEndpoint(*seq, (MIDIEndpointRef) ref), fail);
return Qnil;
fail:
RAISE_OSSTATUS(err, "MusicSequenceSetMIDIEndpoint()");
}
|
#save ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'ext/music_player/music_player.c', line 385
static VALUE
sequence_save (VALUE self, VALUE rb_path)
{
CFURLRef url = PATH2CFURL(rb_funcall(rb_path, rb_intern("to_s"), 0));
MusicSequence *seq;
OSStatus err;
Data_Get_Struct(self, MusicSequence, seq);
require_noerr( err = MusicSequenceFileCreate(*seq, url, kMusicSequenceFile_MIDIType, kMusicSequenceFileFlags_EraseFile, 0), fail );
CFRelease(url);
return Qnil;
fail:
CFRelease(url);
RAISE_OSSTATUS(err, "MusicSequenceFileCreate()");
}
|
#type ⇒ Object
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'ext/music_player/music_player.c', line 337
static VALUE
sequence_get_type (VALUE self)
{
MusicSequence *seq;
MusicSequenceType type;
OSStatus err;
Data_Get_Struct(self, MusicSequence, seq);
require_noerr( err = MusicSequenceGetSequenceType(*seq, &type), fail );
switch (type) {
case kMusicSequenceType_Beats:
return rb_sBeat;
case kMusicSequenceType_Seconds:
return rb_sSecs;
case kMusicSequenceType_Samples:
return rb_sSamp;
default:
rb_raise(rb_eRuntimeError, "Unrecognized sequence type.");
}
fail:
RAISE_OSSTATUS(err, "MusicSequenceGetSequenceType()");
}
|
#type= ⇒ Object
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'ext/music_player/music_player.c', line 362
static VALUE
sequence_set_type (VALUE self, VALUE rb_type)
{
MusicSequence *seq;
MusicSequenceType type;
if (rb_type == rb_sBeat)
type = kMusicSequenceType_Beats;
else if (rb_type == rb_sSecs)
type = kMusicSequenceType_Seconds;
else if (rb_type == rb_sSamp)
type = kMusicSequenceType_Samples;
else
rb_raise(rb_eArgError, "Expected :type to be one of :beat, :secs, :samp.");
Data_Get_Struct(self, MusicSequence, seq);
OSStatus err;
require_noerr( err = MusicSequenceSetSequenceType(*seq, type), fail );
return Qnil;
fail:
RAISE_OSSTATUS(err, "MusicSequenceSetSequenceType()");
}
|