Module: AMS::MIDI
- Defined in:
- docs/ams/midi.rb
Overview
All methods below were made compatible with Mac OS X since 3.4.0 unless otherwise stated.
This namespace contains functions associated with the MIDI output interface.
Class Method Summary collapse
-
.change_channel_controller(channel, cnum, cval) ⇒ Boolean
Set note controller.
-
.change_channel_expression(channel, expression) ⇒ Boolean
Set channel expression.
-
.change_channel_instrument(channel, instrument) ⇒ Boolean
Change channel program.
-
.change_channel_position(channel, pos, max_hearing_range) ⇒ Boolean
Set channel position in 3d space.
-
.change_channel_stereo_pan(channel, pan) ⇒ Boolean
Distribute channel volume between left and right speakers.
-
.change_channel_volume(channel, volume) ⇒ Boolean
Set channel volume.
-
.close_device ⇒ Boolean
Close MIDI device.
-
.get_device_handle ⇒ Integer?
Get handle to an open MIDI device.
-
.get_volume ⇒ Array<Numeric>?
Get volume of both channels.
-
.is_device_open? ⇒ Boolean
Determine whether the device is open.
-
.open_device ⇒ Boolean
Open MIDI device.
-
.out_message(*args) ⇒ Boolean
Send MIDI message.
-
.play_note(instrument, note, channel = 0, volume = 127) ⇒ Integer?
Play MIDI note.
-
.play_note2(channel, note, volume) ⇒ Boolean
Turn on MIDI note.
-
.reset ⇒ Boolean
Stop all playing notes.
-
.reset_channel_controllers(channel) ⇒ Boolean
Reset channel controllers.
-
.set_note_position(id, pos, max_hearing_range) ⇒ Boolean
Set MIDI note position in 3D space.
- .set_volume(*args) ⇒ Object
-
.stop_note(id) ⇒ Boolean
Stop MIDI note.
-
.stop_note2(channel, note, volume) ⇒ Boolean
Turn off MIDI note.
-
.sustain_channel_pedal(channel, state) ⇒ Boolean
Control channel pedal.
Class Method Details
.change_channel_controller(channel, cnum, cval) ⇒ Boolean
Set note controller.
.change_channel_expression(channel, expression) ⇒ Boolean
Set channel expression. This is used for dynamics within a single track.
.change_channel_instrument(channel, instrument) ⇒ Boolean
Change channel program.
.change_channel_position(channel, pos, max_hearing_range) ⇒ Boolean
Same as set_note_position but takes channel instead of id as parameter.
Set channel position in 3d space.
.change_channel_stereo_pan(channel, pan) ⇒ Boolean
Distribute channel volume between left and right speakers.
.change_channel_volume(channel, volume) ⇒ Boolean
Set channel volume.
.close_device ⇒ Boolean
Close MIDI device.
.get_device_handle ⇒ Integer?
Get handle to an open MIDI device.
.get_volume ⇒ Array<Numeric>?
Doesn't work on Mac OS X; return [1.0, 1.0]
Get volume of both channels.
.is_device_open? ⇒ Boolean
Determine whether the device is open.
.open_device ⇒ Boolean
Open MIDI device.
.out_message(arg0, arg1, arg2) ⇒ Boolean .out_message(arg0, arg1) ⇒ Boolean .out_message(arg0) ⇒ Boolean
Send MIDI message.
.play_note(instrument, note, channel = 0, volume = 127) ⇒ Integer?
Setting channel to 9 will play midi notes from the "General MIDI Percussion Key Map." Any other channel will play midi notes from the "General MIDI Instrument Patch Map". If channel is set to 9, the instrument parameter will have no effect and the note parameter will be used to play particular percussion sound, if note's value is between 27 and 87. According to my experiments, values outside that 27-87 range won't yield any sounds.
Some instruments have notes that never seem to end. For this reason it might come in handy to use stop_note function when needed.
Play MIDI note.
.play_note2(channel, note, volume) ⇒ Boolean
Turn on MIDI note.
.reset ⇒ Boolean
Stop all playing notes.
.reset_channel_controllers(channel) ⇒ Boolean
Reset channel controllers.
.set_note_position(id, pos, max_hearing_range) ⇒ Boolean
Sound volume and panning is not adjusted automatically with respect to camera orientation. It is required to manually call this function every frame until the note is stopped or has finished playing. Sometimes it's just enough to call this function once after playing the note. Other times, when the note is endless or pretty long, it might be useful to update position of the note every frame until the note ends or is stopped. Meantime, there is no function to determine when the note ends. It is up to the user to decide for how long to call this function or when to stop calling this function.
When it comes to setting 3D positions of multiple sounds, make sure to play each sound on separate channel. That is, play sound 1 on channel 0, sound 2 on channel 1, sound 3 on channel 2, and etcetera until channel gets to 15, as there are only 15 channels available. Read the note below to find out why each sound is supposed to be played on separate channel. I think it would make more sense if the function was renamed to set_channel_position and had the 'id' parameter replaced with 'channel'.
This function works by adjusting panning and volume of the note's and instrument's channel, based on camera's angle and distance to the origin of the sound. Now, there is only one function that adjusts stereo and panning, but it adjusts panning and volume of all notes and instruments that are played on same channel. As of my research, I haven't found a way to adjust panning and volume of channel that belongs to particular note and instrument. There's only a function that can adjust panning and volume of channel that belongs to all notes and instruments that are played on particular channel. For instance, if you play instrument 1 and instrument 2, both on channel zero, they will still play simultaneously, without cancelling out each other, as if they are playing on separate channels, but when it comes to adjusting panning and volume of one of them, the properties of both sounds will be adjusted. This means that this function is only limited to playing 16 3D sounds, with each sound played on different channel. Otherwise, sounds played on same channel at different locations, will endup being tuned as if they are playing from the same location.
Set MIDI note position in 3D space.
.set_volume(left, right) ⇒ Boolean .set_volume(volume) ⇒ Boolean
.stop_note(id) ⇒ Boolean
Stop MIDI note.
.stop_note2(channel, note, volume) ⇒ Boolean
The volume parameter isn't logically necessary to stop a note, but it could be used to fade out the note. Pass zero to stop the note immediately.
Turn off MIDI note.
.sustain_channel_pedal(channel, state) ⇒ Boolean
Message must be sent prior to the note it affects.
Control channel pedal.