Git Product home page Git Product logo

Comments (9)

Gadgetoid avatar Gadgetoid commented on May 22, 2024

I've just realised this when testing today- it's not actually sending MIDI over Serial at all, but is instead sending a string representation of it.

See: https://github.com/Microsoft/pxt-midi/blob/fb9de98860c6c5cd0a60844673f450f1bc55abbf/midi.ts#L80-L95

The practical upshot of this is that the "MIDI" is very human-readable, but unfortunately isn't readable by any off-the-shell Serial->MIDI bridge software I've come across.

The format is:

midi:<command>,<arg>,<arg> \r\n

(Not I've taken liberty with the amount of whitespace, but that is part of the output)

You could write your own client in Python that handles MIDI messages in this format and injects them directly into the system. It'd be relatively easy using serial.readline.

However I think this library needs a new block: "useRawSerial()"

This block would run the following code:

function send(data: Buffer): void {
    serial.writeBuffer(data)
}
midi.setTransport(send);

This writes the raw - not human readable - MIDI data directly out to the serial port, and I can confirm this works with Hairless MIDI <-> Serial Bridge.

from pxt-midi.

JonahPi avatar JonahPi commented on May 22, 2024

Using the new block "midi use raw serial" it works like a charm. Thanks a lot for your help!

from pxt-midi.

pelikhan avatar pelikhan commented on May 22, 2024

Anyone up to write a project on how to use this?

from pxt-midi.

JonahPi avatar JonahPi commented on May 22, 2024

micromidiconnection
microbitsamplecode

This setup allows to connect any kind of instrument with a midi-input. I tested it with an e-piano and this little devices which was described in the German Make magazine.

from pxt-midi.

CaptainCredible avatar CaptainCredible commented on May 22, 2024

from pxt-midi.

pelikhan avatar pelikhan commented on May 22, 2024

from pxt-midi.

JonahPi avatar JonahPi commented on May 22, 2024

@pelikhan : Sure, 'would be cool to see more people using it.

@CaptainCredible : No long time tests run yet but I will work on a midi project soon, 'hope it works out.

from pxt-midi.

pelikhan avatar pelikhan commented on May 22, 2024

from pxt-midi.

JonahPi avatar JonahPi commented on May 22, 2024

In this case I think it should be a little bit extended to see the differences between polymorphic and single tones:

let Guitar: midi.MidiController = null
input.onButtonPressed(Button.A, () => {
    basic.showIcon(IconNames.EigthNote)
    Guitar.note(midi.frequencyToKey(262), music.beat(BeatFraction.Whole))
    basic.pause(100)
    Guitar.note(midi.frequencyToKey(330), music.beat(BeatFraction.Whole))
    basic.pause(200)
    Guitar.note(midi.frequencyToKey(440), music.beat(BeatFraction.Whole))
    basic.pause(300)
    basic.showIcon(IconNames.Yes)
})
input.onButtonPressed(Button.B, () => {
    basic.showIcon(IconNames.Heart)
    Guitar.noteOn(midi.frequencyToKey(262))
    Guitar.noteOn(midi.frequencyToKey(330))
    Guitar.noteOn(midi.frequencyToKey(440))
    basic.pause(800)
    Guitar.noteOff(midi.frequencyToKey(262))
    basic.pause(500)
    Guitar.noteOff(midi.frequencyToKey(330))
    basic.pause(500)
    Guitar.noteOff(midi.frequencyToKey(440))
    basic.showIcon(IconNames.Yes)
})
serial.redirect(
SerialPin.P0,
SerialPin.P1,
BaudRate.BaudRate31250
)
midi.useRawSerial()
basic.showIcon(IconNames.Yes)
Guitar = midi.channel(1)
Guitar.setInstrument(MidiInstrument.AcousticGuitarNylon)

from pxt-midi.

Related Issues (6)

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.