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 for Arduino #2943

Closed
wants to merge 7 commits into from
Closed

Conversation

gurbrinder
Copy link

Added USB MIDI device capability top Arduino Due

@facchinm facchinm self-assigned this Apr 13, 2015
@facchinm
Copy link
Member

Hi @gurbrinder ,
I think that something horrible happened to your commit ed21dbd , as the full cpp file is replaced by its header.

Could you recover the correct one (with your modifications, of course) and push force over it?

@facchinm facchinm added the Waiting for feedback More information must be provided before we can proceed label Apr 14, 2015
@cmaglie cmaglie added feature request A request to make an enhancement (not a bug fix) Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Component: USB Device Opposed to USB Host. Related to the USB subsystem (SerialUSB, HID, ...) labels Apr 15, 2015
@gurbrinder
Copy link
Author

Fixed the file.

@gurbrinder
Copy link
Author

Hi,
I fixed the file.

Gary

On Tue, Apr 14, 2015 at 12:44 AM, Martino Facchin notifications@github.com
wrote:

Hi @gurbrinder https://github.com/gurbrinder ,
I think that something horrible happened to your commit ed21dbd
ed21dbd
, as the full cpp file is replaced by its header.

Could you recover the correct one (with your modifications, of course) and
push force over it?


Reply to this email directly or view it on GitHub
#2943 (comment).

Regards,
Gurbrinder Grewal

@facchinm facchinm added Architecture: SAM Applies only to the SAM microcontrollers (Due) and removed Architecture: AVR Applies only to the AVR microcontrollers (Uno, etc.) Waiting for feedback More information must be provided before we can proceed labels Apr 20, 2015
@facchinm
Copy link
Member

@ArduinoBot build this please

@facchinm
Copy link
Member

facchinm commented May 6, 2015

I finally found some time to test the patch and it works great (setting up my Linux machine to hear something was a PITA instead 😄 )

The example must be moved (for example to libraries/Audio/USBMIDI/ folder) because it will open as a project if placed in the same folder with SimpleAudioPlayer

Then it would be great to have some smart functions wrappers like USBMIDI.noteOn to mimic Mouse and Keyboard classes, which hide the complexity in a very smart way

@facchinm
Copy link
Member

facchinm commented Sep 7, 2015

Completely ported to PluggableUSB in this repo.
Thanks @gurbrinder for the initial code, it was extremely useful.

@facchinm facchinm closed this Sep 7, 2015
@ffissore ffissore modified the milestone: Release 1.6.6 Sep 7, 2015
@odbol
Copy link

odbol commented Nov 7, 2015

Hi @gurbrinder ! I've been further testing the USB MIDI implementation you made, and have come across an issue that I can't figure out: the whole Arduino sketch will freeze if you try using it after the USB is connected, but before an app opens the MIDI port and starts listening to the MIDI sent from the Arduino. Was hoping you could help me figure it out or at least point me in the right direction.

I've narrowed it down to this:

  1. When you plug the USB into a computer, the SerialUSB port initializes.
  2. The sketch calls MidiUSB.sendMIDI(), which freezes the whole sketch.
  3. The reason, is that the USBD_Send() function blocks until there is a connection.
  4. Once you open a MIDI app on the PC (such as MIDI Monitor or Garageband), it opens the MIDI port, and the sketch unfreezes ( USBD_Send() stops blocking).
  5. Sending over SerialUSB works: the SerialUSB.write() function does not block if there is nothing connected. See the "if (_usbLineInfo.lineState > 0)" line in CDC.cpp for how they do this.
  6. We need to figure out a way to tell if USBD_Send() will block (i.e. the MIDI port is opened on the other end), and avoid calling it if it will block (just drop the messages if there's nothing listening).

I've attempted to duplicate the "_usbLineInfo.lineState" technique in CDC.cpp, but couldn't get it to work:

https://github.com/odbol/Arduino/tree/midi-fixserial (differences from this version: odbol/Arduino@midi...odbol:midi-fixserial)

Any advice or help would be much appreciated! If you'd like me to write a test sketch to show the problem, let me know.

Thanks so much for your help!

Tyler

@odbol
Copy link

odbol commented Nov 8, 2015

I've crafted a very simple test sketch to illustrate the problem:

https://github.com/odbol/Arduino-MIDI-Test-Sketch

When you run it on a Due, the LED should blink consistently. If MIDI is enabled in your Arduino Core, the LED stops blinking (until you launch a MIDI app that opens the MIDI port of the Arduino—then it works as expected).

@odbol
Copy link

odbol commented Nov 8, 2015

Just opened this as an issue on the new repo where this code is housed, since that's where we'd apply the fix: arduino-libraries/MIDIUSB#4

@odbol
Copy link

odbol commented Nov 9, 2015

I think I may have fixed this now: arduino-libraries/MIDIUSB#5

@gurbrinder
Copy link
Author

Tyler,

I am sorry I have not been responsive. I am currently in China for work.
Also I have switched my job to Apple and I don't work on Arduino anymore so
don't have hardware to test with.

Gary
On Mon, Nov 9, 2015 at 5:17 PM Tyler Freeman notifications@github.com
wrote:

I think I may have fixed this now: arduino-libraries/MIDIUSB#5
arduino-libraries/MIDIUSB#5


Reply to this email directly or view it on GitHub
#2943 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Architecture: SAM Applies only to the SAM microcontrollers (Due) Component: USB Device Opposed to USB Host. Related to the USB subsystem (SerialUSB, HID, ...) feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants