项目作者: eeyrw

项目描述 :
高级语言: C++
项目地址: git://github.com/eeyrw/midi-to-hex.git
创建时间: 2018-01-21T04:57:11Z
项目社区:https://github.com/eeyrw/midi-to-hex

开源协议:GNU General Public License v3.0

下载


Building midi-to-hex

The midi-to-hex is written with C++ and uses cmake as build tool. The bootloader software inside requires libusb-1.0. Following examples explain the detail building steps in different O.S.

Windows

  1. Install mingw64 and cmake (Do it by yourself…) .
  2. Open a shell ( I use powershell ) and locate it at the root directory of project and input cmake -G "MinGW Makefiles" . (DO NOT MISS THE DOT IN THE END) and press Enter.
  3. If everything goes well… You can start to build and input mingw32-make.exe -j5 and press Enter. You may see the ouput from cmake such as [100%] Built target midi-to-hex (which means that you have built the midi-to-hex successfully) or a lot of error info…

    Mac

    1. I installed Xcode and brew to get Apple Clang and libusb-1.0 and cmake.
    2. Open a terminal emulator and locate it at the root directory of project and input cmake . (DO NOT MISS THE DOT IN THE END) and press Enter.
    3. If everything goes well… You can start to build and input make -j5 and press Enter. You may see the output from cmake such as [100%] Built target midi-to-hex (which means that you have built the midi-to-hex successfully) or a lot of error info…

      Linux

  4. Install libusb-1.0 and cmake by apt-get ( maybe other tool )…
  5. Open a terminal emulator and locate it at the root directory of project and input cmake . ( A Linux user definitely never misses the DOT. ) .
  6. If everything goes well… You can start to build and input make -j5 and press Enter. You may see the ouput from cmake such as [100%] Built target midi-to-hex (which means that you have built the midi-to-hex successfully) or a lot of error info…

Usage of midi-to-hex

The midi-to-hex is a command line tool. Here is an example of usage:

  1. PS F:\Users\yuan\Desktop\midi-to-hex> .\midi-to-hex.exe -m .\midi-sample\twinkle.mid -d --device t167
  2. Song duration: 8 s
  3. Note pitch v.s. occur times table:
  4. +--------------------------------------+
  5. | Note pitch| Occur times| Is in range|
  6. +--------------------------------------+
  7. | 3:C| 2| YES|
  8. | 3:F| 1| YES|
  9. | 3:G| 1| YES|
  10. | 3:A| 1| YES|
  11. | 3:B| 1| YES|
  12. | 4:C| 5| YES|
  13. | 4:D| 1| YES|
  14. | 4:E| 2| YES|
  15. | 4:F| 1| YES|
  16. | 5:C| 3| YES|
  17. | 5:D| 2| YES|
  18. | 5:E| 2| YES|
  19. | 5:F| 2| YES|
  20. | 5:G| 3| YES|
  21. | 5:A| 2| YES|
  22. | Fine| 1| NO|
  23. +--------------------------------------+
  24. Highest pitch: 5:A
  25. Lowest pitch: 3:C
  26. Transpose suggestion: 0 half note
  27. Mem size: 46b
  28. Generate hex file for ATTINY 167.
  29. Download target.hex to mcu through micronucleus bootloader.
  30. Please ensure the mcu device is under bootloader mode (usally by re-pluging usb or reseting mcu).
  31. > Please plug in the device ...
  32. > Press CTRL+C to terminate the program.

You can plug in your music-box to PC at the moment and something will happen like this:

  1. > Device is found!
  2. waiting: 20% complete
  3. > Device has firmware version 2.2
  4. > Device signature: 0x1e9487
  5. > Available space for user applications: 14842 bytes
  6. > Suggested sleep time between sending pages: 5ms
  7. > Whole page count: 116 page size: 128
  8. > Erase function sleep duration: 580ms
  9. parsing: 40% complete
  10. parsing: 60% complete
  11. > Erasing the memory ...
  12. erasing: 65% complete
  13. erasing: 70% complete
  14. erasing: 75% complete
  15. erasing: 80% complete
  16. > Starting to upload ...
  17. writing: 85% complete
  18. writing: 90% complete
  19. writing: 95% complete
  20. writing: 100% complete
  21. >> Micronucleus done. Thank you!

Then the firmware of music-box has been updated with your midi file.
There are some parameters that should be explain here:

-m or —midi : Specify midi file. This parameter is mandatory.

-t or —transpose : Specify a wanted transpose in half pitch. If you do not specify, the suggestion transpose calculated by midi-to-hex will be applied.

-d or —download: With this parameter means download hex file to music-box is required.

—device : Specify the mcu device used in your music-box. It only support t85 and t167 by now. The t85 will be default if without this parameter.

-scorelist or l: Specify a list file with midi files path.

Great Thanks to:

ELM-Chan : http://elm-chan.org/works/mxb/report.html

Who put forward the original idea about firmware and hardware of music box.

Stuart Cording : https://github.com/codinghead/Intel-HEX-Class

Who powered midi-to-hex with ability to access intel hex file.

Jenna Fox & Tim : https://github.com/micronucleus/micronucleus

Who created a robust bootloader for ATtiny MCU with V-USB.

Craig Stuart Sapp : https://github.com/craigsapp/midifile

Who powered midi-to-hex with ability to access midi file and he is so warmhearted and answer my question by a vivid example : )