0

Grand Central USB MIDI Controller in CircuitPython
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Grand Central USB MIDI Controller in CircuitPython

by vincerocker on Thu Mar 04, 2021 8:32 pm

Hi
As my first project with a microcontroller I'm having a go at https://learn.adafruit.com/grand-central-usb-midi-controller-in-circuitpython/overview
I've built a prototype board and successfully got the Grand Central working and running code. I'm using CircuitPython 6.1.0 and the matching library bundle downloaded today. However I'm having problems with the example code for this project. To get it to start running I had to add
Code: Select all | TOGGLE FULL SIZE
import usb_midi
and change the line which creates the midi object to
Code: Select all | TOGGLE FULL SIZE
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=5)
(I have other midi devices on channels 1 - 4.)
This now runs to almost the end of the code but I get an error (I'm using Mu) reported as "Traceback (most recent call last): File "code.py", line 85, in <module> AttributeError: 'MIDI' object has no attribute 'control_change'" In my version (with the edits above) lines 84 and 85 are 82 and 83 in the example code:
Code: Select all | TOGGLE FULL SIZE
for n in range(knob_count):
        midi.control_change(n, cc_value[n][0] + cc_range[n][0])

If I change these two lines to
Code: Select all | TOGGLE FULL SIZE
 for n in range(knob_count):
        print(n)
#        midi.control_change(n, cc_value[n][0] + cc_range[n][0])

then Mu shows that n loops from 0 to 15 as expected so I'm pretty sure the problem is in the line reported by the error message.
Can anyone reproduce this error or suggest a solution?
Cheers
EDIT BTW the Simple Test code at https://circuitpython.readthedocs.io/projects/midi/en/latest/examples.html works OK for me after adding in_channel=0 to line 14 - it plays the note in VCV Rack.
Code: Select all | TOGGLE FULL SIZE
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], in_channel=0, out_channel=0)

vincerocker
 
Posts: 4
Joined: Thu Mar 04, 2021 8:02 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by adafruit_support_carter on Thu Mar 04, 2021 9:15 pm

What was the issue you originally ran into when you tried running the code per the guide?

adafruit_support_carter
 
Posts: 21405
Joined: Tue Nov 29, 2016 2:45 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by vincerocker on Thu Mar 04, 2021 9:35 pm

Thanks adafruit_support_carter. The error message in Mu when I run the original code is

code.py output:
---Grand Central MIDI Knobs---
Traceback (most recent call last):
File "code.py", line 13, in <module>
File "adafruit_midi/__init__.py", line 66, in __init__
ValueError: No midi_in or midi_out provided

Fixed by
import usb_midi
and
midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], out_channel=5)
as in my post above.

vince

vincerocker
 
Posts: 4
Joined: Thu Mar 04, 2021 8:02 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by adafruit_support_carter on Thu Mar 04, 2021 9:53 pm

Thanks. We should take a look at the guide code and see if we can fix it. Seems like something is up with it. I'll pass this on.

adafruit_support_carter
 
Posts: 21405
Joined: Tue Nov 29, 2016 2:45 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by johnpark on Thu Mar 04, 2021 11:47 pm

Thanks for catching this, a number of things changed in adafruit_midi after this guide, so I'm going to go through and update the code to work with current versions.

johnpark
 
Posts: 894
Joined: Wed Mar 25, 2009 2:15 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by vincerocker on Fri Mar 05, 2021 11:24 am

Thanks for the rapid responses adafruit_support_carter and johnpark - it's good to know it's not just me!
Will you post here when the fixes are made? And do you have an idea of timescale? It's not a problem at all but if it's going to be weeks or months I'll look for another project for the board, now I've got it I want to play :-)
I'll have another poke about with this later and let you know if I get anywhere.

vince

vincerocker
 
Posts: 4
Joined: Thu Mar 04, 2021 8:02 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by johnpark on Fri Mar 05, 2021 11:44 am

Hi Vince, I should have this fixed and updated later today. I'll post here once it's done.
-John

johnpark
 
Posts: 894
Joined: Wed Mar 25, 2009 2:15 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by johnpark on Fri Mar 05, 2021 4:27 pm

Here's the updated code if you'd like to give it a whirl:
https://raw.githubusercontent.com/adafr ... I_Knobs.py

I also added the ability to assign each knob to a particular CC number and to send classic MIDI over the serial UART port if you want to solder on a MIDI jack or TRS jack.

johnpark
 
Posts: 894
Joined: Wed Mar 25, 2009 2:15 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by vincerocker on Fri Mar 05, 2021 7:16 pm

That works for me, johnpark. The "don't send if new value = old value" is a good addition and adding the ability to assign a cc for each knob is great too, I though I was going to have to work that out for myself :-)
Many thanks for your help.

vincerocker
 
Posts: 4
Joined: Thu Mar 04, 2021 8:02 pm

Re: Grand Central USB MIDI Controller in CircuitPython

by johnpark on Thu Sep 23, 2021 2:38 pm

You're welcome!

johnpark
 
Posts: 894
Joined: Wed Mar 25, 2009 2:15 pm

Please be positive and constructive with your questions and comments.