Comments (9)
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.
Using the new block "midi use raw serial" it works like a charm. Thanks a lot for your help!
from pxt-midi.
Anyone up to write a project on how to use this?
from pxt-midi.
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.
from pxt-midi.
from pxt-midi.
@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.
from pxt-midi.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pxt-midi.