A MIDI interface for MakeCode
Перейти к файлу
Peli de Halleux 58a4543e39 2.1.2 2018-09-06 08:38:12 -07:00
.vscode first drop 2017-04-21 23:19:58 -07:00
.gitignore first drop 2017-04-21 23:19:58 -07:00
.travis.yml added travis 2018-05-02 08:10:49 -07:00
LICENSE Initial commit 2017-04-21 17:26:47 -07:00
Makefile first drop 2017-04-21 23:19:58 -07:00
README.md code of conduct 2018-05-23 09:08:36 -07:00
drums.ts fixed pitch bend 2017-04-23 05:35:09 -07:00
enums.d.ts using closed formula to resolve notes 2017-04-23 08:13:30 -07:00
extension.cpp using closed formula to resolve notes 2017-04-23 08:13:30 -07:00
icon.png added icon 2017-04-22 22:15:05 -07:00
instruments.ts fixed pitch bend 2017-04-23 05:35:09 -07:00
midi.ts avoid / operator 2018-09-06 08:38:10 -07:00
pxt.json 2.1.2 2018-09-06 08:38:12 -07:00
shims.d.ts using closed formula to resolve notes 2017-04-23 08:13:30 -07:00
tests.ts Aligning terminology to MIDI 2017-04-23 22:40:45 -07:00
tsconfig.json first drop 2017-04-21 23:19:58 -07:00

README.md

MIDI Build Status

Emulates a MIDI output controller.

Usage

Setup

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.

  • for bridge applications like Hairless MIDI, call useRawSerial

midi.useRawSerial()

Playing tones

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))

Tone on / off

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)

Drums

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)

Pitch bending

Place a ||midi pitch bend|| block to applying a sound bending effect to channel 1.

midi.pitchBend(8192 + input.acceleration(Dimension.X) * 8)

Channels

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);

play a note

let piano = midi.channel(1);
piano.note(30, music.beat(BeatFraction.Whole));

play a note on / off

let piano = midi.channel(1);
piano.noteOn(30);
basic.pause(100)
piano.noteOff(30)

change instrument

let trumpet = midi.channel(2);
trumpet.setInstrument(MidiInstrument.Trumpet);

change pitch bend

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)

License

MIT

Supported targets

  • for PXT/microbit
  • for PXT/calliope

(The metadata above is needed for package search.)

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.