Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB-MIDI documentation? #3233

Open
davidhtims opened this issue Oct 16, 2022 · 6 comments
Open

USB-MIDI documentation? #3233

davidhtims opened this issue Oct 16, 2022 · 6 comments
Labels
docs Documentation needed

Comments

@davidhtims
Copy link

davidhtims commented Oct 16, 2022

I have a Xiao RP2040 working in that the device can be recognized as a MIDI device but I'm lost as to how to send data.
Is there any documentation for USB-MIDI?
I have asked this question in TinyGoMIDI, a Google Group I've started, and the code I have at the moment is there:
https://groups.google.com/g/tinygomidi/c/s8P8fqm3BaE

package main

import (
   "machine"
   "machine/usb"
)

func init() {
   machine.EnableMIDI(midiTx, midiRx, midiSetup)
}

func main() {
}

func midiRx(bs []byte) {
}

func midiTx() {
}

func midiSetup(sup usb.Setup) bool {
   return true
}
@sago35
Copy link
Member

sago35 commented Oct 16, 2022

To receive and process MIDI signals from a PC or other source, the following code can be used as a reference.

m.SetHandler(func(b []byte) {
led.Set(!led.Get())
fmt.Printf("% X\r\n", b)
m.Write(b)
})

@sago35
Copy link
Member

sago35 commented Oct 16, 2022

I think there is no documentation on USB-MIDI at this time.
But would be great to have.

@davidhtims
Copy link
Author

davidhtims commented Oct 17, 2022

Thanks, a question please:

Why or when do I need to use the init function as mentioned in the RP2040 docs:

func init() {
   machine.EnableMIDI(midiTx, midiRx, midiSetup)
}

I'm using tinygo version 0.26.0 darwin/amd64 (using go version go1.19.2 and LLVM version 14.0.0)

Also, in the example tinygo/src/examples/usb-midi/main.go I get an undeclared error on machine.BUTTON.

@sago35
Copy link
Member

sago35 commented Oct 17, 2022

You do not need to call machine.EnableMIDI() .
EnableMIDI is called internally.

func init() {
if Midi == nil {
Midi = newMidi()
}
}

func init() {
if Midi == nil {
Midi = newMidi()
}
}

So the first thing you should do is examples/usb-midi.

I get an undeclared error on machine.BUTTON.

If machine.BUTTON is not defined, replace it with machine.GPIO0 , etc.

@davidhtims
Copy link
Author

Thanks for the help, I can now send MIDI notes to the pc from Seeed Studio's Xiao RP2040.

@kenbell kenbell added the docs Documentation needed label Oct 20, 2022
@deadprogram
Copy link
Member

I just added PR #3889 to make some improvements to the current USB-MIDI support, please have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation needed
Projects
None yet
Development

No branches or pull requests

4 participants