Emulates a MIDI output controller.
You will need to connect a MIDI via serial, radio or bluetooth get it to "talk" to the MIDI output device.
- for Bluetooth, use the bluetooth midi package.
Place a ||midi play tone||
block to play a single note (on channel 1).
The frequency is mapped to the nearest note.
midi.playTone(Note.A, music.beat(BeatFraction.Whole))
Place a ||midi tone on||
block to start a tone (on channel 1).
Place a ||midi tone off||
to turn it off.
midi.toneOn(Note.A)
midi.toneOn(Note.B)
basic.pause(music.beat())
midi.toneOff(Note.A)
midi.toneOff(Note.B)
Place a ||midi play drum||
block to play a drum sound. This blocks plays sounds on channel 10 which is reserved for drums.
midi.playDrum(DrumSound.HandClap)
Place a ||midi pitch bend||
block to applying a sound bending effect to channel 1.
midi.pitchBend(8192 + input.acceleration(Dimension.X) * 8)
You can access and manipulate individual channels using the ||midi channel||
block.
Channels are indexed from 1 to 16 and mapped internally to 0..15.
let piano = midi.channel(1);
let piano = midi.channel(1);
piano.note(30, music.beat(BeatFraction.Whole));
let piano = midi.channel(1);
piano.noteOn(30);
basic.pause(100)
piano.noteOff(30)
let trumpet = midi.channel(2);
trumpet.setInstrument(MidiInstrument.Trumpet);
The pitch bend expects values between 0..16383
where 8192
means no bend.
let piano = midi.channel(1);
piano.pitchBend(8192 + input.acceleration(Dimension.X) * 8)
MIT
- for PXT/microbit (The metadata above is needed for package search.)
midi=github:microsoft/pxt-midi