Class: AudioToolbox::MIDINoteMessage
- Inherits:
-
Object
- Object
- AudioToolbox::MIDINoteMessage
- Defined in:
- lib/music_player.rb,
ext/music_player/music_player.c
Instance Method Summary collapse
- #==(msg) ⇒ Object
- #add(time, track) ⇒ Object
- #channel ⇒ Object
- #duration ⇒ Object
- #initialize ⇒ Object constructor
- #note ⇒ Object
- #release_velocity ⇒ Object
- #velocity ⇒ Object
Constructor Details
#initialize ⇒ Object
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
# File 'ext/music_player/music_player.c', line 891
static VALUE
midi_note_message_init (VALUE self, VALUE rb_opts)
{
Check_Type(rb_opts, T_HASH);
MIDINoteMessage *msg;
VALUE rb_chn, rb_note, rb_vel, rb_rel_vel, rb_dur;
Data_Get_Struct(self, MIDINoteMessage, msg);
rb_chn = rb_hash_aref(rb_opts, rb_sChannel);
msg->channel = FIXNUM_P(rb_chn) ? FIX2UINT(rb_chn) : 1;
rb_note = rb_hash_aref(rb_opts, rb_sNote);
if (FIXNUM_P(rb_note))
msg->note = FIX2UINT(rb_note);
else
rb_raise(rb_eArgError, ":note is required.");
rb_vel = rb_hash_aref(rb_opts, rb_sVelocity);
msg->velocity = FIXNUM_P(rb_vel) ? FIX2UINT(rb_vel) : 64;
rb_rel_vel = rb_hash_aref(rb_opts, rb_sReleaseVelocity);
msg->releaseVelocity = FIXNUM_P(rb_rel_vel) ? FIX2UINT(rb_rel_vel) : 0;
rb_dur = rb_hash_aref(rb_opts, rb_sDuration);
msg->duration = (MusicTimeStamp) (PRIM_NUM_P(rb_dur)) ? NUM2DBL(rb_dur) : 1.0;
return self;
}
|
Instance Method Details
#==(msg) ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/music_player.rb', line 94 def ==(msg) self.class == msg.class && channel == msg.channel && note == msg.note && velocity == msg.velocity && release_velocity == msg.release_velocity && duration == msg.duration end |
#add(time, track) ⇒ Object
103 104 105 |
# File 'lib/music_player.rb', line 103 def add(time, track) track.(time, self) end |
#channel ⇒ Object
921 922 923 924 925 926 927 |
# File 'ext/music_player/music_player.c', line 921
static VALUE
midi_note_message_channel (VALUE self)
{
MIDINoteMessage *msg;
Data_Get_Struct(self, MIDINoteMessage, msg);
return UINT2NUM(msg->channel);
}
|
#duration ⇒ Object
953 954 955 956 957 958 959 |
# File 'ext/music_player/music_player.c', line 953
static VALUE
midi_note_message_duration (VALUE self)
{
MIDINoteMessage *msg;
Data_Get_Struct(self, MIDINoteMessage, msg);
return UINT2NUM(msg->duration);
}
|
#note ⇒ Object
929 930 931 932 933 934 935 |
# File 'ext/music_player/music_player.c', line 929
static VALUE
midi_note_message_note (VALUE self)
{
MIDINoteMessage *msg;
Data_Get_Struct(self, MIDINoteMessage, msg);
return UINT2NUM(msg->note);
}
|
#release_velocity ⇒ Object
945 946 947 948 949 950 951 |
# File 'ext/music_player/music_player.c', line 945
static VALUE
midi_note_message_release_velocity (VALUE self)
{
MIDINoteMessage *msg;
Data_Get_Struct(self, MIDINoteMessage, msg);
return UINT2NUM(msg->releaseVelocity);
}
|
#velocity ⇒ Object
937 938 939 940 941 942 943 |
# File 'ext/music_player/music_player.c', line 937
static VALUE
midi_note_message_velocity (VALUE self)
{
MIDINoteMessage *msg;
Data_Get_Struct(self, MIDINoteMessage, msg);
return UINT2NUM(msg->velocity);
}
|