Go Down

Topic: 'NoteOn' was not declared in scope (Read 1 time) previous topic - next topic

taro

I'm not good at writing English. Please forgive me.
I want to use midi library in MIDI.getType(),
I wrote sorce and compile, But compilation error has occurred,
I want if send NoteOn(tap sampler) ,display note number,

This is sorce,
Code: [Select]

#include <LiquidCrystal.h>
#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>

#define PEDAL_MARGIN 64
#define AD_CONVERTER 14
#define INPUT_MIDI_CH 10


MIDI_CREATE_DEFAULT_INSTANCE();
int switchPins[] = {1, 2, 3 , 0}; //アナログpin
int pedalPins[] = {5, 6, 7, 8};//デジタルpin

////////////////////////////
//5, 6, 7, 8, 1, 2, 3, 0,pin//
//1, 2, 3, 4, 5, 6, 7, 0,port//
///////////////////////////

void setup() {
  Serial.begin(9600);// 9600bpsでシリアルポートを開く
  MIDI.begin();
  //アナログpin設定
  //デジタルpinとして認識させる
  for (int i = 0; i < sizeof(switchPins); i++) {
    pinMode(switchPins[i] + AD_CONVERTER, INPUT); // ピンを入力に設定
    digitalWrite(switchPins[i] + AD_CONVERTER, HIGH); // プルアップ抵抗を有効に
  }

  //デジタルpinを設定
  for (int i = 0; i < sizeof(pedalPins); i++) {
    pinMode(pedalPins[i], INPUT); // ピンを入力に設定
    digitalWrite(pedalPins[i], HIGH); // プルアップ抵抗を有効に
  }
}

void loop() {
  uint8_t data1, data2;
  if (MIDI.read()) {
    MIDI.setInputChannel(INPUT_MIDI_CH);   //読み込むチャンネルを設定
    switch (MIDI.getType()) {
      case NoteOn : //鍵盤を押す   ←this
        data1 = MIDI.getData1(); // ノートNo.(音階)
        Serial.print(data1);
    }
  }


  //参考url
  //midiinout,http://ichirowo.com/2011/05/arduino-midi-library/
  //make,http://qiita.com/emahub/items/8209b5606934ab60cc6f



exit status 1
'NoteOn' was not declared in this scope



Please teach me the reason for the error. m(_ _)m

Grumpy_Mike

#1
Aug 11, 2016, 06:59 am Last Edit: Aug 11, 2016, 07:08 am by Grumpy_Mike
Quote
exit status 1
'NoteOn' was not declared in this scope
That is not the error message I get.

It says there is an error compiling it for a Uno, or Mega. What type of Arduino are you trying to use?

Anyway try:-
Code: [Select]
case midi::NoteOn:

taro

I use the UNO.
I made it!!!
Thank you!

I use only java once.
How use I that switch sentence in C(?) ?

Grumpy_Mike

Quote
How use I that switch sentence in C(?) ?
I don't understand, this code is C++

el_supremo

I think there may be two MIDI libraries here. There is one here which has the files and syntax being used by @taro but I suspect that the IDE is trying to use the standard MIDI library.
To use the FortySevenEffects library, I think you would have to move the distributed MIDI library somewhere where the IDE can't see it.

Pete
Don't send me technical questions via Private Message.

Go Up