Module: MTK
- Defined in:
- lib/mtk.rb,
lib/mtk/core/pitch.rb,
lib/mtk/events/note.rb,
lib/mtk/events/rest.rb,
lib/mtk/io/notation.rb,
lib/mtk/events/event.rb,
lib/mtk/groups/chord.rb,
lib/mtk/io/midi_file.rb,
lib/mtk/lang/pitches.rb,
lib/mtk/core/duration.rb,
lib/mtk/core/interval.rb,
lib/mtk/groups/melody.rb,
lib/mtk/io/midi_input.rb,
lib/mtk/lang/tutorial.rb,
lib/mtk/lang/tutorial.rb,
lib/mtk/core/intensity.rb,
lib/mtk/io/midi_output.rb,
lib/mtk/lang/durations.rb,
lib/mtk/lang/intervals.rb,
lib/mtk/patterns/chain.rb,
lib/mtk/patterns/cycle.rb,
lib/mtk/patterns/lines.rb,
lib/mtk/events/timeline.rb,
lib/mtk/io/jsound_input.rb,
lib/mtk/patterns/choice.rb,
lib/mtk/core/pitch_class.rb,
lib/mtk/events/parameter.rb,
lib/mtk/io/jsound_output.rb,
lib/mtk/io/unimidi_input.rb,
lib/mtk/lang/intensities.rb,
lib/mtk/patterns/pattern.rb,
lib/mtk/groups/collection.rb,
lib/mtk/io/unimidi_output.rb,
lib/mtk/patterns/for_each.rb,
lib/mtk/patterns/function.rb,
lib/mtk/patterns/sequence.rb,
lib/mtk/lang/pitch_classes.rb,
lib/mtk/io/dls_synth_device.rb,
lib/mtk/io/dls_synth_output.rb,
lib/mtk/patterns/palindrome.rb,
lib/mtk/lang/tutorial_lesson.rb,
lib/mtk/sequencers/sequencer.rb,
lib/mtk/lang/pseudo_constants.rb,
lib/mtk/groups/pitch_class_set.rb,
lib/mtk/groups/pitch_collection.rb,
lib/mtk/sequencers/event_builder.rb,
lib/mtk/sequencers/step_sequencer.rb,
lib/mtk/sequencers/legato_sequencer.rb,
lib/mtk/sequencers/rhythmic_sequencer.rb,
lib/mtk/lang/parser.rb
Overview
And now that we’ve got some colors we can define colored constants
Defined Under Namespace
Modules: Core, Events, Groups, IO, Lang, Patterns, Sequencers
Class Method Summary collapse
-
.Chord(*anything) ⇒ Object
Construct an ordered Groups::Chord with no duplicates.
-
.Duration(*anything) ⇒ Object
Construct a MTK.Duration from any supported type.
-
.Intensity(*anything) ⇒ Object
Construct a MTK.Duration from any supported type.
-
.Interval(*anything) ⇒ Object
Construct a MTK.Duration from any supported type.
-
.Melody(*anything) ⇒ Object
Construct an ordered Groups::Melody that allows duplicates.
-
.MIDIFile(f) ⇒ Object
Shortcut for MTK::IO::MIDIFile.new.
-
.Note(*anything) ⇒ Object
Construct a Events::Note from a list of any supported type for the arguments: pitch, intensity, duration, channel.
-
.Pitch(*anything) ⇒ Object
Construct a MTK.Pitch from any supported type.
-
.PitchClass(anything) ⇒ Object
Construct a MTK.PitchClass from any supported type.
-
.PitchClassSet(*anything) ⇒ Object
Construct a Groups::PitchClassSet.
-
.Rest(*anything) ⇒ Object
Construct a Events::Rest from a list of any supported type for the arguments: pitch, intensity, duration, channel.
Class Method Details
.Chord(*anything) ⇒ Object
Construct an ordered MTK::Groups::Chord with no duplicates.
51 52 53 |
# File 'lib/mtk/groups/chord.rb', line 51 def Chord(*anything) MTK::Groups::Chord.new MTK::Groups.to_pitches(*anything) end |
.Duration(*anything) ⇒ Object
Construct a Duration from any supported type
217 218 219 220 221 222 223 224 225 |
# File 'lib/mtk/core/duration.rb', line 217 def Duration(*anything) anything = anything.first if anything.length == 1 case anything when Numeric then MTK::Core::Duration[anything] when String, Symbol then MTK::Core::Duration.from_s(anything) when Duration then anything else raise "Duration doesn't understand #{anything.class}" end end |
.Intensity(*anything) ⇒ Object
Construct a Duration from any supported type
149 150 151 152 153 154 155 156 157 |
# File 'lib/mtk/core/intensity.rb', line 149 def Intensity(*anything) anything = anything.first if anything.length == 1 case anything when Numeric then MTK::Core::Intensity[anything] when String, Symbol then MTK::Core::Intensity.from_s(anything) when Intensity then anything else raise "Intensity doesn't understand #{anything.class}" end end |
.Interval(*anything) ⇒ Object
Construct a Duration from any supported type
153 154 155 156 157 158 159 160 161 |
# File 'lib/mtk/core/interval.rb', line 153 def Interval(*anything) anything = anything.first if anything.length == 1 case anything when Numeric then MTK::Core::Interval[anything] when String, Symbol then MTK::Core::Interval.from_s(anything) when Interval then anything else raise "Interval doesn't understand #{anything.class}" end end |
.Melody(*anything) ⇒ Object
Construct an ordered MTK::Groups::Melody that allows duplicates
91 92 93 |
# File 'lib/mtk/groups/melody.rb', line 91 def Melody(*anything) MTK::Groups::Melody.new MTK::Groups.to_pitches(*anything) end |
.MIDIFile(f) ⇒ Object
Only available if you require ‘mtk/midi/file’
Shortcut for MTK::IO::MIDIFile.new
213 214 215 |
# File 'lib/mtk/io/midi_file.rb', line 213 def MIDIFile(f) ::MTK::IO::MIDIFile.new(f) end |
.Note(*anything) ⇒ Object
Construct a MTK::Events::Note from a list of any supported type for the arguments: pitch, intensity, duration, channel
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/mtk/events/note.rb', line 72 def Note(*anything) anything = anything.first if anything.size == 1 case anything when MTK::Events::Note then anything when MTK::Core::Pitch then MTK::Events::Note.new(anything) when Array pitch = nil duration = nil intensity = nil channel = nil unknowns = [] anything.each do |item| case item when MTK::Core::Pitch then pitch = item when MTK::Core::Duration then duration = item when MTK::Core::Intensity then intensity = item else unknowns << item end end pitch = MTK.Pitch(unknowns.shift) if pitch.nil? and not unknowns.empty? raise "MTK::Note() couldn't find a pitch in arguments: #{anything.inspect}" if pitch.nil? duration = MTK.Duration(unknowns.shift) if duration.nil? and not unknowns.empty? intensity = MTK.Intensity(unknowns.shift) if intensity.nil? and not unknowns.empty? channel = unknowns.shift.to_i if channel.nil? and not unknowns.empty? duration ||= MTK::Events::Note::DEFAULT_DURATION intensity ||= MTK::Events::Note::DEFAULT_INTENSITY MTK::Events::Note.new( pitch, duration, intensity, channel ) else raise "MTK::Note() doesn't understand #{anything.class}" end end |
.Pitch(*anything) ⇒ Object
Construct a Pitch from any supported type
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/mtk/core/pitch.rb', line 139 def Pitch(*anything) anything = anything.first if anything.length == 1 case anything when Numeric then MTK::Core::Pitch.from_f(anything) when String, Symbol then MTK::Core::Pitch.from_s(anything) when MTK::Core::Pitch then anything when Array if anything.length == 2 MTK::Core::Pitch[*anything] else MTK::Core::Pitch.new(*anything) end else raise ArgumentError.new("Pitch doesn't understand #{anything.class}") end end |
.PitchClass(anything) ⇒ Object
Construct a PitchClass from any supported type
187 188 189 190 191 192 193 194 |
# File 'lib/mtk/core/pitch_class.rb', line 187 def PitchClass(anything) case anything when Numeric then MTK::Core::PitchClass.from_f(anything) when String, Symbol then MTK::Core::PitchClass.from_s(anything) when MTK::Core::PitchClass then anything else raise ArgumentError.new("PitchClass doesn't understand #{anything.class}") end end |
.PitchClassSet(*anything) ⇒ Object
Construct a MTK::Groups::PitchClassSet
158 159 160 |
# File 'lib/mtk/groups/pitch_class_set.rb', line 158 def PitchClassSet(*anything) MTK::Groups::PitchClassSet.new MTK::Groups.to_pitch_classes(*anything) end |
.Rest(*anything) ⇒ Object
Construct a MTK::Events::Rest from a list of any supported type for the arguments: pitch, intensity, duration, channel
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mtk/events/rest.rb', line 54 def Rest(*anything) anything = anything.first if anything.size == 1 case anything when MTK::Events::Rest then anything when MTK::Events::Event then MTK::Events::Rest.new(anything.duration, anything.channel) when Numeric then MTK::Events::Rest.new(anything) when Duration then MTK::Events::Rest.new(anything) when Array duration = nil channel = nil unknowns = [] anything.each do |item| case item when MTK::Core::Duration then duration = item else unknowns << item end end duration = MTK.Duration(unknowns.shift) if duration.nil? and not unknowns.empty? raise "MTK::Rest() couldn't find a duration in arguments: #{anything.inspect}" if duration.nil? channel = unknowns.shift.to_i if channel.nil? and not unknowns.empty? MTK::Events::Rest.new(duration, channel) else raise "MTK::Rest() doesn't understand #{anything.class}" end end |