Shop OBEX P1 Docs P2 Docs Learn Events
Foot Piano with Midi Output — Parallax Forums

Foot Piano with Midi Output

ajajackajajack Posts: 26
edited 2007-08-24 16:19 in BASIC Stamp
Hello,

I am trying to create a large touch sensitive foot piano that is able to output to midi on my BASIC Stamp.· I want it to be able to play multiple notes at once.· My original setup was going to use 12 of the i/o pins and just create a switch for each note.· But my problem is how to interface with midi and how to have it be able to play multiple notes at once.· I am very new to programming the BASIC Stamp so any help would be great.

Thank You,

AJ

Comments

  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-08-24 10:46
    Midi out is easy. Midi is a serial data stream notes are sent one after the other, not simultaneously so polyphony is easy - just don't send a zero velocity or a note-off command and the note sustains.
    Here's the MIDI format:
    http://www.borg.com/~jglatt/tech/midispec.htm

    Here's how to hook it up:

    midicircuit.gif
    here's a good resource for Basic Stamp MIDI output -http://www.audiomulch.com/midipic/

    Now you just have to figure out how to build the foot pedal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 8/24/2007 11:46:54 AM GMT
  • ajajackajajack Posts: 26
    edited 2007-08-24 13:48
    Thank You, that information helps but what would the BASIC Stamp code look like for my project.· I mean how do you send note on/off commands.
  • TechnoRobboTechnoRobbo Posts: 323
    edited 2007-08-24 16:19
    All this info is included in the links I posted:

    Basic Stamp Code

    statusbyte var byte···· 'MIDI status; controller, noteon, or pitchbend
    data1 var byte········· 'first data byte, eg. controller or note number
    data2 var byte········· 'second MIDI data byte, eg. value or velocity
    midioutpin con 0······· 'pin connected to MIDI out connector
    midibaudmode con 32780

    serout midioutpin, midibaudmode, [noparse][[/noparse]statusbyte, data1, data2]

    Note ON

    Status

    $90 to $9F where the low nibble is the MIDI channel.

    Data

    Two data bytes follow the Status.

    The first data is the note number. There are 128 possible notes on a MIDI device, numbered 0 to 127 (where Middle C is note number 60). This indicates which note should be played.

    The second data byte is the velocity, a value from 0 to 127. This indicates with how much force the note should be played (where 127 is the most force). It's up to a MIDI device how it uses velocity information. Often velocity is be used to tailor the VCA (Voltage Controlled Amplifiers*)·attack time and/or attack level (and therefore the overall volume of the note). MIDI devices that can generate Note On messages, but don't implement velocity features, will transmit Note On messages with a preset velocity of 64.

    A Note On message that has a velocity of 0 is considered to actually be a Note Off message, and the respective note is therefore released.

    Note OFF

    Status

    $80 to $8F where the low nibble is the MIDI channel.

    Data

    Two data bytes follow the Status.

    The first data is the note number. There are 128 possible notes on a MIDI device, numbered 0 to 127 (where Middle C is note number 60). This indicates which note should be released.

    The second data byte is the velocity, a value from 0 to 127. This indicates how quickly the note should be released (where 127 is the fastest). It's up to a MIDI device how it uses velocity information. Often velocity will be used to tailor the VCA release time. MIDI devices that can generate Note Off messages, but don't implement velocity features, will transmit Note Off messages with a preset velocity of 64.

    TR's Footnote:

    *VCA - Voltage controlled amplifier is the component on an analog synth that controls the volume "Envelope" the usual components are -·Attack( volume fade in time), Decay (initial volume fade out after attack),Sustain (level the volume stays at while the key is held),·and Release (volume fade out time).· With the onset of Digital, the Envelope shapes became more complex.

    ···213px-ADSR_Envelope_Graph_svg_copy.jpg

    Go to http://en.wikipedia.org/wiki/ADSR_envelope·for more info

    This Example Plays 2 bass note simltaneously·1 octave apart in and old fashion random sequencer style (I was inspired by Kraftwerk early on). changing the value of "seed" changes pattern:

    'Techno Robbo's Random Bass Thump Demo
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}


    statusbyte VAR Byte···· 'MIDI status; controller, noteon, or pitchbend
    data1 VAR Byte········· 'note
    data2 VAR Byte········· 'octave
    result VAR Word
    notecount VAR Byte

    seed CON 0·············· 'change seed to change pattern (0-65535)
    midioutpin CON 14······· 'pin connected to MIDI out connector
    midibaudmode CON 32780
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]$B0,7,127] 'Full Volume
    PAUSE 1
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]$B0,123,0] 'all notes off
    PAUSE 1
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]$B0,120,0] 'all sound off
    PAUSE 500
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]$C0, 33] ' change instrument to bass
    notecount=0
    result=seed

    DO
    RANDOM result
    data1=result// 8
    data2=data1
    statusbyte = $90

    LOOKUP data1,[noparse][[/noparse]24,26,28,29,31,33,35,36], data1
    LOOKUP data2,[noparse][[/noparse]36,38,40,41,43,45,47,48],· data2
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]statusbyte, data1, 127]
    PAUSE 1
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]statusbyte, data2, 127]
    PAUSE 60
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]statusbyte, data1, 0]
    PAUSE 1
    SEROUT midioutpin, midibaudmode, [noparse][[/noparse]statusbyte, data2, 0]
    PAUSE 63

    notecount=notecount + 1 // 32······ 'recycle pattern
    IF notecount=0 THEN result=seed
    LOOP

    For a more comprehensive Demo with variable note cycles - 65536 paterns·,variable tempo ,selectable note value, see below attachment.

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Have Fun


    TR

    Post Edited (TechnoRobbo) : 8/28/2007 1:37:23 AM GMT
Sign In or Register to comment.