Grand Central USB MIDI Controller in CircuitPython

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
vincerocker
 
Posts: 4
Joined: Thu Mar 04, 2021 8:02 pm

Grand Central USB MIDI Controller in CircuitPython

Post by vincerocker »

Hi
As my first project with a microcontroller I'm having a go at https://learn.adafruit.com/grand-centra ... n/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

import usb_midi
and change the line which creates the midi object to

Code: Select all

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

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

 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/pr ... amples.html works OK for me after adding in_channel=0 to line 14 - it plays the note in VCV Rack.

Code: Select all

midi = adafruit_midi.MIDI(midi_out=usb_midi.ports[1], in_channel=0, out_channel=0)

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: Grand Central USB MIDI Controller in CircuitPython

Post by adafruit_support_carter »

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

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

Re: Grand Central USB MIDI Controller in CircuitPython

Post by vincerocker »

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

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: Grand Central USB MIDI Controller in CircuitPython

Post by adafruit_support_carter »

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.

User avatar
johnpark
 
Posts: 985
Joined: Wed Mar 25, 2009 2:15 pm

Re: Grand Central USB MIDI Controller in CircuitPython

Post by johnpark »

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.

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

Re: Grand Central USB MIDI Controller in CircuitPython

Post by vincerocker »

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

User avatar
johnpark
 
Posts: 985
Joined: Wed Mar 25, 2009 2:15 pm

Re: Grand Central USB MIDI Controller in CircuitPython

Post by johnpark »

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

User avatar
johnpark
 
Posts: 985
Joined: Wed Mar 25, 2009 2:15 pm

Re: Grand Central USB MIDI Controller in CircuitPython

Post by johnpark »

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.

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

Re: Grand Central USB MIDI Controller in CircuitPython

Post by vincerocker »

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.

User avatar
johnpark
 
Posts: 985
Joined: Wed Mar 25, 2009 2:15 pm

Re: Grand Central USB MIDI Controller in CircuitPython

Post by johnpark »

You're welcome!

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”