A modern C++ library for controlling the AKAI APC Mini MIDI controller. This library provides a complete interface for handling button inputs, LED control, and fader movements, making it perfect for creating custom light shows, MIDI applications, or integrating the APC Mini into your C++ projects.
- 🎛 Complete MIDI input/output management
- 💡 Full LED control (8x8 grid + round buttons)
- 🎚 Fader input support
- 🎨 Built-in light pattern animations
- 🔄 Asynchronous event handling
- 🧵 Thread-safe implementation
- 🎯 Easy-to-use callback system
- CMake 3.15 or higher
- C++17 compatible compiler
- RtMidi library (automatically fetched via CMake)
- Clone the repository:
git clone https://github.com/gastonmorixe/lib-midi-akai-apc-mini.git
cd lib-midi-akai-apc-mini
- Build the project:
make build
Or manually:
mkdir build
cd build
cmake ..
cmake --build .
Here's a simple example to get you started:
#include "apc_mini_controller.hpp"
#include <iostream>
int main() {
APCMiniController controller;
if (!controller.connect()) {
std::cerr << "Failed to connect to APC Mini" << std::endl;
return 1;
}
// Set up button callback
controller.setButtonCallback([](APCMiniController::ButtonType type, int note, bool isPressed) {
std::cout << "Button " << note << (isPressed ? " pressed" : " released") << std::endl;
});
// Set up fader callback
controller.setFaderCallback([](APCMiniController::Fader fader, int value) {
std::cout << "Fader " << static_cast<int>(fader) << " value: " << value << std::endl;
});
// Light up some LEDs
controller.setGridLED(0, APCMiniController::LedColor::GREEN);
controller.setHorizontalLED(APCMiniController::HorizontalButton::STOP_ALL,
APCMiniController::RoundLedState::ON);
// Keep the program running
std::cout << "Press Enter to exit..." << std::endl;
std::cin.get();
return 0;
}
The main class for interacting with the APC Mini controller.
// Control grid LEDs (8x8 matrix)
void setGridLED(int index, LedColor color);
// Available colors:
enum class LedColor {
OFF = 0,
GREEN = 1,
GREEN_BLINK = 2,
RED = 3,
RED_BLINK = 4,
YELLOW = 5,
YELLOW_BLINK = 6
};
// Control horizontal button LEDs (bottom row)
void setHorizontalLED(HorizontalButton button, RoundLedState state);
// Control vertical button LEDs (right column)
void setVerticalLED(VerticalButton button, RoundLedState state);
// LED states for round buttons:
enum class RoundLedState {
OFF,
ON,
BLINK
};
// Set button callback
void setButtonCallback(ButtonCallback callback);
// ButtonCallback = std::function<void(ButtonType type, int note, bool isPressed)>
// Set fader callback
void setFaderCallback(FaderCallback callback);
// FaderCallback = std::function<void(Fader fader, int value)>
enum class ButtonType {
GRID, // 8x8 matrix (0-63)
HORIZONTAL, // Bottom row (64-71)
VERTICAL, // Right column (82-89)
SPECIAL // Button 98
};
enum class HorizontalButton {
STOP_ALL = 64,
LEFT = 65,
RIGHT = 66,
UP = 67,
DOWN = 68,
VOLUME = 69,
PAN = 70,
SEND = 71
};
enum class VerticalButton {
SCENE_1 = 82,
SCENE_2 = 83,
SCENE_3 = 84,
SCENE_4 = 85,
SCENE_5 = 86,
SCENE_6 = 87,
SCENE_7 = 88,
SCENE_8 = 89
};
enum class Fader {
TRACK_1 = 48,
TRACK_2 = 49,
TRACK_3 = 50,
TRACK_4 = 51,
TRACK_5 = 52,
TRACK_6 = 53,
TRACK_7 = 54,
TRACK_8 = 55,
MASTER = 56
};
The library includes a LightPatternController
class that provides several pre-built light patterns:
- Snake Pattern (Button 64)
- Rainfall Pattern (Button 65)
- Color Wave (Button 66)
- Expanding Square (Button 67)
- Sparkle Pattern (Button 68)
- Checkerboard (Button 69)
- Spiral Pattern (Button 70)
- Binary Counter (Button 71)
To use the light patterns:
#include "light_pattern_controller.hpp"
APCMiniController controller;
LightPatternController patternController(controller);
// Start a pattern
patternController.startPattern(64); // Start snake pattern
// Stop current pattern
patternController.stopCurrentPattern();
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the BSD 2-Clause License - see the LICENSE file for details.
Gaston Morixe ([email protected])
- Built with RtMidi for MIDI communication
- Thanks to the AKAI Professional team for the APC Mini hardware specifications