# Touchscreen MIDI Controller: Creating MidiInputs and MidiOutputs

**URL:** <https://forum.juce.com/t/touchscreen-midi-controller-creating-midiinputs-and-midioutputs/23512>\
**Category:** General JUCE discussion\
**Created:** [July 28, 2017, 4:18pm UTC](https://forum.juce.com/t/touchscreen-midi-controller-creating-midiinputs-and-midioutputs/23512 "2017-07-28T16:18:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathantcrawford](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jonathantcrawford/32/1933_2.png) [@jonathantcrawford](https://forum.juce.com/u/jonathantcrawford)\
**Post date:** [July 28, 2017, 4:18pm UTC](https://forum.juce.com/t/touchscreen-midi-controller-creating-midiinputs-and-midioutputs/23512/1 "2017-07-28T16:18:03Z")

</div>

I am trying to develop a launchpad midi controller app in Xcode, but I am having trouble with properly setting up the midi connections.

```
class Foo : public MidiInputCallback
{
public:
    Foo()
    {
        midiIn = MidiInput::createNewDevice ("Foo Input", this);
        midiIn->start();
    }

    ~Foo()
    {
        midiIn->stop();
    }

    void handleIncomingMidiMessage (MidiInput *source, const MidiMessage &message) override
    {
    }

private:
    ScopedPointer<MidiInput> midiIn;
}

```

I get a Core MIDI error regardless of where I run it. Does my class also need to inherit from the AudioProcessor class? Or maybe include an AudioDeviceManager member?

I just need the MidiInput and MidiOutput to be recognized by other applications.

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [July 28, 2017, 4:39pm UTC](https://forum.juce.com/t/touchscreen-midi-controller-creating-midiinputs-and-midioutputs/23512/2 "2017-07-28T16:39:04Z")

</div>

Did your project include the module that has the MidiInput class in it?

I could be mistaken, but I believe you need an AudioDeviceManager instance as well.

---

<div class="post-metadata">

**Author:** ![jonathantcrawford](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jonathantcrawford/32/1933_2.png) [@jonathantcrawford](https://forum.juce.com/u/jonathantcrawford)\
**Post date:** [July 28, 2017, 5:04pm UTC](https://forum.juce.com/t/touchscreen-midi-controller-creating-midiinputs-and-midioutputs/23512/3 "2017-07-28T17:04:12Z")

</div>

Should my Foo class inherit from the AudioDeviceManager class or just include one as a private member?

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [July 28, 2017, 5:05pm UTC](https://forum.juce.com/t/touchscreen-midi-controller-creating-midiinputs-and-midioutputs/23512/4 "2017-07-28T17:05:26Z")

</div>

include one.

Also, post your error message.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [July 28, 2017, 8:16pm UTC](https://forum.juce.com/t/touchscreen-midi-controller-creating-midiinputs-and-midioutputs/23512/5 "2017-07-28T20:16:51Z")

</div>

> [@matkatmusic](#):
>
> include one.

Sorry to correct you:

1. It is the module juce\_audio\_devices. The DeviceManager is not needed. You can use the static methods [MidiInput::openDevice()](https://juce.com/doc/classMidiInput#ae7bb7e3f91dfe6bda7bce3e13a3efa8e) et al. instead. The AudioDeviceManager is for AudioDevices (surprise)
2. include is not needed. If you have added the module and created the project with the projucer, the line `#include "../JuceLibraryCode/JuceHeader.h"` in each cpp file includes all available juce classes.

So matkatmusic is right, no point in guessing without the error message.

EDIT: ok, double-checked, AudioDeviceManager provides stuff for Midi, but it should work without… sorry for the naughty comment… 😉 The AudioDeviceManager is intended to save and restore user settings like which device was selected etc afaik.

A thought that occurred to me, maybe the startMidi doesn’t like, that the constructor of the MidiInputCallback is not finished? Maybe try that after the constructor… but it is a shot in the blue…
