Class: AudioToolbox::MIDIChannelMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/music_player.rb,
ext/music_player/music_player.c

Instance Method Summary collapse

Constructor Details

#initializeObject



989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
# File 'ext/music_player/music_player.c', line 989

static VALUE
midi_channel_message_init (VALUE self, VALUE rb_opts)
{
    Check_Type(rb_opts, T_HASH);
    MIDIChannelMessage *msg;
    VALUE rb_status, rb_data1, rb_data2;
    
    Data_Get_Struct(self, MIDIChannelMessage, msg);
    
    rb_status = rb_hash_aref(rb_opts, rb_sStatus);
    if (!FIXNUM_P(rb_status))
        rb_raise(rb_eArgError, ":status is required.");
    else
        msg->status = NUM2DBL(rb_status);
    
    rb_data1 = rb_hash_aref(rb_opts, rb_sData1);
    if (!NIL_P(rb_data1)) msg->data1 = (UInt8) FIX2INT(rb_data1);
    
    rb_data2 = rb_hash_aref(rb_opts, rb_sData2);
    if (!NIL_P(rb_data2)) msg->data2 = (UInt8) FIX2INT(rb_data2);
    
    return self;
}

Instance Method Details

#==(msg) ⇒ Object



109
110
111
112
113
114
# File 'lib/music_player.rb', line 109

def ==(msg)
  self.class == msg.class &&
  status     == msg.status &&
  data1      == msg.data1 &&
  data2      == msg.data2
end

#add(time, track) ⇒ Object



124
125
126
# File 'lib/music_player.rb', line 124

def add(time, track)
  track.add_midi_channel_message(time, self)
end

#channelObject



116
117
118
# File 'lib/music_player.rb', line 116

def channel
  status ^ mask
end

#data1Object



1021
1022
1023
1024
1025
1026
1027
# File 'ext/music_player/music_player.c', line 1021

static VALUE
midi_channel_message_data1 (VALUE self)
{
    MIDIChannelMessage *msg;
    Data_Get_Struct(self, MIDIChannelMessage, msg);
    return UINT2NUM(msg->data1);
}

#data2Object



1029
1030
1031
1032
1033
1034
1035
# File 'ext/music_player/music_player.c', line 1029

static VALUE
midi_channel_message_data2 (VALUE self)
{
    MIDIChannelMessage *msg;
    Data_Get_Struct(self, MIDIChannelMessage, msg);
    return UINT2NUM(msg->data2);
}

#maskObject

Raises:

  • (NotImplementedError)


120
121
122
# File 'lib/music_player.rb', line 120

def mask
  raise NotImplementedError, "Subclass responsibility."
end

#statusObject



1013
1014
1015
1016
1017
1018
1019
# File 'ext/music_player/music_player.c', line 1013

static VALUE
midi_channel_message_status (VALUE self)
{
    MIDIChannelMessage *msg;
    Data_Get_Struct(self, MIDIChannelMessage, msg);
    return UINT2NUM(msg->status);
}