Shop OBEX P1 Docs P2 Docs Learn Events
My midi notes program needs help — Parallax Forums

My midi notes program needs help

TonyATonyA Posts: 226
edited 2005-09-09 04:42 in BASIC Stamp
Hi,

I have this program which is supposed to read midi data notes from an eeprom data table:

' =========================================================================

'
[noparse][[/noparse] I/O Definitions ]

Prog_change PIN 14 ' Program changes
MidiOut PIN 15 ' midi output pin
NoteCtrl_5 PIN 5

'
[noparse][[/noparse] Constants ]

Baud CON 12
NoteOn CON $90
Noteoff CON $80

'
[noparse][[/noparse] Variables ]

result VAR Word ' raw pot reading
note VAR Byte ' note, 0 (C) to 11 (B)
soundVar VAR Word

noteOut VAR Byte
velocity VAR Byte

'
[noparse][[/noparse] Initialization ]

Reset:
velocity = 127 ' high volume

'
[noparse][[/noparse]EEPROM DATA ]

' D# F G G# A# C C#
'
D_sharpscale DATA 003,005,007,008,010,000,001
DATA 015,017,019,020,022,012,013
DATA 027,029,031,032,034,024,025
DATA 039,041,043,044,046,036,037
DATA 051,053,055,056,058,038,049
DATA 064,065,068,069,071,060,061
DATA 075,077,079,080,082,072,073
DATA 087,089,091,092,094,084,085
DATA 099,101,103,104,106,096,097
DATA 111,113,115,116,118,108,109
DATA 123,125,127,$FF,$FF,120,121

'
[noparse][[/noparse] Program ]

Main:
DO
GOSUB Get_keyofDsharp
GOSUB Soundbank_Change
GOSUB Notes_Off

READ (D_sharpscale + note), noteOut
IF (noteOut <= 127) THEN
SEROUT MidiOut, Baud, [noparse][[/noparse]NoteOn, noteOut, velocity]
ENDIF
LOOP
END


'
[noparse][[/noparse] Subroutines ]
Key of D Sharp

Get_keyofDsharp:
HIGH NoteCtrl_5
PAUSE 1
RCTIME NoteCtrl_5, 1, result ' read pot on 5
note = result / 53 ' convert to 0..11
RETURN

'
[noparse][[/noparse] Notes Off ]

Notes_Off:
IF (IN6 = 0) THEN
SEROUT MidiOut, Baud, [noparse][[/noparse]$B0, $78, $00]
ENDIF
RETURN


'
[noparse][[/noparse] Sound Bank Change ]

Soundbank_Change:
HIGH 14
PAUSE 1
RCTIME 14, 1, soundVar
soundVar = soundVar/4
SEROUT MidiOut, Baud, [noparse][[/noparse]$C0, soundVar]
RETURN


My problems seems to be at : READ (D_sharpscale + note), noteOut

For some reason the program doesn't seem to be reading the eeprom data table. I could strip away the D_sharpscale part and still get the same sounds.

Just wondering if someone with more experience might be able to see the problem.

Thank you for any help.

Tony

Post Edited (TonyA) : 9/8/2005 8:11:05 PM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-08 21:46
    Hasn't this program been posted in several other threads?....

    You should really consider learning to use DEBUG so that you can test your program logic before attempting to send notes to a MIDI instrument.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 9/9/2005 1:35:11 AM GMT
  • TonyATonyA Posts: 226
    edited 2005-09-08 23:27
    Hi,

    Sorry, I thought maybe someone could help me see where I went wrong. This program has not been posted in previous thrreads however. There were posts similar to this.

    I've got if figured out now though. Thanks,

    Tony
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-09-09 01:40
    Sorry, my mistake ... but I would have sworn that I'd helped you that same program two or three times before (my head's buried in a tough project ... I'm cloudy). Glad you got it working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • TonyATonyA Posts: 226
    edited 2005-09-09 04:42
    Jon,

    There were numerous other code that were very similar, so no need for apology. I should go back and look at your previous help with my questions though.

    I just threw that up in case someone else could add to what I was doing.
    Thanks again for all your great help.

    Tony
Sign In or Register to comment.