Midi drums
garylake
Posts: 41
I want to make midi drums with the Propeller. Could anyone convert this Arduino code to Spin?
// Variables:
byte note = 0; // The MIDI note value to be played
void setup() {
// Set MIDI baud rate:
Serial.begin(31250);
}
void loop() {
// play notes from F#-0 (30) to F#-5 (90):
for (note = 30; note < 90; note ++) {
//Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
noteOn(0x90, note, 0x45);
delay(100);
//Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
noteOn(0x90, note, 0x00);
delay(100);
}
}
// plays a MIDI note. Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:
void noteOn(byte cmd, byte data1, byte data2) {
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
// Variables:
byte note = 0; // The MIDI note value to be played
void setup() {
// Set MIDI baud rate:
Serial.begin(31250);
}
void loop() {
// play notes from F#-0 (30) to F#-5 (90):
for (note = 30; note < 90; note ++) {
//Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
noteOn(0x90, note, 0x45);
delay(100);
//Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
noteOn(0x90, note, 0x00);
delay(100);
}
}
// plays a MIDI note. Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:
void noteOn(byte cmd, byte data1, byte data2) {
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
Comments
Could you possibly keep the MIDI out questions to one thread? You have three threads going with the same question, and a 4th with Bob's excellent list of helpful threads:
http://forums.parallax.com/showthread.php?127635-MIDI-Examples&highlight=MIDI
It's hard to hit a moving target.
Jim
This expects a board with a 5MHz crystal.
If your synth knows the general midi standard, then the drumscan be played on channel 10, so I set this as default. I've also changed some comments and velocity values.
If this not works, then you need to show your MIDI out circuit shematic. Depending on the Out-Pin, you need also to set the right value in the CON section.
Andy
Next I want thank Bob and Ariba for their time and help.
I have tried both Bob and Ariba code and it still doesn't work. Now I know the keyboard (sound module) works because I connected another keyboards midi out to midi in of the keyboard I'm using to test this. As far as the midi out circuit on the Prop goes I have it wired like this. Looking at the back of the Din 5 from left to right. Pin 1 not used, Pin 4 to a 220 ohm resistor to +5v, Pin 2 not used, Pin 5 to a 220 ohm resistor to Pin 17 on the Prop.
I am using the Propeller Education Kit.
(Go down to the 12-06-2009 09:28 PM #4 Ariba)
http://forums.parallax.com/showthread.php?118144-MIDI-Output-%28Via-USB-or-MIDI%29&highlight=Midi+Schematic
MIDI is a 5mA current loop. In the original implementation with 5V levels there are 3 x 220 Ohm resistors (2 in the MIDI OUT and 1 in the MIDI IN circuit). The LED in the Optocoupler needs 1.7V when lighting, so the current is: (5V -1.7V) / 660 = 5mA.
To adapt it to 3.3V we can only change the MIDI OUT circuit, so the LED and the 220R in the MIDI IN are given. With one 100R the current is:
(3.3V-1.7V) / 320 = 5mA
Andy
It was the midi out circuit. I took Bobs advice and looked at Aribas schematic. It didn't even occur to me that the circuits I have been looking at on the internet are all for 5V microcontrollers. So that means I have to make a lot of circuit changes.
You guys have been a big help. Thanks so much.
Gary