{"action":"created","issue":{"url":"https://api.github.com/repos/FortySevenEffects/arduino_midi_library/issues/42","repository_url":"https://api.github.com/repos/FortySevenEffects/arduino_midi_library","labels_url":"https://api.github.com/repos/FortySevenEffects/arduino_midi_library/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/FortySevenEffects/arduino_midi_library/issues/42/comments","events_url":"https://api.github.com/repos/FortySevenEffects/arduino_midi_library/issues/42/events","html_url":"https://github.com/FortySevenEffects/arduino_midi_library/issues/42","id":149110275,"number":42,"title":"How to use pass MIDI pointer reference into a class?","user":{"login":"trevor-sonic","id":307560,"avatar_url":"https://avatars.githubusercontent.com/u/307560?v=3","gravatar_id":"","url":"https://api.github.com/users/trevor-sonic","html_url":"https://github.com/trevor-sonic","followers_url":"https://api.github.com/users/trevor-sonic/followers","following_url":"https://api.github.com/users/trevor-sonic/following{/other_user}","gists_url":"https://api.github.com/users/trevor-sonic/gists{/gist_id}","starred_url":"https://api.github.com/users/trevor-sonic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevor-sonic/subscriptions","organizations_url":"https://api.github.com/users/trevor-sonic/orgs","repos_url":"https://api.github.com/users/trevor-sonic/repos","events_url":"https://api.github.com/users/trevor-sonic/events{/privacy}","received_events_url":"https://api.github.com/users/trevor-sonic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-18T10:26:55Z","updated_at":"2016-04-21T01:30:59Z","closed_at":"2016-04-18T10:46:45Z","body":"Sorry for this question but I couldn't find anywhere any info about it.\r\nIf we want to use MIDI.sendNote in a class/lib we need to pass the instance and/or pointer to the class but I couldn't find any example about it. If it's wrong place please delete my message."},"comment":{"url":"https://api.github.com/repos/FortySevenEffects/arduino_midi_library/issues/comments/212683832","html_url":"https://github.com/FortySevenEffects/arduino_midi_library/issues/42#issuecomment-212683832","issue_url":"https://api.github.com/repos/FortySevenEffects/arduino_midi_library/issues/42","id":212683832,"user":{"login":"mink99","id":11485843,"avatar_url":"https://avatars.githubusercontent.com/u/11485843?v=3","gravatar_id":"","url":"https://api.github.com/users/mink99","html_url":"https://github.com/mink99","followers_url":"https://api.github.com/users/mink99/followers","following_url":"https://api.github.com/users/mink99/following{/other_user}","gists_url":"https://api.github.com/users/mink99/gists{/gist_id}","starred_url":"https://api.github.com/users/mink99/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mink99/subscriptions","organizations_url":"https://api.github.com/users/mink99/orgs","repos_url":"https://api.github.com/users/mink99/repos","events_url":"https://api.github.com/users/mink99/events{/privacy}","received_events_url":"https://api.github.com/users/mink99/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T01:30:59Z","updated_at":"2016-04-21T01:30:59Z","body":"Hi,\r\n\r\n\r\ntry this:\r\nthis is to create the midi interface as a **class member**\r\n```\r\n\r\n\r\n#include <MIDI.h>\r\nclass ThisClassHasAMidiPortAsMemberAndAFarTooLongName\r\n{\r\n  public:\r\n    ThisClassHasAMidiPortAsMemberAndAFarTooLongName() {}\r\n    void begin()\r\n    {\r\n      MIDI.begin(4);\r\n    }\r\n    \r\n  private:\r\n    midi::MidiInterface<HardwareSerial> MIDI = midi::MidiInterface<HardwareSerial>((HardwareSerial&)Serial1);\r\n};\r\n\r\nThisClassHasAMidiPortAsMemberAndAFarTooLongName a;\r\nvoid setup() \r\n{\r\n  a.begin();  // to enable MIDI.BEGIN\r\n}\r\nvoid loop() {\r\n  // put your main code here, to run repeatedly:\r\n}\r\n\r\n```\r\nthis is to create the midi interface **pointer as a class member**\r\n\r\n```\r\n#include <MIDI.h>\r\nMIDI_CREATE_DEFAULT_INSTANCE();\r\nclass ThisClassHasAMidiPortAsPointerAndAFarTooLongName\r\n{\r\n  public:\r\n    ThisClassHasAMidiPortAsPointerAndAFarTooLongName() {}\r\n    void begin(midi::MidiInterface<HardwareSerial> *pM)\r\n    {\r\n      pMIDI = pM;\r\n    }\r\n  private:\r\n    midi::MidiInterface<HardwareSerial> *pMIDI;\r\n};\r\nThisClassHasAMidiPortAsPointerAndAFarTooLongName a;\r\nvoid setup()\r\n{\r\n  MIDI.begin();\r\n  a.begin(&MIDI);\r\n \r\n}\r\nvoid loop() {\r\n}\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\nthere is a bug in the gcc compiler that will not let you use that macro MIDI_CREATE_DEFAULT_INSTANCE(); within a class declaration.\r\ntherefore you will have to explicitely call the constructor.\r\n\r\ntook me a while to find out, you owe me a beer....\r\n\r\nregards Kris\r\n\r\n\r\nsupported by ArtGenossen\r\nunderpowered by mink\r\n\r\n\r\n\r\nGesendet: Montag, 18. April 2016 um 12:26 Uhr\r\nVon: \"Trevor D. BEYDAG\" <notifications@github.com>\r\nAn: FortySevenEffects/arduino_midi_library <arduino_midi_library@noreply.github.com>\r\nBetreff: [FortySevenEffects/arduino_midi_library] How to use pass MIDI pointer reference into a class? (#42)\r\nSorry for this question but I couldn't find anywhere any info about it.\r\nIf we want to use MIDI.sendNote in a class/lib we need to pass the instance and/or pointer to the class but I couldn't find any example about it. If it's wrong place please delete my message.\r\n\r\n—\r\nYou are receiving this because you are subscribed to this thread.\r\nReply to this email directly or view it on GitHub\r\n"}}