Cov txheej txheem:

MIDI Drum Kit ntawm Python thiab Arduino: 5 Kauj Ruam (nrog Duab)
MIDI Drum Kit ntawm Python thiab Arduino: 5 Kauj Ruam (nrog Duab)

Video: MIDI Drum Kit ntawm Python thiab Arduino: 5 Kauj Ruam (nrog Duab)

Video: MIDI Drum Kit ntawm Python thiab Arduino: 5 Kauj Ruam (nrog Duab)
Video: How to separate drum kontakt in cubase (kev cais koos ntawm kontakt hauv cubase) 2024, Hlis ntuj nqeg
Anonim
Image
Image
MIDI Drum Kit ntawm Python thiab Arduino
MIDI Drum Kit ntawm Python thiab Arduino
MIDI Drum Kit ntawm Python thiab Arduino
MIDI Drum Kit ntawm Python thiab Arduino

Kuv ib txwm xav yuav cov khoom siv nruas txij thaum kuv tseem yog menyuam yaus. Rov qab los, tag nrho cov cuab yeej siv suab paj nruag tsis muaj txhua daim ntawv thov digital raws li peb muaj ntau niaj hnub no, yog li tus nqi nrog rau kev cia siab tau siab dhau. Tsis ntev los no kuv tau txiav txim siab yuav cov khoom siv nruas uas pheej yig tshaj los ntawm eBay, nrog qhov muaj feem thib ib: Muaj peev xwm rhuav nws thiab muab kuv tus kheej kho vajtse thiab software tso rau hauv lub cuab yeej.

Kev yuav khoom tsis muaj kev poob siab hlo li: Cov khoom siv txav mus los nruas nruas nrog 9 lub suab sib txawv, ob txhais taw hloov pedals rau ncaws nruas thiab lub kaus mom thiab lub micro-USB lub qhov (socket). Dab tsi yog demotivating tiag tiag, nws yog lub suab tso tawm (Kev siv tiag rau cov khoom siv no yog txuas rau tus neeg hais lus sab nraud thiab txaus siab rau nws). Yog li, kuv txiav txim siab hloov nws mus rau kuv tus kheej programmable ntawm USB, MIDI nruas cov khoom siv raws Arduino thiab Tus Neeg Siv Kev Sib Tham raws li Python, rau kev siv yooj yim thiab hloov pauv yooj yim xws li, ntim, nco thiab xaiv channel.

Nta ntawm lub cuab yeej:

  • Tus nqi qis
  • Tsim cov khoom siv nruas los ntawm txhua qhov kev nkag mus digital - txawm tias muaj cov khawm thawb
  • Kev txhawb nqa kev sib txuas lus thiab lub zog siv ntawm USB interface nkaus xwb - Kev koom ua ke ntawm USB rau UART hloov pauv thiab Arduino ntaus ntawv
  • Mininum qhov rau kev ua haujlwm kom raug
  • Ib qho yooj yim-rau-siv Python raws UI
  • Ua tiav MIDI kev txhawb nqa nrog kev hloov kho nrawm, nco thiab Arduino pins
  • Txuag & Thauj khoom nruas teeb tsa kev teeb tsa cia hauv lub cuab yeej 'nco

Cia peb mus rau qhov project …

Kauj Ruam 1: Txoj Kev Ua Haujlwm

Txoj Kev Ua Haujlwm
Txoj Kev Ua Haujlwm
Txoj Kev Ua Haujlwm
Txoj Kev Ua Haujlwm
Txoj Kev Ua Haujlwm
Txoj Kev Ua Haujlwm

Thaiv daim duab

Ua ntej tshaj plaws, cia peb tsom mus rau cov phiaj xwm phiaj xwm, thiab faib nws mus rau hauv cov cais cais:

Roll-Up Drum Kit

Lub hauv paus tseem ceeb ntawm txoj haujlwm. Nws suav nrog 9 lub nruas sib cais, qhov twg txhua lub ncoo yog kab ntawm cov nyees khawm uas hloov lawv lub xeev kev xav thaum raug ntaus. Vim tias nws cov qauv, muaj peev xwm tsim cov khoom siv tshwj xeeb nruas no los ntawm txhua lub laub khawm. Txhua lub nruas ncoo tau txuas nrog rub tawm ntawm cov khoom siv hluav taws xob tseem ceeb, yog li thaum lub nruas ncoo raug ntaus ntau zaus, qhov kev hloov pauv tshwj xeeb tau txuas rau hauv Circuit Court hauv av thiab muaj qhov LOW muaj nyob ntawm kab nruas kab. Thaum tsis muaj kev thov siab, lub nruas ncoo hloov tau qhib thiab vim rub tawm tus neeg tawm tsam mus rau kab hluav taws xob, qhov laj thawj HIGH nyob ntawm kab nruas ncoo kab. Vim tias lub hom phiaj ntawm txoj haujlwm yog txhawm rau ua kom tiav cov cuab yeej MIDI digital, txhua qhov sib piv ntawm lub PCB tseem ceeb tuaj yeem tsis quav ntsej. Nws yog ib qho tseem ceeb uas yuav tsum tau ceeb toom, cov khoom siv nruas muaj ob lub pedals rau ncaws nruas thiab lub kaus mom, uas tseem tau khi rau qhov rub tawm cov neeg tawm tsam thiab sib koom ua haujlwm tib lub tswv yim raws li txhua lub nruas tas (Peb yuav tham txog nws me ntsis tom qab)).

Arduino Pro-Micro Cov

Lub paj hlwb ntawm cov khoom siv nruas. Nws lub hom phiaj yog txhawm rau txheeb xyuas seb puas muaj lub teeb liab tawm los ntawm lub nruas ncoo thiab muab qhov tsim nyog MIDI tso tawm nrog rau txhua qhov tsis tsim nyog: Nco tseg, tshaj tawm thiab lub sijhawm teeb liab. Vim tias cov xwm txheej ntawm cov nruas pawm, lawv tuaj yeem yooj yim khi rau arduino cov tswv yim digital (10 pins tag nrho). Txhawm rau khaws txhua qhov kev xav tau thiab cov ntaub ntawv MIDI, peb yuav siv nws lub cim xeeb-EEPROM, yog li txhua lub sijhawm peb siv lub zog ntaus ntawv, MIDI cov ntaub ntawv raug thauj los ntawm EEPROM, ua rau nws rov tsim tau thiab rov teeb tsa tau. Tsis tas li, Arduino Pro-Micro muaj nyob hauv pob me me thiab tuaj yeem faib tau yooj yim hauv cov khoom siv nruas sab hauv.

FTDI USB Rau Serial Converter

Txhawm rau ua haujlwm thiab txheeb xyuas peb cov cuab yeej tshwj xeeb nrog kev pab ntawm PC daim ntawv thov, yuav tsum tau hloov pauv USB interface rau ntu, vim tias Arduino Pro-Micro tsis muaj USB. Txij li kev sib txuas lus nruab nrab ntawm cov cuab yeej siv raws li UART, FTDI cov cuab yeej siv hauv txoj haujlwm no, vim nws yooj yim ntawm kev siv tsis hais nws cov khoom ntxiv.

Daim Ntawv Thov PC - Python

Thaum nws los txog rau kev txhim kho cov neeg siv cuam tshuam thiab kev tsim kho kom nrawm, Python yog qhov kev daws teeb meem zoo. Lub hom phiaj ntawm UI daim ntawv thov yog ua kom nws yooj yim dua los txhais cov MIDI cov khoom rau peb cov khoom siv nruas, khaws cov ntaub ntawv, cov cuab yeej siv thiab ua kev sib txuas lus ntawm cov kab ke yam tsis tas yuav suav cov lej ntau dua. Vim tias peb tab tom siv cov lej sib tham los sib txuas lus nrog cov khoom siv nruas, muaj ntau qhov pub dawb pub dawb thoob plaws hauv is taws nem, uas txhawb nqa txhua hom kev sib txuas lus. Ib qho ntxiv, raws li nws yuav tham tom qab, UART interface muaj tag nrho ntawm peb tus pin: RXD, TXD thiab DTR. DTR tau siv los ua qhov pib dua ntawm Arduino module, yog li thaum peb txaus siab ua haujlwm MIDI app lossis txuas UI rau cov cuab yeej siv, tsis muaj qhov xav tau txuas dua USB cable lossis ib qho twg.

Kauj Ruam 2: Qhov Chaw thiab Cov Ntsuas

Qhov

  • Roll-Up Drum Kit
  • 2 x Soj Ntsuam Pedals (Feem ntau, suav nrog hauv DK pob).
  • FTDI - USB rau Serial Converter
  • Arduino Pro Micro Cov
  • Micro-USB Cable

Ntsuas

  • Soldering Hlau/Chaw Nres Tsheb
  • Soldering Tin
  • Nyias Txoj Kab Ib Leeg Tub Ntxhais hlau
  • Tweezers
  • Cutter
  • Plier
  • Riam
  • Ntsia Hlau Tsav
  • 3D Tshuab Luam Ntawv (Tsis teb los tau - rau kev kho lub tsheb kauj vab)

Software

  • Arduino IDE Cov
  • Nab hab sej 3 lossis siab dua
  • JetBrains Pycharm
  • Tsis muaj plaub hau MIDI interface
  • loopMIDI

Kauj Ruam 3: Soldering thiab Assembly

Soldering thiab Assembly
Soldering thiab Assembly
Soldering thiab Assembly
Soldering thiab Assembly
Soldering thiab Assembly
Soldering thiab Assembly

Txij li muaj peb tus qauv uas yuav tsum tau sib koom ua ke, cov txheej txheem sib dhos thiab sib dhos yog luv thiab yooj yim:

  • Txuas ua ke Arduino Pro-Micro nrog FTDI cov cuab yeej, nco ntsoov tias kev sib txuas ua raws I/O txhais ntawm txhua lub cuab yeej:

    • VBUS-VBUS
    • GND-GND
    • DTR-DTR
    • RXD-TXD
    • TXD-RXD
  • Tshem tag nrho cov ntsia hlau los ntawm lub nruas yas ntim khoom, xyuas kom tseeb tias koj tuaj yeem tsom mus rau kab ntawv-rau-board cable, thiab nws cov khoom tiv thaiv rub tawm
  • Cov kab hluav taws xob nyias nyias rau Arduino-FTDI module uas peb tau tsim yav dhau los:

    • Cov tswv yim digital: D [2:11]
    • VBUS
    • D+
    • D-
    • GND
  • Ntxig tus qauv sab hauv lub roj teeb kom cov xov hlau yuav ntab rau ntawm ib sab ib yam li rub tawm cov khoom tiv thaiv
  • Siv tag nrho cov tswv yim digital rau lub nruas ncoo qhov kawg raws li nws tau qhia hauv daim duab kawg.
  • Solder micro-USB npav (VBUS, D+, D-, GND) rau FTDI ntaus ntawv, xyuas kom tseeb tias tsis muaj qhov yuam kev taug cov xov hlau no.
  • Txuas Arduino-FTDI module nrog cov kua nplaum kub rau lub roj teeb
  • Sib dhos cov cuab yeej nrog cov ntsia hlau tsim nyog

Peb tau ua tiav nws, cov cuab yeej sib sau ua ke. Cia peb txuas ntxiv mus rau cov cai…

Kauj Ruam 4: Programming A: Arduino

Programming A: Arduino
Programming A: Arduino

Cia Piav qhia peb cov duab kos ib qib zuj zus:

Ua ntej tshaj plaws, yuav tsum muaj ob lub tsev qiv ntawv tsim nyog rau kev ua haujlwm kom raug. EEPROM twb tau teeb tsa ua ntej hauv Arduino IDE, tab sis qhov debouncer module rau ncaws nruas yuav tsum tau teeb tsa cais

#ncig #ncig

Cov keyboards no yog siv feem ntau hauv kev debugging ntu. Yog tias koj xav sim tawm Arduino lub davhlau ya nyob twg txuas rau lub nruas tas, thiab txiav txim siab txhua qhov kev siv digital, cov hloov pauv no yuav tsum tau txhais

/ * Hloov Chaw Tsim Kho: Tsis pom zoo yam xav tau rau kev debugging lossis pib ua * ///#txhais LOAD_DEFAULT_VALUES // Thauj khoom qhov tseem ceeb hloov ntawm EEPROM //#txhais PRINT_PADS_PIN_NUMBERS // Luam tus lej tus lej uas txuas nrog lub ncoo uas raug ntaus ntawm chaw nres nkoj

Cov teb tsis tu ncua sawv cev rau txhua qhov txiaj ntsig yav dhau los, suav nrog lub nruas pad enumeration. Txhawm rau khiav cov cuab yeej thawj zaug, yuav tsum paub paub qhov sib txuas ntawm Hi-Hat thiab Kick pedals

/ * Ntaus hom nruas */

enum DRUM_POSITION {KICK = 0, SNARE, HIHAT, RIDE, CYMBAL1, CYMBAL2, TOM_HIGH, TOM_MID, TOM_LO, HIHAT_PEDAL};

/ * Default values */

const uint8_t DRUM_NOTES [10] = {36, 40, 42, 51, 49, 55, 47, 45, 43, 48}; const uint8_t DRUM_VELOCITIES [10] = {110, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110, 110}; const uint8_t DRUM_PINS [10] = {8, 6, 4, 3, 11, 9, 5, 10, 2, 7};

/ * Ncua lub sijhawm ncua debounce */

const uint8_t KICK_DB_DURATION = 30;

EEPROM yog siv los khaws/thauj tag nrho cov ntaub ntawv los ntawm daim ntawv thov PC. Cov chaw nyob tau piav qhia saum toj no, qhia meej qhov chaw rau MIDI cov ntaub ntawv rau txhua lub nruas ncoo

/* EEPROM Chaw nyob qhia

Sau ntawv: | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 |

Pins: | 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13 | Tshaj tawm | 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23 | */ const uint8_t NOTES_ADDR = 0x00; const uint8_t VELOCITIES_ADDR = 0x14; const uint8_t PINS_ADDR = 0x0A;

Kev hloov pauv thoob ntiaj teb tau siv los txiav txim siab txhua lub ncoo lub xeev, thiab ua MIDI kev sib txuas lus kom haum

/ * Ntiaj teb Variables */

uint8_t drumNotes [10], drumVelocities [10], drumPins [10]; // MIDI Variables

uint8_t uartBuffer [64]; // UART Tsis rau sau thiab khaws cia MIDI Cov Ntaub Ntawv Debouncer ncaws (DRUM_PINS [KICK], KICK_DB_DURATION); // Debouncer kwv rau ncaws nruas volatile bool yav dhau los State [9] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Nruas ncoo yav dhau los lub xeev cov ntaub ntawv hloov pauv bool currentState [9] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Drum pad tam sim no lub xeev cov laj thawj

EEPROM Cov Haujlwm

/* Khw teeb tsa hauv EEPROM*/

void storeEEPROM () {

memcpy (nruasNotes, uartBuffer, 10); memcpy (drumPins, uartBuffer + 10, 10); memcpy (nruasVelocities, uartBuffer + 20, 10); rau (uint8_t i = 0; i <10; i ++) EEPROM.write (NOTES_ADDR+i, drumNotes ); rau (uint8_t i = 0; i <10; i ++) EEPROM.write (PINS_ADDR+i, drumPins ); rau (uint8_t i = 0; i <10; i ++) EEPROM.write (VELOCITIES_ADDR+i, drumVelocities ); }

/* Thauj chaw los ntawm EEPROM*/

void loadEEPROM () {rau (uint8_t i = 0; i <10; i ++) drumNotes = EEPROM.read (NOTES_ADDR+i); rau (uint8_t i = 0; i <10; i ++) drumPins = EEPROM.read (PINS_ADDR+i); rau (uint8_t i = 0; i <10; i ++) drumVelocities = EEPROM.read (VELOCITIES_ADDR+i); }

Kev pib ua haujlwm ntawm cov kev hloov pauv thiab hom kev ua haujlwm, thaum cov pedals thiab Arduino khau raj tau qhib ua haujlwm ib txhij

void enterProgrammingMode () {

bool confirmBreak = tsis tseeb; uint8_t lineCnt = 0; uint8_t charCnt = 0; char readChar = 0; thaum (! confirmBreak) {yog (Serial.available ()) {uartBuffer [charCnt] = Serial.read (); yog (charCnt> = 29) confirmBreak = muaj tseeb; lwm charCnt ++; }} Serial.println ("OK"); khwEEPROM (); }

void initValues () {

#ifdef LOAD_DEFAULT_VALUES memcpy (nruasNotes, DRUM_NOTES, 10); memcpy (drumVelocities, DRUM_VELOCITIES, 10); memcpy (drumPins, DRUM_PINS, 10); #else loadEEPROM (); #endif}

MIDI Kev sib txuas lus cov neeg lis haujlwm nrog ncua ntawm 1ms nco tseg sijhawm

/ * Ua si MIDI nco ua haujlwm */

void midiOut (enum DRUM_POSITION drumIn) {

yog tias (drumIn == HIHAT) {// Yog HI-HAT raug ntaus, yuav tsum tau ua qhov kev kuaj xyuas seb tus pedal raug nias yog (! digitalRead (drumPins [HIHAT_PEDAL])) {noteOn (0x90, drumNotes [HIHAT_PEDAL], drumVelocities [HIHAT_PEDAL]); ncua (1); noteOn (0x90, drumNotes [HIHAT_PEDAL], 0); } lwm {noteOn (0x90, drumNotes [HIHAT], drumVelocities [HIHAT]); ncua (1); noteOn (0x90, drumNotes [HIHAT], 0); }} lwm yam {// Cov nruas tsis tu ncua MIDI kis tau tus mob sau (0x90, drumNotes [drumIn], drumVelocities [drumIn]); ncua (1); noteOn (0x90, drumNotes [drumIn], 0); }}

void noteOn (int cmd, int pitch, int velocity) {Serial.write (cmd); Serial.write (suab); Serial.write (tshaj tawm); }

teeb tsa () thiab lub voj () ua haujlwm nrog cov cuab yeej ua haujlwm tsis muaj qhov kawg:

void teeb tsa () {

Serial.begin (115200);

rau (uint8_t i = 0; i <10; i ++) {pinMode (i+2, INPUT); } #ifdef PRINT_PADS_PIN_NUMBERS thaum (tseeb) {// Infinite debug loop rau (uint8_t i = 0; i <10; i ++) {if (! digitalRead (i+2)) {Serial.print ("Pin No: D"); Serial.print (kuv + '0'); // Hloov tus lej rau ASCII cim}}} #else initValues (); / * Hom phiaj hom phiaj: Yog tias ob tus pedals raug nias thaum qhib - hom tau qhib */ yog (! DigitalRead (drumPins [KICK]) &&! DigitalRead (drumPins [HIHAT_PEDAL])) enterProgrammingMode (); #endif}

void loop () {rau (uint8_t i = 1; i <9; i = i + 1) {currentState = digitalRead (drumPins ); yog (! currentState && previousState ) midiOut (i); // Sib piv cov xeev thiab kuaj pom ntug ntog yav dhau los = currentState ; } ncaws.update (); // Ntaus nruas siv kev cai debounce algorithm yog (kick.edge ()) yog (kick.falling ()) midiOut (KICK); }

Kauj Ruam 5: Programming B: Python & User Interface

Programming B: Python & Tus Neeg Siv Kev Sib Tham
Programming B: Python & Tus Neeg Siv Kev Sib Tham
Programming B: Python & Tus Neeg Siv Kev Sib Tham
Programming B: Python & Tus Neeg Siv Kev Sib Tham
Programming B: Python & Tus Neeg Siv Kev Sib Tham
Programming B: Python & Tus Neeg Siv Kev Sib Tham

Python User Interface yog qhov nyuaj me ntsis kom nkag siab thaum pom thawj zaug, yog li peb yuav sim piav qhia nws cov hauv paus, yuav siv li cas, ua haujlwm li cas txhua lub pob muaj thiab yuav ua li cas rau program Arduino ntaus ntawv kom raug.

Neeg siv interface - Daim ntawv thov

UI yog cov duab sawv cev rau peb cov khoom siv nruas, ua rau nws yooj yim siv thiab yooj yim rau program Arduino ntaus ntawv txhua lub sijhawm. UI suav nrog ntau qhov qauv duab uas txuas rau lawv cov haujlwm uas tau hais qhia. cia peb tshuaj xyuas lawv ib tus zuj zus:

  1. Nruas Teeb Duab: Python UI siv X-Y duab ua haujlwm los txiav txim seb hom nruas twg raug xaiv. Yog tias siv tau thaj tsam nruas raug xaiv, IO cov lus qhia thib ob tshwm sim, nrog cov lus ceeb toom, tshaj tawm thiab Arduino lub davhlau ya nyob twg rau nruas nruas ncoo. Tom qab cov kev ntsuas no tau txheeb xyuas los ntawm tus neeg siv thiab pom zoo, cov txiaj ntsig no tuaj yeem xa ncaj qha mus rau Arduino ntaus ntawv.
  2. Cov Duab Sab Nraud Sab Nraud: Txhawm rau siv tau MIDI cov khoom siv nruas nrog VST/Suab paj nruag tsim ib puag ncig, yuav tsum muaj tus txhais lus Serial-To-MIDI. Kuv tau siv Hairless, uas muaj pub dawb thiab tuaj yeem khiav ncaj qha los ntawm peb UI, tsuas yog nias nws cov duab.
  3. COM Port List: Txhawm rau sib txuas lus nrog Arduino, yuav tsum tau hais kom meej nws txuas nrog COM chaw nres nkoj. Cov npe tau rov ua dua tshiab los ntawm nias lub khawm Refresh.
  4. Load/Save Configuration: Muaj qhov default MIDI qhov tseem ceeb tau hais tseg hauv txoj cai, uas tuaj yeem hloov kho los ntawm tus neeg siv los ntawm kev cuam tshuam nrog UI. Kev teeb tsa tau piav qhia hauv cov ntawv config.txt hauv hom tshwj xeeb, uas tuaj yeem khaws lossis thauj khoom los ntawm tus neeg siv.
  5. Khawm Ntaus Ntawv: Txhawm rau khaws txhua qhov hloov pauv MIDI qhov tseem ceeb hauv Arduino EEPROM, yuav tsum tau nias ob txhais ko taw (Kick nruas thiab Hi-hat pedal) tom qab ntawd, tos kom xa cov ntaub ntawv kom tiav. Yog tias muaj teeb meem kev sib txuas lus, qhov tshwm sim zoo yuav tshwm. Yog tias kis tau zoo, UI yuav qhia nws cov lus ua tiav.
  6. Khawm Tawm: Tsuas yog tawm daim ntawv thov, nrog rau tus neeg siv kev tso cai.

Python Code Cov ntsiab lus tseem ceeb

Muaj ntau yam tshwm sim hauv txoj cai, yog li peb yuav nthuav dav ntawm cov ntawv sau ua haujlwm ntau dua li ntawm tag nrho cov cai.

Ua ntej tshaj plaws, txhawm rau siv UI, yuav tsum rub tawm ob peb lub qauv, txhawm rau ua txoj haujlwm:

ntshuam osimport threading ntshuam tkinter li tk los ntawm tkinter ntshuam xov ntawm tkinter ntshuam * los ntawm PIL ntshuam ImageTk, Duab ntshuam numpy li np ntshuam ntshuam ntshuam thoob ntiaj teb

Qee qhov qauv tau suav nrog hauv pob Python vim. Ntau qhov qauv yuav tsum tau teeb tsa ntawm PIP cov cuab yeej:

pip nruab hauv ncoo

pip nruab numpy pip nruab ScreenInfo

Nws tau pom zoo kom khiav daim ntawv thov los ntawm PyCharm. Hauv kev tshaj tawm yav tom ntej, Kuv tab tom npaj xa tawm qhov ua tiav rau txoj haujlwm.

Kev piav qhia luv Code

Nws yuav yooj yim dua rau nkag siab cov cai yog tias peb yuav saib nws cov kab los ntawm kev xav ntawm cov haujlwm thiab chav kawm:

1. Lub luag haujlwm tseem ceeb - ntawm no pib txoj cai

yog _name_ == '_main_': drumkit_gui ()

2. Nruas Cov Khoom Siv tsis tu ncua, tswj hwm thiab tsis paub meej MIDI cov ntaub ntawv

chav Drums: DRUM_TYPES = ["Kick", "Hihat", "Snare", "Crash 1", "Crash 2", "Tom High", "Tom Mid", "Tom Low", "Caij", "Hihat Pedal" "," Tus Tswj "]

COORDINATES_X = [323, 117, 205, 173, 565, 271, 386, 488, 487, 135, 79]

COORDINATES_Y = [268, 115, 192, 40, 29, 107, 104, 190, 71, 408, 208] DIMS_WIDTH = [60, 145, 130, 120, 120, 70, 70, 130, 120, 70, 145] DIMS_LENGTH = [60, 60, 80, 35, 35, 40, 40, 70, 35, 100, 50]

DRUM_ENUM = ["Kick", "Snare", "Hihat", "Caij", "Crash 1", "Crash 2", "Tom High", "Tom Mid", "Tom Low", "Hihat Pedal"]

DRUM_NOTES = [36, 40, 42, 51, 49, 55, 47, 45, 43, 48] DRUM_VELOCITIES = [110, 100, 100, 110, 110, 110, 110, 110, 110, 110, 110] DRUM_PINS = [8, 6, 4, 3, 11, 9, 5, 10, 2, 7]

3. UI Ua Haujlwm - Ua haujlwm ntawm cov neeg siv interface thiab khoom siv duab

def set_active (ua)

def secondary_ui (drum_type)

Class SelectionUi (tk. Frame)

Daim ntawv thov chav kawm (tk. Frame)

def drumkit_gui ()

def event_ui_click (xwm txheej)

def getorigin (tus kheej, xwm txheej)

4. Kev sib txuas lus sib txuas

def tau_serial_ports ()

def sib tham_with_arduino (chaw nres nkoj)

5. Ua haujlwm nrog cov ntaub ntawv: Khaws/Thauj khoom nqis los ntawm cov ntawv txt

def txuag_config ()

def load_config () cov

6. Khiav lwm daim ntawv thov hairless.exe los ntawm txoj cai siv Python Threading peev xwm

chav kawm Sab nrauvExecutableThread (threading. Thread)

def run_hairless_executable ()

Txhawm rau kom ua txoj cai, muaj cov npe ntawm cov ntaub ntawv uas yuav tsum tau muab txuas nrog rau qhov project nplaub tshev:

  • config.txt: Cov ntaub ntawv teeb tsa
  • hairless.exe: Hairless MIDI converter
  • drumkit.png: Duab uas piav qhia txhua qhov nyem tau nruas los ntawm peb tus UI (Yuav tsum rub tawm los ntawm cov kauj ruam no 'teeb duab)
  • drumgui.py: Txoj haujlwm txoj cai

Nov yog txhua yam peb xav tau los hais kom ua haujlwm. Nws yog ib qho tseem ceeb heev los ntxiv cov ntaub ntawv rau txoj haujlwm: nruas teeb duab, hairless.exe ua tiav thiab teeb tsa cov ntaub ntawv config.txt.

Thiab.. Ntawm no peb tau ua tiav!:)

Vam tias koj yuav pom cov ntawv qhia no muaj txiaj ntsig.

Ua tsaug rau kev nyeem ntawv!:)

Pom zoo: