{"id":681,"date":"2013-06-03T13:06:36","date_gmt":"2013-06-03T03:06:36","guid":{"rendered":"http:\/\/legoeng.local\/?p=681"},"modified":"2020-04-06T16:39:33","modified_gmt":"2020-04-06T06:39:33","slug":"musical-instruments-with-the-nxt","status":"publish","type":"post","link":"http:\/\/legoeng.local\/musical-instruments-with-the-nxt\/","title":{"rendered":"MIDI and the NXT"},"content":{"rendered":"
<\/a>In this article, we talk about how you can make your own digital musical instrument with the LEGO NXT and connect it to an iPad using MIDI.<\/p>\n You can design and build your own musical instrument with the NXT where the sensors act as the note control inputs – just like the keys on a piano or the strings on a guitar. By “playing” the sensors on your instrument, you can cause the NXT to interpret the input values as specific musical notes. These digital notes are sent out of the NXT in a special language, the MIDI protocol, designed specifically for electronic musical instruments. Speaking the standard digital music protocol means all you have to do is plug your NXT into a MIDI compatible synthesizer, such as the iPad, and voila! Instant digital music!<\/p>\n In traditional (acoustic) instruments, the musician uses the keys, strings, and other input devices to directly change how the instrument produces sound and, thus, plays different notes. In an electronic instrument, the musician still uses the input controls to dictate what notes to play, but this can be completely separate from the module that actually turns those digital notes into sound waves. In this way, the system has two parts: 1) the control instrument that the musician physically “plays”; and 2) the synthesizer that takes the instructions from the control instrument of what notes to produce and makes the audible noise (or hopefully, music!).<\/p>\n Today, we are focusing on just the control instrument – which is your LEGO NXT creation. The synthesizer can be any device with a speaker that understands MIDI. We used the Garage Band app for the iPad, but most computers can act as synthesizers with freely-available or built-in software.<\/p>\n For our LEGO NXT Musical Instruments, there are four main components, as seen in the System Diagram below.<\/a><\/p>\n System Diagram<\/p>\n The program on the NXT is where you decide what notes your instrument can play and how you will interact with your NXT instrument. In the MIDI protocol, musical notes are enumerated from 0-127, which represent increasing frequencies of the notes. However, this is a very large range and not always appropriate for most synthesized instruments and sound sets. ‘Middle C’ on a normal piano is MIDI note number 60. Each piano key above and below Middle C is increments or decrements the MIDI note number respectively. Thus, if we want our instrument to play piano sounds, MIDI notes 40-88 would be a good range to use.<\/p>\n In the MIDI protocol, notes are communicated with two events: Note On, and Note Off. It is easy to think about this in terms of a piano key. When you press the key down, a Note On message is sent with that MIDI note number. When you lift your finger and release the key, a Note Off message is sent with that same key number. (This is important! Otherwise the note will never stop playing!) Below you can see the LabVIEW code to turn a single note On and then Off when a touch sensor is pressed.<\/p>\n <\/a><\/p>\n In the Downloads section you can find the MIDI VIs palette set. Just drop this in your user.lib folder and you will be able to use them right along side the NXT Toolkit VIs. The only VI you will need to use directly is the MIDI Poly VI. From this VI, you will be able to access the two main Note On and Note Off subVIs, and a variety of other MIDI commands that will let you further alter the sound and effects of your instrument.<\/p>\n <\/a><\/p>\n Also included in the MIDI VIs folder are two demo programs called TestDemo_basic.vi and TestDemo_advanced. These will show you a slightly more complex programming style in addition to demonstrating using different note values with one sensor.<\/p>\n <\/a><\/p>\n <\/p>\n The MIDI Cable is a homemade adapter for communicating between the NXT and a USB port. The information in messages going in and going out is the same, just different packaging. The NXT uses a communication protocol called i2c. The Teensy board reads the i2c message from the NXT and sends it on via the USB protocol to the computer.<\/p>\n The Teensy board also has the ability to pretend to be a standard USB device. This means, just like you have computer keyboards that create digital letters, and mice that create digital pointers, our NXT Musical Instrument can automatically appear to computers as a digital MIDI instrument to create digital MIDI music.<\/p>\n As mentioned before, a USB-mini cord connects from the Teensy to a computer, iPad, or any other speaker system that can understand the MIDI standard music protocol. When connecting to the iPad, an Apple iPad Camera Connection Kit is also necessary (for the USB port it provides).<\/p>\n <\/p>\n In this article, we talk about how you can make your own digital musical instrument with the LEGO NXT and connect it to an iPad using MIDI. The idea You can design and build your own musical instrument with the NXT where the sensors act as the note control inputs – just like the keys […]<\/p>\n","protected":false},"author":29,"featured_media":696,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[159],"tags":[152,628,627],"_links":{"self":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/posts\/681"}],"collection":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/comments?post=681"}],"version-history":[{"count":0,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/posts\/681\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/media\/696"}],"wp:attachment":[{"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/media?parent=681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/categories?post=681"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/legoeng.local\/wp-json\/wp\/v2\/tags?post=681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}The idea<\/h2>\n
The system<\/h2>\n
The components<\/h2>\n
\n
The code<\/h2>\n
The MIDI VIs<\/h2>\n
The MIDI cable<\/h2>\n
Building instructions<\/h3>\n
\n
\n<\/a><\/li>\n
\n<\/a><\/li>\n
\n<\/a><\/li>\n<\/ol>\nCable programming onstructions<\/h3>\n
\n
Downloads<\/h2>\n
\n
For more information<\/h2>\n
\n