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 8856981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:29:00+00:00 2026-06-14T14:29:00+00:00

I’m attempting to editing the pitch of existing midi notes in a sequence by

  • 0

I’m attempting to editing the pitch of existing midi notes in a sequence by moving the graphical notes (rectangles) in a piano roll editor up or down. Reading over the APIs and online documents, it doesn’t get very specific on how to edit existing notes. From the best I can tell, I need to use the setMessage() method to overwrite the existing ShortMessage. Here’s what I’ve got right now:

public void changePitch(int pitchUpOrDown) {
    MidiMessage message =  this.getMessage();
    message.setMessage(___?, ____?, ____? + pitchUpOrDown, ____?);
}

I’m calling changePitch() from a JPanel by mouse-dragging a note, and I’m sending either +1 or –1 as the increment by which the pitch will be adjusted. What I can’t find is the values that need to go in the other four blank parameters of the setMessage() call. Logically, I want to keep the existing values for command, channel and timestamp, but how do I access these existing values so that I can put them in the blanks? I’ve tried things like message.command, or message[0], etc. but they don’t work. Also, in the documentation, the args for set Message are shown as (byte[] data, int length). The explanation for these args is really vague, and they definitely don’t match the args I used to create the ShortMessage in the first place. Any suggestions?

  • 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-06-14T14:29:01+00:00Added an answer on June 14, 2026 at 2:29 pm

    Cast the MidiMessage down to ShortMessage and then you can get the pitch and velocity as data1 and data2:

    if (message instanceof ShortMessage) {
        ShortMessage shortMessage = (ShortMessage) message;
    
        if(shortMessage.getCommand() == ShortMessage.NOTE_ON) {
            int channel = shortMessage.getChannel();
            int pitch = shortMessage.getData1();
            int vel = shortMessage.getData2();
            if(vel > 0) {
                shortMessage.setMessage(ShortMessage.NOTE_ON, channel, pitch + pitchUpOrDown, vel);
            }
        }
    }
    

    You might need to change the next NOTE_OFF message as well. This will either be a shortMessage with a NOTE_OFF command, or a NOTE_ON command with a velocity of 0.

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

Sidebar

Related Questions

I am editing already existing code, which is why this question is formed as
I am attempting to provide a mechanism for editing entries in an observable array.
I am attempting to write a batch file for editing the hosts file. I
Attempting to dive in to Kohana and I'm reading the Unofficial 3.0 Kohana wiki
I'm attempting to dynamically load a select box's options based on some existing criteria
I'm attempting to write my own WYSWG text editor in Javascript, but I'm struggling
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Attempting to get Spring internationalization working. I have used classpath:messages basename, created .properties files
Attempting to set up an automated texting service for customers, where people can text
Attempting to use the data series from this example no longer passes the JSONLint

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.