{"id":22689161,"url":"https://github.com/flokapi/pymikro","last_synced_at":"2025-04-12T21:52:38.821Z","repository":{"id":181792075,"uuid":"667302643","full_name":"flokapi/pymikro","owner":"flokapi","description":"Python API for Maschine Mikro MK3","archived":false,"fork":false,"pushed_at":"2024-12-02T20:21:51.000Z","size":414,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T21:52:35.101Z","etag":null,"topics":["driver","maschine"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flokapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-17T07:47:42.000Z","updated_at":"2025-03-30T01:17:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"6da01580-8efb-4739-871c-dcc2998ab722","html_url":"https://github.com/flokapi/pymikro","commit_stats":null,"previous_names":["flokapi/pymikro"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flokapi%2Fpymikro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flokapi%2Fpymikro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flokapi%2Fpymikro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flokapi%2Fpymikro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flokapi","download_url":"https://codeload.github.com/flokapi/pymikro/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637834,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["driver","maschine"],"created_at":"2024-12-10T00:17:51.356Z","updated_at":"2025-04-12T21:52:38.802Z","avatar_url":"https://github.com/flokapi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pymikro\n\nPython module to control the Maschine Mikro MK3. It allows you to use this\nmaschine not only to create music, but also to control a home automation or a\nrobot or any other creative stuff.\n\nIt uses directly the USB HID protocol, as a result there is no dependency on a\nproduct specific driver and it can run on any operating system. Furthermore,\nthis gives you access to the full capabilities of this hardware which makes it\neven more fun to use.\n\n## Usage\n\n```python\nimport pymikro\n\nmaschine = pymikro.MaschineMikroMk3()\n\n# control LEDs\nlState = {\n    'button': {\n        'stop': {'val': 1}\n    },\n    'strip': {\n        1: {'val': 3, 'color': 'blue'}\n    },\n    'pad': {\n        1: {'val': 3, 'color': 'purple'}\n    }\n}\nmaschine.lights.set_all(lState)\n\nmaschine.lights.set('pad', 6, 3, 'orange')\nmaschine.lights.set('strip', 5, 3, 'green')\nmaschine.lights.set('button', 'notes', 4)\nmaschine.lights.update()\n\n# control screen\nmaschine.screen.set(\"Hello World!\\nIt's working\")\n\n# get button and pad updates\nwhile True:\n    cmd = maschine.read_cmd()\n    if cmd:\n        if cmd['cmd'] == 'pad':\n            print('Pad number {} pressed: {}'.format(cmd['pad_nb'], cmd['pad_val']))\n        if cmd['cmd'] == 'btn':\n            print('Buttons pressed: {}'.format(cmd['btn_pressed']))\n```\n\n## Setup\n\n### Linux\n\nInstall the hid driver\n\n```bash\nsudo apt-get install libhidapi-hidraw0\n```\n\nInstall the package\n\n```bash\npip3 install pymikro\n```\n\nSet permissions for the device\n\n```bash\ncd /tmp\nwget https://raw.githubusercontent.com/flokapi/pymikro/main/50-ni-maschine.rules\nsudo cp 50-ni-maschine.rules /etc/udev/rules.d/\n```\n\nPlug or re-plug the maschine mikro USB cable.\n\n### Windows\n\nInstall the hid driver:\n\n1. Donwload the latest version of `hidapi-win.zip` from\n   \u003chttps://github.com/libusb/hidapi/releases\u003e\n\n2. Extract the zip file and copy the `hidapi.dll` corresponding to your\n   architecture to `C:\\Users\\\u003cUsername\u003e\\AppData\\Local\\Programs\\Python`\n\nInstall the package\n\n```bash\npip3 install pymikro\n```\n\nPlug or re-plug the maschine mikro USB cable.\n\n## About\n\n### Supported hardware features\n\nOverall, there is actually more feature than the manufacturer uses :)\n\nPads:\n\n- Set color (17 possible values) and intensity\n- Get pressure value\n- Info whether pressed, touched, or released\n\nButtons:\n\n- get buttons being pressed\n- set light brightness\n\nEncoder:\n\n- get value of the encoder (1 byte), and how much it moved\n- whether it's being touched (not pressed)\n\nTouch strip:\n\n- get position of up to 2 fingers\n- set color and brightness of each LED\n\nScreen:\n\n- set text with adjustable size, on 1 or 2 lines\n\n### Supported operating systems\n\nTested on Linux \u0026 Windows\n\nShould also work on OSX by installing the hid api. See\n\u003chttps://pypi.org/project/hid/\u003e\n\n### API\n\n#### Connection\n\n```python\nimport pymikro\n\nmaschine = pymikro.MaschineMikroMk3()\nmaschine.hid.show_info()\n```\n\n#### Inputs\n\nLEDs:\n\n- The state of the LEDs for the pads/touch strip/buttons is defined in a single\n  data-structure which can be accessed and modified using the `lights.get_all`\n  and `lights.set_all` methods. The LEDs can also be set individually using\n  `lights.set`.\n\n- To apply the changes, `lights.update` must be called. Using a separate command\n  allows to apply all the changes in a single write procedure (about 15ms) and\n  increases the reactivity.\n\n- Example:\n\n  ```python\n  maschine.lights.set_all({})                         # set empty dictionary to disable all LEDs\n  maschine.lights.update()\n\n  time.sleep(1)\n\n  lState = {\n      'button': {\n          'stop': {'val': 1}                     # Button brighness value must be between 0\n      },\n      'strip': {\n          1: {'val': 4, 'color': 'blue'}         # Touch Strip LED brightness value must be between 0 and 3\n      },\n      'pad': {\n          1: {'val': 3, 'color': 'purple'}       # Pad brightness value must be between 0 and 3\n      }\n  }\n  maschine.lights.set_all(lState)\n\n  maschine.lights.set('pad', 6, 3, 'orange')       # pad nb 6, brightness 3.\n  maschine.lights.set('strip', 5, 3, 'green')      # strip led nb 5, brightness 3.\n  maschine.lights.set('button', 'notes', 4)        # button 'notes', brightness 4.\n  maschine.lights.update()\n  ```\n\nScreen\n\n- Example\n\n  ```python\n  maschine.screen.set(\"Hello\", 24)                       # Font size set to 24\n\n  maschine.screen.set(f\"Hello World!\\nIt's working\")     # Printing text on both lines with '\\n'.\n                                                        # Default font size is 14\n  ```\n\n#### Outputs\n\nOutput commands can be read in a non-blocking way using the `read_cmd` method,\nwhich returns:\n\n- `None` if no new command is available\n- A dictionary which content differs depending on the `cmd` key value (`btn` or\n  `pad`)\n- Example: `cmd = maschine.read_cmd()`\n\nPads\n\n- The pad command is only sent when the state of a pad is being changed\n  (pressed/touched/released). The pad command is sent for a single pad at the\n  time.\n\n- Example\n\n  ```python\n  {\n      'cmd': 'pad',\n      'pad_nb': 5,\n      'pad_val': 1360,                                 # between 0 and 4095\n      'touched': True,                                 # finger in contact with the pad\n      'pressed': False,                                # finger just pressed the pad (not 100% reliable)\n      'released': False                                # finger just released the pad (not 100% reliable)\n  }\n  ```\n\nButtons:\n\n- The button command is only sent when the state of the buttons/touch\n  strip/encoder changed (including button release). The command contains the\n  full state of the button group.\n\n- Example\n\n  ```python\n  {\n      'cmd': 'btn',\n      'btn_pressed': ['group', 'pattern', 'enter'],   # currently pressed buttons\n      'encoder_pos': 10,                              # byte, cyclic value between 0 and 15\n      'encoder_move': 1,                              # encoded moved to the right (+1) or left (-1)\n      'encoder_touched': True,                        # finger in contact with the encoder\n      'strip_pos_1': 123,                             # value of the strip if one finger touching\n      'strip_pos_2': 0                                # second value if another finger is on the strip\n  }\n  ```\n\n### Alternatives\n\n[maschine-mikro-mk3-driver](https://github.com/r00tman/maschine-mikro-mk3-driver)\n\n- Built for Linux only\n- Makes the Maschine Mikro available through a midi interface\n- Coded in Rust\n\nMidi mode\n\n- Windows/OSX only (midi interface emulated by the driver)\n\n- press `shift` and `project` to enter midi mode\n- you can use [mido](https://pypi.org/project/mido/) or any other software to\n  handle the midi commands\n- limited features/customization\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflokapi%2Fpymikro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflokapi%2Fpymikro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflokapi%2Fpymikro/lists"}