Git Product home page Git Product logo

pxt-midi's Introduction

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.

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)

Radio serial

You can use radio to send MIDI messages from various @boardname@ and play them via Hairless MIDI.

radio.setGroup(10)
// routes all radio messages via radio
midi.setTransport(function (data: Buffer) {
    led.toggle(3, 4)
    radio.sendBuffer(data);
})

// proxies all radio buffers to serial
radio.onReceivedBuffer(function (buffer: Buffer) {
    serial.writeBuffer(buffer);
    led.toggle(4, 4);
})

// test send message
input.onButtonPressed(Button.A, function () {
    led.toggle(0, 0)
    midi.playTone(Note.C, 500)
})

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 [email protected] with any additional questions or comments.

pxt-midi's People

Contributors

gadgetoid avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar pelikhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pxt-midi's Issues

Specifying Control Change parameters

I can specify two parameters (CC # and value) in JavaSript Editor, but only 1 in Blocks Edtor.
The same, Polyphonic afer touch.

Could you please correct them?

https://github.com/Microsoft/pxt-midi/blob/3861e254d610c5c66728354afbf060bec6b892f0/midi.ts#L294
-->
//% blockId=midi_control_change block="%this|control change %fn| to %value"

https://github.com/Microsoft/pxt-midi/blob/3861e254d610c5c66728354afbf060bec6b892f0/midi.ts#L277
-->
//% blockId=midi_polyphonic_after_touch block="%this|polyphonic after touch %key| %pressure"

makecode.microbit.org Version: 0.14.54
Microsoft MakeCode Version: 0.19.16
C++ runtime Version: v2.1.0

erro

boa tarde a todos do grupo recentemente decidi fazer um projeto de arduino entao comprei um leonardo e uma mux 16 , e me enviaram o codigo pra mux ms quando carrego o codigo no monitor serial tudo normal as portas do analogicas do mux respondem normal porem no HAIERLESS da o seguindo erro .

+202.67 - Error: got unexpected data byte 0xd.

se necessario enviarei o codigo pro mux

// Mapeamento dos pinos
#define SIG A0 // pino analógico
#define S0 8
#define S1 9
#define S2 10
#define S3 11
// o pino EN do mux vai no GND

int mix[4]={S3,S2,S1,S0};

int valores_analogicos[16];

// Valores em binario
byte ci[16][4]={
{0,0,0,0}, // 0 em decimal
{0,0,0,1}, // 1 em decimal
{0,0,1,0}, // 2 em decimal
{0,0,1,1}, // 3 em decimal
{0,1,0,0}, // 4 em decimal
{0,1,0,1}, // 5 em decimal
{0,1,1,0}, // 6 em decimal
{0,1,1,1}, // 7 em decimal
{1,0,0,0}, // 8 em decimal
{1,0,0,1}, // 9 em decimal
{1,0,1,0}, // 10 em decimal
{1,0,1,1}, // 11 em decimal
{1,1,0,0}, // 12 em decimal
{1,1,0,1}, // 13 em decimal
{1,1,1,0}, // 14 em decimal
{1,1,1,1}, // 15 em decimal
};

void setup(){
Serial.begin(9600);

pinMode(S0,OUTPUT);
pinMode(S1,OUTPUT);
pinMode(S2,OUTPUT);
pinMode(S3,OUTPUT);

}

void loop(){

// vai para a rotina de leitura do mux
multiplex();

for (int x = 0; x <= 15; x++){
Serial.print("Pino ");
Serial.print(x);
Serial.print(" = ");
Serial.println(valores_analogicos[x]);
}
Serial.println("");

// Serial.print("Pino 15 = ");
// Serial.println(valores_analogicos[15]); // de 0 a 15

// Esse delay pode ser removido
delay(2000);

}// fim do loop

//Função de leitura dos valores
void multiplex(){

for(int x=0; x <= 15; x++){
for (int y = 0; y <= 3; y++){
digitalWrite (mix[y], ci[x][y]);
}
valores_analogicos[x] = analogRead(SIG);
}

}// fim do multiplex

na imagem pode ver o referido erro

error

serial unexpected data byte

I am trying to use hairless midi serial bridge and I am getting an error: got unexpected data byte 0xa or some such incorrect byte. When I first start sending messages I get this error: +2648.05 - Warning: got a status byte when we were expecting 3 more data bytes, sending possibly incomplete MIDI message 0xff
Do you have any suggestions. I noticed it outputs the string "midi:" is this what it is complaining about. Also I believe MIDI::sendNoteOn(pitch, velocity, channel) is the correct order. Is the package sending channel, pitch, velocity. There is a description of a fix in this link Control Change command "Unexpected data byte". thanks I look forward to getting it working over usb.

Midi signal via serial seems wrong

I used the Midi package with a very simple program but was not able to get out any tone. Using a similar Python code worked perfectly fine. In both cases I transmit the Midi-code via Pin 0 and use the Midi via Serial command. When I compared the signals from the Phython code with the one from the PXT-code there was an obivious difference. (s.a. forum entry here: link )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.