Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:32:21+00:00 2026-05-28T00:32:21+00:00

After laying out some ideas in Processing, I’ve decided to move my MIDI project

  • 0

After laying out some ideas in Processing, I’ve decided to move my MIDI project to C++ for portability to an embedded platform. I’ve decided to use the RtMidi library for MIDI I/O but I’m having some troubles laying out the code how I want it. I’m not great with C++ yet.

Basically, I want to pass the RtMidiIn object and RtMidiOut object to my printMidiPorts function (the code is the same as some example code bundled with RtMidi). I understand that it has something to do with initializing the midiin and midiout as pointers, but I’m not totally sure.

This is my code:

#include <stdio.h>
#include <iostream>
#include <string>
#include "rtmidi/RtMidi.h"

using namespace std;

void printMidiPorts(RtMidiIn midiin, RtMidiOut midiout)
{
    // Check inputs.
    unsigned int nPorts = midiin->getPortCount();
    std::cout << "\nThere are " << nPorts << " MIDI input sources available.\n";
    std::string portName;
    for ( unsigned int i=0; i<nPorts; i++ ) {
        try {
            portName = midiin->getPortName(i);
        }
        catch ( RtError &error ) {
            error.printMessage();
            goto cleanup;
        }
        std::cout << "  Input Port #" << i+1 << ": " << portName << '\n';
    }

    // Check outputs.
    nPorts = midiout->getPortCount();
    std::cout << "\nThere are " << nPorts << " MIDI output ports available.\n";
    for ( unsigned int i=0; i<nPorts; i++ ) {
        try {
            portName = midiout->getPortName(i);
        }
        catch (RtError &error) {
            error.printMessage();
            goto cleanup;
        }
        std::cout << "  Output Port #" << i+1 << ": " << portName << '\n';
    }
    std::cout << '\n';

    // Clean up
    cleanup:
    delete midiin;
    delete midiout;

}

int main ()
{

    RtMidiIn  *midiin = 0;
    RtMidiOut *midiout = 0;

    // RtMidiIn constructor
    try {
        midiin = new RtMidiIn();
    }
    catch ( RtError &error ) {
        error.printMessage();
        exit( EXIT_FAILURE );
    }

    // RtMidiOut constructor
    try {
        midiout = new RtMidiOut();
    }
    catch ( RtError &error ) {
        error.printMessage();
        exit( EXIT_FAILURE );
    }

    printMidiPorts(midiin, midiout);

    return 0;
}

And this is my compiler output:

    lightArray.cpp: In function ‘void printMidiPorts(RtMidiIn, RtMidiOut)’:
    lightArray.cpp:19: error: base operand of ‘->’ has non-pointer type ‘RtMidiIn’
    lightArray.cpp:24: error: base operand of ‘->’ has non-pointer type ‘RtMidiIn’
    lightArray.cpp:34: error: base operand of ‘->’ has non-pointer type ‘RtMidiOut’
    lightArray.cpp:38: error: base operand of ‘->’ has non-pointer type ‘RtMidiOut’
    lightArray.cpp:50: error: type ‘class RtMidiIn’ argument given to ‘delete’, expected pointer
    lightArray.cpp:51: error: type ‘class RtMidiOut’ argument given to ‘delete’, expected pointer
    lightArray.cpp: In function ‘int main()’:
    lightArray.cpp:79: error: conversion from ‘RtMidiIn*’ to non-scalar type ‘RtMidiIn’ req

Any help is much appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:32:22+00:00Added an answer on May 28, 2026 at 12:32 am

    It looks like in the main function, midiin and midiout are of types RtMidiIn* and RtMidiOut* (pointers to objects), while the parameters to printMidiPorts are of types RtMidiIn and RtMidiOut (objects). It looks like all you need to do is change the signature for printMidiPorts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After laying out my schema diagram in SQL Server (both 2000 and 2005), I
After the suggestion to use a library for my ajax needs I am going
After installing VS2008, the platform builder mod, and the WM7 aku, VS usually prompts
I've got a standard RelativeLayout laying out my Button s and TextArea s. What
What is the correct way to use CMAttitude:multiplyByInverseOfAttitude? Assuming an iOS5 device laying flat
After working with a lot of GD recently (for some fairly large scale projects
I was developing a web page, where I was laying out a board for
After nearly 10 hours of searching and trying different things I couldn't figure out,
I have been laying out a GUI uing ASP.NET and find I am confused
In my project I have a page which contains 5 image buttons laying horizantally.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.