November 22, 2024, 01:05:21 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Annoying MIDI

Started by Hack, May 03, 2008, 03:09:38 AM

Previous topic - Next topic

Hack

Well, I've been up all night trying to figure this one out..

It seems that when I send a MIDI message via "HEX2 MidiVAL" I get a different result than "$3C" (if the values match!) I've tried so many different ways to figure out what's going on-- and how to fix it.. but nothing works...

I am not an expert but from what I can see, it looks correct... If you hook up a MIDI output to a keyboards MIDI input, you will hear the issue I am referring to.


' {$STAMP BS2}
' {$PBASIC 2.5}


' -----[ I/O Definitions ]-------------------------------------------------
MidiOut   PIN 15

' -----[ Variables ]-------------------------------------------------------
MidiBaud  CON $8000 + 12
MIDIVAL   VAR Byte
Counter   VAR Word
' -----[ Program Code ]----------------------------------------------------

DO
Counter = Counter + 1

    SEROUT MidiOut, MidiBaud, [$96, $3C, $55, $96, HEX2 MIDIVAL, $7F]
    DEBUG HOME, "PLAYING $3C + MIDIVAL = $", HEX2 MIDIVAL, CR

    IF (Counter < 70) THEN
      IF (MIDIVAL + 1 < 61) THEN MIDIVAL = MIDIVAL + 1
        DEBUG "WHERE IS UNISON?                  "
      ELSE
        MIDIVAL = MIDIVAL + 1
        DEBUG "TRANSITION BETWEEN 9F AND A0?"
    ENDIF
    IF (MIDIVAL > 127) THEN
      Counter = 0
      MIDIVAL = 0
    ENDIF
    PAUSE 200
LOOP




I tried stripping down the code to make this as easy as possible to solve:

' {$STAMP BS2}
' {$PBASIC 2.5}


' -----[ I/O Definitions ]-------------------------------------------------
MidiOut   PIN 15

' -----[ Variables ]-------------------------------------------------------
MidiBaud  CON $8000 + 12
MIDITEST  CON 60 'BASE10 = 60, BASE16 = $3C
' -----[ Program Code ]----------------------------------------------------

DO
    SEROUT MidiOut, MidiBaud, [$96, $3C, $55, $96, HEX2 MIDITEST, $7F]
    DEBUG HOME, "PLAYING $3C + MIDITEST = $", HEX2 MIDITEST
    PAUSE 200
LOOP



Shouldn't this make sense? But it SOUNDS so wrong! I'm going crazy!!

JonnyMac

Keep in mind that the HEX2 modifier will convert your MIDI byte to a string of two characters -- this will throw things off. 

This article may be helpful: http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol4/col/nv94.pdf
Jon McPhalen
EFX-TEK Hollywood Office