Trying to create a Midi pedalboard for Hauptwerk

As it says in the title, I've wired up a 32 note pedal board from a pipe organ to control the Hauptwerk virtual pipe organ software. The pedal board has 32 individual switches. The board is a Due, being used with native USB. I'm using digital pins 2-10 and 22-44.

Here's my sketch:

#include <Control_Surface.h>
#include <MIDIUSB.h>
#include <MIDIUSB_Defs.h>
#include <frequencyToNote.h>
#include <pitchToFrequency.h>
#include <pitchToNote.h>

USBMIDI_Interface pedals;

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t channel = 4; // MIDI channel 4


Digital buttons[] = {
  { 2, pitchC1, channel, velocity }, // button connected to pin 2, sends MIDI note C1 on channel 4 with velocity 127
  { 3, pitchD1b, channel, velocity },
  { 4, pitchD1, channel, velocity },
  { 5, pitchE1b, channel, velocity },
  { 6, pitchE1, channel, velocity },
  { 7, pitchF_1, channel, velocity },
  { 8, pitchG1b, channel, velocity },
  { 9, pitchG1, channel, velocity },
  {10, pitchA1b, channel, velocity },
  {22, pitchA1, channel, velocity },
  {23, pitchB1b, channel, velocity },
  {24, pitchB1, channel, velocity }
  {25, pitchC2, channel, velocity }, 
  {26, pitchD2b, channel, velocity },
  {27, pitchD2, channel, velocity },
  {28, pitchE2b, channel, velocity },
  {29, pitchE2, channel, velocity },
  {30, pitchF_2, channel, velocity },
  {31, pitchG2b, channel, velocity },
  {32, pitchG2, channel, velocity },
  {33, pitchA2b, channel, velocity },
  {34, pitchA2, channel, velocity },
  {35, pitchB2b, channel, velocity },
  {36, pitchB2, channel, velocity }
  {37, pitchC3, channel, velocity }, 
  {38, pitchD3b, channel, velocity },
  {39, pitchD3, channel, velocity },
  {40, pitchE3b, channel, velocity },
  {41, pitchE3, channel, velocity },
  {42, pitchF_3, channel, velocity },
  {43, pitchG3b, channel, velocity },
  {44, pitchG3, channel, velocity }
  
};

void setup() {
    Control_Surface.begin();
}
void loop() {  // Refresh the buttons (check whether a button's state has changed since last time, if so, send it over MIDI)
  Control_Surface.loop();

}

and the error I'm getting on compile is:

In file included from C:\Users\kurts\Documents\Arduino\libraries\Control_Surface_main\src/Display/Helpers/Bresenham.hpp:5:0,
                 from C:\Users\kurts\Documents\Arduino\libraries\Control_Surface_main\src/Display/MCU/VUDisplay.hpp:102,
                 from C:\Users\kurts\Documents\Arduino\libraries\Control_Surface_main\src/Control_Surface.h:25,
                 from C:\Users\kurts\Documents\Arduino\Pedalboard 32\Pedalboard 32.ino:1:
C:\Users\kurts\Documents\Arduino\libraries\Control_Surface_main\src/AH/STL/cmath:16:31: note: #pragma message: FMA math fix
 #pragma message("FMA math fix")
                               ^
C:\Users\kurts\Documents\Arduino\Pedalboard 32\Pedalboard 32.ino:14:1: error: 'Digital' does not name a type
 Digital buttons[] = {
 ^

exit status 1

Compilation error: 'Digital' does not name a type

A type name is required. Did you misspell 'Digital'?
Where and how is Digital declared?

Thanks for the reply. That's exactly the problem. I have tried several different ways of declaring it, each one returns an error message. The code is based on an example from PieterP using his control surface library.

please provide the link to the example

Here's the example I based it off of:

#include <MIDI_Controller.h> // Include the library

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t channel = 1; // MIDI channel 1

// Create an array of 14 new instances of the class 'Digital', called 'buttons', 
// on pins 0,1, ..., 13 that send MIDI messages with notes 
// 12, 13, ..., 25 on MIDI channel 1, with maximum velocity (127)
Digital buttons[] = {
  { 0, 12, channel, velocity }, // button connected to pin 0, sends MIDI note 12 on channel 1 with velocity 127
  { 1, 13, channel, velocity },
  { 2, 14, channel, velocity },
  { 3, 15, channel, velocity },
  { 4, 16, channel, velocity },
  { 5, 17, channel, velocity },
  { 6, 18, channel, velocity },
  { 7, 19, channel, velocity },
  { 8, 20, channel, velocity },
  { 9, 21, channel, velocity },
  {10, 22, channel, velocity },
  {11, 23, channel, velocity },
  {12, 24, channel, velocity },
  {13, 25, channel, velocity }
};

// Create an array of 6 new instances of the class 'Analog', called 'potentiometers', 
// on pins A0, A1, .., A5 that send MIDI CC messages with controller numbers 16, 17, ... 21
// on MIDI channel 1
Analog potentiometers[] = {
  { A0, 16, channel }, // potentiometer connected to pin A0, sends CC #16 on MIDI channel 1
  { A1, 17, channel },
  { A2, 18, channel },
  { A3, 19, channel },
  { A4, 20, channel },
  { A5, 21, channel },
};

void setup() {} // nothing to set up

void loop() {  // Refresh the buttons and potentiometers (check whether a button's state or a potentiometer's position has changed since last time, if so, send it over MIDI)
  MIDI_Controller.refresh();
}

which library you don't use in your code…

a7

Correct, I just added it. Just have a few more errors to eliminate now. I'll report back.

OK, now I get this. I have double and triple checked, I have no open brackets. What am I doing wrong?

1 Like

Posting an illegible picture of your error. Cut and paste that and get much more attention!

Post the code, too. We need the context.

a7

1 Like

Thanks for the input. If you click on the picture it brings up the full size photo. But, since you requested it, Here's the complete code:

#include <Control_Surface.h>

#include <MIDI_Controller.h>

//#include <MIDI.h>

#include <MIDIUSB.h>
//#include <MIDIUSB_Defs.h>
//#include <frequencyToNote.h>
//#include <pitchToFrequency.h>
#include <pitchToNote.h>

USBMIDI_Interface pedals;

const uint8_t velocity = 0b1111111; // Maximum velocity (0b1111111 = 0x7F = 127)
const uint8_t channel = 4; // MIDI channel 4


Digital buttons[] {
  { 2, pitchC1, channel, velocity }, // button connected to pin 2, sends MIDI note C1 on channel 4 with velocity 127
  { 3, pitchD1b, channel, velocity },
  { 4, pitchD1, channel, velocity },
  { 5, pitchE1b, channel, velocity },
  { 6, pitchE1, channel, velocity },
  { 7, pitchF1, channel, velocity },
  { 8, pitchG1b, channel, velocity },
  { 9, pitchG1, channel, velocity },
  {10, pitchA1b, channel, velocity },
  {22, pitchA1, channel, velocity },
  {23, pitchB1b, channel, velocity },
  {24, pitchB1, channel, velocity },
  {25, pitchC2, channel, velocity }, 
  {26, pitchD2b, channel, velocity },
  {27, pitchD2, channel, velocity },
  {28, pitchE2b, channel, velocity },
  {29, pitchE2, channel, velocity },
  {30, pitchF2, channel, velocity },
  {31, pitchG2b, channel, velocity },
  {32, pitchG2, channel, velocity },
  {33, pitchA2b, channel, velocity },
  {34, pitchA2, channel, velocity },
  {35, pitchB2b, channel, velocity },
  {36, pitchB2, channel, velocity },
  {37, pitchC3, channel, velocity }, 
  {38, pitchD3b, channel, velocity },
  {39, pitchD3, channel, velocity },
  {40, pitchE3b, channel, velocity },
  {41, pitchE3, channel, velocity },
  {42, pitchF3, channel, velocity },
  {43, pitchG3b, channel, velocity },
  {44, pitchG3, channel, velocity }
  
}
 
void setup() { Control_Surface.begin(); }
void loop() { Control_Surface.loop(); }

and error message:

C:\Users\kurts\Documents\Arduino\Pedalboard 32\Pedalboard 32.ino:56:39: error: expected '}' at end of input
void loop() { Control_Surface.loop(); }
                                      ^
C:\Users\kurts\Documents\Arduino\Pedalboard 32\Pedalboard 32.ino:56:39: error: expected unqualified-id at end of input

exit status 1

Compilation error: expected '}' at end of input

You omitted semicolon after the Digital buttons[] structure definition.

Then you have a corrupt library that misses a closing bracket.

I have abandoned this sketch and written another which works perfectly. Thanks everyone for all the help and suggestions

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.