Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(usbmidi): use channel in int16_t USB MIDI pitch bend #11795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Copy link
Contributor

@Skyslycer Skyslycer commented Sep 3, 2025

Description of Change

This pull request fixes a small oversight in the USBMIDI pitch bend implementation:
There are three overloaded pitch bend functions for three different types of data: uint16_t, int16_t and double.
The actual implementation is located within the function accepting a uint16_t as the value parameter, while the other two simply convert the given data to match a uint16_t. However, the channel value, which should be passed along to the main function with the actual pitch bend implementation is ignored and unused in the int16_t function.

Functions

 // Pitch Bend Change [-8192,0,8191]
 void pitchBend(int16_t pitchBendValue, uint8_t channel = 1); // this one does not pass the channel value along
 // Pitch Bend Change [0,8192,16383]
 void pitchBend(uint16_t pitchBendValue, uint8_t channel = 1);
 // Pitch Bend Change [-1.0,0,1.0]
 void pitchBend(double pitchBendValue, uint8_t channel = 1);

I have confirmed this with the following minimal example on an ESP32 S3:

#include <Arduino.h>
#include <USB.h>
#include <USBMIDI.h>
USBMIDI MIDI;
void setup() {
 USB.begin();
 MIDI.begin();
}
void loop() {
 int16_t v = 0;
 while (true) {
 MIDI.pitchBend(v, 4); // channel 4
 if (++v >= 8191) v = -8191;
 delay(2);
 }
}

Probing this MIDI output with aseqdump shows, that the pitch bend values are being sent on channel 1 (the tool shows it as 0) instead of the specified channel 4:

 32:0 Pitch bend 0, value -6981
 32:0 Pitch bend 0, value -6980
 32:0 Pitch bend 0, value -6979
 32:0 Pitch bend 0, value -6978

This pull request aims to fix this slight oversight.

Test Scenarios

I have tested my changes on both a LOLIN S3 Mini and a full size ESP32 S3, but I otherwise don't have any USB-native ESPs. The test consists of the same code above being ran. On both devices aseqdump displayed the correct channel 4 (the tool shows it as 3):

 32:0 Pitch bend 3, value 2444
 32:0 Pitch bend 3, value 2445
 32:0 Pitch bend 3, value 2446
 32:0 Pitch bend 3, value 2447

Related links

I have just encountered this issue myself. I have not found an open issue matching this pull request.

lyusupov reacted with thumbs up emoji
Copy link

CLAassistant commented Sep 3, 2025
edited
Loading

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

github-actions bot commented Sep 3, 2025
edited
Loading

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello Skyslycer, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 0da3b04

Copy link
Contributor

github-actions bot commented Sep 4, 2025
edited
Loading

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32P4000.000.00000.000.00
ESP32S3000.000.00000.000.00
ESP32S2000.000.00000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32P4ESP32S3ESP32S2
ExampleFLASHRAMFLASHRAMFLASHRAM
libraries/USB/examples/MIDI/MidiController000000
libraries/USB/examples/MIDI/MidiInterface000000
libraries/USB/examples/MIDI/MidiMusicBox000000
libraries/USB/examples/MIDI/ReceiveMidi000000

Copy link
Contributor

github-actions bot commented Sep 4, 2025
edited
Loading

Test Results

76 files 76 suites 15m 7s ⏱️
38 tests 38 ✅ 0 💤 0 ❌
241 runs 241 ✅ 0 💤 0 ❌

Results for commit 0da3b04.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@SuGlider SuGlider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@me-no-dev me-no-dev merged commit 0dbaa3f into espressif:master Sep 4, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@me-no-dev me-no-dev me-no-dev approved these changes

@lucasssvaz lucasssvaz lucasssvaz approved these changes

@SuGlider SuGlider SuGlider approved these changes

@P-R-O-C-H-Y P-R-O-C-H-Y P-R-O-C-H-Y approved these changes

Assignees
No one assigned
Labels
Area: Peripherals API Relates to peripheral's APIs. Status: Pending Merge Pull Request is ready to be merged
Projects
Milestone
3.3.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /