MIDI In with Basic Stamp II (drumbot)
Tom2.0
Posts: 2
I'm making an automated drum machine for my senior design project and so far I have it set up to simply play off a loop of high/low commands programmed onto the stamp...
http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=2025416436
I want it to be able to read from a midi file (each drum component can be on a separate channel) and play the drums accordingly. ·I'm trying to use the m-audio Uno USB to MIDI cable, which has an LED that seems to trigger in concordance with beats on midi files, but I'm having trouble translating that to my solenoids.
Here's my questions:
1) Can I simply stick wires into the female MIDI (5 pin DIN) port when connecting it to my optoisolator circuit or is there some barrier·there that I'm not seeing?
2) I'm new to BASIC and found some code online and altered it to this...
it seems to make sense...for all I know. ·However, this isn't working for me...should it?
I can't wait to get all this working and throw some LED rope lights onto my drums (connected in the solenoid firing circuit) and rock out in a calculated and efficient manner.
any help would be great. ·Thanks.
-Tom
http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=2025416436
I want it to be able to read from a midi file (each drum component can be on a separate channel) and play the drums accordingly. ·I'm trying to use the m-audio Uno USB to MIDI cable, which has an LED that seems to trigger in concordance with beats on midi files, but I'm having trouble translating that to my solenoids.
Here's my questions:
1) Can I simply stick wires into the female MIDI (5 pin DIN) port when connecting it to my optoisolator circuit or is there some barrier·there that I'm not seeing?
2) I'm new to BASIC and found some code online and altered it to this...
snare con 1 bass con 2 hihat con 3 crash con 4 midiString var byte(3) main: serin 8, 12, [noparse][[/noparse]midiString] if midiString(0) = 144 then pos1 if midiString(0) = 145 then pos2 if midiString(0) = 146 then pos3 if midiString(0) = 147 then pos4 goto main pos1: high snare pause 10 low snare goto main pos2: high bass pause 10 low bass goto main pos3: high hihat pause 10 low hihat goto main pos4: high crash pause 10 low crash goto main
it seems to make sense...for all I know. ·However, this isn't working for me...should it?
I can't wait to get all this working and throw some LED rope lights onto my drums (connected in the solenoid firing circuit) and rock out in a calculated and efficient manner.
any help would be great. ·Thanks.
-Tom
Comments
A few other points:
Midi uses channel 10 as the drum but you're using different channels for different drum sounds.
For instance channel 10 note 36 ($99,·$24)·is the kick and channel 10 note 38 ($99,·$26) is a snare.
Polyphony is almost out of the question (stamp has no buffer). your going to have to use notes representing multiple drum hits such as 39=high hat +Kick
All that being said can you post your circuit for the optocoupled midi input so we can review it?
Here's one design
http://www.troikaranch.org/misc/midi_schem.gif
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 5/6/2007 10:23:16 PM GMT
32 kHz right ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I think you could use the serin, then convert the midi to binary and use the parallel out commands for polyphony.
I.E.
0001 cymbal
0010 snare
0100 kick
1000 tom
1111 all
To quote Tracey Allens indispensible website (http://www.emesystems.com/BS2rs232.htm#SERIN):
Polyphony would require the Stamp to receive the following datastream for the cymbal/snare/kick/tom combo which comes at the stamp at random times (no handshaking no requests):
Note on events
$99,$31,$7F,$99,$26,$7F,$99,$28,$7F,$99,$2B,$7F
follow by note off events
$89,$31,$00,$89,$26,$00,$89,$28,$00,$89,$2B,$00
That's 24 bytes - 12 per polyphonic·event. BS2 has 26 bytes.
Tom's only hope with MIDI is to send a single event and hope he captures the note byte or (like his code implies)·use the channel number as the drum number.
The way I see it. His best bet though is to use DATA and READ statments to create a Piano Roll type drum machine, load drum patterns·into EEPROM·memory from the debug port and ditch the midi file idea.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
You can easily substitute the midiOutShortMsg command with a serout (MSComm1.Output = x)command and send the stamp 1 byte concatenating 8 instruments for up to 8 solenoids to be fired by the stamp simultaneously. This should solve most timing issues.
This is the file:
http://home.comcast.net/~technorobbo/MIDI.xls
and here's a website to get test files from.
http://www.mididrumfiles.com/free/
I hope this helps and I hope I'm not too late for you to finish your project.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 5/18/2007 10:54:16 AM GMT
Assign bits to drums on the CommSettings Tab
Baud Rate and Comm Port too.
http://home.comcast.net/~technorobbo/MIDItoBS2.xls
Here's the BS2 Code:
' {$STAMP BS2}
' {$PBASIC 2.5}
'MIDI to BS2
MIDI· VAR Byte
CRT· VAR Byte
DIRL=255
DO
· SERIN 16, 16780, [noparse][[/noparse]MIDI] '2400 Baud
· OUTL =MIDI
· PAUSE·10
· MIDI =0
· OUTL =MIDI
LOOP
END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 5/20/2007 8:50:49 PM GMT
thanks for all the help,
Tom
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR