Just for the fun of it, I did hack in a version of the song playing stuff I had up on the AVR processors. I did it on my current test setup, which is now an ABB board so I used P4-P6 switches instead of the P12-P14 where the switches are on the BB2, but that is easy to change…
If You hit buttonA it plays one song, not to bad and if you hit B it plays a different one (sort of…), but then again this is not saying Hello…
Kurt
[code];--------------------------------------------------------------------
; Simple test program to play a simple song when you press a button…
;
TRUE con 1
FALSE con 0
;button init
buttonA var bit
buttonB var bit
buttonC var bit
prevA var bit
prevB var bit
prevC var bit
;--------------------------------------------------------------------
;[Sound definitions] - Make defines for different frequencies… in hz
FREQ_A0 con 28: FREQ_A1 con 55: FREQ_A2 con 110: FREQ_A3 con 220: FREQ_A4 con 440: FREQ_A5 con 880: FREQ_A6 con 1760
FREQ_Bb0 con 29: FREQ_Bb1 con 58: FREQ_Bb2 con 117: FREQ_Bb3 con 233: FREQ_Bb4 con 466: FREQ_Bb5 con 932: FREQ_Bb6 con 1865
FREQ_B0 con 31: FREQ_B1 con 62: FREQ_B2 con 123: FREQ_B3 con 247: FREQ_B4 con 494: FREQ_B5 con 988: FREQ_B6 con 1976
FREQ_C0 con 33: FREQ_C1 con 65: FREQ_C2 con 131: FREQ_C3 con 262: FREQ_C4 con 523: FREQ_C5 con 1047: FREQ_C6 con 2093
FREQ_Db0 con 35: FREQ_Db1 con 69: FREQ_Db2 con 139: FREQ_Db3 con 277: FREQ_Db4 con 554: FREQ_Db5 con 1109: FREQ_Db6 con 2217
FREQ_D0 con 37: FREQ_D1 con 73: FREQ_D2 con 147: FREQ_D3 con 294: FREQ_D4 con 587: FREQ_D5 con 1175: FREQ_D6 con 2349
FREQ_Eb0 con 39: FREQ_Eb1 con 78: FREQ_Eb2 con 156: FREQ_Eb3 con 311: FREQ_Eb4 con 622: FREQ_Eb5 con 1245: FREQ_Eb6 con 2489
FREQ_E0 con 41: FREQ_E1 con 82: FREQ_E2 con 165: FREQ_E3 con 330: FREQ_E4 con 659: FREQ_E5 con 1319: FREQ_E6 con 2637
FREQ_F0 con 44: FREQ_F1 con 87: FREQ_F2 con 175: FREQ_F3 con 349: FREQ_F4 con 698: FREQ_F5 con 1397: FREQ_F6 con 2794
FREQ_Gb0 con 46: FREQ_Gb1 con 92: FREQ_Gb2 con 185: FREQ_Gb3 con 370: FREQ_Gb4 con 740: FREQ_Gb5 con 1480: FREQ_Gb6 con 2960
FREQ_G0 con 49: FREQ_G1 con 98: FREQ_G2 con 196: FREQ_G3 con 392: FREQ_G4 con 784: FREQ_G5 con 1568: FREQ_G6 con 3136
FREQ_Ab0 con 52: FREQ_Ab1 con 104: FREQ_Ab2 con 208: FREQ_Ab3 con 415: FREQ_Ab4 con 831: FREQ_Ab5 con 1661: FREQ_Ab6 con 3322
;--------------------------------------------------------------------
;[Song Defs]
FurElise wordtable | ;
8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_B4, 8,FREQ_D5, 8,FREQ_C5, 4,FREQ_A4, 8,0, |
8,FREQ_C4, 8,FREQ_E4, 8,FREQ_A4, 4,FREQ_B4, 8,0, 8,FREQ_E4, 8,FREQ_Ab4, 8,FREQ_B4, 4,FREQ_C5, 8,0, 8,FREQ_E4,|
8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_Eb5, 8,FREQ_E5, 8,FREQ_B4, 8,FREQ_D5, 8,FREQ_C5, 4,FREQ_A4, 8,0, 8,FREQ_C4, |
8,FREQ_E4, 8,FREQ_A4, 4,FREQ_B4, 8,0, 8,FREQ_E4, 8,FREQ_C5, 8,FREQ_B4, 4,FREQ_A4, |
0, 0
Mozart wordtable |
16,FREQ_Gb4, 16,FREQ_E4, 16,FREQ_Eb4, 16,FREQ_E4, 4,FREQ_G4, 16,FREQ_A4, 16,FREQ_G4, 16,FREQ_Gb4, 16,FREQ_G4, |
4,FREQ_B4, 16,FREQ_C5, 16,FREQ_B4, 16,FREQ_Bb4, 16,FREQ_B4, 16,FREQ_Gb5, 16,FREQ_E5, 16,FREQ_Eb5, 16,FREQ_E5, |
16,FREQ_Gb5, 16,FREQ_E5, 16,FREQ_Eb5, 16,FREQ_E5, 4,FREQ_G5, 8,FREQ_E5, 8,FREQ_G5, 32,FREQ_D5, 32,FREQ_E5, |
16,FREQ_Gb5, 8,FREQ_E5, 8,FREQ_D5, 8,FREQ_E5, 32,FREQ_D5, 32,FREQ_E5, 16,FREQ_Gb5, 8,FREQ_E5, 8,FREQ_D5, 8,FREQ_E5, |
32,FREQ_D5, 32,FREQ_E5, 16,FREQ_Gb5, 8,FREQ_E5, 8,FREQ_D5, 8,FREQ_Db5, 4,FREQ_B4, |
0, 1
;====================================================================
;Interrupt init
;====================================================================
;[INIT]
;PS2 controller
input p4
input p5
input p6
sound P9,[100\5000, 100\4500, 100\4000]
;====================================================================
;[MAIN]
main:
prevA = buttonA
prevB = buttonB
prevC = buttonC
buttonA = in4 ; BUGBUG for BB2 12-14
buttonB = in5
buttonC = in6
if (buttonA = 0) AND (prevA = 1) then
gosub PlayASong@FurElise]
endif
if (buttonB = 0) AND (prevB = 1) then
gosub PlayASong@Mozart]
endif
pause 100
goto main
;--------------------------------------------------------------------
;[PlayASong] - takes the pointer as a set of times and notes and runs
; them on the spaker
SongPtr var pointer
Dur var word
Note var word
PlayASong [SongPtr]:
; serout s_out, i9600, “Song: “, hex songPtr, 13]
; See if Pointer properly uses the type information to increment
while @SongPtr
Dur = @SongPtr * 16 ; scale it up
SongPtr = SongPtr + 2 ; Ok it does not scale the add
Note = @SongPtr
SongPtr = SongPtr + 2 ; Ok it does not scale the add
; Serout s_out, i9600, “P:”, hex SongPtr, " D:”, dec dur, " N:”, dec Note, 13]
Sound P9, [Dur\Note]
wend
return
[/code]
P.S - I tried this using the Pointer variable. Took a few attempts as I was not sure if adding to a pointer variable would scale the addition to size of what is in it (It does not). Also tried using the pointer with array index numbers and did not get what I expected… but you can ignore all of that.