Saturday, May 25, 2013

Receiving Teensy MIDI Channels as Indexed from Zero

There are many instances when my Teensy / Arduino code may not work on standard Teensy installations as expected.

This applies to many cases where MIDI data is received by the Teensy.  This is because I prefer to deal with MIDI channels when indexed from zero instead of one.

If you would like to run my Teensy code on your install, one things you can do is update the Teensy MIDI API files.

To do this, right click on the Arduino app, go to Show Package Contents and navigate to the following file, and opening it in a text editor:
Arduino > Contents > Resources > Java > Hardware > Teensy > cores > usb_midi > usb_api.cpp

Find the following code:

type2 = b1 & 0xF0;
    c = (b1 & 0x0F) + 1;


And change it to:

type2 = b1 & 0xF0;
    c = (b1 & 0x0F);


Save the file. As a result, any MIDI data received will return channel numbers 0 - 15 instead of 1 - 16.

Piggybacked SN76489 Chips








One SN76489 is piggybacked on another. They share many pins and only a small number need to be isolated from each other.

• Removal of !READY pin
• Isolation of !WRITE_ENABLE pin
• Isolation of SOUND_OUT pin
• Shared data bus, ground and 5V pins

Quad SN76489 Prototype Demonstration


SN76489 USB MIDI Firmware 102: Linear Pitchbend, Clock-based Pitch

Overview
SN76489 USB MIDI Firmware 102 for the Teensy features the following changes:
• Pitchbend is musically linear, meaning that the same value pitch bend will give the same pitch distance no matter which pitch is played.

• CC71 on MIDI channels 1 - 4 sets the pitch bend range in semitones. The default is 12 semitones. 

• The frequency data for the SN76489 is calculated using a formula rather than a look up table.

• The advantage of this is there is a line of code in the program that reads: long clock = 1843200; Simply change the value of clock in Hz to support any value of crystal oscillator whilst staying in tune!

• The default is 1843200 (i.e. a clock speed of 1.8432 MHz) as this is the crystal speed that I prefer, however the SN76489 can accept a wide range of clock speeds. If you want a bassier pitch range, simply use a lower value crystal oscillator.


Download the firmware here: http://milkcrate.com.au/_other/downloads/teensy/SN76489_USB_MIDI_102/SN76489_USB_MIDI_102.ino



Example Breadboard Layout



Demonstration Video




Friday, May 24, 2013

Circuit Bending Basics 8: Independent Multi Button Triggering

Overview
This post assumes that you are familiar with the previous Circuit Bending Basics Posts.

Circuit bending is about the non-thereoretical exploration of sound making circuits via shorting different points together. Take a toy (that is battery powered - important!) and let's get to work!



Multi Button Triggering
A previous post demonstrated how to trigger a single button using a 4066 chip. The 4066 chip has four such functional blocks. This article demonstrates how to use all four of these blocks. It is a assumed that you have read the previous post in question.



Schematic

The red pair, yellow pair, green pair and orange pair of connections each represent a pair of points on a circuit board that triggers sounds and thus replaces buttons. 



Code


Download here: http://milkcrate.com.au/_other/downloads/projects/_4066_example/_4066_example.ino



Example - Toy Keyboard





Video Demonstration