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

  • Home
  • SEARCH
  • 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 3791666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:30:16+00:00 2026-05-19T12:30:16+00:00

I am using a track to play my noteOn/noteOff events and everything works as

  • 0

I am using a track to play my noteOn/noteOff events and everything works as intended, the problem I am having is that I would like to change the instruments that is being used within the track.

I’ve come up with the following code which is designed invoke the “program change” command on all the MIDI channels with the new instrument, the problem I am having is working out how to apply this to the track so the instruments is different.

public void LoadInstrument()
{
    for(int i = 0; i < instruments.length; i++)
    {
        if(instruments[i].getName() == "Clean Guitar")
        {
            instrumentToLoad = instruments[i];
        }
    }

    drumPatch = instrumentToLoad.getPatch();
}

I’ve seen that you can send the Track a PROGRAM_CHANGE event to signify the instrument is changing but I’m not sure how to go about creating the object to hold the necessary information and adding it to the Track.
Many 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-19T12:30:17+00:00Added an answer on May 19, 2026 at 12:30 pm

    After doing a little more digging around I’ve found the solution:

             try
            {
                 ShortMessage instrumentChange = new ShortMessage();
    
                 instrumentChange.setMessage(ShortMessage.PROGRAM_CHANGE, 0, 6,0);
    
                 //MidiEvent instrumentChange = new MidiEvent(ShortMessage.PROGRAM_CHANGE,drumPatch.getBank(),drumPatch.getProgram());
                 track.add(new MidiEvent(instrumentChange,0));
            }
            catch(Exception e)
            {
                //Handle
            }
    

    Note: The “6” parameter in the .setMessage method is the number of the instrument to play.

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

Sidebar

Related Questions

I have a xml web service which I would like to track using Google
I'm using the SimpleAudioEngine for cocos2d and when one track finished I would like
I'm using counterCache to track the number of chapters that have been posted to
I have a bunch of Thingy objects that I'm keeping track of using long
I would like to track the last position of a media item (song or
I have made a simple play/pause button that works in conjunction with the audio
I'm using JavaZoom's mp3spi-1.9.5 and jl-1.0.1 to play MP3 files. This works fine, but
We are using Tasks to track individual development items and the out of the
We are using Subversion to keep track of our code. As part of the
I am using Google Adwords to push and track subscriber acquisitions on my site,

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.