arduino-libraries/MIDIUSB

Warnings when compiling example sketches

lorenzopetralia opened this issue · 3 comments

Hi, since today i'm getting weird error in the controlChange sendnote functions.

Compiling does not work anymore, I've even tried your read MIDI example from this github.. Reinstalled all libraries. Nothing seem to work.

C:\Users\i4studio\Documents\Arduino\MIDI READ EXAMPLE GIHUB\MIDI READ EXAMPLE GIHUB.ino: In function 'void noteOn(byte, byte, byte)':
C:\Users\i4studio\Documents\Arduino\MIDI READ EXAMPLE GIHUB\MIDI READ EXAMPLE GIHUB.ino:19:42: warning: narrowing conversion of '(int)(144 | ((unsigned char)((int)channel)))' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
                                     ~~~~~^~~~~~~~~
C:\Users\i4studio\Documents\Arduino\MIDI READ EXAMPLE GIHUB\MIDI READ EXAMPLE GIHUB.ino: In function 'void noteOff(byte, byte, byte)':
C:\Users\i4studio\Documents\Arduino\MIDI READ EXAMPLE GIHUB\MIDI READ EXAMPLE GIHUB.ino:24:43: warning: narrowing conversion of '(int)(128 | ((unsigned char)((int)channel)))' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
                                      ~~~~~^~~~~~~~~
C:\Users\i4studio\Documents\Arduino\MIDI READ EXAMPLE GIHUB\MIDI READ EXAMPLE GIHUB.ino: In function 'void controlChange(byte, byte, byte)':
C:\Users\i4studio\Documents\Arduino\MIDI READ EXAMPLE GIHUB\MIDI READ EXAMPLE GIHUB.ino:38:41: warning: narrowing conversion of '(int)(176 | ((unsigned char)((int)channel)))' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
   midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
                                    ~~~~~^~~~~~~~~
Sketch uses 4908 bytes (17%) of program storage space. Maximum is 28672 bytes.
Global variables use 457 bytes (17%) of dynamic memory, leaving 2103 bytes for local variables. Maximum is 2560 bytes.

Hi @lorenzopetralia. It is important to understand the difference between warnings and errors. A warning is the compiler telling you there is something in the code that could possibly cause a problem but doesn't cause the compilation to fail. An error is a problem with the code that causes compilation to fail. In this case you have posted warnings, not errors.

Compiling does not work anymore

This is incorrect. The output you shared shows a successful compilation. So you can get back to progressing with your project. If you require any assistance working on your project or fixing the warnings in your sketch code, you can post on the Arduino Forum:

https://forum.arduino.cc/c/using-arduino/audio/24

I'm sure we will be able to help you out over there.

Closing as duplicate of #91